Пример #1
0
        private void OnDoManagement(object sender, EventArgs e)
        {
            if (DateUtilities.WithinDates(StartDate, clock.Today, EndDate))
            {
                if (TypeOfDraft == DraftType.Fixed)
                {
                    // Loop through all tag numbers.
                    for (int t = 0; t < TagNumbers.Length; t++)
                    {
                        // Find the animal groups that have the tag number and move them to the
                        // specified padock.
                        foreach (var group in stock.StockModel.Animals.Skip(1).Where(g => g.Tag == TagNumbers[t]))
                        {
                            group.MoveToPaddock(PaddockNames[t]);
                        }
                    }
                }
                else
                {
                    var fullStartDate = DateUtilities.GetDate(StartDate, clock.Today);
                    if (fullStartDate > clock.Today)
                    {
                        fullStartDate = fullStartDate.AddYears(-1);
                    }
                    var numDaysSinceStartDate = (clock.Today - fullStartDate).Days;

                    // Flexible grazing
                    // X day intervals from the start of the period - is this the check day or day one?
                    if (CheckEvery > 0 && numDaysSinceStartDate % CheckEvery == 0)
                    {
                        MoveAnimals();
                    }
                }
            }
        }
Пример #2
0
        // 3. Public methods
        //-----------------------------------------------------------------------------------------------------------------

        /// <summary>Computes the phenological development during one time-step.</summary>
        /// <remarks>Returns true when target is met.</remarks>
        public bool DoTimeStep(ref double propOfDayToUse)
        {
            bool proceedToNextPhase = false;

            TTForTimeStep = phenology.thermalTime.Value() * propOfDayToUse;
            if (EmergenceDate != null)
            {
                Target = (DateUtilities.GetDate(EmergenceDate, clock.Today) - plant.SowingDate).TotalDays;
                ProgressThroughPhase += 1;
                if (DateUtilities.DatesEqual(EmergenceDate, clock.Today))
                {
                    proceedToNextPhase = true;
                }
            }
            else
            {
                ProgressThroughPhase += TTForTimeStep;
                if (ProgressThroughPhase > Target)
                {
                    if (TTForTimeStep > 0.0)
                    {
                        proceedToNextPhase = true;
                        propOfDayToUse     = (ProgressThroughPhase - Target) / TTForTimeStep;
                        TTForTimeStep     *= (1 - propOfDayToUse);
                    }
                    ProgressThroughPhase = Target;
                }
            }
            return(proceedToNextPhase);
        }
Пример #3
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            if (Verbose)
            {
                summary.WriteMessage(this, "Initialising the Manager for grazing, urine return and reporting");
            }

            if (GrazingRotationType == GrazingRotationTypeEnum.TargetMass ||
                GrazingRotationType == GrazingRotationTypeEnum.TargetMassAndLength)
            {
                if (PreGrazeDMArray == null || PreGrazeDMArray.Length != 12)
                {
                    throw new Exception("There must be 12 values input for the pre-grazing DM");
                }
                if (PostGrazeDMArray == null || PostGrazeDMArray.Length != 12)
                {
                    throw new Exception("There must be 12 values input for the post-grazing DM");
                }
            }
            if (GrazingRotationType == GrazingRotationTypeEnum.TargetMassAndLength)
            {
                if (RotationLengthArray == null || RotationLengthArray.Length != 12)
                {
                    throw new Exception("There must be 12 values input for rotation length");
                }
            }

            if (FractionOfBiomassToDung.Length != 1 && FractionOfBiomassToDung.Length != 12)
            {
                throw new Exception("You must specify either a single value for 'proportion of biomass going to dung' or 12 monthly values.");
            }

            if (FractionOfBiomassToUrine.Length != 1 && FractionOfBiomassToUrine.Length != 12)
            {
                throw new Exception("You must specify either a single value for 'proportion of biomass going to urine' or 12 monthly values.");
            }

            if (Verbose)
            {
                summary.WriteMessage(this, "Finished initialising the Manager for grazing, urine return and reporting");
            }

            if (NoGrazingStartString != null)
            {
                NoGrazingStart = DateUtilities.GetDate(NoGrazingStartString);
            }
            if (NoGrazingEndString != null)
            {
                NoGrazingEnd = DateUtilities.GetDate(NoGrazingEndString);
            }
        }