Пример #1
0
    public void OnSow(SowPlant2Type Sow)
    {
        SowingData = Sow;

        // Go through all our children and find all organs.
        Organs.Clear();
        foreach (object ChildObject in My.ChildrenAsObjects)
        {
            Organ Child = ChildObject as Organ;
            if (Child != null)
            {
                Organs.Add(Child);
            }
        }

        if (NewCrop != null)
        {
            NewCropType Crop = new NewCropType();
            Crop.crop_type = CropType;
            Crop.sender    = Name;
            NewCrop.Invoke(Crop);
        }

        if (Sowing != null)
        {
            Sowing.Invoke();
        }

        // tell all our children about sow
        foreach (Organ Child in Organs)
        {
            Child.OnSow(Sow);
        }
    }
Пример #2
0
    public void OnEndCrop()
    {
        NewCropType Crop = new NewCropType();

        Crop.crop_type = CropType;
        Crop.sender    = Name;
        if (CropEnding != null)
        {
            CropEnding.Invoke(Crop);
        }

        // Keep track of some variables for reporting.
        Biomass AboveGroundBiomass = new Biomass(AboveGround);
        Biomass BelowGroundBiomass = new Biomass(BelowGround);

        // 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.OnEndCrop(BiomassRemovedData);
        }
        BiomassRemovedData.crop_type = CropType;
        BiomassRemoved.Invoke(BiomassRemovedData);

        Console.WriteLine("    Organic matter from crop:-      Tops to surface residue      Roots to soil FOM");
        Console.WriteLine(string.Format("                      DM (kg/ha) = {0,21:F1}{1,24:F1}",
                                        AboveGroundBiomass.Wt, BelowGroundBiomass.Wt));
        Console.WriteLine(string.Format("                      N  (kg/ha) = {0,22:F2}{1,24:F2}",
                                        AboveGroundBiomass.N, BelowGroundBiomass.N));
        //Console.WriteLine(string.Format("                      P  (kg/ha) = {0,22:F2}{1,24:F2}",
        //                                AboveGroundBiomass.P, BelowGroundBiomass.P));
    }
Пример #3
0
    public void OnEndCrop()
    {
        NewCropType Crop = new NewCropType();

        Crop.crop_type = CropType;
        Crop.sender    = Name;
        if (CropEnding != null)
        {
            CropEnding.Invoke(Crop);
        }

        BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();

        BiomassRemovedData.crop_type           = CropType;
        BiomassRemovedData.dm_type             = new string[Organs.Count];
        BiomassRemovedData.dlt_crop_dm         = new float[Organs.Count];
        BiomassRemovedData.dlt_dm_n            = new float[Organs.Count];
        BiomassRemovedData.dlt_dm_p            = new float[Organs.Count];
        BiomassRemovedData.fraction_to_residue = new float[Organs.Count];
        int i = 0;

        foreach (Organ O in Organs)
        {
            if (O is AboveGround)
            {
                BiomassRemovedData.dm_type[i]             = O.Name;
                BiomassRemovedData.dlt_crop_dm[i]         = (float)(O.Live.Wt + O.Dead.Wt) * 10f;
                BiomassRemovedData.dlt_dm_n[i]            = (float)(O.Live.N + O.Dead.N) * 10f;
                BiomassRemovedData.dlt_dm_p[i]            = 0f;
                BiomassRemovedData.fraction_to_residue[i] = 1f;
            }
            else
            {
                BiomassRemovedData.dm_type[i]             = O.Name;
                BiomassRemovedData.dlt_crop_dm[i]         = 0f;
                BiomassRemovedData.dlt_dm_n[i]            = 0f;
                BiomassRemovedData.dlt_dm_p[i]            = 0f;
                BiomassRemovedData.fraction_to_residue[i] = 0f;
            }
            i++;
        }
        BiomassRemoved.Invoke(BiomassRemovedData);

        // tell all our children about sow
        foreach (Organ Child in Organs)
        {
            Child.OnEndCrop();
        }
    }
Пример #4
0
        private void OnSow(SowPlant2Type Sow)
        {
            plant_status = "alive";

            if (NewCrop != null)
            {
                NewCropType Crop = new NewCropType();
                Crop.crop_type = Crop_Type;
                Crop.sender    = Name;
                NewCrop.Invoke(Crop);
            }

            if (Sowing != null)
            {
                Sowing.Invoke();
            }
        }
