Пример #1
0
        public WheatLeafState(WheatLeafState toCopy)
        {
            System.Collections.Generic.List <int> _State = new List <int>(toCopy._State);

            System.Collections.Generic.List <int> _PreviousState = new List <int>(toCopy._PreviousState);

            System.Collections.Generic.List <int> _isPrematurelyDying = new List <int>(toCopy._isPrematurelyDying);

            System.Collections.Generic.List <double> _TTGroLamina = new List <double>(toCopy._TTGroLamina);

            System.Collections.Generic.List <double> _MaxAI = new List <double>(toCopy._MaxAI);

            System.Collections.Generic.List <double> _TTsen = new List <double>(toCopy._TTsen);

            System.Collections.Generic.List <double> _TTem = new List <double>(toCopy._TTem);

            System.Collections.Generic.List <double> _LaminaAI = new List <double>(toCopy._LaminaAI);

            System.Collections.Generic.List <double> _SheathAI = new List <double>(toCopy._SheathAI);

            System.Collections.Generic.List <double> _GAI = new List <double>(toCopy._GAI);

            System.Collections.Generic.List <double> _TTmat = new List <double>(toCopy._TTmat);

            System.Collections.Generic.List <double> _laminaSpecificN = new List <double>(toCopy._laminaSpecificN);

            System.Collections.Generic.List <double> _Phyllochron = new List <double>(toCopy._Phyllochron);

            System.Collections.Generic.List <int> _isSmallPhytomer = new List <int>(toCopy._isSmallPhytomer);

            System.Collections.Generic.List <double> _deltaAI = new List <double>(toCopy._deltaAI);
        }
 public void resetDeltaAI(SiriusQualityWheatLAI.WheatLeafState wheatleafstate)
 {
     for (int ilayer = 0; ilayer < wheatleafstate.deltaAI.Count; ilayer++)
     {
         wheatleafstate.deltaAI[ilayer] = 0;
     }
 }
        public WheatLAIWrapper()
        {
            wheatLAI_        = new SiriusQualityWheatLAI.Strategies.WheatLAI();
            wheatLaistate_   = new SiriusQualityWheatLAI.WheatLAIState();
            wheatLeafstate_  = new SiriusQualityWheatLAI.WheatLeafState();
            wheatLeafstate1_ = new SiriusQualityWheatLAI.WheatLeafState();

            loadParametersWheat();
        }
        /// <summary>
        /// Calculate method for the component with test of preconditions
        /// </summary>
        /// <param name=w>WheatLAIState Domain class contains the accessors to values</param>
        /// <param name=w1>WheatLeafState Domain class contains the accessors to values</param>
        /// <param name=w2>WheatLeafState Domain class contains the accessors to values</param>
        /// <param name=ae>AgroManagement objects of impact parameters</param>
        /// <param name="saveLog">Save log via a writer or show on screen</param>
        /// <param name="callID">Context description for violations</param>
        public void Estimate
            (IStrategySiriusQualityWheatLAI st, WheatLAIState w, WheatLeafState w1, WheatLeafState w2, ActEvents ae, bool saveLog, string callID)
        {
            _resultPreConditions  = String.Empty;
            _resultPostConditions = String.Empty;
            _resultPreConditions  = st.TestPreConditions(w, w1, w2, callID);
            st.Estimate
                (w, w1, w2, ae);
            _resultPostConditions = st.TestPostConditions(w, w1, w2, callID);

            if (_resultPreConditions != String.Empty || _resultPostConditions != String.Empty)
            {
                p.TestsOut(_resultPreConditions + _resultPostConditions, saveLog, callID);
            }
        }
Пример #5
0
        /// <summary>
        /// Run the strategy to calculate the outputs. In case of error during the execution, the preconditions tests are executed.
        /// </summary>
        public void Estimate(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            try
            {
                CalculateModel(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);

                //Uncomment the next line to use the trace
                //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 1005,"Strategy: " + this.GetType().Name + " - Model executed");
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1003,		"Strategy: " + this.GetType().Name + " - Unhandled exception running model");

                string msg = "Error in component SiriusQualityWheatLAI.Strategies, strategy: " + this.GetType().Name + ": Unhandled exception running model. " + exception.GetType().FullName + " - " + exception.Message;
                throw new Exception(msg, exception);
            }
        }
        private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation

            if (wheatleafstate.isSmallPhytomer[wheatlaistate.index] == 0)
            {
                wheatleafstate.TTmat[wheatlaistate.index] = PlagLL * wheatleafstate.Phyllochron[wheatlaistate.index];
            }
            else
            {
                wheatleafstate.TTmat[wheatlaistate.index] = PlagSL * wheatleafstate.Phyllochron[wheatlaistate.index];
            }


            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
