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:
model
.h
):
model_types
.h
):
model
.c
):
model
.h
):
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 rtM
s of more than one model, simply include the * headers for each model, as in the following code fragment.
#include "modelA
.h" /* Make model A entry points visible */ #include "modelB
.h" /* Make model B entry points visible */ void myHandWrittenFunction(void) { const char_T *errStatus; modelA_initialize(1); /* Call model A initializer */ modelB_initialize(1); /* Call model B initializer */ /* Refer to model A's rtM */ errStatus = rtmGetErrorStatus(modelA_M); /* Refer to model B's rtM */ errStatus = rtmGetErrorStatus(modelB_M); }
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.
![]() | Data Structures and Program Execution | Code Modules | ![]() |