Пример #5
0
    public void OnSow(SowPlant2Type Sow)
    {
        SowingData   = Sow;
        plant_status = "alive";
        Population   = SowingData.Population;

        if (NewCrop != null)
        {
            NewCropType Crop = new NewCropType();
            Crop.crop_type = Crop_Type;
            Crop.sender    = Name;
            NewCrop.Invoke(Crop);
        }

        if (Sowing != null)
        {
            Sowing.Invoke();
        }
    }
Пример #6
0
    public void OnSow(SowPlant2Type Sow)
    {
        if (Sow.Cultivar == "")
        {
            throw new Exception("Cultivar not specified on sow line.");
        }

        SowingData = Sow;

        // Go through all our children and find all organs.
        Organ1s.Clear();
        foreach (object ChildObject in My.ChildrenAsObjects)
        {
            Organ1 Child1 = ChildObject as Organ1;
            if (Child1 != null)
            {
                Organ1s.Add(Child1);
                if (Child1 is AboveGround)
                {
                    Tops.Add(Child1);
                }
            }
        }

        if (NewCrop != null)
        {
            NewCropType Crop = new NewCropType();
            Crop.crop_type = CropType;
            Crop.sender    = Name;
            NewCrop.Invoke(Crop);
        }

        if (Sowing != null)
        {
            Sowing.Invoke();
        }

        WriteSowReport(Sow);
    }
Пример #7
0
        /// <summary>Sows the specified population.</summary>
        /// <param name="population">The population.</param>
        /// <param name="cultivar">The cultivar.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="rowSpacing">The row spacing.</param>
        /// <param name="budNumber">Bud number not used</param>
        /// <param name="maxCover">Maximum cover not used</param>
        /// <exception cref="System.Exception">Cultivar not specified on sow line.</exception>
        public void Sow(string cultivar, double population, double depth, double rowSpacing, double maxCover = 1, double budNumber = 1)
        {
            SowingData = new SowPlant2Type();
            SowingData.Population = population;
            SowingData.Cultivar = cultivar;
            SowingData.Depth = depth;
            SowingData.RowSpacing = rowSpacing;

            if (SowingData.Cultivar == "")
                throw new Exception("Cultivar not specified on sow line.");

            // Find cultivar and apply cultivar overrides.
            cultivarDefinition = Cultivar.Find(Cultivars, SowingData.Cultivar);
            cultivarDefinition.Apply(this);

            if (NewCrop != null)
            {
                NewCropType Crop = new NewCropType();
                Crop.crop_type = CropType;
                Crop.sender = Name;
                NewCrop.Invoke(Crop);
            }

            if (Sowing != null)
                Sowing.Invoke(this, new EventArgs());

            if (PlantSowing != null)
                PlantSowing.Invoke(this, SowingData);

            Population.OnSow(SowingData);
            WriteSowReport(SowingData);
            OnPrepare(null, null); // Call this because otherwise it won't get called on the sow date.
        }
Пример #8
0
        /// <summary>Called when [end crop].</summary>
        public void OnEndCrop()
        {
            NewCropType Crop = new NewCropType();
            Crop.crop_type = CropType;
            Crop.sender = Name;
            if (CropEnding != null)
                CropEnding.Invoke(Crop);

            if (PlantEnding != null)
                PlantEnding.Invoke(this, new ModelArgs() { Model = this });

            // Keep track of some variables for reporting.
            Biomass AboveGroundBiomass = new Biomass(AboveGround);
            Biomass BelowGroundBiomass = new Biomass(BelowGround);

            // 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.OnEndCrop(BiomassRemovedData);
            BiomassRemovedData.crop_type = CropType;
            BiomassRemoved.Invoke(BiomassRemovedData);

            string message = string.Format("Organic matter from crop to surface organic matter:-\r\n" +
                                           "  DM tops  (kg/ha) = {0,10:F1}\r\n" +
                                           "  DM roots (kg/ha) = {1,10:F1}\r\n" +
                                           "  N  tops  (kg/ha) = {0,10:F2}\r\n" +
                                           "  N  roots (lh/ha) = {1,10:F2}",
                     AboveGroundBiomass.Wt, BelowGroundBiomass.Wt,
                     AboveGroundBiomass.N, BelowGroundBiomass.N);
            Summary.WriteMessage(this, message);

            cultivarDefinition.Unapply();
            SowingData = null;
        }
Пример #9
0
        private void OnSow(SowPlant2Type Sow)
        {
            plant_status = "alive";

            if (NewCrop != null)
            {
                NewCropType Crop = new NewCropType();
                Crop.crop_type = Crop_Type;
                Crop.sender = Name;
                NewCrop.Invoke(Crop);
            }

            if (Sowing != null)
                Sowing.Invoke();
        }