Use the Real-Time Model Data Structure
The code generator uses the real-time model (RT_MODEL) data structure. This structure is also referred to as thertModel
data structure. You can accessrtModel
data by using a set of macros analogous to thessSetxxx
andssGetxxx
宏S-functions用来访问SimStruct
data, including noninlined S-functions compiled by the code generator.
You need to use the set of macrosrtmGetxxx
andrtmSetxxx
to access the real-time model data structure. ThertModel
is an optimized data structure that replacesSimStruct
as the top level data structure for a model. ThertmGetxxx
andrtmSetxxx
macros are used in the generated code as well as from themain.c
ormain.cpp
module. If you are customizingmain.c
ormain.cpp
(either a static file or a generated file), you need to usertmGetxxx
andrtmSetxxx
instead of thessSetxxx
andssGetxxx
macros.
Usage ofrtmGetxxx
andrtmSetxxx
macros is the same as for thessSetxxx
andssGetxxx
versions, except that you replaceSimStruct S
by real-time model data structurertM
. The following table listsrtmGetxxx
andrtmSetxxx
macros that are used ingrt_main.c
andgrt_main.cpp
.
Macros for Accessing the Real-Time Model Data Structure
rtm Macro Syntax |
Description |
---|---|
|
Get the derivatives of block continuous states |
|
Return the pointer to vector that stores sample time offsets of the model associated with rtM |
|
Get the number of sample times that a block has |
|
Return a pointer to |
|
Return an external mode information data structure of the model (used internally for external mode) |
|
Return a data structure used by code generator logging (internal use only) |
|
Return a data structure of real-time model methods information (internal use only) |
|
返回的数据结构,其中包含解算器有限公司mation of the model (internal use only) |
|
Return a pointer to Sample Hit flag vector |
|
Get task sample time |
|
Get pointer to a task sample time |
|
Get pointer to a task ID |
|
Return simulation step type ID ( |
|
Return the fundamental step size of the model |
|
Get the current simulation time |
|
Set the time of the next sample hit |
|
Get the current time for the current task |
|
Get the simulation stop time |
|
Set the simulation stop time |
|
Return a data structure used by timing engine of the model (internal use only) |
|
Return a pointer to the current time |
|
Get the simulation start time |
|
Determine whether a task is continuous |
|
Determine whether the simulation is in a major step |
|
Determine whether the sample time is hit |
rtmGetErrorStatus(rtm) |
Get the current error status |
rtmSetErrorStatus(rtm,val) |
Set the current error status |
rtmGetErrorStatusPointer(rtm) |
Return a pointer to the current error status |
rtmGetStopRequested(rtm) |
Return whether a stop is requested |
rtmGetBlockIO(rtm) |
Get the block I/O data structure |
rtmSetBlockIO(rtm,val) |
Set the block I/O data structure |
rtmGetContStates(rtm) |
Get the continuous states data structure |
rtmSetContStates(rtm,val) |
Set the continuous states data structure |
rtmGetDefaultParam(rtm) |
Get the default parameters data structure |
rtmSetDefaultParam(rtm,val) |
Set the default parameters data structure |
rtmGetPrevZCSigState(rtm) |
Get the previous zero-crossing signal state data structure |
rtmSetPrevZCSigState(rtm,val) |
Set the previous zero-crossing signal state data structure |
rtmGetRootDWork(rtm) |
Get the DWork data structure |
rtmSetRootDWork(rtm,val) |
Set the DWork data structure |
rtmGetU(rtm) |
Get the root inputs data structure (when root inputs are passed as part of the model data structure) |
rtmSetU(rtm,val) |
Set the root inputs data structure (when root inputs are passed as part of the model data structure) |
rtmGetY(rtm) |
Get the root outputs data structure (when root outputs are passed as part of the model data structure) |
rtmSetY(rtm,val) |
Set the root outputs data structure (when root outputs are passed as part of the model data structure) |
For additional details on usage, seeSimStruct Macros and Functions Listed by Usage(Simulink).