Target Language Compiler | ![]() ![]() |
Object Information in the model.rtw File
During code generation, Real-Time Workshop writes information about signal and parameter objects to the model
.rtw
file. An Object
record is written for each parameter or signal that meets certain conditions. These conditions are described in Object Records For Parameters and Object Records For Signals.
The Object
records contain all of the information corresponding to the associated object. To access Object
records, you must write Target Language Compiler code (see Accessing Object Information via TLC).
Object Records For Parameters
An Object
record is included in the in the ModelParameters
section of the model
.rtw
file for each parameter, under the following conditions:
Simulink.Parameter
object (or to a parameter object that comes from a class derived from the Simulink.Parameter
class).
The following is an example of an Object
record for a parameter.
ModelParameters { ... Parameter { Identifier Kp Tunable yes ... Value [5.0] Dimensions [1, 1] HasObject 1 Object { Package Simulink Class Parameter ObjectProperties { RTWInfo { Object { Package Simulink Class RTWInfo ObjectProperties { StorageClass "SimulinkGlobal" } } } Value 5.0 ... } } } }
Object Records For Signals
An Object
record is included in the BlockOutputs
section of the model
.rtw
file for each signal which meets the following conditions:
Simulink.Signal
object (or to an object that comes from a class derived from the Simulink.Signal
class).
Note If the signal is configured to be an unstructured global variable in the generated code, its validity and uniqueness are enforced and its symbol is always preserved. |
The following is an example of an Object
record for a signal:
BlockOutputs { ... BlockOutput { Identifier SinSig ... SigLabel "SinSig" HasObject 1 Object { Package Simulink Class Signal ObjectProperties { RTWInfo { Object { Package Simulink Class RTWInfo ObjectProperties { StorageClass "SimulinkGlobal" } } } ... } } }
Accessing Object Information via TLC
This section provides sample code to illustrate how to access object information from the model
.rtw
file using TLC code. For more information on TLC and the model
.rtw
file, see model.rtw.
Accessing Parameter Object Records. The following code fragment iterates over the ModelParameters section of the model
.rtw
file and extracts information from any parameter Object records encountered.
%with CompiledModel.ModelParameters %foreach modelParamIdx = NumParameters %assign thisModelParam = Parameter[modelParamIdx] %assign paramName = thisModelParam.Identifier %if EXISTS("thisModelParam.Object.ObjectProperties") %with thisModelParam.Object.ObjectProperties %assign valueInObject = Value %with RTWInfo.Object.ObjectProperties %assign storageClassInObject = StorageClass %endwith %% *********************************** %% Access user-defined properties here %% *********************************** %if EXISTS("MY_PROPERTY_NAME") %assign userDefinedPropertyName = MY_PROPERTY_NAME %endif %% *********************************** %endwith %endif %endforeach %endwith
Accessing Signal Object Records. The following code fragment iterates over the BlockOutputs section of the model
.rtw
file and extracts information from any signal Object records encountered.
%with CompiledModel.BlockOutputs %foreach blockOutputIdx = NumBlockOutputs %assign thisBlockOutput = BlockOutput[blockOutputIdx] %assign signalName = thisBlockOutput.Identifier %if EXISTS("thisBlockOutput.Object.ObjectProperties") %with thisBlockOutput.Object.ObjectProperties %with RTWInfo.Object.ObjectProperties %assign storageClassInObject = StorageClass %endwith \ %% ***********************************\ %% Access user-defined properties here\ %% *********************************** %if EXISTS("MY_PROPERTY_NAME") %assign userDefinedPropertyName = MY_PROPERTY_NAME %endif %% *********************************** %endwith %endif %endforeach %endwith
![]() | Using Scopes in the model.rtw File | Using Library Functions to Access model.rtw Contents | ![]() |