Пример #1
0
 /// <summary>
 /// Switch between sheep and cattle controls
 /// </summary>
 /// <param name="theAnimal"></param>
 private void EnablePeakMilkOrFleece(GrazType.AnimalType theAnimal)
 {
     // Visibility of animal - specific parameters
     lblConception3.Visible = (theAnimal == GrazType.AnimalType.Sheep);
     deConception3.Visible  = (theAnimal == GrazType.AnimalType.Sheep);
     //unitConception.Visible = (theAnimal == GrazType.AnimalType.Sheep);
     deWoolYield.Visible    = (theAnimal == GrazType.AnimalType.Sheep);
     untWoolYield.Visible   = (theAnimal == GrazType.AnimalType.Sheep);
     lblWoolYield.Visible   = (theAnimal == GrazType.AnimalType.Sheep);
     deBreedMaxMu.Visible   = (theAnimal == GrazType.AnimalType.Sheep);
     unitBreedMaxMu.Visible = (theAnimal == GrazType.AnimalType.Sheep);
     lblBreedMaxMu.Visible  = (theAnimal == GrazType.AnimalType.Sheep);
     if (theAnimal == GrazType.AnimalType.Sheep)
     {
         lblBreedPFW_PeakMilk.Text  = "Breed potential fleece weight";
         unitBreedPFW_PeakMilk.Text = "kg";
     }
     else
     {
         //cattle
         lblBreedPFW_PeakMilk.Text  = "Peak milk production";
         unitBreedPFW_PeakMilk.Text = "kg FCM";
     }
 }
