Example #1
0
    public void OnHarvest(HarvestType Harvest)
    {
        WriteHarvestReport();

        // Tell the rest of the system we are about to harvest
        if (Harvesting != null)
        {
            Harvesting.Invoke();
        }

        // Check some bounds
        if (Harvest.Remove < 0 || Harvest.Remove > 1.0)
        {
            throw new Exception("Harvest remove fraction needs to be between 0 and 1");
        }
        if (Harvest.Height < 0 || Harvest.Height > 1000.0)
        {
            throw new Exception("Harvest height needs to be between 0 and 1000");
        }

        // Set the population denisty if one was provided by user.
        if (Harvest.Plants != 0)
        {
            Population.Density = Harvest.Plants;
        }

        // Call each organ's OnHarvest. They fill a BiomassRemoved structure. We then publish a
        // BiomassRemoved event.
        BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.OnHarvest(Harvest, BiomassRemovedData);
        }
        BiomassRemovedData.crop_type = CropType;
        BiomassRemoved.Invoke(BiomassRemovedData);
        WriteBiomassRemovedReport(BiomassRemovedData);

        // now update new canopy covers
        PlantSpatial.Density     = Population.Density;
        PlantSpatial.CanopyWidth = Leaf.width;
        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoCover();
        }
        UpdateCanopy();

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoNConccentrationLimits();
        }
    }