private void OnWFRequestFeed(object sender, EventArgs e) { RuminantHerd ruminantHerd = Resources.RuminantHerd(); List <Ruminant> herd = ruminantHerd.Herd; IResourceType grazeStoreType = null; if (FeedArbitratorName != "") { grazeStoreType = Arbitrators.GetByName(FeedArbitratorName) as IResourceType; } // for each paddock defined in PastureActivityManage foreach (PastureActivityManage pasture in Activities.Children.Where(a => a.GetType() == typeof(PastureActivityManage))) { if (FeedArbitratorName == "") { grazeStoreType = pasture.FeedType; } // create feeding activity for this pasture RuminantActivityGraze activity = new RuminantActivityGraze(); activity.FeedPriority = this.FeedPriority; activity.FeedType = pasture.FeedType; activity.HoursGrazed = this.HoursGrazed; activity.Name = String.Format("Graze {0}", pasture.FeedType.Name); // calculate kg per ha available double kgPerHa = pasture.FeedType.Amount / pasture.Area; if (pasture.FeedType.Amount > 0) { // get list of all Ruminants in this paddock foreach (Ruminant ind in herd.Where(a => a.Location == pasture.Name)) { RuminantFeedRequest freqest = new RuminantFeedRequest(); freqest.FeedActivity = activity; freqest.Requestor = ind; // Reduce potential intake based on pasture quality for the proportion consumed. // calculate intake from potential modified by pasture availability and hours grazed freqest.Amount = ind.PotentialIntake * (1 - Math.Exp(-ind.BreedParams.IntakeCoefficientBiomass * kgPerHa)) * (HoursGrazed / 8); grazeStoreType.Remove(freqest); } } } }
private void OnWFRequestFeed(object sender, EventArgs e) { RuminantHerd ruminantHerd = Resources.RuminantHerd(); List<Ruminant> herd = ruminantHerd.Herd; IResourceType grazeStoreType = null; if (FeedArbitratorName != "") { grazeStoreType = Arbitrators.GetByName(FeedArbitratorName) as IResourceType; } // for each paddock defined in PastureActivityManage foreach (PastureActivityManage pasture in Activities.Children.Where(a => a.GetType() == typeof(PastureActivityManage))) { if (FeedArbitratorName == "") { grazeStoreType = pasture.FeedType; } // create feeding activity for this pasture RuminantActivityGraze activity = new RuminantActivityGraze(); activity.FeedPriority = this.FeedPriority; activity.FeedType = pasture.FeedType; activity.HoursGrazed = this.HoursGrazed; activity.Name = String.Format("Graze {0}", pasture.FeedType.Name); // calculate kg per ha available double kgPerHa = pasture.FeedType.Amount / pasture.Area; if (pasture.FeedType.Amount > 0) { // get list of all Ruminants in this paddock foreach (Ruminant ind in herd.Where(a => a.Location == pasture.Name)) { RuminantFeedRequest freqest = new RuminantFeedRequest(); freqest.FeedActivity = activity; freqest.Requestor = ind; // Reduce potential intake based on pasture quality for the proportion consumed. // calculate intake from potential modified by pasture availability and hours grazed freqest.Amount = ind.PotentialIntake * (1 - Math.Exp(-ind.BreedParams.IntakeCoefficientBiomass * kgPerHa)) * (HoursGrazed / 8); grazeStoreType.Remove(freqest); } } } }