示例#1
0
        /// <summary>
        /// Does the actual work of harvesting individual sites
        /// </summary>
        public void HarvestSite(ActiveSite site, Stand stand)
        {
            // Site selection may have spread to other stands beyond the
            // original stand.
            Stand standForCurrentSite = SiteVars.Stand[site];

            // Always record the prescription even if nothing harvested; Supports plantOnly prescriptions
            SiteVars.Prescription[site]     = this;
            SiteVars.PrescriptionName[site] = this.Name;

            if (isDebugEnabled)
            {
                log.DebugFormat("  Cutting cohorts at {0} in stand {1}{2}", site,
                                SiteVars.Stand[site].MapCode,
                                (standForCurrentSite == stand)
                                    ? ""
                                    : string.Format(" (initial stand {0})",
                                                    stand.MapCode));
            }
            cohortCutter.Cut(site, cohortCounts);

            if (cohortCounts.AllSpecies > 0)
            {
                SiteVars.CohortsDamaged[site] = cohortCounts.AllSpecies;
                standForCurrentSite.DamageTable.IncrementCounts(cohortCounts);
                stand.LastAreaHarvested += Model.Core.CellArea;
                if (isDebugEnabled)
                {
                    log.DebugFormat("    # of cohorts damaged = {0}; stand.LastAreaHarvested = {1}",
                                    SiteVars.CohortsDamaged[site],
                                    stand.LastAreaHarvested);
                }
                HarvestExtensionMain.OnSiteHarvest(this, site);
            }

            if (speciesToPlant != null)
            {
                if (isDebugEnabled)
                {
                    Model.Core.UI.WriteLine("  {0} {1}", speciesToPlant.ToString(), site.ToString());
                }
                Reproduction.ScheduleForPlanting(speciesToPlant, site);
            }
        }
示例#2
0
        //---------------------------------------------------------------------

        /// <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();
                }
            }
        }
示例#3
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Harvests a stand (and possibly its neighbors) according to the
        /// prescription's site-selection method.
        /// </summary>
        /// <returns>
        /// The area that was harvested (units: hectares).
        /// </returns>
        // This is called by AppliedPrescription
        public virtual void Harvest(Stand stand)
        {
            if (isDebugEnabled)
            {
                log.DebugFormat("  Harvesting stand {0} by {1} ...", stand.MapCode, Name);
            }

            //set prescription name for stand
            stand.PrescriptionName = this.Name;
            stand.HarvestedRank    = AppliedPrescription.CurrentRank;
            stand.LastPrescription = this;

            stand.MinTimeSinceDamage = this.minTimeSinceDamage;

            //set current stand
            currentStand = stand;
            currentStand.ClearDamageTable();

            // SelectSites(stand) is where either complete, complete stand spreading, or partial stand
            // spreading are activated.
            // tjs - This is what gets the sites that will be harvested


            foreach (ActiveSite site in siteSelector.SelectSites(stand))
            {
                // Site selection may have spread to other stands beyond the
                // original stand.
                Stand standForCurrentSite = SiteVars.Stand[site];

                // Always record the prescription even if nothing harvested; Supports plantOnly prescriptions
                SiteVars.Prescription[site]     = this;
                SiteVars.PrescriptionName[site] = this.Name;


                if (isDebugEnabled)
                {
                    log.DebugFormat("  Cutting cohorts at {0} in stand {1}{2}", site,
                                    SiteVars.Stand[site].MapCode,
                                    (standForCurrentSite == stand)
                                        ? ""
                                        : string.Format(" (initial stand {0})",
                                                        stand.MapCode));
                }
                cohortCutter.Cut(site, cohortCounts);

                if (cohortCounts.AllSpecies > 0)
                {
                    SiteVars.CohortsDamaged[site] = cohortCounts.AllSpecies;
                    standForCurrentSite.DamageTable.IncrementCounts(cohortCounts);
                    stand.LastAreaHarvested += Model.Core.CellArea;
                    if (isDebugEnabled)
                    {
                        log.DebugFormat("    # of cohorts damaged = {0}; stand.LastAreaHarvested = {1}",
                                        SiteVars.CohortsDamaged[site],
                                        stand.LastAreaHarvested);
                    }
                    HarvestExtensionMain.OnSiteHarvest(this, site);
                }


                if (speciesToPlant != null)
                {
                    Model.Core.UI.WriteLine("  {0} {1}", speciesToPlant.ToString(), site.ToString());
                    Reproduction.ScheduleForPlanting(speciesToPlant, site);
                }
            }
            return;
        }