Пример #1
0
        /// <summary>
        /// Add a forage provider component
        /// </summary>
        /// <param name="paddock"></param>
        /// <param name="paddName"></param>
        /// <param name="forageName"></param>
        /// <param name="hostID"></param>
        /// <param name="driverID"></param>
        /// <param name="forageObj"></param>
        /// <param name="usePlantCohorts"></param>
        public void AddProvider(TPaddockInfo paddock, string paddName, string forageName, int hostID, int driverID, Object forageObj, bool usePlantCohorts)
        {
            TForageProvider forageProvider;

            //this is a forage provider
            // this provider can host a number of forages/species
            forageProvider = new TForageProvider();
            forageProvider.PaddockOwnerName = paddName;    // owning paddock
            forageProvider.ForageHostName = forageName;    // host pasture/plant component name
            forageProvider.HostID = hostID;                // plant/pasture comp
            forageProvider.DriverID = driverID;            // driving property ID
            forageProvider.ForageObj = forageObj;          // setting property ID
            // keep a ptr to the paddock owned by the model so the forages can be assigned there as they become available
            forageProvider.OwningPaddock = paddock;
            forageProvider.UseCohorts = usePlantCohorts;   // use cohorts array type

            FForageProviderList.Add(forageProvider);
        }
Пример #2
0
        // Outputs to other models .................................................
        /// <summary>
        /// Get the mass for the area
        /// </summary>
        /// <param name="paddID"></param>
        /// <param name="provider"></param>
        /// <param name="sUnit"></param>
        /// <returns></returns>
        public double returnMassPerArea(int paddID, TForageProvider provider, string sUnit)
        {
            double Result;
            TPaddockInfo ThePadd;
            double fMassKGHA;
            int Idx;

            if (provider != null)
                ThePadd = provider.OwningPaddock;
            else
                ThePadd = FPaddocks.byID(paddID);

            fMassKGHA = 0.0;
            if (ThePadd != null)
            {
                for (Idx = 1; Idx <= Count(); Idx++)
                    if (getPaddInfo(Idx) == ThePadd)
                    {
                        fMassKGHA = fMassKGHA + At(Idx).NoAnimals * At(Idx).LiveWeight;
                        if (At(Idx).Young != null)
                            fMassKGHA = fMassKGHA + At(Idx).Young.NoAnimals * At(Idx).Young.LiveWeight;
                    }
                fMassKGHA = fMassKGHA / ThePadd.fArea;
            }

            if (sUnit == "kg/ha")
                Result = fMassKGHA;
            else if (sUnit == "kg/m^2")
                Result = fMassKGHA * 0.0001;
            else if (sUnit == "dse/ha")
                Result = fMassKGHA * WEIGHT2DSE;
            else if (sUnit == "g/m^2")
                Result = fMassKGHA * 0.1;
            else
                throw new Exception("Stock: Unit (" + sUnit + ") not recognised");

            return Result;
        }