Пример #7
0
        private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation
            if (wheatlaistate.newLeafHasAppeared == 1)
            {
                wheatlaistate.MaximumPotentialLaminaeAI.Add(PotentialLaminaAreaIndex(wheatlaistate.roundedFinalLeafNumber, wheatlaistate.finalLeafNumber, wheatlaistate.leafNumber, wheatleafstate.isSmallPhytomer[wheatlaistate.index] == 1, wheatlaistate.phytonum, wheatlaistate.index, wheatlaistate.tilleringProfile, wheatlaistate.leafTillerNumberArray));
                wheatlaistate.MaximumPotentialSheathAI.Add(PotentialSheathAreaIndex(wheatlaistate.roundedFinalLeafNumber, wheatleafstate.isSmallPhytomer[wheatlaistate.index] == 1, wheatlaistate.phytonum, wheatlaistate.index, wheatlaistate.tilleringProfile, wheatlaistate.leafTillerNumberArray));
            }


            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
Пример #8
0
        /// <summary>Update all leaf state </summary>
        private void CalculateNewStates(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1)
        {
            wheatleafstate1.State        = new List <int>();
            wheatleafstate.PreviousState = new List <int>();

            for (int i = 0; i < wheatleafstate.GAI.Count; i++)
            {
                double TTgro = wheatleafstate.TTGroLamina[i] + wheatlaistate.TTgroSheathList[i];
                CalculateNewLeafLayerState(wheatlaistate, wheatleafstate, wheatleafstate1, i, wheatleafstate.GAI[i], wheatleafstate.TTem[i], TTgro, wheatleafstate.TTmat[i], wheatleafstate.TTsen[i], wheatleafstate.laminaSpecificN[i]);
            }
        }
Пример #9
0
        //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section2
        //Code written below will not be overwritten by a future code generation

        /// <summary>Calculate potential delta area index of the day (either growth or senescence)</summary>
        /// <param name="potentialIncDeltaArea">Potential delta area index increment of the day</param>
        private void CalculatePotIncDeltaAI(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1)
        {
            wheatlaistate.potentialIncDeltaArea = 0;
            for (int i = 0; i < wheatleafstate.GAI.Count; i++)
            {
                CalculateWaterLimitedPotentialDeltaArea(wheatlaistate, wheatleafstate, wheatleafstate1, i);
                var potDelta = wheatlaistate.WaterLimitedPotDeltaAIList[i];
                if (potDelta > 0)
                {
                    wheatlaistate.potentialIncDeltaArea += potDelta;
                }
            }

            wheatlaistate.incDeltaAreaLimitSF = wheatlaistate.potentialIncDeltaArea * wheatlaistate.DEF;
        }
Пример #10
0
        //Parameters static VarInfo list of the composite class


        #endregion

        #region pre/post conditions management

        /// <summary>
        /// Test to verify the postconditions
        /// </summary>
        public string TestPostConditions(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, string callID)
        {
            try
            {
                //Set current values of the outputs to the static VarInfo representing the output properties of the domain classes

                SiriusQualityWheatLAI.WheatLAIStateVarInfo.incDeltaAreaLimitSF.CurrentValue        = wheatlaistate.incDeltaAreaLimitSF;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.WaterLimitedPotDeltaAIList.CurrentValue = wheatlaistate.WaterLimitedPotDeltaAIList;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.potentialIncDeltaArea.CurrentValue      = wheatlaistate.potentialIncDeltaArea;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.State.CurrentValue = wheatleafstate.State;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.isPrematurelyDying.CurrentValue = wheatleafstate.isPrematurelyDying;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.TT.CurrentValue = wheatlaistate.TT;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.TTgroSheathList.CurrentValue = wheatlaistate.TTgroSheathList;

                //Create the collection of the conditions to test
                ConditionsCollection prc = new ConditionsCollection();
                Preconditions        pre = new Preconditions();


                RangeBasedCondition r20 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.incDeltaAreaLimitSF);
                if (r20.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.incDeltaAreaLimitSF.ValueType))
                {
                    prc.AddCondition(r20);
                }
                RangeBasedCondition r21 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.WaterLimitedPotDeltaAIList);
                if (r21.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.WaterLimitedPotDeltaAIList.ValueType))
                {
                    prc.AddCondition(r21);
                }
                RangeBasedCondition r22 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.potentialIncDeltaArea);
                if (r22.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.potentialIncDeltaArea.ValueType))
                {
                    prc.AddCondition(r22);
                }
                RangeBasedCondition r23 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.State);
                if (r23.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.State.ValueType))
                {
                    prc.AddCondition(r23);
                }
                RangeBasedCondition r24 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.isPrematurelyDying);
                if (r24.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.isPrematurelyDying.ValueType))
                {
                    prc.AddCondition(r24);
                }
                RangeBasedCondition r25 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.TT);
                if (r25.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.TT.ValueType))
                {
                    prc.AddCondition(r25);
                }
                RangeBasedCondition r26 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.TTgroSheathList);
                if (r26.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.TTgroSheathList.ValueType))
                {
                    prc.AddCondition(r26);
                }



                //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section4
                //Code written below will not be overwritten by a future code generation



                //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
                //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section4

                //Get the evaluation of postconditions
                string postConditionsResult = pre.VerifyPostconditions(prc, callID);
                //if we have errors, send it to the configured output
                if (!string.IsNullOrEmpty(postConditionsResult))
                {
                    pre.TestsOut(postConditionsResult, true, "PostConditions errors in component SiriusQualityWheatLAI.Strategies, strategy " + this.GetType().Name);
                }
                return(postConditionsResult);
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1001,	"Strategy: " + this.GetType().Name + " - Unhandled exception running post-conditions");

                string msg = "Component SiriusQualityWheatLAI.Strategies, " + this.GetType().Name + ": Unhandled exception running post-condition test. ";
                throw new Exception(msg, exception);
            }
        }
        private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation

            wheatleafstate.TTGroLamina[wheatlaistate.index] = wheatleafstate.Phyllochron[wheatlaistate.index] * PexpL;

            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
