public void Setup() { id = Guid.NewGuid().ToString(); stateFactory = new SimulationStateFactory(new PlantDescriptorService()); plant = TestPlant.CreatePlant(); stateData = new SimulationStateSnapshot(100); }
public static void SaveMemoryUsage(string path, IPlant plant) { StringBuilder str = new StringBuilder(); if (!File.Exists(path)) { str.AppendLine("\"Part Count\";\"Cell Count\";\"Usage (MB)\""); } int cellCount = 0; int partCount = 0; var parts = new Stack <IPlantPart>(new IPlantPart[] { plant.ShootSystem.Stem, plant.RootSystem.PrimaryRoot }); while (parts.Count > 0) { var p = parts.Pop(); cellCount += p.Cells.Count(); partCount++; foreach (var c in p.Connections) { parts.Push(c); } } str.AppendLine($"\"{partCount}\";\"{cellCount}\";\"{MemoryUsage()}\""); File.AppendAllText(path, str.ToString(), Encoding.UTF8); }
public AddProgressReportViewModel(IPlant plant) { Plant = plant; PopulateData(); SaveCommand = new Command(SaveReport, CanExecute); CancelCommand = new Command(Cancel, CanCancel); }
private IPlant GeneratePlant(string name, int wonumber) { IPlant plant = Substitute.For <IPlant>(); plant.Name.Returns(name); IMes mes = Substitute.For <IMes>(); IWork wo = Substitute.For <IWork>(); Dictionary <int, IWork> dic = new Dictionary <int, IWork>(); wo.Id.Returns(wonumber); wo.Operations.Returns(new List <Op>() { new Op(Op.OpTypes.DrillOpType1) }); wo.CurrentOpIndex.Returns(1); dic.Add(wonumber, wo); mes.Workorders.Returns(dic); plant.Mes.Returns(mes); IAcceptWorkorders wc = Substitute.For <IAcceptWorkorders>(); wc.Name.Returns("Wc" + wonumber); wc.ListOfValidTypes().Returns(new List <Op.OpTypes>() { Op.OpTypes.DrillOpType1 }); plant.Workcenters.Returns(new List <IAcceptWorkorders>() { wc }); return(plant); }
/// <summary> /// Updates the model (Just one column) /// Updates the lists of Cultivar and Field names in the model. /// This is used when the model has been changed. For example, when a /// new crop has been selecled. /// </summary> /// <param name="model">The new model</param> private void UpdateModel(int propListIndex) { IGridCell curCell = this.grid.GetCurrentCell; for (int i = 0; i < this.properties[propListIndex].Count; i++) { IGridCell cell = this.grid.GetCell(propListIndex + 1, i); //add 1 because of Description column if (curCell != null && cell.RowIndex == curCell.RowIndex && cell.ColumnIndex == curCell.ColumnIndex) { continue; } if (this.properties[propListIndex][i].Display.Type == DisplayType.CultivarName) { IPlant crop = this.GetCrop(this.properties[propListIndex]); if (crop != null) { cell.DropDownStrings = this.GetCultivarNames(crop); } } else if (this.properties[propListIndex][i].Display.Type == DisplayType.FieldName) { string[] fieldNames = this.GetFieldNames(propListIndex); if (fieldNames != null) { cell.DropDownStrings = fieldNames; } } } }
void OnPlantUI(IPlant plant, PlantBase.BaseInfo info) { if (activeInfo != info && LeftMouseDown && IsMouseAround(info.position.ToVector3())) { Event.current.Use(); CourseBase.ActivePlant = plant; activeInfo = info; firstHit = CourseBase.CameraTerrainHit; originalPoint = info.position.ToVector3(); if (MainToolUI.SelectedTool != MainToolUI.Tool.PlantTool) { MainToolUI.SelectedTool = MainToolUI.Tool.PlantTool; } return; } if (info == activeInfo) { RaycastHit?hit = CourseBase.CameraTerrainHit; if (firstHit != null && hit != null) { PlatformBase.Editor.RecordObject(plant.Transform.gameObject, "Plant Info Position Change"); Vector3 position = (originalPoint + hit.Value.point - firstHit.Value.point); position.y = CourseBase.TerrainHeight(position.x, position.z); plant.Position = position; info.position.Set(position); } } }
/// <summary> /// Updates the lists of Cultivar and Field names in the model. /// This is used when the model has been changed. For example, when a /// new crop has been selecled. /// </summary> /// <param name="model">The new model</param> public void UpdateModel(Model model) { this.model = model; if (this.model != null) { IGridCell curCell = this.grid.GetCurrentCell; for (int i = 0; i < this.properties.Count; i++) { IGridCell cell = this.grid.GetCell(1, i); if (curCell != null && cell.RowIndex == curCell.RowIndex && cell.ColumnIndex == curCell.ColumnIndex) { continue; } if (this.properties[i].Display != null && this.properties[i].Display.Type == DisplayType.CultivarName) { IPlant crop = this.GetCrop(this.properties); if (crop != null) { cell.DropDownStrings = this.GetCultivarNames(crop); } } else if (this.properties[i].Display != null && this.properties[i].Display.Type == DisplayType.FieldName) { string[] fieldNames = this.GetFieldNames(); if (fieldNames != null) { cell.DropDownStrings = fieldNames; } } } } }
public GenericPlantRunner(IPlant plant, SimulationEnvironment environment, IPlantGrower plantGrower, FluidsPlantCycle sucroseCycle) { this.plantGrower = plantGrower; this.sucroseCycle = sucroseCycle; Plant = plant; Environment = environment; }
public GenericCellGrower(IPlant plant, SimulationEnvironment environment, ICellBodySystemSolver systemSolver, IPlantSimulatorOptionsService optionsService) { this.plant = plant; this.environment = environment; this.systemSolver = systemSolver; this.optionsService = optionsService; }
private bool PopulateData(IPlant plant) { SaveCommand = new Command(Save, CanSave); CancelCommand = new Command(Cancel, CanCancel); try { Strains = Strain.FindAll().OrderBy(x => x.Name); Schedules = Schedule.FindAll().OrderBy(x => x.Name); Gardens = Garden.FindAll().OrderBy(x => x.Name); if (plant == null) { Plant = new Plant(); return(true); } Plant = Plant.Find(plant.Id); SelectedSchedule = Schedules.Where(x => x.Id == plant.ScheduleId).FirstOrDefault(); SelectedStrain = Strains.Where(x => x.Id == plant.Strain.Id).FirstOrDefault(); SelectedGarden = Gardens.Where(x => x.Id == plant.GardenId).SingleOrDefault(); _isDirty = false; return(true); } catch (Exception) { return(false); } }
protected void SetUp() { Test test = new Test("Default", 0, 0, 0, 0, 0); Configuration.Initialize(test); _workorder = Substitute.For <IWork>(); _workorder.CurrentOpType.Returns(Op.OpTypes.DrillOpType1); _workorder.CurrentOpSetupTime.Returns(0); _workorder.CurrentOpEstTimeToComplete.Returns(1); _workorder.Id.Returns(1); ISchedulePlants ps = Substitute.For <ISchedulePlants>(); ps.ValidateWoForMachines(Arg.Any <int>(), Arg.Any <string>()).Returns(x => x[0]); _plant = Substitute.For <IPlant>(); _plant.PlantScheduler.Returns(ps); _bigData = Substitute.For <IHandleBigData>(); _bigData.IsBreakdown(Arg.Any <string>(), Arg.Any <DayTime>()).Returns(x => x[1]); _bigData.IsNonConformance(Arg.Any <string>()).Returns(false); _mes = Substitute.For <IMes>(); _dayTime = new DayTime(); _subject = new Workcenter("TestWC", Machine.Types.BigDrill); _subject.SetMes(_mes); _subject.AddPlant(_plant); _subject.AddBigData(_bigData); }
protected new void DestroyOrganism() { base.DestroyOrganism(); eatable = false; plantFuncs = null; grownWatch.Stop(); }
public static void CollectInput(Farm farm, IPlant sunflower) { Utils.Clear(); try { for (int i = 1; i <= farm.PlantFields.Count; i++) { IPlantable field = farm.PlantFields[i - 1]; if (field.Capacity > field.numOfPlants()) { Console.WriteLine($"{i}. {field.Type} {field.shortId()} has {field.numOfPlants() / field.PlantsPerRow } rows of plants."); // Print out the counts of each type of animal var counts = field.Plants.GroupBy(plant => plant.Type) .Select(group => new PrintReport { Name = group.Key, Count = group.Count() }); foreach (PrintReport report in counts) { Console.WriteLine($"{report.Name}: {report.Count}"); } } else { Console.WriteLine($"{i}. {farm.PlantFields[i-1].Type} {farm.PlantFields[i-1].shortId()} is at capacity with {farm.PlantFields[i - 1].numOfPlants()} plants."); } } // for (int i = 1; i <= farm.PlantFields.Count; i++) { // Console.WriteLine($"{i}. {farm.PlantFields[i - 1].Type} {farm.PlantFields[i - 1].shortId()} has {farm.PlantFields[i - 1].numOfPlants()} plants."); // } Console.WriteLine(); // How can I output the type of seed chosen here? Console.WriteLine($"Place the plant where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); farm.PlantFields[choice - 1].AddResource(sunflower); } catch { Console.WriteLine("Please enter a valid selection."); Thread.Sleep(1000); CollectInput(farm, sunflower); } /* * Couldn't get this to work. Can you? * Stretch goal. Only if the app is fully functional. */ // farm.PurchaseResource<IGrazing>(animal, choice); }
protected void SetUp() { _plant1 = Substitute.For <IPlant>(); _plant1.Name.Returns(PLANT1_NAME); IMes mes1 = Substitute.For <IMes>(); ISchedulePlants isp1 = Substitute.For <ISchedulePlants>(); _plant1.Mes.Returns(mes1); _plant1.PlantScheduler.Returns(isp1); _plant1.Workcenters.Returns(new List <IAcceptWorkorders>()); _plant2 = Substitute.For <IPlant>(); _plant2.Name.Returns(PLANT2_NAME); IMes mes2 = Substitute.For <IMes>(); ISchedulePlants isp2 = Substitute.For <ISchedulePlants>(); _plant2.Mes.Returns(mes2); _plant2.PlantScheduler.Returns(isp2); _plant2.Workcenters.Returns(new List <IAcceptWorkorders>()); List <IPlant> list = new List <IPlant>() { _plant1, _plant2 }; _subject = new Erp(ERP_NAME); _subject.Add(_plant1); _subject.Add(_plant2); }
static void Write(IPlant plant, ICompany company) { Multicast writeInfo = plant.Write_Plant; writeInfo += company.Write_Company; writeInfo(); }
public void Setup() { environment = new SimulationEnvironment { LightPosition = new Vertex(0, 10000, 0), Temperature = 22 }; plant = TestPlant.CreatePlant(); cellFactory = new GenericCellFactory(); optionsService = PlantSimulatorOptionsHelper.CreateOptionsService(); divider = new GenericCellDivider(cellFactory); helper = new GeometryHelper(); cellSizer = new GenericCellSizer(helper, new LoggerAdapter <GenericCellSizer>(new NullLogger <GenericCellSizer>())); cellCollisionDetection = new CellCollisionDetection(helper); bodySystemSolver = new GenericCellBodySystemSolver(cellCollisionDetection, cellSizer); cellGrower = new GenericCellGrower(plant, environment, bodySystemSolver, optionsService); descriptorService = new PlantDescriptorService(); cellCreator = new HexagonCellCreator(cellFactory); gridCreator = new HexagonalCellGridFactory(cellCreator, CornCellTypeLocator.GetCornCellTypeLocator(), optionsService); plantPartCellCreator = new PlantPartCellCreator(gridCreator); internodePartFactory = new GenericInternodePartFactory(optionsService, gridCreator); stemPartFactory = new GenericStemPartFactory(optionsService, internodePartFactory); petiolePartFactory = new GenericPetiolePartFactory(cellFactory, optionsService); nodePartFactory = new GenericNodePartFactory(optionsService, cellFactory, stemPartFactory, petiolePartFactory); internodePlantPartDevelopment = new InternodePartDevelopment(optionsService, nodePartFactory, cellGrower, descriptorService, internodePartFactory); rootFactory = new GenericRootPartFactory(optionsService, plantPartCellCreator); rootPlantPartDevelopment = new RootPartDevelopment(optionsService, nodePartFactory, rootFactory, cellGrower, descriptorService); developer = new PlantPartDeveloper(internodePlantPartDevelopment, rootPlantPartDevelopment); sucroseCarrierCollection = new SucroseCarrierCollection( new LoggerAdapter <SucroseCarrierCollection>(new NullLogger <SucroseCarrierCollection>())); sucroseTransporter = new SucroseTransporter(cellCollisionDetection, helper, sucroseCarrierCollection, new LoggerAdapter <FluidTransporter <Sucrose> >(new NullLogger <FluidTransporter <Sucrose> >())); plantGrower = new GenericPlantGrower(bodySystemSolver, developer, sucroseTransporter); runner = new GenericPlantRunner(plant, environment, plantGrower, new FluidsPlantCycle(plant, optionsService, sucroseCarrierCollection, new LoggerAdapter <FluidsPlantCycle>(new NullLogger <FluidsPlantCycle>()))); RangeExtensions.Random = new Random(optionsService.Options.Simulation.RandomSeed); }
public IPlant Grow() { IPlant plant = _seedBank.Identify(this); plant.Plant(_soil); return(plant.Grow()); }
public EditPlantViewModel(IPlant plant) { if (!PopulateData(plant)) { Plant = new Plant(); _isDirty = false; } }
private PlantModelState CreatePlantState(IPlant plant) { return(new PlantModelState { ShootSystem = CreateShootState(plant.ShootSystem), RootSystem = CreateRootState(plant.RootSystem) }); }
public void AddPlant(IPlant plant) { if (_plant != null) { return; } _plant = plant; }
public int EatPlant(IPlant p) { if (p != null) { return(p.GetEatenQuantity(this.biteSize)); } return(0); }
public SimulationState Create(string id, IPlant plant, SimulationStateSnapshot data) { return(new SimulationState { Id = id, SimulationTime = data.CurrentTime, Plant = CreatePlantState(plant) }); }
public FluidsPlantCycle(IPlant plant, IPlantSimulatorOptionsService optionsService, ICarrierCollection <Sucrose> sucroseCarrierCollection, ILoggerAdapter <FluidsPlantCycle> logger) { this.plant = plant; this.optionsService = optionsService; this.sucroseCarrierCollection = sucroseCarrierCollection; this.logger = logger; random = new Random(optionsService.Options.Simulation.RandomSeed); }
public int EatPlant(IPlant plant) { if (plant != null) { ++this.Size; return(plant.GetEatenQuantity(this.biteSize)); } return(0); }
public static void CollectInput(Farm farm, IPlant plant) { Utils.Clear(); try { for (int i = 1; i <= farm.NaturalFields.Count; i++) { NaturalField field = farm.NaturalFields[i - 1]; if (field.Capacity > field.numOfPlants()) { Console.WriteLine($"{i}. Natural Field {field.shortId()} has {(field.numOfPlants() / 6)} rows of plants."); // Print out the counts of each type of animal var counts = field.Plants.GroupBy(plant => plant.Type) .Select(group => new PrintReport { Name = group.Key, Count = group.Count() }); foreach (PrintReport report in counts) { Console.WriteLine($"{report.Name}: {report.Count}"); } } else { Console.WriteLine($"{i}. Natural Field {field.shortId()} is at capacity with {field.numOfPlants()} plants."); // Print out the counts of each type of animal var counts = field.Plants.GroupBy(plant => plant.Type) .Select(group => new PrintReport { Name = group.Key, Count = group.Count() }); foreach (PrintReport report in counts) { Console.WriteLine($"{report.Name}: {report.Count}"); } } } Console.WriteLine(); // How can I output the type of seed chosen here? Console.WriteLine($"Place the plant where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); farm.NaturalFields[choice - 1].AddResource(plant); } catch { Console.WriteLine("Please enter a valid selection."); Thread.Sleep(1000); CollectInput(farm, plant); } }
public virtual void Process(InitializePlantArgs args) { IPlant plant = args.IPlantObject; if (plant.Description.IsNullOrEmpty() || plant.HumanSupportingName.IsNullOrEmpty()) { Log.Warn("Plant '{0}' doesn't provide correct name and description. It will be disabed".FormatWith(args.PlantID), this); args.Abort(); args.ResolvedPlantEx = null; } }
/// <summary>Get a list of cultivars for crop.</summary> /// <param name="crop">The crop.</param> /// <returns>A list of cultivars.</returns> public static string[] GetCultivarNames(IPlant crop) { Simulations simulations = (crop as IModel).FindAncestor <Simulations>(); Replacements replacements = simulations.FindChild <Replacements>(); if (replacements == null) { return(crop.CultivarNames); } IPlant replacementCrop = replacements.FindChild((crop as IModel).Name) as IPlant; if (replacementCrop != null) { return(replacementCrop.CultivarNames); } // Check for cultivar folders under replacements. List <string> cultivarNames = crop.CultivarNames.ToList(); foreach (CultivarFolder cultivarFolder in (crop as IModel).FindAllChildren <CultivarFolder>()) { IModel replacementFolder = replacements.FindChild(cultivarFolder.Name); if (replacementFolder != null) { // If we find a matching cultivar folder under replacements, remove // all cultivar names added by this folder in the official plant // model, and add the cultivar names added by the matching cultivar // folder under replacements. foreach (IModel cultivar in cultivarFolder.FindAllDescendants <Cultivar>()) { cultivarNames.Remove(cultivar.Name); // If the cultivar has memo children, then the memo text will // be appended to the cultivar name after a vertical bar |. // Technically, there could be a cultivar x and x|y, but the UI // will prevent users from doing this, so the user would really // just be digging their own hole at this point. cultivarNames.RemoveAll(c => c.StartsWith(cultivar.Name + "|")); } foreach (Alias alias in cultivarFolder.FindAllDescendants <Alias>()) { cultivarNames.RemoveAll(c => c.StartsWith(alias.Name + "|")); } foreach (IModel cultivar in replacementFolder.FindAllDescendants <Cultivar>()) { cultivarNames.Add(cultivar.Name); } } } return(cultivarNames.ToArray()); }
protected void Setup() { _dayTime = new DayTime(); _plant1 = GeneratePlant("P1", 1); _plant2 = GeneratePlant("P2", 2); //List<IPlant> list = new List<IPlant>() { _plant1, _plant2 }; _customer = new Customer(); _subject = new Enterprise(_customer); _subject.Add(_plant1); _subject.Add(_plant2); }
public static void Print(object obj) { IPlant plant = obj as IPlant; if (plant as IPlant != null) { Print(plant); } else { Console.WriteLine("---------------Print for " + obj.GetType() + "---------------"); Console.WriteLine(obj.ToString()); } }
public virtual void Process(InitializePlantArgs args) { IPlant plant = args.IPlantObject; try { plant.Initialize(); } catch (Exception ex) { Log.Error("Unable to initialize plant {0}".FormatWith(plant.GetType()), ex, this); args.Abort(); } }
public Rabbit(IPlant food) { this.Food = food; }
public Plant(IPlant plant) : base(plant) { }
public void DoSomething(IPlant plant) { Console.WriteLine(String.Format("{0} has a soil moisture of {1}% and needs some water", plant.Name, plant.SoilMoisture)); }