Access Property-Specific C API Arrays
Property-specific maps are structure arrays and primitive-type arrays dedicated each to catalog and store information about a generic property, unrelated to specific elements, such as the data type property. These are the property specific-maps:
dataTypeMap
— Gateway to obtaining information about model elements data typefixPtMap
— Gateway to obtaining information about fixed-point information about model elementselementMap
— Gateway to obtaining information about Simulink® bus structuressampleTimeMap
— Gateway to the sample time of model elementsdimensionMap
— Gateway to obtaining the number of dimensions of model elements dimensionsdimensionArray
— Integer array that contains the actual dimensions of model elementsdataAddrMap
— Pointer array that contains computer memory addresses with the real-time value of model elements
Each entry in these arrays corresponds to a specific value of the property
it represents, without being directly associated with any specific model element. For
example, a single entry in the dataTypeMap
array is reserved for
describing the double
data type without being associated with any
specific model element among those defined as double
. Your code uses
indices it previously obtained to reference entries in these property-specific arrays to
obtain further information about the property it is currently investigating. For example,
if your code needs to access information about the data type of the model parameter
myParam
, your code:
Finds the entry in the model parameters map array that corresponds to
myParam
.Gets the value of the
dataTypeIndex
field from within the entry.Uses the value as an index to reference the
dataTypeMap
map array. The referenced entry corresponds to the data type ofmyParam
. This entry also corresponds to all other model elements that have the same data type asmyParam
.Gets the necessary information about the data type of
myParam
, such as the name of the data type and how many bytes of memory it uses.
Print Data Type Names of Model Signals Example
This example uses the C API signal array to access the data type property array and prints the data type names of the model signals. The example code is also provided as standalone code (see Standalone C Code for Printing Data Type Names of Model Signals Example) so that you can copy it more easily.
C Code for Printing Data Type Names of Model Signals Example
Description | Sample C Code with Direct Data Structure Access | Sample C Code with Macros and Get-Functions |
---|---|---|
Include these header files:
|
|
|
Declare variables to use for storing the map objects and the signal information. |
|
|
Get the pointers to the C API model maps (see Obtain Access to C API Maps Example for more details). Then extract the number of signals that are included in the generated C API code, and get the pointer to the signal structure array. |
|
|
Get a pointer to the data type map array. |
|
|
Print the number of signals in the model and an introductory
announcement about their types. Then start a
for -loop to go over the signals. |
|
|
For each signal, get the index that references into the data type map array. |
|
|
Use the index to access the corresponding entry in the data type array and print the name of the data type. |
|
|
Here is a schematic illustration of the map structure that is accessed by the code in the example:
The names of the signal data types are unsigned
int
and double
.
Standalone C Code for Printing Data Type Names of Model Signals Example
Print Dimensions of Model Signals Example
This example uses the C API signal array and the dimensionMap
array to access the dimensionArray
and print the actual dimensions of
the model signals.
The example code is also provided as standalone code (see Standalone C Code for Printing Dimensions of Model Signals Example) so that you can copy it more easily.
C Code for Printing Dimensions of Model Signals Example
Description | Sample C Code with Direct Data Structure Access | Sample C Code with Macros and Get-Functions |
---|---|---|
Include these header files:
|
|
|
Declare variables to use for storing the map objects and the signal information. |
|
|
Get the pointers to the C API model maps (see Obtain Access to C API Maps Example for more details). Then extract the number of signals that are included in the generated C API code and obtain the pointer to the signal structure array. |
|
|
Get the pointers to:
|
|
|
Print the number of signals in the model and an introductory
announcement about their dimensions. Then start a
for -loop to go over the signals. |
|
|
For each signal, get the index that references into the dimension map array. |
|
|
Use the index to access the corresponding entry in the dimension map and get the number of dimensions and the index to the dimensions array. |
|
|
Use dimCount and the index to access the
corresponding entries in the dimension array, and then get the actual
dimensions of the signal, and print them. |
|
|
In this example, your code determines that mySig_1
is a variable with dimensions 7-by-2, and mySig_2
is a variable
with dimensions 4-by-5-by-3.
Here is a schematic illustration of the map structure that is accessed by the code in the example:
Standalone C Code for Printing Dimensions of Model Signals Example
C Code Syntax for Accessing Property-Specific C API Arrays
In these tables you can find exhaustive information about how to access property-specific C API arrays. Your code can access each type of property by using the direct approach, or by using get-function-like macros.
C Code for Accessing Data Type C API Information
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
C API model maps |
|
|
Data type map array |
|
|
Direct information about specific data types |
|
|
Indirect information about specific data types, provided as an index that references the C API element map array. For more information about the C API element map, see C Code for Accessing C API Simulink Bus Structure Information (Element Map). |
|
|
C Code for Accessing Fixed-Point C API Information
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
C API model maps |
|
|
Fixed-point map array |
|
|
Direct information about specific fixed-point configurations that are used by model elements |
|
|
To learn more about fixed-point specifications in Simulink, see C Code for Accessing C API Simulink Bus Structure Information (Element Map).
C Code for Accessing Sample Time C API Information
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
C API model maps |
|
|
Sample time map array |
|
|
Direct information about specific sample time configurations that are used by model elements |
|
|
C Code for Accessing C API Simulink Bus Structure Information (Element Map)
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
C API model maps |
|
|
Element map array |
|
|
Direct information about specific bus structures in the model |
|
|
Indirect information about specific bus structures in the model, provided as indices that reference other C API map arrays. For more information about these C API maps, see:
|
|
|
C Code for Obtaining Element Dimensions Through C API
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
C API model maps |
|
|
Dimension map array |
|
|
Direct information about specific dimension configuration used by at least one model element |
Dimension Orientation Enumeration
|
|
Indirect information about the specific dimension configuration, provided as an index into the (primitive type) C API dimension array |
|
|