Пример #12
0
        private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation

            wheatleafstate.isSmallPhytomer[wheatlaistate.index] = isSmallPhytomer(wheatlaistate.index, wheatlaistate.finalLeafNumber, wheatlaistate.roundedFinalLeafNumber);

            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
 /// <summary>
 /// Calculate method for the component
 /// </summary>
 /// <param name=w>WheatLAIState Domain class contains the accessors to values</param>
 /// <param name=w1>WheatLeafState Domain class contains the accessors to values</param>
 /// <param name=w2>WheatLeafState Domain class contains the accessors to values</param>
 /// <param name=ae>AgroManagement objects of impact parameters</param>
 public void Estimate
     (IStrategySiriusQualityWheatLAI st, WheatLAIState w, WheatLeafState w1, WheatLeafState w2, ActEvents ae)
 {
     st.Estimate
         (w, w1, w2, ae);
 }
        private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation

            if (wheatlaistate.potentialIncDeltaArea > 0.0)
            {
                if (wheatlaistate.incDeltaAreaLimitSF == 0.0)
                {
                    wheatlaistate.incDeltaArea = 0;
                }
                else
                {
                    wheatlaistate.incDeltaArea = wheatlaistate.incDeltaAreaLimitSF * Math.Min(1.0, wheatlaistate.availableN / (wheatlaistate.incDeltaAreaLimitSF * SLNcri));
                    IsNumber(wheatlaistate.incDeltaArea);
                }

                double stressGrowth = wheatlaistate.incDeltaArea / wheatlaistate.potentialIncDeltaArea;

                for (int ilayer = 0; ilayer < wheatleafstate.GAI.Count; ilayer++)
                {
                    if (wheatlaistate.WaterLimitedPotDeltaAIList[ilayer] > 0.0)     // leaf layer is growing
                    {
                        IsNumber(stressGrowth);
                        wheatleafstate.deltaAI[ilayer] = wheatlaistate.WaterLimitedPotDeltaAIList[ilayer] * stressGrowth;
                        if ((wheatlaistate.cumulTTShoot - wheatleafstate.TTem[ilayer]) < wheatleafstate.Phyllochron[ilayer] * PexpL)
                        {
                            wheatleafstate1.LaminaAI[ilayer] = wheatleafstate.LaminaAI[ilayer] + wheatleafstate.deltaAI[ilayer];
                            wheatleafstate.LaminaAI[ilayer]  = wheatleafstate1.LaminaAI[ilayer];
                        }
                        else
                        {
                            wheatleafstate1.SheathAI[ilayer] = wheatleafstate.SheathAI[ilayer] + wheatleafstate.deltaAI[ilayer];
                            wheatleafstate.SheathAI[ilayer]  = wheatleafstate1.SheathAI[ilayer];
                        }

                        wheatleafstate.GAI[ilayer] = wheatleafstate.LaminaAI[ilayer] + wheatleafstate.SheathAI[ilayer];

                        wheatleafstate1.MaxAI[ilayer] = Math.Max(wheatleafstate.MaxAI[ilayer], wheatleafstate.GAI[ilayer]);
                        wheatleafstate.MaxAI[ilayer]  = wheatleafstate1.MaxAI[ilayer];
                    }
                }
            }
            else
            {
                wheatlaistate.incDeltaArea = 0;
            }

            for (int ilayer = 0; ilayer < wheatleafstate.GAI.Count; ilayer++)
            {
                if (wheatleafstate.State[ilayer] == 2)
                {
                    wheatleafstate.deltaAI[ilayer] = wheatlaistate.WaterLimitedPotDeltaAIList[ilayer];
                    double gai = wheatleafstate.GAI[ilayer];
                    if (gai > 0)
                    {
                        var leafLaminaeDec   = wheatlaistate.WaterLimitedPotDeltaAIList[ilayer] * wheatleafstate.LaminaAI[ilayer] / gai;
                        var exposedSheathDec = wheatlaistate.WaterLimitedPotDeltaAIList[ilayer] * wheatleafstate.SheathAI[ilayer] / gai;

                        wheatleafstate1.LaminaAI[ilayer] = wheatleafstate.LaminaAI[ilayer] + leafLaminaeDec;
                        wheatleafstate1.SheathAI[ilayer] = wheatleafstate.SheathAI[ilayer] + exposedSheathDec;

                        wheatleafstate.LaminaAI[ilayer] = wheatleafstate1.LaminaAI[ilayer];
                        wheatleafstate.SheathAI[ilayer] = wheatleafstate1.SheathAI[ilayer];
                    }
                }
            }

            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
