Exemple #1
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            // get details from parent breeding activity
            breedParent = this.Parent.Parent as RuminantActivityBreed;
            if (breedParent is null)
            {
                throw new ApsimXException(this, $"Invalid grandparent component of [a={this.Name}]. Expecting [a=RuminantActivityBreed].[a=RuminantActivityControlledMating].[f=ActivityTimerBreedForMilking]");
            }

            // breed params
            breedParams = Resources.GetResourceItem(this, breedParent.PredictedHerdBreed, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as RuminantType;

            // determine min time between conceptions with full milk production
            double conceiveInterval = Convert.ToInt32(breedParams.GestationLength + Math.Ceiling(breedParams.MilkingDays / 30.4), CultureInfo.InvariantCulture);
            // get the milking period
            double milkInterval = Math.Ceiling(breedParams.MilkingDays / 30.4);

            double numGroups = milkInterval / conceiveInterval;



            // determine number of breeders each timing

            // reduce interval to increase milk production
        }
Exemple #2
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            // get details from parent breeding activity
            controlledMatingParent = this.Parent as RuminantActivityControlledMating;
            if (controlledMatingParent is null)
            {
                throw new ApsimXException(this, $"Invalid parent component of [a={this.Name}]. Expecting [a=RuminantActivityControlledMating].[f=ActivityTimerBreedForMilking]");
            }
            breedParent = controlledMatingParent.Parent as RuminantActivityBreed;
            breedParams = resources.FindResourceType <RuminantHerd, RuminantType>(this, breedParent.PredictedHerdBreed, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop);

            int monthsOfMilking = Convert.ToInt32(Math.Ceiling(breedParams.MilkingDays / 30.4), CultureInfo.InvariantCulture);

            shortenLactationMonths = Math.Max(0, monthsOfMilking - ShortenLactationMonths);

            pregnancyDuration = Convert.ToInt32(breedParams.GestationLength, CultureInfo.InvariantCulture);

            // determine min time between conceptions with full milk production minus cut short and resting
            minConceiveInterval = Math.Max(0, pregnancyDuration + shortenLactationMonths + RestMonths);

            startBreedCycleGestationOffsett = shortenLactationMonths - pregnancyDuration;
            if (startBreedCycleGestationOffsett < pregnancyDuration * -1)
            {
                throw new Exception("Cannot handle condition where milking cycle starts before pregnancy");
            }

            // get the milking period
            milkingsPerConceptionsCycle = Math.Ceiling((minConceiveInterval * 1.0) / monthsOfMilking);
        }
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            this.AllocationStyle = ResourceAllocationStyle.Manual;
            this.InitialiseHerd(false, true);

            attributeList = this.FindAllDescendants <ISetAttribute>().ToList();

            milkingTimer = FindChild <ActivityTimerBreedForMilking>();

            // check that timer exists for controlled mating
            if (!this.TimingExists)
            {
                Summary.WriteMessage(this, $"Breeding with controlled mating [a={this.Parent.Name}].[a={this.Name}] requires a Timer otherwise breeding will be undertaken every time-step", MessageType.Warning);
            }

            // get details from parent breeding activity
            breedingParent = this.Parent as RuminantActivityBreed;
        }