Пример #2
0
        /// <summary>
        /// Fill a cattle init value
        /// </summary>
        /// <param name="model">The animal model</param>
        /// <param name="animal">The animal type</param>
        /// <param name="initValue">The cattle init value</param>
        public static void MakeCattleValue(StockList model, GrazType.AnimalType animal, ref CattleInit[] initValue)
        {
            AnimalGroup animalGroup;
            int         count;
            int         idx, jdx;

            count = 0;
            for (idx = 1; idx <= model.Count(); idx++)
            {
                if (model.At(idx).Genotype.Animal == animal)
                {
                    count++;
                }
            }
            Array.Resize(ref initValue, count);

            jdx = 0;
            for (idx = 1; idx <= model.Count(); idx++)
            {
                if (model.At(idx).Genotype.Animal == animal)
                {
                    animalGroup = model.At(idx);

                    initValue[jdx] = new CattleInit();

                    initValue[jdx].Genotype  = animalGroup.Genotype.sName;
                    initValue[jdx].Number    = animalGroup.NoAnimals;
                    initValue[jdx].Sex       = model.SexString(idx, false);
                    initValue[jdx].Age       = animalGroup.AgeDays;
                    initValue[jdx].Weight    = animalGroup.LiveWeight;
                    initValue[jdx].MaxPrevWt = animalGroup.MaxPrevWeight;
                    initValue[jdx].Pregnant  = animalGroup.Pregnancy;
                    initValue[jdx].Lactating = animalGroup.Lactation;

                    /*if (Animal == GrazType.AnimalType.Sheep)
                     * {
                     *  aValue[Jdx].fleece_wt = aGroup.FleeceCutWeight;
                     *  aValue[Jdx].fibre_diam = aGroup.FibreDiam;
                     *  aValue[Jdx].no_young = Math.Max(aGroup.NoFoetuses, aGroup.NoOffspring);
                     * }
                     * else*/
                    if (animal == GrazType.AnimalType.Cattle)
                    {
                        initValue[jdx].NumFoetuses = animalGroup.NoFoetuses;
                        initValue[jdx].NumSuckling = animalGroup.NoOffspring;
                    }

                    if (animalGroup.Lactation > 0)
                    {
                        initValue[jdx].BirthCS = animalGroup.BirthCondition;
                    }

                    if ((animalGroup.Pregnancy > 0) || (animalGroup.Young != null))
                    {
                        if (animalGroup.MatedTo != null)
                        {
                            initValue[jdx].MatedTo = animalGroup.MatedTo.sName;
                        }
                        else
                        {
                            initValue[jdx].MatedTo = string.Empty;
                        }
                    }
                    else
                    {
                        initValue[jdx].MatedTo = string.Empty;
                    }

                    if (animalGroup.Young != null)
                    {
                        /*if (Animal == GrazType.AnimalType.Sheep)
                         * {
                         *  aValue[Jdx].lamb_wt = aGroup.Young.LiveWeight;
                         *  aValue[Jdx].lamb_fleece_wt = aGroup.Young.FleeceCutWeight;
                         * }
                         * else*/
                        if (animal == GrazType.AnimalType.Cattle)
                        {
                            initValue[jdx].CalfWt = animalGroup.Young.LiveWeight;
                        }

                        initValue[jdx].Paddock  = model.GetInPadd(idx);
                        initValue[jdx].Tag      = model.GetTag(idx);
                        initValue[jdx].Priority = model.GetPriority(idx);
                    }
                }
                jdx++;
            } // next animal
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Model"></param>
        /// <param name="Animal"></param>
        /// <param name="aValue"></param>
        public static void MakeCattleValue(TStockList Model, GrazType.AnimalType Animal, ref TCattleInit[] aValue)
        {
            TAnimalGroup aGroup;
            int          iCount;
            int          Idx, Jdx;

            iCount = 0;
            for (Idx = 1; Idx <= Model.Count(); Idx++)
            {
                if (Model.At(Idx).Genotype.Animal == Animal)
                {
                    iCount++;
                }
            }
            Array.Resize(ref aValue, iCount);

            Jdx = 0;
            for (Idx = 1; Idx <= Model.Count(); Idx++)
            {
                if (Model.At(Idx).Genotype.Animal == Animal)
                {
                    aGroup = Model.At(Idx);

                    aValue[Jdx] = new TCattleInit();

                    aValue[Jdx].genotype    = aGroup.Genotype.sName;
                    aValue[Jdx].number      = aGroup.NoAnimals;
                    aValue[Jdx].sex         = Model.SexString(Idx, false);
                    aValue[Jdx].age         = aGroup.AgeDays;
                    aValue[Jdx].weight      = aGroup.LiveWeight;
                    aValue[Jdx].max_prev_wt = aGroup.MaxPrevWeight;
                    aValue[Jdx].pregnant    = aGroup.Pregnancy;
                    aValue[Jdx].lactating   = aGroup.Lactation;

                    /*if (Animal == GrazType.AnimalType.Sheep)
                     * {
                     *  aValue[Jdx].fleece_wt = aGroup.FleeceCutWeight;
                     *  aValue[Jdx].fibre_diam = aGroup.FibreDiam;
                     *  aValue[Jdx].no_young = Math.Max(aGroup.NoFoetuses, aGroup.NoOffspring);
                     * }
                     * else*/
                    if (Animal == GrazType.AnimalType.Cattle)
                    {
                        aValue[Jdx].no_foetuses = aGroup.NoFoetuses;
                        aValue[Jdx].no_suckling = aGroup.NoOffspring;
                    }

                    if (aGroup.Lactation > 0)
                    {
                        aValue[Jdx].birth_cs = aGroup.BirthCondition;
                    }

                    if ((aGroup.Pregnancy > 0) || (aGroup.Young != null))
                    {
                        if (aGroup.MatedTo != null)
                        {
                            aValue[Jdx].mated_to = aGroup.MatedTo.sName;
                        }
                        else
                        {
                            aValue[Jdx].mated_to = "";
                        }
                    }
                    else
                    {
                        aValue[Jdx].mated_to = "";
                    }

                    if (aGroup.Young != null)
                    {
                        /*if (Animal == GrazType.AnimalType.Sheep)
                         * {
                         *  aValue[Jdx].lamb_wt = aGroup.Young.LiveWeight;
                         *  aValue[Jdx].lamb_fleece_wt = aGroup.Young.FleeceCutWeight;
                         * }
                         * else*/
                        if (Animal == GrazType.AnimalType.Cattle)
                        {
                            aValue[Jdx].calf_wt = aGroup.Young.LiveWeight;
                        }

                        aValue[Jdx].paddock  = Model.getInPadd(Idx);
                        aValue[Jdx].tag      = Model.getTag(Idx);
                        aValue[Jdx].priority = Model.getPriority(Idx);
                    }
                }
                Jdx++;
            } // next animal
        }
Пример #4
0
        /// <summary>
        /// Called by CreateFactory() and creates a mixture of several genotypes                                       
        /// </summary>
        /// <param name="sBreedName"></param>
        /// <param name="Blend"></param>
        public virtual void InitParameterSet(string sBreedName, TAnimalParamBlend[] Blend)
        {
            TParameterDefinition prmDefn;
            TAnimalParamSet Breed0;
            TAnimalParamSet Breed1;
            double fPropn0;
            double fPropn1;
            double fParamSum;
            double fPropnSum;
            int iDecPlaces;
            int Idx, Jdx, Kdx;
            //TGrazType.ReproType Repro;

            if (Blend.Length == 2)                                             // Special case: optimized for speed
            {                                                                  //   (used in producing offspring)
                Breed0 = Blend[0].Breed;
                Breed1 = Blend[1].Breed;

                fPropn0 = Blend[0].fPropn;
                fPropn1 = Blend[1].fPropn;
                if (fPropn1 > 0.0)
                    fPropn0 = fPropn0 / (fPropn0 + fPropn1);
                else
                    fPropn0 = 1.0;
                fPropn1 = 1.0 - fPropn0;

                sEditor = Breed0.sEditor;                                       // String and integer parameters
                sEditDate = Breed0.sEditDate;                                     //   (consistent with the general case)
                Animal = Breed0.Animal;
                bDairyBreed = Breed0.bDairyBreed;
                MaxYoung = Breed0.MaxYoung;
                FUseDairyCurve = Breed0.FUseDairyCurve;
                OvulationPeriod = Breed0.OvulationPeriod;
                Puberty = Breed0.Puberty;

                FBreedSRW = fPropn0 * Breed0.FBreedSRW + fPropn1 * Breed1.FBreedSRW;
                FPotFleeceWt = fPropn0 * Breed0.FPotFleeceWt + fPropn1 * Breed1.FPotFleeceWt;
                FDairyIntakePeak = fPropn0 * Breed0.FDairyIntakePeak + fPropn1 * Breed1.FDairyIntakePeak;
                FDairyIntakeTime = fPropn0 * Breed0.FDairyIntakeTime + fPropn1 * Breed1.FDairyIntakeTime;
                FDairyIntakeShape = fPropn0 * Breed0.FDairyIntakeShape + fPropn1 * Breed1.FDairyIntakeShape;
                FleeceRatio = fPropn0 * Breed0.FleeceRatio + fPropn1 * Breed1.FleeceRatio;
                MaxFleeceDiam = fPropn0 * Breed0.MaxFleeceDiam + fPropn1 * Breed1.MaxFleeceDiam;
                PeakMilk = fPropn0 * Breed0.PeakMilk + fPropn1 * Breed1.PeakMilk;
                for (Idx = 1; Idx <= 2; Idx++)
                    MortRate[Idx] = fPropn0 * Breed0.MortRate[Idx] + fPropn1 * Breed1.MortRate[Idx];
                for (Idx = 1; Idx <= 2; Idx++)
                    MortAge[Idx] = fPropn0 * Breed0.MortAge[Idx] + fPropn1 * Breed1.MortAge[Idx];
                MortIntensity = fPropn0 * Breed0.MortIntensity + fPropn1 * Breed1.MortIntensity;
                MortCondConst = fPropn0 * Breed0.MortCondConst + fPropn1 * Breed1.MortCondConst;
                MortWtDiff = fPropn0 * Breed0.MortWtDiff + fPropn1 * Breed1.MortWtDiff;

                for (Idx = 0; Idx < SRWScalars.Length; Idx++) SRWScalars[Idx] = fPropn0 * Breed0.SRWScalars[Idx] + fPropn1 * Breed1.SRWScalars[Idx];
                for (Idx = 1; Idx < GrowthC.Length; Idx++) GrowthC[Idx] = fPropn0 * Breed0.GrowthC[Idx] + fPropn1 * Breed1.GrowthC[Idx];
                for (Idx = 1; Idx < IntakeC.Length; Idx++) IntakeC[Idx] = fPropn0 * Breed0.IntakeC[Idx] + fPropn1 * Breed1.IntakeC[Idx];
                for (Idx = 0; Idx < IntakeLactC.Length; Idx++) IntakeLactC[Idx] = fPropn0 * Breed0.IntakeLactC[Idx] + fPropn1 * Breed1.IntakeLactC[Idx];
                for (Idx = 1; Idx < GrazeC.Length; Idx++) GrazeC[Idx] = fPropn0 * Breed0.GrazeC[Idx] + fPropn1 * Breed1.GrazeC[Idx];
                for (Idx = 1; Idx < EfficC.Length; Idx++) EfficC[Idx] = fPropn0 * Breed0.EfficC[Idx] + fPropn1 * Breed1.EfficC[Idx];
                for (Idx = 1; Idx < MaintC.Length; Idx++) MaintC[Idx] = fPropn0 * Breed0.MaintC[Idx] + fPropn1 * Breed1.MaintC[Idx];
                for (Idx = 1; Idx < DgProtC.Length; Idx++) DgProtC[Idx] = fPropn0 * Breed0.DgProtC[Idx] + fPropn1 * Breed1.DgProtC[Idx];
                for (Idx = 1; Idx < ProtC.Length; Idx++) ProtC[Idx] = fPropn0 * Breed0.ProtC[Idx] + fPropn1 * Breed1.ProtC[Idx];
                for (Idx = 1; Idx < PregC.Length; Idx++) PregC[Idx] = fPropn0 * Breed0.PregC[Idx] + fPropn1 * Breed1.PregC[Idx];
                for (Idx = 1; Idx < PregScale.Length; Idx++) PregScale[Idx] = fPropn0 * Breed0.PregScale[Idx] + fPropn1 * Breed1.PregScale[Idx];
                for (Idx = 1; Idx < BirthWtScale.Length; Idx++) BirthWtScale[Idx] = fPropn0 * Breed0.BirthWtScale[Idx] + fPropn1 * Breed1.BirthWtScale[Idx];
                for (Idx = 1; Idx < PeakLactC.Length; Idx++) PeakLactC[Idx] = fPropn0 * Breed0.PeakLactC[Idx] + fPropn1 * Breed1.PeakLactC[Idx];
                for (Idx = 1; Idx < LactC.Length; Idx++) LactC[Idx] = fPropn0 * Breed0.LactC[Idx] + fPropn1 * Breed1.LactC[Idx];
                for (Idx = 1; Idx < WoolC.Length; Idx++) WoolC[Idx] = fPropn0 * Breed0.WoolC[Idx] + fPropn1 * Breed1.WoolC[Idx];
                for (Idx = 1; Idx < ChillC.Length; Idx++) ChillC[Idx] = fPropn0 * Breed0.ChillC[Idx] + fPropn1 * Breed1.ChillC[Idx];
                for (Idx = 1; Idx < GainC.Length; Idx++) GainC[Idx] = fPropn0 * Breed0.GainC[Idx] + fPropn1 * Breed1.GainC[Idx];
                for (Idx = 1; Idx < PhosC.Length; Idx++) PhosC[Idx] = fPropn0 * Breed0.PhosC[Idx] + fPropn1 * Breed1.PhosC[Idx];
                for (Idx = 1; Idx < SulfC.Length; Idx++) SulfC[Idx] = fPropn0 * Breed0.SulfC[Idx] + fPropn1 * Breed1.SulfC[Idx];
                for (Idx = 1; Idx < MethC.Length; Idx++) MethC[Idx] = fPropn0 * Breed0.MethC[Idx] + fPropn1 * Breed1.MethC[Idx];
                for (Idx = 1; Idx < AshAlkC.Length; Idx++) AshAlkC[Idx] = fPropn0 * Breed0.AshAlkC[Idx] + fPropn1 * Breed1.AshAlkC[Idx];
                for (Idx = 1; Idx < DayLengthConst.Length; Idx++) DayLengthConst[Idx] = fPropn0 * Breed0.DayLengthConst[Idx] + fPropn1 * Breed1.DayLengthConst[Idx];
                for (Idx = 0; Idx < ToxaemiaSigs.Length; Idx++) ToxaemiaSigs[Idx] = fPropn0 * Breed0.ToxaemiaSigs[Idx] + fPropn1 * Breed1.ToxaemiaSigs[Idx];
                for (Idx = 0; Idx < DystokiaSigs.Length; Idx++) DystokiaSigs[Idx] = fPropn0 * Breed0.DystokiaSigs[Idx] + fPropn1 * Breed1.DystokiaSigs[Idx];
                for (Idx = 0; Idx < ExposureConsts.Length; Idx++) ExposureConsts[Idx] = fPropn0 * Breed0.ExposureConsts[Idx] + fPropn1 * Breed1.ExposureConsts[Idx];

                FertWtDiff = fPropn0 * Breed0.FertWtDiff + fPropn1 * Breed1.FertWtDiff;
                SelfWeanPropn = fPropn0 * Breed0.SelfWeanPropn + fPropn1 * Breed1.SelfWeanPropn;
                for (Idx = 1; Idx < ConceiveSigs.Length; Idx++)
                    for (Jdx = 0; Jdx < ConceiveSigs[Idx].Length; Jdx++)
                        ConceiveSigs[Idx][Jdx] = fPropn0 * Breed0.ConceiveSigs[Idx][Jdx] + fPropn1 * Breed1.ConceiveSigs[Idx][Jdx];

                for (Idx = 0; Idx <= iDefinitionCount() - 1; Idx++)
                    getDefinition(Idx).setDefined(Blend[0].Breed.getDefinition(Idx));
            }
            else                                                                         // Mixture of breeds provided
            {
                if (Blend.Length > 1)                                                 // Blend the numeric parameter values
                {
                    for (Idx = 0; Idx <= iParamCount() - 1; Idx++)
                    {
                        prmDefn = getParam(Idx);
                        if (prmDefn.paramType == ptyReal)
                        {
                            fParamSum = 0.0;
                            fPropnSum = 0.0;
                            for (Jdx = 0; Jdx <= Blend.Length - 1; Jdx++)
                            {
                                if (Blend[Jdx].Breed.bIsDefined(prmDefn.sFullName))
                                {
                                    fParamSum = fParamSum + Blend[Jdx].fPropn * Blend[Jdx].Breed.fParam(prmDefn.sFullName);
                                    fPropnSum = fPropnSum + Blend[Jdx].fPropn;
                                }
                            }
                            if (fPropnSum > 0.0)
                                setParam(prmDefn.sFullName, fParamSum / fPropnSum);
                        }
                    }
                }
            }

            if (Blend.Length > 0)
            {
                fPropnSum = 0.0;
                for (Jdx = 0; Jdx <= Blend.Length - 1; Jdx++)
                    fPropnSum = fPropnSum + Blend[Jdx].fPropn;

                if (fPropnSum > 0.0)
                {
                    for (Idx = 0; Idx <= FParentage.Length - 1; Idx++)
                        FParentage[Idx].fPropn = 0.0;
                    for (Jdx = 0; Jdx <= Blend.Length - 1; Jdx++)
                    {
                        for (Kdx = 0; Kdx <= Blend[Jdx].Breed.FParentage.Length - 1; Kdx++)
                        {
                            Idx = 0;
                            while ((Idx < FParentage.Length) && (Blend[Jdx].Breed.FParentage[Kdx].sBaseBreed != FParentage[Idx].sBaseBreed))
                                Idx++;
                            if (Idx == FParentage.Length)
                            {
                                Array.Resize(ref FParentage, Idx + 1);
                                FParentage[Idx].sBaseBreed = Blend[Jdx].Breed.FParentage[Kdx].sBaseBreed;
                                FParentage[Idx].fPropn = 0.0;
                            }
                            FParentage[Idx].fPropn = FParentage[Idx].fPropn
                                                      + (Blend[Jdx].fPropn / fPropnSum) * Blend[Jdx].Breed.FParentage[Kdx].fPropn;
                        }
                    }
                }
            }

            if (sBreedName != "")                                                    // Construct a name for the new genotype
                sName = sBreedName;
            else if (FParentage.Length == 1)
                sName = FParentage[0].sBaseBreed;
            else if (FParentage.Length > 1)
            {
                iDecPlaces = 0;
                for (Idx = 0; Idx <= FParentage.Length - 1; Idx++)
                {
                    if ((FParentage[Idx].fPropn > 0.0005) && (FParentage[Idx].fPropn <= 0.05))
                        iDecPlaces = 1;
                }

                sName = "";
                for (Idx = 0; Idx <= FParentage.Length - 1; Idx++)
                {
                    if (FParentage[Idx].fPropn > 0.0005)
                    {
                        if (sName != "")
                            sName = sName + ", ";
                        sName = sName + FParentage[Idx].sBaseBreed + " "
                                         + String.Format("{0:0." + new String('0', iDecPlaces) + "}", 100.0 * FParentage[Idx].fPropn) + "%";
                    }
                }
            }
        }
Пример #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sTagList"></param>
 /// <param name="sValue"></param>
 protected override void setTextParam(string[] sTagList, string sValue)
 {
     if (sTagList[0] == "editor")
         sEditor = sValue;
     else if (sTagList[0] == "edited")
         sEditDate = sValue;
     else if (sTagList[0] == "animal")
     {
         if (sValue.ToLower().Trim() == GrazType.AnimalText[(int)GrazType.AnimalType.Cattle].ToLower())
             Animal = GrazType.AnimalType.Cattle;
         else
             Animal = GrazType.AnimalType.Sheep;
     }
 }
Пример #6
0
        /// <summary>
        /// Overrides the base function and copies all the animal parameters
        /// </summary>
        /// <param name="srcSet"></param>
        /// <param name="bCopyData"></param>
        protected override void copyParams(TParameterSet srcSet, bool bCopyData)
        {
            int Idx;

            base.copyParams(srcSet, false);

            TAnimalParamSet prmSet = (TAnimalParamSet)srcSet;

            if (bCopyData && (prmSet != null))
            {
                FBreedSRW = prmSet.FBreedSRW;
                FPotFleeceWt = prmSet.FPotFleeceWt;
                FDairyIntakePeak = prmSet.FDairyIntakePeak;
                FDairyIntakeTime = prmSet.FDairyIntakeTime;
                FDairyIntakeShape = prmSet.FDairyIntakeShape;
                FUseDairyCurve = prmSet.FUseDairyCurve;
                Array.Resize(ref FParentage, prmSet.FParentage.Length);
                for (Idx = 0; Idx <= FParentage.Length - 1; Idx++)
                    FParentage[Idx] = prmSet.FParentage[Idx];

                sEditor = prmSet.sEditor;
                sEditDate = prmSet.sEditDate;
                Animal = prmSet.Animal;
                MaxYoung = prmSet.MaxYoung;
                Array.Copy(prmSet.SRWScalars,SRWScalars, prmSet.SRWScalars.Length);
                FleeceRatio = prmSet.FleeceRatio;
                MaxFleeceDiam = prmSet.MaxFleeceDiam;
                bDairyBreed = prmSet.bDairyBreed;
                PeakMilk = prmSet.PeakMilk;
                Array.Copy(prmSet.MortRate, MortRate, prmSet.MortRate.Length);
                Array.Copy(prmSet.MortAge, MortAge, prmSet.MortAge.Length);
                MortIntensity = prmSet.MortIntensity;
                MortCondConst = prmSet.MortCondConst;
                MortWtDiff = prmSet.MortWtDiff;
                Array.Copy(prmSet.GrowthC,GrowthC, prmSet.GrowthC.Length);
                Array.Copy(prmSet.IntakeC, IntakeC,prmSet.IntakeC.Length);
                Array.Copy(prmSet.IntakeLactC, IntakeLactC, prmSet.IntakeLactC.Length);
                Array.Copy(prmSet.GrazeC, GrazeC, prmSet.GrazeC.Length);
                Array.Copy(prmSet.EfficC, EfficC, prmSet.EfficC.Length);
                Array.Copy(prmSet.MaintC,MaintC, prmSet.MaintC.Length);
                Array.Copy(prmSet.DgProtC,DgProtC, prmSet.DgProtC.Length);
                Array.Copy(prmSet.ProtC, ProtC, prmSet.ProtC.Length);
                Array.Copy(prmSet.PregC, PregC, prmSet.PregC.Length);
                Array.Copy(prmSet.PregScale, PregScale, prmSet.PregScale.Length);
                Array.Copy(prmSet.BirthWtScale, BirthWtScale,prmSet.BirthWtScale.Length);
                Array.Copy(prmSet.PeakLactC, PeakLactC, prmSet.PeakLactC.Length);
                Array.Copy(prmSet.LactC,LactC, prmSet.LactC.Length);
                Array.Copy(prmSet.WoolC, WoolC, prmSet.WoolC.Length);
                Array.Copy(prmSet.ChillC, ChillC,prmSet.ChillC.Length);
                Array.Copy(prmSet.GainC, GainC, prmSet.GainC.Length);
                Array.Copy(prmSet.PhosC, PhosC, prmSet.PhosC.Length);
                Array.Copy(prmSet.SulfC, SulfC, prmSet.SulfC.Length);
                Array.Copy(prmSet.MethC, MethC, prmSet.MethC.Length);
                Array.Copy(prmSet.AshAlkC, AshAlkC, prmSet.AshAlkC.Length);
                OvulationPeriod = prmSet.OvulationPeriod;
                Array.Copy(prmSet.Puberty, Puberty, prmSet.Puberty.Length);
                Array.Copy(prmSet.DayLengthConst, DayLengthConst, prmSet.DayLengthConst.Length);
                for (int i = 0; i < prmSet.ConceiveSigs.Length; i++)
                    Array.Copy(prmSet.ConceiveSigs[i], ConceiveSigs[i], prmSet.ConceiveSigs[i].Length);
                FertWtDiff = prmSet.FertWtDiff;
                Array.Copy(prmSet.ToxaemiaSigs, ToxaemiaSigs, prmSet.ToxaemiaSigs.Length);
                Array.Copy(prmSet.DystokiaSigs, DystokiaSigs, prmSet.DystokiaSigs.Length);
                Array.Copy(prmSet.ExposureConsts,ExposureConsts, prmSet.ExposureConsts.Length);
                SelfWeanPropn = prmSet.SelfWeanPropn;

                for (Idx = 0; Idx <= iDefinitionCount() - 1; Idx++)
                    getDefinition(Idx).setDefined(prmSet.getDefinition(Idx));
            }
        }
Пример #7
0
        /// <summary>
        /// Fill an init array with animal details from the model
        /// </summary>
        /// <param name="model"></param>
        /// <param name="initValue"></param>
        public static void MakeAnimalValue(StockList model, ref AnimalInits[] initValue)
        {
            AnimalGroup animalGroup;
            int         idx, jdx;

            Array.Resize(ref initValue, model.Count());

            jdx = 0;
            for (idx = 1; idx <= model.Count(); idx++)
            {
                animalGroup = model.At(idx);

                initValue[jdx] = new AnimalInits();

                initValue[jdx].Genotype  = animalGroup.Genotype.Name;
                initValue[jdx].Number    = animalGroup.NoAnimals;
                initValue[jdx].Sex       = animalGroup.ReproState;
                initValue[jdx].AgeDays   = animalGroup.AgeDays;
                initValue[jdx].Weight    = animalGroup.LiveWeight;
                initValue[jdx].MaxPrevWt = animalGroup.MaxPrevWeight;
                initValue[jdx].Pregnant  = animalGroup.Pregnancy;
                initValue[jdx].Lactating = animalGroup.Lactation;

                GrazType.AnimalType animal = model.At(idx).Genotype.Animal;
                if (animal == GrazType.AnimalType.Sheep)
                {
                    initValue[jdx].FleeceWt    = animalGroup.FleeceCutWeight;
                    initValue[jdx].FibreDiam   = animalGroup.FibreDiam;
                    initValue[jdx].NumFoetuses = Math.Max(animalGroup.NoFoetuses, animalGroup.NoOffspring);
                }
                else if (animal == GrazType.AnimalType.Cattle)
                {
                    initValue[jdx].NumFoetuses = animalGroup.NoFoetuses;
                    initValue[jdx].NumSuckling = animalGroup.NoOffspring;
                }

                if (animalGroup.Lactation > 0)
                {
                    initValue[jdx].BirthCS = animalGroup.BirthCondition;
                }

                if ((animalGroup.Pregnancy > 0) || (animalGroup.Young != null))
                {
                    if (animalGroup.MatedTo != null)
                    {
                        initValue[jdx].MatedTo = animalGroup.MatedTo.Name;
                    }
                    else
                    {
                        initValue[jdx].MatedTo = string.Empty;
                    }
                }
                else
                {
                    initValue[jdx].MatedTo = string.Empty;
                }

                if (animalGroup.Young != null)
                {
                    initValue[jdx].YoungWt = animalGroup.Young.LiveWeight;
                    if (animal == GrazType.AnimalType.Sheep)
                    {
                        initValue[jdx].YoungGFW = animalGroup.Young.FleeceCutWeight;
                    }

                    initValue[jdx].Paddock  = model.GetInPadd(idx);
                    initValue[jdx].Tag      = model.GetTag(idx);
                    initValue[jdx].Priority = model.GetPriority(idx);
                }
                jdx++;
            } // next animal
        }