//--------------------------------------------------------------------- public override void Run() { SiteVars.GetExternalVars(); // ReInitialize(); SiteVars.Prescription.ActiveSiteValues = null; SiteVars.CohortsDamaged.ActiveSiteValues = 0; //harvest each management area in the list foreach (ManagementArea mgmtArea in managementAreas) { totalSites = new int[Prescription.Count]; totalDamagedSites = new int[Prescription.Count]; totalSpeciesCohorts = new int[Prescription.Count, PlugIn.ModelCore.Species.Count]; prescriptionReported = new bool[Prescription.Count]; mgmtArea.HarvestStands(); //and record each stand that's been harvested foreach (Stand stand in mgmtArea) { if (stand.Harvested) { WriteLogEntry(mgmtArea, stand); } } // updating for preventing establishment foreach (Stand stand in mgmtArea) { if (stand.Harvested && stand.LastPrescription.PreventEstablishment) { List <ActiveSite> sitesToDelete = new List <ActiveSite>(); foreach (ActiveSite site in stand) { if (SiteVars.CohortsDamaged[site] > 0) { Reproduction.PreventEstablishment(site); sitesToDelete.Add(site); } } foreach (ActiveSite site in sitesToDelete) { stand.DelistActiveSite(site); } } } // foreach (Stand stand in mgmtArea) foreach (AppliedPrescription aprescription in mgmtArea.Prescriptions) { Prescription prescription = aprescription.Prescription; //string species_string = ""; double[] species_count = new double[modelCore.Species.Count]; foreach (ISpecies species in PlugIn.ModelCore.Species) { species_count[species.Index] += totalSpeciesCohorts[prescription.Number, species.Index]; } if (totalSites[prescription.Number] > 0 && prescriptionReported[prescription.Number] != true) { //summaryLog.WriteLine("{0},{1},{2},{3}{4}", // PlugIn.ModelCore.CurrentTime, // mgmtArea.MapCode, // prescription.Name, // totalDamagedSites[prescription.Number], // species_string); summaryLog.Clear(); SummaryLog sl = new SummaryLog(); sl.Time = modelCore.CurrentTime; sl.ManagementArea = mgmtArea.MapCode; sl.Prescription = prescription.Name; sl.HarvestedSites = totalDamagedSites[prescription.Number]; sl.CohortsHarvested_ = species_count; summaryLog.AddObject(sl); summaryLog.WriteToFile(); prescriptionReported[prescription.Number] = true; } } } prescriptionMaps.WriteMap(PlugIn.ModelCore.CurrentTime); }
//--------------------------------------------------------------------- public override void Run() { SiteVars.ReInitialize(); SiteVars.Prescription.ActiveSiteValues = null; SiteVars.CohortsDamaged.ActiveSiteValues = 0; //harvest each management area in the list foreach (ManagementArea mgmtArea in managementAreas) { totalSites = new int[Prescription.Count]; totalDamagedSites = new int[Prescription.Count]; totalSpeciesCohorts = new int[Prescription.Count, PlugIn.ModelCore.Species.Count]; prescriptionReported = new bool[Prescription.Count]; mgmtArea.HarvestStands(); //and record each stand that's been harvested foreach (Stand stand in mgmtArea) { if (stand.Harvested) WriteLogEntry(mgmtArea, stand); } // updating for preventing establishment foreach (Stand stand in mgmtArea) { if (stand.Harvested && stand.LastPrescription.PreventEstablishment) { List<ActiveSite> sitesToDelete = new List<ActiveSite>(); foreach (ActiveSite site in stand) { if (SiteVars.CohortsDamaged[site] > 0) { Reproduction.PreventEstablishment(site); sitesToDelete.Add(site); } } foreach (ActiveSite site in sitesToDelete) { stand.DelistActiveSite(site); } } } // foreach (Stand stand in mgmtArea) foreach (AppliedPrescription aprescription in mgmtArea.Prescriptions) { Prescription prescription = aprescription.Prescription; //string species_string = ""; double[] species_count = new double[modelCore.Species.Count]; foreach (ISpecies species in PlugIn.ModelCore.Species) species_count[species.Index] += totalSpeciesCohorts[prescription.Number, species.Index]; if (totalSites[prescription.Number] > 0 && prescriptionReported[prescription.Number] != true) { //summaryLog.WriteLine("{0},{1},{2},{3}{4}", // PlugIn.ModelCore.CurrentTime, // mgmtArea.MapCode, // prescription.Name, // totalDamagedSites[prescription.Number], // species_string); summaryLog.Clear(); SummaryLog sl = new SummaryLog(); sl.Time = modelCore.CurrentTime; sl.ManagementArea = mgmtArea.MapCode; sl.Prescription = prescription.Name; sl.HarvestedSites = totalDamagedSites[prescription.Number]; sl.CohortsHarvested_ = species_count; summaryLog.AddObject(sl); summaryLog.WriteToFile(); prescriptionReported[prescription.Number] = true; } } } prescriptionMaps.WriteMap(PlugIn.ModelCore.CurrentTime); }