private void AddBought(List <AnimalFoodStoreType> types, AnimalFoodStore store) { var fodders = Fodder.Elements().Skip(2).ToList(); var indices = from fodder in fodders where fodder.Elements().ElementAt(3).Value == "TRUE" select fodders.IndexOf(fodder); var slist = FodderSpecs.Elements().Skip(3).ToList(); var specs = from spec in slist where indices.Contains(slist.IndexOf(spec)) select new string[3] { spec.Name.LocalName, spec.Elements().ElementAt(1).Value, spec.Elements().ElementAt(2).Value }; foreach (var spec in specs) { types.Add(new AnimalFoodStoreType(store) { Name = spec[0], DMD = Convert.ToDouble(spec[1]), Nitrogen = Convert.ToDouble(spec[2]) }); } }
/// <summary> /// Add a RuminantActivityFeed for each item in the AnimalFoodStore /// </summary> private ActivityFolder GetFeed(ActivityFolder herd) { AnimalFoodStore store = SearchTree <AnimalFoodStore>((ZoneCLEM)Parent); if (store.Children.Count == 0) { return(null); } ActivityFolder feed = new ActivityFolder(herd) { Name = "Feed ruminants" }; foreach (Node child in store.Children) { feed.Add(new RuminantActivityFeed(feed) { Name = "Feed " + child.Name, FeedTypeName = "AnimalFoodStore." + child.Name }); } return(feed); }
private void AddSupplements(List <AnimalFoodStoreType> types, AnimalFoodStore store) { // List of all supplement allocations (skipping metadata) var allocs = SuppAllocs.Elements().Skip(2).ToList(); // Indices of non-zero allocations var indices = from alloc in allocs where alloc.Elements().Select(e => e.Value).ToList().Exists(v => v != "0") select allocs.IndexOf(alloc); // List of all supplement specifications (skipping metadata) var supps = SuppSpecs.Elements().Skip(3).ToList(); // Collection of specifications with allocations var specs = from spec in supps where indices.Contains(supps.IndexOf(spec)) select new string[3] { spec.Name.LocalName, spec.Elements().ElementAt(1).Value, spec.Elements().ElementAt(2).Value }; foreach (var spec in specs) { types.Add(new AnimalFoodStoreType(store) { Name = spec[0], DMD = Convert.ToDouble(spec[1]), Nitrogen = Convert.ToDouble(spec[2]) }); } }
public IEnumerable <AnimalFoodStoreType> GetAnimalStoreTypes(AnimalFoodStore store) { List <AnimalFoodStoreType> types = new List <AnimalFoodStoreType>(); AddSupplements(types, store); AddBought(types, store); return(types); }
/// <summary> /// Model fodder available through the common land /// </summary> public CommonLandFoodStoreType GetCommonFoodStore(AnimalFoodStore store) { // Checks if there is any yield from the common land before adding it to the foodstore double yield = Convert.ToDouble(GetCellValue(Part, 81, 4)); if (yield > 0) { return(new CommonLandFoodStoreType(store)); } else { return(null); } }
/// <summary> /// Model each fodder pool in the AnimalFoodStore /// </summary> public IEnumerable <AnimalFoodStoreType> GetAnimalStoreTypes(AnimalFoodStore store) { List <AnimalFoodStoreType> types = new List <AnimalFoodStoreType>(); // Add each fodder pool to the animal food store foreach (int pool in Pools.Keys) { types.Add(new AnimalFoodStoreType(store) { Name = Pools[pool] }); } return(types); }
public CommonLandFoodStoreType GetCommonFoodStore(AnimalFoodStore store) { return(null); }