Exemple #1
0
 /// <summary>Clears this instance.</summary>
 private void Clear()
 {
     SowingData      = new SowingParameters();
     plantPopulation = 0.0;
     IsAlive         = false;
     SowingDate      = DateTime.MinValue;
 }
Exemple #2
0
 protected void OnPlantSowing(object sender, SowingParameters data)
 {
     if (data.Plant == plant)
     {
         sowingDensity = data.Population;
     }
 }
Exemple #3
0
        virtual protected void OnPlantSowing(object sender, SowingParameters data)
        {
            List <IArbitration> organsToArbitrate = new List <IArbitration>();

            foreach (IOrgan organ in plant.Organs)
            {
                if (organ is IArbitration)
                {
                    organsToArbitrate.Add(organ as IArbitration);
                }
            }

            Organs = organsToArbitrate;
            DM     = new BiomassArbitrationType("DM", Organs);
            N      = new BiomassArbitrationType("N", Organs);
        }
Exemple #4
0
        /// <summary>Sow the crop with the specified parameters.</summary>
        /// <param name="cultivar">The cultivar.</param>
        /// <param name="population">The population.</param>
        /// <param name="depth">The depth mm.</param>
        /// <param name="rowSpacing">The row spacing mm.</param>
        /// <param name="maxCover">The maximum cover.</param>
        /// <param name="budNumber">The bud number.</param>
        /// <param name="rowConfig">SkipRow configuration.</param>
        public void Sow(string cultivar, double population, double depth, double rowSpacing, double maxCover = 1, double budNumber = 1, double rowConfig = 0)
        {
            SowingDate = clock.Today;

            SowingData            = new SowingParameters();
            SowingData.Plant      = this;
            SowingData.Population = population;
            SowingData.Depth      = depth;
            SowingData.Cultivar   = cultivar;
            SowingData.MaxCover   = maxCover;
            SowingData.BudNumber  = budNumber;
            SowingData.RowSpacing = rowSpacing;
            SowingData.SkipType   = rowConfig;

            if (rowConfig == 0)
            {
                // No skip row
                SowingData.SkipPlant = 1.0;
                SowingData.SkipRow   = 0.0;
            }
            if (rowConfig == 1)
            {
                // Alternate rows (plant 1 – skip 1)
                SowingData.SkipPlant = 1.0;
                SowingData.SkipRow   = 1.0;
            }
            if (rowConfig == 2)
            {
                // Planting two rows and skipping one row (plant 2 – skip 1)
                SowingData.SkipPlant = 2.0;
                SowingData.SkipRow   = 1.0;
            }
            if (rowConfig == 3)
            {
                // Alternate pairs of rows (plant 2 – skip 2)
                SowingData.SkipPlant = 2.0;
                SowingData.SkipRow   = 2.0;
            }

            // Adjusting number of plant per meter in each row
            SowingData.SkipDensityScale = 1.0 + SowingData.SkipRow / SowingData.SkipPlant;

            IsAlive = true;

            this.Population = population;

            // Find cultivar and apply cultivar overrides.
            Cultivar cultivarDefinition = FindAllDescendants <Cultivar>().FirstOrDefault(c => c.IsKnownAs(SowingData.Cultivar));

            if (cultivarDefinition == null)
            {
                throw new ApsimXException(this, $"Cannot find a cultivar definition for '{SowingData.Cultivar}'");
            }

            cultivarDefinition.Apply(this);

            // Invoke an AboutToSow event.
            if (Sowing != null)
            {
                Sowing.Invoke(this, new EventArgs());
            }

            // Invoke a sowing event.
            if (PlantSowing != null)
            {
                PlantSowing.Invoke(this, SowingData);
            }

            summary.WriteMessage(this, string.Format("A crop of " + PlantType + " (cultivar = " + cultivar + ") was sown today at a population of " + Population + " plants/m2 with " + budNumber + " buds per plant at a row spacing of " + rowSpacing + " and a depth of " + depth + " mm"));
        }