public static void WriteSummaryLogEntry(ManagementArea mgmtArea, AppliedPrescription prescription, uint repeatNumber = 0, bool lastHarvest = false)
        {
            double[] species_cohorts = new double[modelCore.Species.Count];
            double[] species_biomass = new double[modelCore.Species.Count];
            foreach (ISpecies species in modelCore.Species)
            {
                species_cohorts[species.Index] = totalSpeciesCohorts[prescription.Prescription.Number, species.Index];
                species_biomass[species.Index] = totalSpeciesBiomass[prescription.Prescription.Number, species.Index];
            }

            if (totalSites[prescription.Prescription.Number] > 0 && prescriptionReported[prescription.Prescription.Number] != true)
            {
                string name = prescription.Prescription.Name;

                if (repeatNumber > 0)
                {
                    name = name + "(" + repeatNumber + ")";
                }
                summaryLog.Clear();
                SummaryLog sl = new SummaryLog();
                sl.Time                        = modelCore.CurrentTime;
                sl.ManagementArea              = mgmtArea.MapCode;
                sl.Prescription                = name;
                sl.HarvestedSites              = totalDamagedSites[prescription.Prescription.Number];
                sl.TotalBiomassHarvested       = totalBiomassRemoved[prescription.Prescription.Number];
                sl.TotalCohortsPartialHarvest  = totalCohortsDamaged[prescription.Prescription.Number];
                sl.TotalCohortsCompleteHarvest = totalCohortsKilled[prescription.Prescription.Number];
                sl.CohortsHarvested_           = species_cohorts;
                sl.BiomassHarvestedMg_         = species_biomass;
                summaryLog.AddObject(sl);
                summaryLog.WriteToFile();

                // Do not mark this as recorded until the final summary is logged. Because repeat steps will be
                // recorded first and then new initiations, mark this as reported once the initiation step is complete
                if (repeatNumber == 0 || (ModelCore.CurrentTime > prescription.EndTime && lastHarvest))
                {
                    prescriptionReported[prescription.Prescription.Number] = true;
                }

                // Clear the log for the initial harvests
                if (lastHarvest)
                {
                    totalDamagedSites[prescription.Prescription.Number]   = 0;
                    totalBiomassRemoved[prescription.Prescription.Number] = 0;
                    totalCohortsDamaged[prescription.Prescription.Number] = 0;
                    totalCohortsKilled[prescription.Prescription.Number]  = 0;

                    foreach (ISpecies species in modelCore.Species)
                    {
                        totalSpeciesCohorts[prescription.Prescription.Number, species.Index] = 0;
                        totalSpeciesBiomass[prescription.Prescription.Number, species.Index] = 0;
                    }
                }
            }
        }
Exemple #2
0
        public static ExtendedPrescription ToExtendedPrescription(
            this AppliedPrescription appliedPrescription, ManagementArea managementArea)
        {
            var prescription    = appliedPrescription.Prescription;
            var areaToHarvest   = appliedPrescription.PercentageToHarvest;
            var standsToHarvest = appliedPrescription.PercentStandsToHarvest;
            var beginTime       = appliedPrescription.BeginTime;
            var endTime         = appliedPrescription.EndTime;

            return(new ExtendedPrescription(prescription, managementArea, areaToHarvest, standsToHarvest,
                                            beginTime, endTime));
        }