Exemple #1
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            Items = new List <GrazeFoodStoreType>();

            IEnumerable <IModel> childNodes = FindAllChildren <IModel>();

            foreach (IModel childModel in childNodes)
            {
                switch (childModel.GetType().ToString())
                {
                case "Models.CLEM.Resources.GrazeFoodStoreType":
                    GrazeFoodStoreType grazefood = childModel as GrazeFoodStoreType;
                    grazefood.TransactionOccurred            += Resource_TransactionOccurred;
                    grazefood.EcologicalIndicatorsCalculated += Resource_EcologicalIndicatorsCalculated;
                    Items.Add(grazefood);
                    break;

                case "Models.CLEM.Resources.CommonLandFoodStoreType":
                    CommonLandFoodStoreType commonfood = childModel as CommonLandFoodStoreType;
                    commonfood.TransactionOccurred += Resource_TransactionOccurred;
                    break;

                default:
                    break;
                }
            }
        }
Exemple #2
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            Items = new List <GrazeFoodStoreType>();

            List <IModel> childNodes = Apsim.Children(this, typeof(IModel));

            foreach (IModel childModel in childNodes)
            {
                //cast the generic IModel to a specfic model.
                GrazeFoodStoreType grazefood = childModel as GrazeFoodStoreType;
                grazefood.TransactionOccurred            += Resource_TransactionOccurred;
                grazefood.EcologicalIndicatorsCalculated += Resource_EcologicalIndicatorsCalculated;
                Items.Add(grazefood);
            }
        }
Exemple #3
0
        private new void OnSimulationCommencing(object sender, EventArgs e)
        {
            Items = new List <GrazeFoodStoreType>();

            foreach (IModel childModel in FindAllChildren <IModel>())
            {
                switch (childModel.GetType().ToString())
                {
                case "Models.CLEM.Resources.GrazeFoodStoreType":
                    GrazeFoodStoreType grazefood = childModel as GrazeFoodStoreType;
                    grazefood.EcologicalIndicatorsCalculated += Resource_EcologicalIndicatorsCalculated;
                    Items.Add(grazefood);
                    break;

                default:
                    break;
                }
            }
        }
Exemple #4
0
 private void OnSimulationCommencing(object sender, EventArgs e)
 {
     parentPasture = this.Parent as GrazeFoodStoreType;
     timingPresent = FindAllChildren <ActivityTimerMonthRange>().Count() >= 1;
 }
Exemple #5
0
        /// <summary>
        /// Provides the description of the model settings for summary (GetFullSummary)
        /// </summary>
        /// <param name="formatForParentControl">Use full verbose description</param>
        /// <returns></returns>
        public override string ModelSummary(bool formatForParentControl)
        {
            bool timerpresent = FindAllChildren <ActivityTimerMonthRange>().Count() > 0;

            parentPasture = this.Parent as GrazeFoodStoreType;

            string html = "";

            html += "\n<div class=\"activityentry\">";
            html += "\nThe nitrogen content of new pasture will be reduced by ";
            if (NitrogenReduction == 0)
            {
                html += "<span class=\"errorlink\">Not Set</span>";
            }
            else
            {
                html += "<span class=\"setvalue\">";
                html += NitrogenReduction.ToString("P0");
                html += "</span>";
            }
            html += " if";

            if (timerpresent)
            {
                html += "</div>";
                html += "\n<div class=\"activityentry\">";
                html += "<b>(A)</b>";
            }

            html += " an annual nitrogen supply of  ";
            if (AnnualNitrogenSupply == 0)
            {
                html += "<span class=\"errorlink\">Not Set</span>";
            }
            else
            {
                html += "<span class=\"setvalue\">";
                html += AnnualNitrogenSupply.ToString("N0");
                html += "</span> kg per hectare has been used since ";
            }
            if (AnnualYieldStartMonth == MonthsOfYear.NotSet)
            {
                html += "<span class=\"errorlink\">Month not set";
            }
            else
            {
                html += "<span class=\"setvalue\">";
                html += AnnualYieldStartMonth.ToString();
            }
            html += "</span>\n</div>";

            if (AnnualNitrogenSupply > 0)
            {
                html += "\n<div class=\"activityentry\">";
                if (parentPasture.GreenNitrogen > 0)
                {
                    html += $"This equates to <span class=\"setvalue\">{AnnualNitrogenSupply / (parentPasture.GreenNitrogen / 100)}</span> kg per hectare of pasture production given the new growth nitrogen content of <span class=\"setvalue\">{parentPasture.GreenNitrogen}%</span>.";
                }
                else
                {
                    html += $"This equates to <span class=\"errorlink\">Undefined</span> kg per hectare of pasture production given the green growth nitrogen content of <span class=\"errorlink\">Not set</span>.";
                }
                html += "\n</div>";
            }

            if (timerpresent)
            {
                html += "\n<div class=\"activityentry\">";
                html += "or <b>(B)</b> the growth month falls within the specified period below";
                html += "\n</div>";
            }
            else
            {
                html += "\n<div class=\"activityentry\">";
                html += "or <b>(B)</b> Add a ActivityMonthRangeTimer below to reduce nitrogen content in specified months";
                html += "\n</div>";
            }
            return(html);
        }