Пример #1
0
    public static FeedItem operator +(FeedItem c1, FeedItem c2)
    {
        FeedItem returnItem = new FeedItem();

        returnItem.setAmount(+c2.getAmount());
        returnItem.C_content = c1.C_content + c2.C_content;
        returnItem.K_content = c1.K_content + c2.K_content;

        returnItem.code = c1.code + c2.code;
        returnItem.proteinN_digestibility = c1.getAmount() / returnItem.getAmount() * c1.proteinN_digestibility + c2.getAmount() / returnItem.getAmount() * c2.proteinN_digestibility;
        returnItem.dryMatter = c1.getAmount() / returnItem.getAmount() * c1.dryMatter + c2.getAmount() / returnItem.getAmount() * c2.dryMatter;
        returnItem.OMD       = c1.getAmount() / returnItem.getAmount() * c1.OMD + c2.getAmount() / returnItem.getAmount() * c2.OMD;
        returnItem.proteinN_digestibility = c1.getAmount() / returnItem.getAmount() * c1.proteinN_digestibility + c2.getAmount() / returnItem.getAmount() * c2.proteinN_digestibility;
        returnItem.P_digest                = c1.getAmount() / returnItem.getAmount() * c1.P_digest + c2.getAmount() / returnItem.getAmount() * c2.P_digest;
        returnItem.P_content               = c1.getAmount() / returnItem.getAmount() * c1.P_content + c2.getAmount() / returnItem.getAmount() * c2.P_content;
        returnItem.orgN_content            = c1.getAmount() / returnItem.getAmount() * c1.orgN_content + c2.getAmount() / returnItem.getAmount() * c2.orgN_content;
        returnItem.NO3_content             = c1.getAmount() / returnItem.getAmount() * c1.NO3_content + c2.getAmount() / returnItem.getAmount() * c2.NO3_content;
        returnItem.NH4_content             = c1.getAmount() / returnItem.getAmount() * c1.NH4_content + c2.getAmount() / returnItem.getAmount() * c2.NH4_content;
        returnItem.K_content               = c1.getAmount() / returnItem.getAmount() * c1.K_content + c2.getAmount() / returnItem.getAmount() * c2.K_content;
        returnItem.pigFeedUnitsPerItemUnit = c1.getAmount() / returnItem.getAmount() * c1.pigFeedUnitsPerItemUnit + c2.getAmount() / returnItem.getAmount() * c2.pigFeedUnitsPerItemUnit;
        return(returnItem);
    }
Пример #2
0
    public void OnProcess()
    {
        // Console.WriteLine(MyPaddock.ChildrenAsObjects.Count);
        // Console.WriteLine("con pig"+ My.ChildrenAsObjects.Count());
        FeedItem afeedItem;



        for (int i = 0; i < My.ChildrenAsObjects.Count; i++)
        {
            afeedItem = (FeedItem)My.ChildrenAsObjects[i];


            FeedItem storedfeedItem = new FeedItem();
            //  FeedItem storedfeedItem = (FeedItem)theProducts.GetCopyStoredFeedProduct( afeedItem);    // returns a copy of the product if it is found in storage


            if ((storedfeedItem.getAmount() > 0.0))
            {
                storedfeedItem.setAmount(afeedItem.getAmount());
                // theProducts.SubtractProduct(storedfeedItem);    // subtract feed from storage
                if (currentfeed.getAmount() != 0)
                {
                    currentfeed = currentfeed + storedfeedItem;
                }
                else
                {
                    currentfeed = storedfeedItem;
                }
            }
            else
            {
                if (afeedItem.GetproteinN_digestibility() < 0.0)
                {
                    throw new System.ArgumentException("attempt to access feed with protein digestibility less than zero, code =" + afeedItem.GetCode(), "attempt to access feed with protein digestibility less than zero, code =" + afeedItem.GetCode());
                }

                //theProducts.SubtractProduct(afeedItem);    // subtract feed from storage


                if (currentfeed.getAmount() != 0)
                {
                    currentfeed = currentfeed + afeedItem;
                }
                else
                {
                    currentfeed = afeedItem;
                }
            }
        }

        if (currentfeed.getAmount() == 0)
        {
            throw new System.ArgumentException("Pig:: No feed provided!", "Pig:: No feed provided!");
        }

        double surplusN = ProduceManure(fluidManurePrDay, solidManurePrDay);     // calculates the amount of manure pr day;

        // while (surplusN<0) //iteration necessary as feed quality could vary with amount requested from store, if several stores contain the desired feed
        if (surplusN < 0)
        {
            throw new System.ArgumentException("Pig:: Insufficient protein in feed for " + GetName(), "Pig:: Insufficient protein in feed for " + GetName());
        }

        manurePrDay = fluidManurePrDay;
        manurePrDay = manurePrDay + solidManurePrDay;



        // fudge - should calculate heat from diet + latent heat loss
        // GetStableSection()->AddanimalHeatOp(NumberPrDay*heatProduction);
        CinFeed    = currentfeed.getAmount() * currentfeed.GetC_content();
        CinSoldPig = NumberPrDay * C_growth;
        CinManure  = manurePrDay.GetAmount() * manurePrDay.GetC_content();
        CinCH4     = 0.01 * GetGrossEnergyinDryMatter() * currentfeed.getAmount() * currentfeed.GetdryMatter() / 55.55;

        //   Console.WriteLine(NumberPrDay+" "+C_growth);

        double CinCO2 = CinFeed - (CinSoldPig + CinManure + CinCH4);

        if (CinCO2 < 0.0)
        {
            throw new System.ArgumentException("pig::DailyUpdate - CO2 production cannot be negative", "pig::DailyUpdate - CO2 production cannot be negative");
        }
    }