Access Element-Specific C API Maps
Element-specific maps are structure arrays dedicated each for storing information about a distinct type of model elements such as model signals. Each entry within these arrays corresponds to a particular model element, acting as the gateway to obtain information about the element. These are the element-specific C API maps:
Root-level input port signals — Gateway to output signals of root-level input port blocks
Root-level output port signals — Gateway to input signals of root-level output port blocks
Inner model signals — Gateway to output signals of blocks that are not root-level input-port blocks
Model parameters — Gateway to parameters that are available to be used by the model, and that are used by at least one model element
Block parameters — Gateway to block parameters
Block states — Gateway to block states
Each entry contains:
Direct information such as the element name (as a field of type
char*
).Indirect information in the form of indices that reference entries in property-specific C API arrays. The referenced entries provide further information about the model element. For example, the data type of the element is provided as an index that references the data type map array. The referenced entry in the data type map array contains information about the data type of the element. To learn how to use those indices, see Access Property-Specific C API Arrays.
Some model elements belong to multiple types of C API elements and can therefore be accessed in multiple ways. For example, a signal line that connects a Gain block and an Outport block can be accessed as a model signal or as a root-level output port signal.
For exhaustive information about how to access element-specific C API information, see C Code Syntax for Accessing Element-Specific C API Arrays, which includes:
Access Model Signals Example
This is an example C language function that obtains initial information about model signals.
The example code is also provided as standalone code (see Standalone C Code for Accessing Model Signals Example) so that you can copy it more easily.
C Code for Accessing 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 signals information. |
|
|
Get the pointers to the main and the static C API maps. See Obtain Access to C API Maps Example. |
|
|
Extract the number of signals that are included in the generated C API code. |
|
|
Obtain the pointer to the signal structure array. |
|
|
Print the number of signals and their names. |
|
|
Here is a schematic illustration of the map structure that is accessed by the code in the example:
The model has two signals named mySig_1
and
mySig_1
.
Standalone C Code for Accessing Model Signals Example
C Code Syntax for Accessing Element-Specific C API Arrays
In these tables you can find exhaustive information about how to access element-specific C API arrays. Your code can access each type of model elements by using the direct approach, or by using get-function-like macros.
C Code for Accessing Signal C API Information
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
For each type of model signal, the signal count and the signal array. There are three main types of model signals:
|
|
|
Direct information about specific signals |
|
|
Indirect information about specific signals, provided as indices that reference entries in property-specific arrays. For more information about property-specific C API arrays, see Access Property-Specific C API Arrays. |
|
|
C Code for Accessing Model Parameters C API Information
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
Model parameters, which can be shared by multiple model blocks |
|
|
Direct information about specific parameters |
|
|
Indirect information about specific parameter, provided as indices that reference entries in property-specific arrays. For more information about property-specific C API arrays, see Access Property-Specific C API Arrays |
|
|
C Code for Accessing Block Parameters C API Information
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
Block parameters, used privately by specific model blocks |
|
|
Direct information about specific parameters |
|
|
Indirect information about specific parameter, provided as indices that reference entries in property-specific arrays. For more information about property-specific C API arrays, see Access Property-Specific C API Arrays. |
|
|
C Code for Accessing Block States C API Information
Required Item / Information | Code for Direct Data Structure Access | Code for Access Through Get-Function-Like Macros |
---|---|---|
Block states |
|
|
Direct information about specific states |
|
|
Indirect information about specific states, provided as indices that reference entries in property-specific arrays. For more information about property-specific C API arrays, see Access Property-Specific C API Arrays. |
|
|