Ejemplo n.º 1
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            if (Resources.GrazeFoodStore() != null)
            {
                this.InitialiseHerd(true, true);
                // create activity for each pasture type (and common land) and breed at startup
                // do not include common land pasture..
                foreach (GrazeFoodStoreType pastureType in Resources.GrazeFoodStore().Children.Where(a => a.GetType() == typeof(GrazeFoodStoreType) || a.GetType() == typeof(CommonLandFoodStoreType)))
                {
                    RuminantActivityGrazePasture ragp = new RuminantActivityGrazePasture();
                    ragp.GrazeFoodStoreModel = pastureType;
                    ragp.Clock  = Clock;
                    ragp.Parent = this;
                    ragp.Name   = "Graze_" + (pastureType as Model).Name;
                    ragp.OnPartialResourcesAvailableAction = this.OnPartialResourcesAvailableAction;
                    ragp.ActivityPerformed += BubblePaddock_ActivityPerformed;
                    ragp.Resources          = this.Resources;
                    ragp.InitialiseHerd(true, true);

                    foreach (RuminantType herdType in Resources.RuminantHerd().Children)
                    {
                        RuminantActivityGrazePastureHerd ragpb = new RuminantActivityGrazePastureHerd
                        {
                            GrazeFoodStoreModel = pastureType,
                            RuminantTypeModel   = herdType,
                            HoursGrazed         = HoursGrazed,
                            Parent = ragp,
                            Name   = ragp.Name + "_" + herdType.Name,
                            OnPartialResourcesAvailableAction = this.OnPartialResourcesAvailableAction
                        };
                        if (ragpb.Resources == null)
                        {
                            ragpb.Resources = this.Resources;
                        }
                        if (ragpb.Clock == null)
                        {
                            ragpb.Clock = this.Clock;
                        }
                        ragpb.InitialiseHerd(true, true);
                        if (ragp.ActivityList == null)
                        {
                            ragp.ActivityList = new List <CLEMActivityBase>();
                        }
                        ragp.ActivityList.Add(ragpb);
                        ragpb.ResourceShortfallOccurred += GrazeAll_ResourceShortfallOccurred;
                        ragpb.ActivityPerformed         += BubblePaddock_ActivityPerformed;
                    }
                    if (ActivityList == null)
                    {
                        ActivityList = new List <CLEMActivityBase>();
                    }
                    ActivityList.Add(ragp);
                }
            }
            else
            {
                Summary.WriteWarning(this, "No GrazeFoodStore is available for the ruminant grazing activity!");
            }
        }
Ejemplo n.º 2
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            // create activity for each pasture type and breed at startup
            foreach (GrazeFoodStoreType pastureType in Resources.GrazeFoodStore().Children)
            {
                RuminantActivityGrazePasture ragp = new RuminantActivityGrazePasture();
                ragp.GrazeFoodStoreModel = pastureType;
                ragp.Clock  = Clock;
                ragp.Parent = this;
                ragp.Name   = "Graze_" + pastureType.Name;
                ragp.OnPartialResourcesAvailableAction = this.OnPartialResourcesAvailableAction;
                ragp.ActivityPerformed += BubblePaddock_ActivityPerformed;

                foreach (RuminantType herdType in Resources.RuminantHerd().Children)
                {
                    RuminantActivityGrazePastureHerd ragpb = new RuminantActivityGrazePastureHerd
                    {
                        GrazeFoodStoreModel = pastureType,
                        RuminantTypeModel   = herdType,
                        HoursGrazed         = HoursGrazed,
                        Parent = ragp,
                        Name   = ragp.Name + "_" + herdType.Name,
                        OnPartialResourcesAvailableAction = this.OnPartialResourcesAvailableAction
                    };
                    if (ragpb.Resources == null)
                    {
                        ragpb.Resources = this.Resources;
                    }
                    if (ragpb.Clock == null)
                    {
                        ragpb.Clock = this.Clock;
                    }
                    ragpb.InitialiseHerd(true, true);
                    if (ragp.ActivityList == null)
                    {
                        ragp.ActivityList = new List <CLEMActivityBase>();
                    }
                    ragp.ActivityList.Add(ragpb);
                    ragpb.ResourceShortfallOccurred += GrazeAll_ResourceShortfallOccurred;
                    ragpb.ActivityPerformed         += BubblePaddock_ActivityPerformed;
                }
                if (ActivityList == null)
                {
                    ActivityList = new List <CLEMActivityBase>();
                }
                ActivityList.Add(ragp);
            }
        }
Ejemplo n.º 3
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            GrazeFoodStore grazeFoodStore = Resources.FindResourceGroup <GrazeFoodStore>();

            if (grazeFoodStore != null)
            {
                this.InitialiseHerd(true, true);
                // create activity for each pasture type (and common land) and breed at startup
                // do not include common land pasture..
                foreach (GrazeFoodStoreType pastureType in grazeFoodStore.Children.Where(a => a.GetType() == typeof(GrazeFoodStoreType) || a.GetType() == typeof(CommonLandFoodStoreType)))
                {
                    RuminantActivityGrazePasture ragp = new RuminantActivityGrazePasture
                    {
                        GrazeFoodStoreModel = pastureType,
                        Clock  = clock,
                        Parent = this,
                        Name   = "Graze_" + (pastureType as Model).Name,
                        OnPartialResourcesAvailableAction = this.OnPartialResourcesAvailableAction
                    };
                    ragp.ActivityPerformed += BubblePaddock_ActivityPerformed;
                    ragp.SetLinkedModels(Resources);
                    ragp.InitialiseHerd(true, true);

                    foreach (RuminantType herdType in HerdResource.FindAllChildren <RuminantType>())
                    {
                        RuminantActivityGrazePastureHerd ragpb = new RuminantActivityGrazePastureHerd
                        {
                            GrazeFoodStoreModel = pastureType,
                            RuminantTypeModel   = herdType,
                            HoursGrazed         = HoursGrazed,
                            Parent = ragp,
                            Name   = ragp.Name + "_" + herdType.Name,
                            OnPartialResourcesAvailableAction = this.OnPartialResourcesAvailableAction
                        };

                        ragpb.SetLinkedModels(Resources);

                        if (ragpb.Clock == null)
                        {
                            ragpb.Clock = this.clock;
                        }

                        ragpb.InitialiseHerd(true, true);
                        if (ragp.ActivityList == null)
                        {
                            ragp.ActivityList = new List <CLEMActivityBase>();
                        }

                        ragp.ActivityList.Add(ragpb);
                        ragpb.ResourceShortfallOccurred += GrazeAll_ResourceShortfallOccurred;
                        ragpb.ActivityPerformed         += BubblePaddock_ActivityPerformed;
                    }
                    if (ActivityList == null)
                    {
                        ActivityList = new List <CLEMActivityBase>();
                    }
                    ActivityList.Add(ragp);
                }
            }
            else
            {
                Summary.WriteMessage(this, $"No GrazeFoodStore is available for the ruminant grazing activity [a={this.Name}]!", MessageType.Warning);
            }
        }