Exemplo n.º 1
0
 /// <summary>
 /// Assign a forage to this paddock
 /// </summary>
 /// <param name="Forage"></param>
 public void AssignForage(TForageInfo Forage)
 {
     FForages.Add(Forage);
     Forage.InPaddock = this;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Return the removal
        /// </summary>
        /// <param name="forage"></param>
        /// <param name="sUnit"></param>
        /// <returns></returns>
        public GrazType.TGrazingOutputs ReturnRemoval(TForageInfo forage, string sUnit)
        {
            double fArea;
            double fScale;
            int iClass;
            int iSpecies;
            int iRipe;

            GrazType.TGrazingOutputs Result = new GrazType.TGrazingOutputs();

            if (forage != null)
            {
                Result = forage.RemovalKG;
                fArea = forage.InPaddock.fArea;
            }
            else
            {
                Result = new GrazType.TGrazingOutputs();
                fArea = 0.0;
            }

            if (fArea > 0.0)
            {
                if (sUnit == "kg")
                    fScale = 1.0;
                else if (sUnit == "g/m^2")
                    fScale = 0.10 / fArea;
                else if (sUnit == "kg/ha")
                    fScale = 1.0 / fArea;
                else
                    throw new Exception("Stock: Unit (" + sUnit + ") not recognised");

                if (fScale != 1.0)
                {
                    for (iClass = 1; iClass <= GrazType.DigClassNo; iClass++)
                        Result.Herbage[iClass] = fScale * Result.Herbage[iClass];
                    for (iSpecies = 1; iSpecies <= GrazType.MaxPlantSpp; iSpecies++)
                        for (iRipe = GrazType.UNRIPE; iRipe <= GrazType.RIPE; iRipe++)
                            Result.Seed[iSpecies, iRipe] = fScale * Result.Seed[iSpecies, iRipe];
                }
            }
            return Result;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="forage"></param>
        /// <param name="Grazing"></param>
        /// <param name="sUnit"></param>
        public void passGrazingInputs(TForageInfo forage,
                                      GrazType.TGrazingInputs Grazing,
                                      string sUnit)
        {
            double fScale;

            if (sUnit == "kg/ha")                                                     // Convert to kg/ha                      
                fScale = 1.0;
            else if (sUnit == "g/m^2")
                fScale = 10.0;
            else
                throw new Exception("Stock: Unit (" + sUnit + ") not recognised");

            if (forage != null)
                forage.setAvailForage(GrazType.scaleGrazingInputs(Grazing, fScale));
            else
                throw new Exception("Stock: Forage not recognised");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update the forages for this provider
        /// </summary>
        /// <param name="availableForage"></param>
        /// <returns></returns>
        public void UpdateForages(TAvailableToAnimal[] availableForage)
        {
            int i;
            TAvailableToAnimal cohortItem;
            string sCohort;
            string sOrgan;
            string sAge;
            string sCohortName;
            TForageInfo forage;

            if (FUseCohorts) 
            {
                // Need to clear the forage data for all the forages in this provider
                for (i = 0; i <= FForages.Count() - 1; i++) // for each forage
                    FForages.byIndex(i).clearForageData();

                for (i = 1; i <= availableForage.Length; i++)
                {
                    cohortItem = availableForage[i-1];
                    sCohort = cohortItem.CohortID;     // wheat, sorghum
                    if (sCohort.Length > 0)                            // must have a cohort name
                    {
                        sOrgan = cohortItem.Organ;
                        sAge = cohortItem.AgeID;
                        sCohortName = (sCohort + '_' + sOrgan + '_' + sAge).ToLower();
                        forage = FForages.byName(sCohortName);

                        // This combination of cohort x organ x age has not been provided previously; allocate storage
                        if (forage == null)
                        {
                            forage = new TForageInfo();
                            forage.sName = sCohortName;
                            forage.sOrgan = sOrgan;
                            forage.sAgeClass = sAge;
                            FOwningPaddock.AssignForage(forage);              // the paddock in the model can access this forage
                            FForages.Add(forage);                             // create a new forage for this cohort
                        }

                        forage.addForageData(sCohort, sOrgan, sAge,      // Accessible when availForage() is called by the model
                                              cohortItem.Chem,
                                              cohortItem.Bottom,
                                              cohortItem.Top,
                                              cohortItem.Weight,
                                              cohortItem.N,
                                              cohortItem.P,
                                              cohortItem.S,
                                              cohortItem.AshAlk);
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Add a forage by name
        /// </summary>
        /// <param name="sName"></param>
        /// <returns></returns>
        public TForageInfo Add(string sName)
        {
            TForageInfo newInfo;

            newInfo = new TForageInfo();
            newInfo.sName = sName.ToLower();
            this.Add(newInfo);
            return newInfo;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Add a forage item
        /// </summary>
        /// <param name="Info"></param>
        public void Add(TForageInfo Info)
        {
            int Idx;

            Idx = FList.Length;
            Array.Resize(ref FList, Idx + 1);
            FList[Idx] = Info;
        }