//--------------------------------------------------------------------- /// <summary> /// Schedules the next harvest for a stand that's been set aside /// (reserved). /// </summary> protected void ScheduleNextHarvest(Stand stand) { int nextTimeToHarvest = Model.Core.CurrentTime + repeatHarvest.Interval; if (nextTimeToHarvest <= Model.Core.EndTime && stand.RepeatNumber < this.repeatHarvest.TimesToRepeat) { reservedStands.Enqueue(new ReservedStand(stand, nextTimeToHarvest)); } else { if (stand.RepeatNumber >= this.repeatHarvest.TimesToRepeat) { stand.SetAsideUntil(Model.Core.CurrentTime); } stand.ResetRepeatNumber(); } }
//--------------------------------------------------------------------- /// <summary> /// Harvests the stands that have repeat harvests scheduled for the /// current time step. /// </summary> public void HarvestReservedStands() { while (reservedStands.Count > 0 && reservedStands.Peek().NextTimeToHarvest <= Model.Core.CurrentTime) { //Stand stand = reservedStands.Dequeue().Stand; Stand stand = reservedStands.Peek().Stand; uint repeat = stand.RepeatNumber; repeatHarvest.Harvest(stand); stand.SetRepeatHarvested(); stand.IncrementRepeat(); HarvestExtensionMain.OnRepeatStandHarvest(this, stand, stand.RepeatNumber); stand = reservedStands.Dequeue().Stand; // Record every instance of a repeat harvest if (reservedStands.Count > 0 && reservedStands.Peek().Stand.RepeatNumber != repeat) { HarvestExtensionMain.OnRepeatHarvestFinished(this, this, this.ActiveMgmtArea, repeat + 1, false); } else if (reservedStands.Count == 0 || reservedStands.Peek().NextTimeToHarvest > Model.Core.CurrentTime) { HarvestExtensionMain.OnRepeatHarvestFinished(this, this, this.ActiveMgmtArea, repeat + 1, true); } if (isMultipleRepeatHarvest) { ScheduleNextHarvest(stand); } else { stand.ResetRepeatNumber(); } } }