APSIMInitiative / ApsimX

ApsimX is the next generation of APSIM
http://www.apsim.info
Other
138 stars 167 forks source link

OnPhaseChange method disappears #5466

Closed hut104 closed 1 year ago

hut104 commented 4 years ago

Move code to other classes

    /// <summary>Called when [phase changed].</summary>
    /// <param name="phaseChange">The phase change.</param>
    /// <param name="sender">Sender plant.</param>
    [EventSubscribe("PhaseChanged")]
    private void OnPhaseChanged(object sender, PhaseChangedType phaseChange)
    {
        if (sender == this && Canopy != null && AboveGround != null)
        {
            string message = Phenology.CurrentPhase.Start + "\r\n";
            if (Canopy != null)
            {
                message += "  LAI = " + Canopy.LAI.ToString("f2") + " (m^2/m^2)" + "\r\n";
                message += "  Above Ground Biomass = " + AboveGround.Wt.ToString("f2") + " (g/m^2)" + "\r\n";
            }
            Summary.WriteMessage(this, message);
            if (Phenology.CurrentPhase.Start == "Flowering" && Flowering != null)
                Flowering.Invoke(this, null);
        }
    }
hol430 commented 4 years ago

Options that I see for this one:

  1. Copy into Leaf, SimpleLeaf, PerennialLeaf and SorghumLeaf (and maybe others too) and have this code duplicated in all of them
  2. Create a base class for leaf, put it in there
  3. Leave as is

Preferences?