Supplementing Generated Ada : READ, WRITTEN, CHANGED, TRUE, and FALSE in Complex Data Types

READ, WRITTEN, CHANGED, TRUE, and FALSE in Complex Data Types

Sensing how the rd() , wr() , and ch() events, as well as tr() and fs(), are related to complex Data-Types requires the Code Generator to create some additional Data-Types and variables. These type declarations are put in the same header file as the type declaration for the complex type itself. Remember that the names and number of header files varies, based on whether the Separate File per Statechart option was selected in the profile under Options > Module Settings.

Additional types are required for wr() and rd() as well as additional variable declarations. These additional types have similar structures to the complex types themselves. The type have fields with the same name but the types of the fields are EVENTS. These are used to store the event of WRITTEN or READ for each of the fields of the complex type.

A separate variable is defined for rd() and wr(). Each is defined as a type COMPLEX_VARIABLE_NAME_event. The name of the variables is the same as the complex type itself, with either wr or rd prefixed, as appropriate. One or more fields in the wr or rd variable is set when these fields are READ or WRITTEN. This is found in the procedure for the action that sets or uses the referenced field values.

If one or more of statements ch() , tr() , or fs() are used in the model, an additional variable is needed that saves the previous value of the referenced model variable. This variable has the same type as the complex variable, and the same name as the complex variable with the letters prev_ prefixed.

This is the same scheme that is used for primitive variables in the code generator. It has been extended to work with complex variables as well.

Note: The prev_ variable is updated every step and using wr and rd has an impact on the performance of the generated code. You should use it discriminatively. Sometimes, it may be more efficient to create your own X_CHANGED flag that is set only when needed.