Пример #15
0
        /// <summary>
        /// Test to verify the preconditions
        /// </summary>
        public string TestPreConditions(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, string callID)
        {
            try
            {
                //Set current values of the inputs to the static VarInfo representing the input properties of the domain classes

                SiriusQualityWheatLAI.WheatLAIStateVarInfo.FPAW.CurrentValue           = wheatlaistate.FPAW;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.isPotentialLAI.CurrentValue = wheatlaistate.isPotentialLAI;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.VPDairCanopy.CurrentValue   = wheatlaistate.VPDairCanopy;

                //Create the collection of the conditions to test
                ConditionsCollection prc = new ConditionsCollection();
                Preconditions        pre = new Preconditions();


                RangeBasedCondition r1 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.FPAW);
                if (r1.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.FPAW.ValueType))
                {
                    prc.AddCondition(r1);
                }
                RangeBasedCondition r2 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.isPotentialLAI);
                if (r2.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.isPotentialLAI.ValueType))
                {
                    prc.AddCondition(r2);
                }
                RangeBasedCondition r3 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.VPDairCanopy);
                if (r3.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.VPDairCanopy.ValueType))
                {
                    prc.AddCondition(r3);
                }
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("LowerFPAWexp")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("UpperFPAWexp")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("MaxDSF")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("LowerFPAWsen")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("UpperFPAWsen")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("UpperVPD")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("LowerVPD")));



                //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section3
                //Code written below will not be overwritten by a future code generation



                //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
                //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section3

                //Get the evaluation of preconditions;
                string preConditionsResult = pre.VerifyPreconditions(prc, callID);
                //if we have errors, send it to the configured output
                if (!string.IsNullOrEmpty(preConditionsResult))
                {
                    pre.TestsOut(preConditionsResult, true, "PreConditions errors in component SiriusQualityWheatLAI.Strategies, strategy " + this.GetType().Name);
                }
                return(preConditionsResult);
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //	TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1002,"Strategy: " + this.GetType().Name + " - Unhandled exception running pre-conditions");

                string msg = "Component SiriusQualityWheatLAI.Strategies, " + this.GetType().Name + ": Unhandled exception running pre-condition test. ";
                throw new Exception(msg, exception);
            }
        }
