
In some cases though it is necessary to discover elements of a simulation as it is running and to then communicate directly with specific components. In a lot of cases, the static approach above provides sufficient functionality. To retrieve a list of APSIM variables and events, use the “Variables” and “Events” components under the “Output file” in the simulation tree in the APSIM User Interface. See the description of APSIM types below. Events must be declared using one of the APSIM types. The name of the event (NegativeBank in this example) will be the name of the event that APSIM sees. Other components in APSIM will be able to subscribe to this event. NET event should be published to the whole APSIM simulation. The name of the method (minus the On prefix) denotes the APSIM event name that will be trapped. The convention is that all handlers will have an On prefix.

This error can be prevented by specifying the Input as optional with a true parameter e.g. If APSIM cannot find the specified variable, then it will throw a fatal error. In the example, APSIM will locate a variable called Fertiliser in another model and retrieve its value. The tag denotes that a value for this variable needs to be supplied by APSIM.This will help ensure that APSIM is able to locate your class.ĪPSIM relies heavily on reflection tags to analyse the model source code to locate variables and methods. Secondly, ensure that your class is not inside a namespace. Firstly, make sure your class is declared as public. Two things to note when creating your models. It subtracts the cost of fertiliser and irrigation water from this bank balance and adds in income based on simulated yield and grain protein. The above example calculates a simple gross margin based on a bank balance.
