public void Init() { abiebals = TestUtil.Species.SampleDataset["abiebals"]; selector_25_50_75_100to200_300to500 = CreateSelector(25, 50, 75, null, 100, 200, 300, 500); selector_2to99_250 = CreateSelector(250, null, 2, 99); isHarvested = new SpeciesCohortBoolArray(); }
//--------------------------------------------------------------------- /// <summary> /// Creates and stores a specific-ages cohort selector for a species /// if at least one percentage was found among the list of ages and /// ranges that were read. /// </summary> /// <returns> /// True if a selector was created and stored in the CohortSelectors /// property. False is returned if no selector was created because /// there were no percentages read for any age or range. /// </returns> public static bool CreateCohortSelectorFor(ISpecies species, IList<ushort> ages, IList<AgeRange> ageRanges) { if (percentages.Count == 0) return false; else { CohortSelectors[species] = new SpecificAgesCohortSelector(ages, ageRanges, percentages); percentages.Clear(); return true; } }
//--------------------------------------------------------------------- private void SelectCohorts(ISpeciesCohorts cohorts, SpecificAgesCohortSelector selector) { isHarvested.SetAllFalse(cohorts.Count); selector.SelectCohorts(cohorts, isHarvested); }
//--------------------------------------------------------------------- public static void AgeOrRangeWasRead(AgeRange ageRange, Percentage percentage) { ageOrRangeWasRead = true; // Have we started reading ages and ranges for another species? // If so, then first clear the old values from the previous // species. bool clearOldValues = (HarvestSpeciesDataset.MostRecentlyFetchedSpecies != null) && (ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] == null); if (clearOldValues) { ages.Clear(); ranges.Clear(); percentages.Clear(); } if (ageRange.Start == ageRange.End) ages.Add(ageRange.Start); else ranges.Add(ageRange); if (percentage != null) percentages[ageRange.Start] = percentage; if (Landis.Extension.BaseHarvest.InputParametersParser.AllSpeciesNameWasRead) ageSelectorForAllSpecies = new SpecificAgesCohortSelector(ages, ranges, percentages); if (HarvestSpeciesDataset.MostRecentlyFetchedSpecies != null) ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] = new SpecificAgesCohortSelector(ages, ranges, percentages); currentSpecies = HarvestSpeciesDataset.MostRecentlyFetchedSpecies; }