Пример #16
0
        private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation
            if (wheatlaistate.isPotentialLAI == 1)
            {
                wheatlaistate.DEF = 1;
                wheatlaistate.DSF = 1;
            }
            else
            {
                wheatlaistate.DEF = CalculateDF(LowerFPAWexp, UpperFPAWexp, 0, 1, wheatlaistate.FPAW, wheatlaistate.VPDairCanopy);
                wheatlaistate.DSF = CalculateDF(LowerFPAWsen, UpperFPAWsen, MaxDSF, 1, wheatlaistate.FPAW, wheatlaistate.VPDairCanopy);
            }


            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
        /// <summary>
        /// Test to verify the preconditions
        /// </summary>
        public string TestPreConditions(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, string callID)
        {
            try
            {
                //Set current values of the inputs to the static VarInfo representing the input properties of the domain classes

                SiriusQualityWheatLAI.WheatLAIStateVarInfo.previousIndex.CurrentValue = wheatlaistate.previousIndex;

                //Create the collection of the conditions to test
                ConditionsCollection prc = new ConditionsCollection();
                Preconditions        pre = new Preconditions();


                RangeBasedCondition r1 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.previousIndex);
                if (r1.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.previousIndex.ValueType))
                {
                    prc.AddCondition(r1);
                }


                string ret = "";
                ret += _issmallphytomer.TestPreConditions(wheatlaistate, wheatleafstate, wheatleafstate1, "strategy SiriusQualityWheatLAI.Strategies.IsSmallPhytomer");
                ret += _laminaexpansionthermaltime.TestPreConditions(wheatlaistate, wheatleafstate, wheatleafstate1, "strategy SiriusQualityWheatLAI.Strategies.LaminaExpansionThermalTime");
                ret += _leafexpansiondroughtfactor.TestPreConditions(wheatlaistate, wheatleafstate, wheatleafstate1, "strategy SiriusQualityWheatLAI.Strategies.LeafExpansionDroughtFactor");
                ret += _maturitythermaltime.TestPreConditions(wheatlaistate, wheatleafstate, wheatleafstate1, "strategy SiriusQualityWheatLAI.Strategies.MaturityThermalTime");
                ret += _maximumpotentialfinallai.TestPreConditions(wheatlaistate, wheatleafstate, wheatleafstate1, "strategy SiriusQualityWheatLAI.Strategies.MaximumPotentialFinalLAI");
                ret += _senescencethermaltime.TestPreConditions(wheatlaistate, wheatleafstate, wheatleafstate1, "strategy SiriusQualityWheatLAI.Strategies.SenescenceThermalTime");
                ret += _updateleafarea.TestPreConditions(wheatlaistate, wheatleafstate, wheatleafstate1, "strategy SiriusQualityWheatLAI.Strategies.UpdateLeafArea");
                ret += _waterlimitedleafexpansion.TestPreConditions(wheatlaistate, wheatleafstate, wheatleafstate1, "strategy SiriusQualityWheatLAI.Strategies.WaterLimitedLeafExpansion");
                if (ret != "")
                {
                    pre.TestsOut(ret, true, "   preconditions tests of associated classes");
                }

                //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section3
                //Code written below will not be overwritten by a future code generation



                //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
                //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section3

                //Get the evaluation of preconditions;
                string preConditionsResult = pre.VerifyPreconditions(prc, callID);
                //if we have errors, send it to the configured output
                if (!string.IsNullOrEmpty(preConditionsResult))
                {
                    pre.TestsOut(preConditionsResult, true, "PreConditions errors in component SiriusQualityWheatLAI.Strategies, strategy " + this.GetType().Name);
                }
                return(preConditionsResult);
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //	TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1002,"Strategy: " + this.GetType().Name + " - Unhandled exception running pre-conditions");

                string msg = "Component SiriusQualityWheatLAI.Strategies, " + this.GetType().Name + ": Unhandled exception running pre-condition test. ";
                throw new Exception(msg, exception);
            }
        }
