private void OnSimulationCommencing(object sender, EventArgs e) { // locate FeedType resource bool resourceAvailable = false; FeedType = Resources.GetResourceItem("AnimalFoodStore", FeedTypeName, out resourceAvailable) as IFeedType; FoodSource = FeedType; 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); } } }
public RuminantActivityGrazeAll(Node parent) : base(parent) { Name = "GrazeAll"; OnPartialResourcesAvailableAction = 2; var labour = new LabourRequirement(this); var group = new LabourFilterGroup(labour); var filter = new LabourFilter(group) { Parameter = 0, Operator = 0, Value = "Male" }; group.Add(filter); labour.Add(group); }
/// <summary> /// Models the availability of each Labour Type /// </summary> public IEnumerable <LabourAvailabilityItem> GetAvailabilityItems(LabourAvailabilityList parent) { List <LabourAvailabilityItem> items = new List <LabourAvailabilityItem>(); int count = -1; foreach (var row in LabourSupply.RowNames) { count++; if (LabourSupply.GetData <string>(count, 0) != "0") { string age = LabourSupply.ExtraNames[count]; string gender = LabourSupply.RowNames[count]; double value = Math.Round(LabourSupply.GetData <double>(count, 2)); LabourAvailabilityItem item = new LabourAvailabilityItem(parent) { Name = age + " " + gender, Value = value }; LabourFilter GenderFilter = new LabourFilter(item) { Name = "GenderFilter", Parameter = 1, Value = gender }; LabourAges.TryGetValue(item.Name, out int years); LabourFilter AgeFilter = new LabourFilter(item) { Name = "AgeFilter", Parameter = 2, Operator = 5, Value = years.ToString() }; item.Children.Add(GenderFilter); item.Children.Add(AgeFilter); items.Add(item); } } return(items.AsEnumerable()); }
private void OnSimulationCommencing(object sender, EventArgs e) { // check payment interval > 0 if (BreedInterval <= 0) { Summary.WriteWarning(this, String.Format("Controlled mating interval must be greater than 1 ({0})", this.Name)); throw new Exception(String.Format("Invalid controlled mating interval supplied for overhead {0}", this.Name)); } if (MonthDue >= Clock.StartDate.Month) { NextDueDate = new DateTime(Clock.StartDate.Year, MonthDue, Clock.StartDate.Day); } else { NextDueDate = new DateTime(Clock.StartDate.Year, MonthDue, Clock.StartDate.Day); while (Clock.StartDate > NextDueDate) { NextDueDate = NextDueDate.AddMonths(BreedInterval); } } // 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 controlled mating settings ({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); } }