CLEM components
Advanced topic - requires coding skills
The term "component" is used throughout this documentation to refer to the various objects used to build a whole-farm simulation whether resources, activities, timers, filters or data readers. These are actually models of type Model in the APSIM Next Generation framework, but referred to as components here to avoid confusion between the various uses of the term "model" which most users would apply to CLEM, or event APSIM itself.

All models in APSIM inherit the IModel interface and are derived from the APSIM model (Model.cs). The IModel interface ensures that the functionality is provided to store the model's name, parent model, children (as a list of models), enabled state, hidden state as well as a switch to include documentation and an OnCreated method.

All components developed for CLEM derive from the CLEMModel base class (Models.CLEM.CLEMModel.cs, itself derived from APSIM Model).

The CLEMModel base class inherit the UI (user interface) interface that ensures a property is available to store the name of the current selected tab in the interface. This allows the interface to remember the last selected state of the display tabs (Summary, Version, Properties).
This base class handles identification of the model, warning logs, setting defaults, checking parent validity and the creation of the model summary description.

While APSIM uses the Name property to identify a model, in CLEM, it is important to be able to distinguish between components in the simulation tree with the same name. For this reason all components have a unique ID property of type System.Guid. A method to SetGuID is available and a property of type string (UniqueID) returns the value.

Each component has a public WarningLog (warninglog.cs) that tracks warnings generated and ensures multiple warnings of the same type are not generated, cluttering summaries.

The SetDefaults method is used to assign default values to component properties where available (see Default parameter values).

The boolean ValidParent method determines whether the parent of a component has a type as provided in the APSIM ValidParent attributes. This is used for validation.

CLEM provides a descriptive summary of the set up of each property that is displayed in the summary tab. This functionality is provided in this base class as well as overridden methods in each component.
For full details on how to generate HTML summary descriptions for display see Providing descriptive summaries.