Пример #18
0
        /// <summary>
        /// Test to verify the preconditions
        /// </summary>
        public string TestPreConditions(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, string callID)
        {
            try
            {
                //Set current values of the inputs to the static VarInfo representing the input properties of the domain classes

                SiriusQualityWheatLAI.WheatLAIStateVarInfo.cumulTTShoot.CurrentValue      = wheatlaistate.cumulTTShoot;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.deltaTTShoot.CurrentValue      = wheatlaistate.deltaTTShoot;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.deltaTTSenescence.CurrentValue = wheatlaistate.deltaTTSenescence;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.DSF.CurrentValue                       = wheatlaistate.DSF;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.DEF.CurrentValue                       = wheatlaistate.DEF;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.GAI.CurrentValue                      = wheatleafstate.GAI;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTGroLamina.CurrentValue              = wheatleafstate.TTGroLamina;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.State.CurrentValue                    = wheatleafstate.State;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.PreviousState.CurrentValue            = wheatleafstate.PreviousState;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTsen.CurrentValue                    = wheatleafstate.TTsen;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTem.CurrentValue                     = wheatleafstate.TTem;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTmat.CurrentValue                    = wheatleafstate.TTmat;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.laminaSpecificN.CurrentValue          = wheatleafstate.laminaSpecificN;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.LaminaAI.CurrentValue                 = wheatleafstate.LaminaAI;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.SheathAI.CurrentValue                 = wheatleafstate.SheathAI;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.MaxAI.CurrentValue                    = wheatleafstate.MaxAI;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.isPrematurelyDying.CurrentValue       = wheatleafstate.isPrematurelyDying;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.MaximumPotentialLaminaeAI.CurrentValue = wheatlaistate.MaximumPotentialLaminaeAI;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.MaximumPotentialSheathAI.CurrentValue  = wheatlaistate.MaximumPotentialSheathAI;

                //Create the collection of the conditions to test
                ConditionsCollection prc = new ConditionsCollection();
                Preconditions        pre = new Preconditions();


                RangeBasedCondition r1 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.cumulTTShoot);
                if (r1.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.cumulTTShoot.ValueType))
                {
                    prc.AddCondition(r1);
                }
                RangeBasedCondition r2 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.deltaTTShoot);
                if (r2.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.deltaTTShoot.ValueType))
                {
                    prc.AddCondition(r2);
                }
                RangeBasedCondition r3 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.deltaTTSenescence);
                if (r3.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.deltaTTSenescence.ValueType))
                {
                    prc.AddCondition(r3);
                }
                RangeBasedCondition r4 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.DSF);
                if (r4.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.DSF.ValueType))
                {
                    prc.AddCondition(r4);
                }
                RangeBasedCondition r5 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.DEF);
                if (r5.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.DEF.ValueType))
                {
                    prc.AddCondition(r5);
                }
                RangeBasedCondition r6 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.GAI);
                if (r6.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.GAI.ValueType))
                {
                    prc.AddCondition(r6);
                }
                RangeBasedCondition r7 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTGroLamina);
                if (r7.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTGroLamina.ValueType))
                {
                    prc.AddCondition(r7);
                }
                RangeBasedCondition r8 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.State);
                if (r8.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.State.ValueType))
                {
                    prc.AddCondition(r8);
                }
                RangeBasedCondition r9 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.PreviousState);
                if (r9.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.PreviousState.ValueType))
                {
                    prc.AddCondition(r9);
                }
                RangeBasedCondition r10 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTsen);
                if (r10.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTsen.ValueType))
                {
                    prc.AddCondition(r10);
                }
                RangeBasedCondition r11 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTem);
                if (r11.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTem.ValueType))
                {
                    prc.AddCondition(r11);
                }
                RangeBasedCondition r12 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTmat);
                if (r12.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.TTmat.ValueType))
                {
                    prc.AddCondition(r12);
                }
                RangeBasedCondition r13 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.laminaSpecificN);
                if (r13.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.laminaSpecificN.ValueType))
                {
                    prc.AddCondition(r13);
                }
                RangeBasedCondition r14 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.LaminaAI);
                if (r14.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.LaminaAI.ValueType))
                {
                    prc.AddCondition(r14);
                }
                RangeBasedCondition r15 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.SheathAI);
                if (r15.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.SheathAI.ValueType))
                {
                    prc.AddCondition(r15);
                }
                RangeBasedCondition r16 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.MaxAI);
                if (r16.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.MaxAI.ValueType))
                {
                    prc.AddCondition(r16);
                }
                RangeBasedCondition r17 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.isPrematurelyDying);
                if (r17.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.isPrematurelyDying.ValueType))
                {
                    prc.AddCondition(r17);
                }
                RangeBasedCondition r18 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.MaximumPotentialLaminaeAI);
                if (r18.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.MaximumPotentialLaminaeAI.ValueType))
                {
                    prc.AddCondition(r18);
                }
                RangeBasedCondition r19 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.MaximumPotentialSheathAI);
                if (r19.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.MaximumPotentialSheathAI.ValueType))
                {
                    prc.AddCondition(r19);
                }
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("SLNmin")));



                //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section3
                //Code written below will not be overwritten by a future code generation



                //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
                //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section3

                //Get the evaluation of preconditions;
                string preConditionsResult = pre.VerifyPreconditions(prc, callID);
                //if we have errors, send it to the configured output
                if (!string.IsNullOrEmpty(preConditionsResult))
                {
                    pre.TestsOut(preConditionsResult, true, "PreConditions errors in component SiriusQualityWheatLAI.Strategies, strategy " + this.GetType().Name);
                }
                return(preConditionsResult);
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //	TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1002,"Strategy: " + this.GetType().Name + " - Unhandled exception running pre-conditions");

                string msg = "Component SiriusQualityWheatLAI.Strategies, " + this.GetType().Name + ": Unhandled exception running pre-condition test. ";
                throw new Exception(msg, exception);
            }
        }
        private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            EstimateOfAssociatedClasses(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);

            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation



            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
