Example #1
0
        /// <summary>Harvest the crop.</summary>
        public void RemoveBiomass(string biomassRemoveType, RemovalFractions removalData = null)
        {
            summary.WriteMessage(this, string.Format("Biomass removed from crop " + Name + " by " + biomassRemoveType.TrimEnd('e') + "ing"));

            // Invoke specific defoliation events.
            if (biomassRemoveType == "Harvest" && Harvesting != null)
            {
                Harvesting.Invoke(this, new EventArgs());
            }

            if (biomassRemoveType == "Prune" && Pruning != null)
            {
                Pruning.Invoke(this, new EventArgs());
            }

            if (biomassRemoveType == "LeafPluck" && LeafPlucking != null)
            {
                LeafPlucking.Invoke(this, new EventArgs());
            }

            if (biomassRemoveType == "Cut" && Cutting != null)
            {
                Cutting.Invoke(this, new EventArgs());
            }

            if (biomassRemoveType == "Graze" && Grazing != null)
            {
                Grazing.Invoke(this, new EventArgs());
            }

            // Set up the default BiomassRemovalData values
            foreach (IOrgan organ in Organs)
            {
                // Get the default removal fractions
                OrganBiomassRemovalType biomassRemoval = null;
                if (removalData != null)
                {
                    biomassRemoval = removalData.GetFractionsForOrgan(organ.Name);
                }
                organ.RemoveBiomass(biomassRemoveType, biomassRemoval);
            }

            // Reset the phenology if SetPhenologyStage specified.
            if (removalData != null && removalData.SetPhenologyStage != 0 && Phenology is Phenology phenology)
            {
                phenology.SetToStage(removalData.SetPhenologyStage);
            }

            // Reduce plant and stem population if thinning proportion specified
            if (removalData != null && removalData.SetThinningProportion != 0 && structure != null)
            {
                structure.DoThin(removalData.SetThinningProportion);
            }

            // Remove nodes from the main-stem
            if (removalData != null && removalData.NodesToRemove > 0)
            {
                structure.DoNodeRemoval(removalData.NodesToRemove);
            }
        }
Example #2
0
    private Grazing()
    {
        if (_instance != null)
        {
            return;
        }

        _instance = this;
    }
Example #3
0
        public async Task Post([FromBody] GrazingDto value)
        {
            var grazing = new Grazing
            {
                Coordinates = value.Coordinates
                              .Select(x => new Coordinate
                {
                    Longitude = x.Longitude,
                    Latitude  = x.Latitude
                }).ToList()
            };

            await _context.Grazings.AddAsync(grazing);

            await _context.SaveChangesAsync();
        }
Example #4
0
 public GrazingAction(Grazing grazing)
     : base(grazing)
 {
 }