Example #1
0
        /// <summary>
        /// Returns the group index of the group that was added. 0->n                    
        /// </summary>
        /// <param name="Inits"></param>
        /// <returns></returns>
        public int Add(TAnimalInits Inits)
        {
            TAnimalGroup NewGroup;
            TPaddockInfo Paddock;

            NewGroup = new TAnimalGroup(getGenotype(Inits.sGenotype),
                                             Inits.Sex,
                                             Inits.Number,
                                             Inits.AgeDays,
                                             Inits.Weight,
                                             Inits.Fleece_Wt,
                                             RandFactory);
            if (bIsGiven(Inits.MaxPrevWt))
                NewGroup.MaxPrevWeight = Inits.MaxPrevWt;
            if (bIsGiven(Inits.Fibre_Diam))
                NewGroup.FibreDiam = Inits.Fibre_Diam;

            if (Inits.sMatedTo != "")
                NewGroup.MatedTo = getGenotype(Inits.sMatedTo);
            if ((NewGroup.ReproState == GrazType.ReproType.Empty) && (Inits.Pregnant > 0))
            {
                NewGroup.Pregnancy = Inits.Pregnant;
                if (Inits.No_Foetuses > 0)
                    NewGroup.NoFoetuses = Inits.No_Foetuses;
            }
            if ((NewGroup.ReproState == GrazType.ReproType.Empty) || (NewGroup.ReproState == GrazType.ReproType.EarlyPreg) || (NewGroup.ReproState == GrazType.ReproType.LatePreg) && (Inits.Lactating > 0))
            {
                NewGroup.Lactation = Inits.Lactating;
                if (Inits.No_Suckling > 0)
                    NewGroup.NoOffspring = Inits.No_Suckling;
                else if ((NewGroup.Animal == GrazType.AnimalType.Cattle) && (Inits.No_Suckling == 0))
                {
                    NewGroup.Young = null;
                }
                if (bIsGiven(Inits.Birth_CS))
                    NewGroup.BirthCondition = TAnimalParamSet.CondScore2Condition(Inits.Birth_CS, TAnimalParamSet.TCond_System.csSYSTEM1_5);
            }

            if (NewGroup.Young != null)
            {
                if (bIsGiven(Inits.Young_Wt))
                    NewGroup.Young.LiveWeight = Inits.Young_Wt;
                if (bIsGiven(Inits.Young_GFW))
                    NewGroup.Young.FleeceCutWeight = Inits.Young_GFW;
            }

            Paddock = FPaddocks.byName(Inits.Paddock.ToLower());
            if (Paddock == null)
                Paddock = FPaddocks.byIndex(0);

            return Add(NewGroup, Paddock, Inits.Tag, Inits.Priority);
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="aValue"></param>
        /// <param name="Inits"></param>
        public void SheepValue2AnimalInits(TSheepInit aValue, ref TAnimalInits Inits)
        {
            Inits = new TAnimalInits();

            Inits.sGenotype = aValue.genotype;
            Inits.Number = aValue.number;
            if (aValue.sex.Length > 0)
                ParseRepro(aValue.sex.ToLower(), ref Inits.Sex);
            else
                Inits.Sex = GrazType.ReproType.Castrated;
            Inits.AgeDays = Convert.ToInt32(aValue.age);
            Inits.Weight = aValue.weight;
            Inits.MaxPrevWt = aValue.max_prev_wt;
            Inits.Fleece_Wt = aValue.fleece_wt;
            Inits.Fibre_Diam = aValue.fibre_diam;
            Inits.sMatedTo = aValue.mated_to;
            Inits.Pregnant = aValue.pregnant;
            Inits.Lactating = aValue.lactating;

            if (Inits.Pregnant > 0)
            {
                Inits.No_Foetuses = aValue.no_young;
            }

            if (Inits.Lactating > 0)
            {
                Inits.No_Suckling = aValue.no_young;
                Inits.Birth_CS = aValue.birth_cs;
                Inits.Young_Wt = aValue.lamb_wt;
                Inits.Young_GFW = aValue.lamb_fleece_wt;
            }
            Inits.Paddock = aValue.paddock;
            Inits.Tag = aValue.tag;
            Inits.Priority = aValue.priority;
        }