Пример #20
0
        private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation
            //update the size of the lists
            for (int i = 0; i < wheatleafstate.GAI.Count; i++)
            {
                //if a new leaf has appeared
                if (i >= wheatlaistate.WaterLimitedPotDeltaAIList.Count)
                {
                    wheatlaistate.WaterLimitedPotDeltaAIList.Add(0);
                    wheatlaistate.TTgroSheathList.Add(wheatleafstate.TTGroLamina[i] * wheatlaistate.MaximumPotentialSheathAI[i] / wheatlaistate.MaximumPotentialLaminaeAI[i]);
                    wheatlaistate.TT.Add(wheatlaistate.cumulTTShoot - wheatlaistate.deltaTTShoot);
                }
            }

            CalculateNewStates(wheatlaistate, wheatleafstate, wheatleafstate1);

            // calculate potential delta area
            CalculatePotIncDeltaAI(wheatlaistate, wheatleafstate, wheatleafstate1);


            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
        //Call of the associated strategies
        private void EstimateOfAssociatedClasses(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            if (wheatlaistate.previousIndex != wheatlaistate.index)
            {
                _issmallphytomer.Estimate(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);
                _laminaexpansionthermaltime.Estimate(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);
                _maturitythermaltime.Estimate(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);
                _senescencethermaltime.Estimate(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);
            }
            _leafexpansiondroughtfactor.Estimate(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);
            _maximumpotentialfinallai.Estimate(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);
            _waterlimitedleafexpansion.Estimate(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);

            resetDeltaAI(wheatleafstate);
        }
Пример #22
0
        private void CalculateWaterLimitedPotentialDeltaArea(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, int i)
        {
            wheatlaistate.WaterLimitedPotDeltaAIList[i] = 0;

            if (wheatleafstate.State[i] >= 2)
            {
                wheatlaistate.WaterLimitedPotDeltaAIList[i] = Math.Max(-wheatleafstate.MaxAI[i] * (wheatlaistate.deltaTTSenescence * wheatlaistate.DSF) / wheatleafstate.TTsen[i], -(wheatleafstate.LaminaAI[i] + wheatleafstate.SheathAI[i]));
            }
            else if (wheatleafstate.State[i] == 0 && wheatleafstate.isPrematurelyDying[i] == 0)
            {
                if ((wheatlaistate.cumulTTShoot - wheatleafstate.TTem[i]) < wheatleafstate.TTGroLamina[i])     //IsLeafLaminaeGrowing
                {
                    wheatlaistate.WaterLimitedPotDeltaAIList[i] = Math.Min(wheatlaistate.MaximumPotentialLaminaeAI[i] * wheatlaistate.deltaTTShoot / wheatleafstate.TTGroLamina[i], Math.Max(0, wheatlaistate.MaximumPotentialLaminaeAI[i] - wheatleafstate.LaminaAI[i]));
                }
                else if (wheatlaistate.TTgroSheathList[i] > 0)
                {
                    wheatlaistate.WaterLimitedPotDeltaAIList[i] = Math.Min(wheatlaistate.MaximumPotentialSheathAI[i] * wheatlaistate.deltaTTShoot / wheatlaistate.TTgroSheathList[i], Math.Max(0, wheatlaistate.MaximumPotentialSheathAI[i] - wheatleafstate.SheathAI[i]));
                }
            }
        }
        //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section2
        //Code written below will not be overwritten by a future code generation

        public void UpdateLeafArea(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents)
        {
            _updateleafarea.Estimate(wheatlaistate, wheatleafstate, wheatleafstate1, actevents);
        }
Пример #24
0
        private void CalculateNewLeafLayerState(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, int leafIndex, double GAI, double TTem, double TTgro, double TTmat, double TTsen, double leafLaminaSpecificN)
        {
            wheatleafstate1.State.Add(wheatleafstate.State[leafIndex]);
            wheatleafstate.PreviousState.Add(wheatleafstate1.State[leafIndex]);

            switch (wheatleafstate.State[leafIndex])
            {
            case 1:
            case 2:  wheatlaistate.TT[leafIndex] += wheatlaistate.deltaTTSenescence * wheatlaistate.DSF; break;

            default: wheatlaistate.TT[leafIndex] += wheatlaistate.deltaTTShoot; break;
            }
            if (GAI <= 0 && wheatleafstate.State[leafIndex] >= 1 && wheatleafstate.State[leafIndex] != 3)
            {
                wheatleafstate1.State[leafIndex] = 3;
            }
            else if (GAI > 0)
            {
                if (wheatleafstate.isPrematurelyDying[leafIndex] == 0)
                {
                    if (wheatlaistate.TT[leafIndex] <= TTem + TTgro)
                    {
                        wheatleafstate1.State[leafIndex] = 0;
                    }
                    else if (wheatlaistate.TT[leafIndex] < TTem + TTgro + TTmat)
                    {
                        wheatleafstate1.State[leafIndex] = 1;
                    }
                    else if (wheatlaistate.TT[leafIndex] < TTem + TTgro + TTmat + TTsen || GAI > 0)
                    {
                        wheatleafstate1.State[leafIndex] = 2;
                    }
                    else
                    {
                        wheatleafstate1.State[leafIndex] = 3;
                    }
                    if (leafLaminaSpecificN <= SLNmin)
                    {
                        wheatleafstate1.isPrematurelyDying[leafIndex] = 1;
                        wheatleafstate1.State[leafIndex] = 2;
                    }
                }
                else
                {
                    wheatleafstate1.State[leafIndex] = 2;
                }
            }

            wheatleafstate.State[leafIndex] = wheatleafstate1.State[leafIndex];
            wheatleafstate.isPrematurelyDying[leafIndex] = wheatleafstate1.isPrematurelyDying[leafIndex];
        }
