Documentation

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 thertModeldata structure. You can accessrtModeldata by using a set of macros analogous to thessSetxxxandssGetxxx宏S-functions用来访问SimStructdata, including noninlined S-functions compiled by the code generator.

You need to use the set of macrosrtmGetxxxandrtmSetxxxto access the real-time model data structure. ThertModelis an optimized data structure that replacesSimStructas the top level data structure for a model. ThertmGetxxxandrtmSetxxxmacros are used in the generated code as well as from themain.cormain.cppmodule. If you are customizingmain.cormain.cpp(either a static file or a generated file), you need to usertmGetxxxandrtmSetxxxinstead of thessSetxxxandssGetxxxmacros.

Usage ofrtmGetxxxandrtmSetxxxmacros is the same as for thessSetxxxandssGetxxxversions, except that you replaceSimStruct Sby real-time model data structurertM. The following table listsrtmGetxxxandrtmSetxxxmacros that are used ingrt_main.candgrt_main.cpp.

Macros for Accessing the Real-Time Model Data Structure

rtm Macro Syntax

Description

rtmGetdX(rtm)

Get the derivatives of block continuous states

rtmGetOffsetTimePtr(RT_MDL rtM)

Return the pointer to vector that stores sample time offsets of the model associated with rtM

rtmGetNumSampleTimes(RT_MDL rtM)

Get the number of sample times that a block has

rtmGetPerTaskSampleHitsPtr(RT_MDL)

Return a pointer toNumSampleTime×NumSampleTimematrix

rtmGetRTWExtModeInfo(RT_MDL rtM)

Return an external mode information data structure of the model (used internally for external mode)

rtmGetRTWLogInfo(RT_MDL)

Return a data structure used by code generator logging (internal use only)

rtmGetRTWRTModelMethodsInfo(RT_MDL)

Return a data structure of real-time model methods information (internal use only)

rtmGetRTWSolverInfo(RT_MDL)

返回的数据结构,其中包含解算器有限公司mation of the model (internal use only)

rtmGetSampleHitPtr(RT_MDL)

Return a pointer to Sample Hit flag vector

rtmGetSampleTime(RT_MDL rtM, int TID)

Get task sample time

rtmGetSampleTimePtr(RT_MDL rtM)

Get pointer to a task sample time

rtmGetSampleTimeTaskIDPtr(RT_MDL rtM)

Get pointer to a task ID

rtmGetSimTimeStep(RT_MDL)

Return simulation step type ID (MINOR_TIME_STEP,MAJOR_TIME_STEP)

rtmGetStepSize(RT_MDL)

Return the fundamental step size of the model

rtmGetT(RT_MDL,t)

Get the current simulation time

rtmSetT(RT_MDL,t)

Set the time of the next sample hit

rtmGetTaskTime(RT_MDL,tid)

Get the current time for the current task

rtmGetTFinal(RT_MDL)

Get the simulation stop time

rtmSetTFinal(RT_MDL,finalT)

Set the simulation stop time

rtmGetTimingData(RT_MDL)

Return a data structure used by timing engine of the model (internal use only)

rtmGetTPtr(RT_MDL)

Return a pointer to the current time

rtmGetTStart(RT_MDL)

Get the simulation start time

rtmIsContinuousTask(rtm)

Determine whether a task is continuous

rtmIsMajorTimeStep(rtm)

Determine whether the simulation is in a major step

rtmIsSampleHit(RT_MDL,tid)

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).

Related Topics

Was this topic helpful?