Beispiel #1
0
        /// <summary>
        /// Adds an amount of a supplement to a store.
        /// * If the store name already exists in the FStores array, the method adds
        /// the supplement to that store.  Otherwise a new store is created.
        /// * The DMP, DMD, MEDM, CP, DG, EE and ADIP2CP parameters may be set to zero,
        /// in which case the default values for the supplement name are used.
        /// Defaults are taken from the current store if the name is already defined,
        /// and from grazSUPP.PAS otherwise.  If defaults cannot be found for a name,
        /// wheat is used as the default composition.
        /// </summary>
        /// <param name="suppKg">Amount (kg fresh weight) of the supplement to be included in the store.</param>
        /// <param name="suppName">Name of the supplement.</param>
        /// <param name="roughage">The roughage.</param>
        /// <param name="DMP">Proportion of the fresh weight which is dry matter   kg/kg FW</param>
        /// <param name="DMD">Dry matter digestibility of the supplement           kg/kg DM</param>
        /// <param name="MEDM">Metabolisable energy content of dry matter           MJ/kg DM</param>
        /// <param name="CP">Crude protein content                                kg/kg DM</param>
        /// <param name="DG">Degradability of the crude protein                   kg/kg CP</param>
        /// <param name="EE">Ether-extractable content                            kg/kg DM</param>
        /// <param name="ADIP2CP">Ratio of acid detergent insoluble protein to CP      kg/kg CP</param>
        /// <param name="phos">Phosphorus content                                   kg/kg DM</param>
        /// <param name="sulf">Sulphur content                                      kg/kg DM</param>
        /// <param name="ashAlk">Ash alkalinity                                       mol/kg DM</param>
        /// <param name="maxPass">Maximum passage rate                                 0-1</param>
        /// <returns>
        /// Index of the supplement in the store
        /// </returns>
        public int AddToStore(double suppKg, string suppName, int roughage = DEFAULT, double DMP = 0.0, double DMD = 0.0,
                              double MEDM = 0.0, double CP   = 0.0, double DG     = 0.0, double EE      = 0.0, double ADIP2CP = 0.0,
                              double phos = 0.0, double sulf = 0.0, double ashAlk = 0.0, double maxPass = 0.0)
        {
            int idx = IndexOf(suppName);

            TSupplement addSupp = new TSupplement(suppName);

            if (idx >= 0)                             // Work out the composition of the supplement being added
            {
                addSupp.Assign(this[idx]);
            }
            else
            {
                addSupp.DefaultFromName();
            }
            addSupp.sName = suppName.ToLower();

            if (roughage == ROUGHAGE)                 // Override the default composition as required
            {
                addSupp.IsRoughage = true;
            }
            else if (roughage != DEFAULT)
            {
                addSupp.IsRoughage = false;
            }

            if (DMP > 0.0)
            {
                addSupp.DM_Propn = DMP;
            }
            if (DMD > 0.0)
            {
                addSupp.DM_Digestibility = DMD;
            }
            if (MEDM > 0.0)
            {
                addSupp.ME_2_DM = MEDM;
            }
            if (CP > 0.0)
            {
                addSupp.CrudeProt = CP;
            }
            if (DG > 0.0)
            {
                addSupp.DgProt = DG;
            }
            if (EE > 0.0)
            {
                addSupp.EtherExtract = EE;
            }
            if (ADIP2CP > 0.0)
            {
                addSupp.ADIP_2_CP = ADIP2CP;
            }
            if (phos > 0.0)
            {
                addSupp.Phosphorus = phos;
            }
            if (sulf > 0.0)
            {
                addSupp.Sulphur = sulf;
            }
            if (ashAlk > 0.0)
            {
                addSupp.AshAlkalinity = ashAlk;
            }
            if (maxPass > 0.0)
            {
                addSupp.MaxPassage = maxPass;
            }

            if (DMD > 0.0 && MEDM == 0.0)
            {
                addSupp.ME_2_DM = addSupp.DefaultME2DM();
            }
            else if (DMD == 0.0 && MEDM > 0.0)
            {
                addSupp.DM_Digestibility = addSupp.DefaultDMD();
            }

            return(AddToStore(suppKg, addSupp));
        }