Пример #25
0
        /// <summary>
        /// Test to verify the preconditions
        /// </summary>
        public string TestPreConditions(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, string callID)
        {
            try
            {
                //Set current values of the inputs to the static VarInfo representing the input properties of the domain classes

                SiriusQualityWheatLAI.WheatLAIStateVarInfo.newLeafHasAppeared.CurrentValue     = wheatlaistate.newLeafHasAppeared;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.leafNumber.CurrentValue             = wheatlaistate.leafNumber;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.roundedFinalLeafNumber.CurrentValue = wheatlaistate.roundedFinalLeafNumber;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.finalLeafNumber.CurrentValue        = wheatlaistate.finalLeafNumber;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.leafTillerNumberArray.CurrentValue  = wheatlaistate.leafTillerNumberArray;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.tilleringProfile.CurrentValue       = wheatlaistate.tilleringProfile;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.phytonum.CurrentValue         = wheatlaistate.phytonum;
                SiriusQualityWheatLAI.WheatLAIStateVarInfo.index.CurrentValue            = wheatlaistate.index;
                SiriusQualityWheatLAI.WheatLeafStateVarInfo.isSmallPhytomer.CurrentValue = wheatleafstate.isSmallPhytomer;

                //Create the collection of the conditions to test
                ConditionsCollection prc = new ConditionsCollection();
                Preconditions        pre = new Preconditions();


                RangeBasedCondition r1 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.newLeafHasAppeared);
                if (r1.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.newLeafHasAppeared.ValueType))
                {
                    prc.AddCondition(r1);
                }
                RangeBasedCondition r2 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.leafNumber);
                if (r2.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.leafNumber.ValueType))
                {
                    prc.AddCondition(r2);
                }
                RangeBasedCondition r3 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.roundedFinalLeafNumber);
                if (r3.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.roundedFinalLeafNumber.ValueType))
                {
                    prc.AddCondition(r3);
                }
                RangeBasedCondition r4 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.finalLeafNumber);
                if (r4.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.finalLeafNumber.ValueType))
                {
                    prc.AddCondition(r4);
                }
                RangeBasedCondition r5 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.leafTillerNumberArray);
                if (r5.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.leafTillerNumberArray.ValueType))
                {
                    prc.AddCondition(r5);
                }
                RangeBasedCondition r6 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.tilleringProfile);
                if (r6.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.tilleringProfile.ValueType))
                {
                    prc.AddCondition(r6);
                }
                RangeBasedCondition r7 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.phytonum);
                if (r7.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.phytonum.ValueType))
                {
                    prc.AddCondition(r7);
                }
                RangeBasedCondition r8 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLAIStateVarInfo.index);
                if (r8.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLAIStateVarInfo.index.ValueType))
                {
                    prc.AddCondition(r8);
                }
                RangeBasedCondition r9 = new RangeBasedCondition(SiriusQualityWheatLAI.WheatLeafStateVarInfo.isSmallPhytomer);
                if (r9.ApplicableVarInfoValueTypes.Contains(SiriusQualityWheatLAI.WheatLeafStateVarInfo.isSmallPhytomer.ValueType))
                {
                    prc.AddCondition(r9);
                }
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("NLL")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("AreaPL")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("RatioFLPL")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("AreaSL")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("AreaSS")));



                //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section3
                //Code written below will not be overwritten by a future code generation



                //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
                //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section3

                //Get the evaluation of preconditions;
                string preConditionsResult = pre.VerifyPreconditions(prc, callID);
                //if we have errors, send it to the configured output
                if (!string.IsNullOrEmpty(preConditionsResult))
                {
                    pre.TestsOut(preConditionsResult, true, "PreConditions errors in component SiriusQualityWheatLAI.Strategies, strategy " + this.GetType().Name);
                }
                return(preConditionsResult);
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //	TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1002,"Strategy: " + this.GetType().Name + " - Unhandled exception running pre-conditions");

                string msg = "Component SiriusQualityWheatLAI.Strategies, " + this.GetType().Name + ": Unhandled exception running pre-condition test. ";
                throw new Exception(msg, exception);
            }
        }