Data Object Information in model
.rtw
File
model
.rtwYou can obtain meta information about the generated code by accessing the
file in the build folder.model
.rtw
During the build process, the code generator writes information about Simulink® signal and parameter data objects to the
file. An model
.rtwObject
record with CoderInfo
property information 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 the information corresponding to the
associated data object. To access Object
records, you must write Target
Language Compiler code (see Access Data Object Information by Using Target Language Compiler (TLC) Code).
For some data, defining storage classes can be helpful. For more information, see Finely Control Data Representation by Writing TLC Code for a Storage Class. Embedded Coder® is required.
Note
These Object
record examples are generated from the example model
ConfigurationRapidPrototypingInterface
. The parameters and signals are
individually configured by using the ExportedGlobal
storage class.
Object Records for Parameters
An Object
record that has CoderInfo
property
information is included in the ModelParameters
section of the
file for each parameter that
meets these conditions:model
.rtw
The parameter resolves to a
Simulink.Parameter
data object or to a parameter data object that comes from a class derived from theSimulink.Parameter
class.The parameter symbol is preserved in the generated code. The symbol is preserved when the
CoderInfo.StorageClass
property of the data object is not set toAuto
or if you set the storage class on the individual parameter by using the Code Mappings editors or thecoder.mapping.api.CodeMapping
object.
This example shows part of an Object
record for a parameter.
ModelParameters { NumParameters 10 ... Parameter { Identifier "K1" LogicalSrc P7 WorkspaceVarName "K1" Protected no Tunable yes StorageClass "ExportedGlobal" Value [2] OriginalDataTypeIdx 2 CGTypeIdx 36 ContainerCGTypeIdx 42 IsPublic 1 ReferencedBy Matrix(1,4) [[1, 0, 4, 2];] GraphicalRef Matrix(1,2) [[0, 10];] GraphicalSource [-1, -1] OwnerSysIdx [1, -1] HasObject 1 Object { Package Simulink Class Parameter ObjectProperties { Value 2.0 CoderInfo { Object { Package Simulink Class CoderInfo ObjectProperties { HasCoderInfo 1 StorageClass "ExportedGlobal" TypeQualifier "" Alias "" Alignment -1 IsCSCPackageOverridden 0 CSCPackageName "Simulink" ParameterOrSignal "Parameter" CustomStorageClass "Default" CustomAttributes { Object { Package SimulinkCSC Class AttribClass_Simulink_Default ObjectProperties { } } } } } } ... }
Object Records for Signals
An Object
record that has CoderInfo
property
information is included in either the ExternalOutputs
,
ExternalInputs
, or BlockOutputs
section of the
file for each signal (including
root-level Inport and Outport blocks) whose symbol is
preserved in the generated code. The symbol is preserved when the signal uses a storage
class other than model
.rtwAuto
and is individually mapped.
An Object
record that has CoderInfo
property
information is included in the
file
for each signal that preserves the signal symbol in the generated code and meets these conditions:model
.rtw
The
CoderInfo.StorageClass
property of the data object is not set toAuto
.The data object is individually mapped to a predefined storage class by using the Code Mappings editor or the
coder.mapping.api.CodeMapping
object.
If you configure the signal to be an unstructured global variable in the generated code, its validity and uniqueness are enforced and its symbol is preserved.
This example shows part of an Object
record for a root-level
Outport block.
ExternalOutputs { ... NumExternalOutputs 1 ... ExternalOutput { ArgSrc Y0 Block [1,3] BlockName "<Root>/Out1" GrSrc [0, 4] Identifier "output" StorageClass "ExportedGlobal" HasObject 1 Object { Package Simulink Class Signal ObjectProperties { CoderInfo { Object { Package Simulink Class CoderInfo ObjectProperties { HasCoderInfo 1 StorageClass "ExportedGlobal" TypeQualifier "" Alias "output" Alignment -1 IsCSCPackageOverridden 0 CSCPackageName "Simulink" ParameterOrSignal "Signal" CustomStorageClass "Default" CustomAttributes { Object { Package SimulinkCSC Class AttribClass_Simulink_Default ObjectProperties { } } } } } } ... }
Access Data Object Information by Using Target Language Compiler (TLC) Code
Here, sample code shows how to access data object information from the
file by using TLC code.model
.rtw
Access Parameter Object Records
This code fragment iterates over Parameter
structures in the
ModelParameters
section of the
file. The code extracts
information from parameter model
.rtwObject
records.
%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 CoderInfo.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
Access Signal Object Records
This code fragment iterates over ExternalBlockOutput
structures in
the BlockOutputs
section of the
file. The code extracts
information from signal model
.rtwObject
records.
%with CompiledModel.BlockOutputs %foreach blockOutputIdx = NumExternalBlockOutputs %assign thisBlockOutput = ExternalBlockOutput[blockOutputIdx] %assign signalName = thisBlockOutput.Identifier %if EXISTS("thisBlockOutput.Object.ObjectProperties") %with thisBlockOutput.Object.ObjectProperties %with CoderInfo.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