Managing Variables and Scope

Configuration Variables

Each task can contain its own configuration as a task local variable named Configuration. Any global configuration is kept in a global structure named gConfiguration. These configuration variables are maintained in permanent memory, and can be backed up and restored to and from a file, configuration.csv.

IO Variables

IO variables should be defined in the task or subsystem that uses them. Similar to Configuration, an IO structure that is a local variable to a task and a gIO makes good sense.

It is also acceptable to have your IO attached directly to a subsystem structure, in a top level IO member structure, however this is usually not the case, and often has a mapping between the task local IO and the subsystem.io.diMyinput. The reasoning for this mapping is to allow for external transformation functions like inverting, scaling, filtering and forcing.

The local IO structure can also be used for task scraping, similar to the Configuration variable.

For inputs it is OK to have multiple mappings to different systems, although this may lead to duplicate transformation functions.

Permanent Memory

Permanent Memory is handled by the Persist library. Using this library gives us more flexibility in how the permanent memory is handled. We can easily back up and restore permanent memory. It also gives us the ability to save local variables and parts of structures. For example: the axis parameter structures are saved directly in permanent memory so that user changes can be saved through power cycles. This is currently not possible as a built in function since only entire global structures can be saved to permanent memory.

Persist is given multiple data chunks so that different parts of permanent memory can be backed up and restored separately. For example, the homing data can be backed up and restored separately from the machine configuration.

It is a good idea to leave some unused space in the buffer. This allows changes to be made to the data structures without having to reconfigure permanent memory.