public PastureActivityManage GetManagePasture(ActivitiesHolder folder) { PastureActivityManage pasture = new PastureActivityManage(folder) { }; pasture.Add(new Relationship(pasture) { Name = "LandConditionIndex", StartingValue = Convert.ToDouble(FindFirst(Source, "Land_con").Value), Minimum = 1, Maximum = 8 }); pasture.Add(new Relationship(pasture) { Name = "GrassBasalArea", StartingValue = Convert.ToDouble(FindFirst(Source, "Grass_BA").Value), Minimum = 1, Maximum = Convert.ToDouble(FindFirst(Source, "GBAmax").Value), YValues = new[] { -0.95, -0.15, 0, 1.05 } }); return(pasture); }
private void OnStartOfSimulation(object sender, EventArgs e) { // This needs to happen after all manage pasture activities have been initialised on commencing // Therefore we use StartOfSimulation event // link to pasture to muster to pasture = Activities.GetByName(ManagedPastureName) as PastureActivityManage; if (pasture == null) { Summary.WriteWarning(this, String.Format("Could not find manage pasture activity named \"{0}\" for {1}", ManagedPastureName, this.Name)); throw new Exception(String.Format("Invalid pasture name ({0}) provided for mustering activity {1}", ManagedPastureName, this.Name)); } if (LabourRequired > 0) { // check for and assign labour filter group LabourFilterList = this.Children.Where(a => a.GetType() == typeof(LabourFilterGroup)).Cast <object>().ToList(); // if not present assume can use any labour and report if (LabourFilterList == null) { Summary.WriteWarning(this, String.Format("No labour filter details provided for feeding activity ({0}). Assuming any labour type can be used", this.Name)); LabourFilterGroup lfg = new LabourFilterGroup(); LabourFilter lf = new LabourFilter() { Operator = FilterOperators.GreaterThanOrEqual, Value = "0", Parameter = LabourFilterParameters.Age }; lfg.Children.Add(lf); LabourFilterList = new List <object>(); LabourFilterList.Add(lfg); } } if (PerformAtStartOfSimulation) { Muster(); } }