Write External Code to Access Generated C API Code
Once you configure your model to include C API elements in the generated code, you can write code to access and use these generated code elements. To access C API elements in the generated code, your code uses a multi-tier, interconnected, structured mapping system through which it navigates to obtain metadata and real-time information about model elements it needs to interact with. Real-time information includes computer memory addresses that hold element values. By accessing memory addresses, your code can measure and tune model elements while the generated model code is running on the target platform.
Note
The C API layer is an extension of the generated code, so model elements that are optimized away cannot exist in the generated C API code.
Your code can access C API elements in one of two equivalent ways, or through a combination of the two:
Directly access C API data structures.
Use predefined get-functions and macros that look and behave like get-functions.
This table summarizes how to access the generated C API code layer and to write code that can interact with it.
Gateway to | Description | Entities | Topic |
---|---|---|---|
Generated C API code layer | Structure containers through which you access C API elements |
| Access C API Model Maps |
Information about model elements | Element-specific structure arrays that store information about distinct types of model elements, such as model signals |
| Access Element-Specific C API Maps |
Information about properties of model elements | Property-specific arrays that catalog and store information about generic properties, such as the data type property |
| Access Property-Specific C API Arrays |
Real-time information of model elements | Real-time values of model elements | Data map array that contains real-time values of model elements | Access Real-time C API Information |
Real-time information of model elements in multiple coexisting model instances | Real-time values of multi-instance model elements | Main C API model map array of child models | Access Multiple Model Instance C API Information |