Real-Time Workshop Embedded Coder    

Data Structures and Code Modules

Real-Time Model Data Structure

The Real-Time Workshop Embedded Coder encapsulates information about the root model in the real-time model data structure. We refer to the real-time model data structure as rtM.

To reduce memory requirements, rtM contains only information required by your model. For example, the fields related to data logging are generated only if the model has the MAT-file logging code generation option enabled. rtM may also contain model-specific rtM information related to timing, solvers, and model data such as inputs, outputs, states, and parameters.

By default, rtM contains an error status field that your code can monitor or set. If you do not need to log or monitor error status in your application, select the Suppress error status in real-time model data structure option. This will further reduce memory usage. Selecting this option may also cause rtM to disappear completely from the generated code.

The symbol definitions for rtM in generated code are as follows:

Accessor Macros

To enable you to interface your code to rtM, the Real-Time Workshop Embedded Coder provides accessor macros. Your code can use the macros, and access the fields they reference, via model.h.

If you are interfacing your code to a single model, you should refer to its rtM generically as model_M, and use the macros to access model_M, as in the following code fragment.

To interface your code to rtMs of more than one model, simply include the * headers for each model, as in the following code fragment.

Table 2-1 summarizes the rtM error status macros. To view other rtM related macros that are applicable to your specific model, generate code with a code generation report (See Generating a Code Generation Report); then view model.h via the hyperlink in the report.

Table 2-1: rtM Error Status Macros
Macro
Argument(s)
Return
Type

Description
rtmGetErrorStatus(rtm)
rtm: reference to real-time model struct
char *
Returns most recent error status string.
rtmSetErrorStatus(rtm,val)
rtm: reference to real-time model struct
val: C string
N/A
Set error status field of real-time model struct to the string val.


  Data Structures and Program Execution Code Modules