Exemple #1
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
        }
Exemple #2
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
        }