C 服务接口
将模型元素和函数映射到在 Embedded Coder 字典中定义的服务接口
当从使用 C 服务代码接口配置的组件模型生成代码时,您需要将模型数据元素映射到服务接口。服务接口为目标平台服务所需的生成代码指定函数原型信息和数据通信方法(直接访问、执行期外或执行期间)。代码生成器在生成服务接口代码时应用约束,以便更轻松地集成代码以用于特定目标环境。可用于映射的服务接口列表由在链接到模型的共享 Embedded Coder 字典中定义的接口确定。如果字典默认服务接口符合您的目标平台服务要求,则您不需要进行映射更改,并且可以跳到生成和检查组件接口代码。
工具
代码映射编辑器 - 服务接口 | Associate model elements with code interface definitions |
对象
coder.mapping.api.CodeMapping | Model data and function interface configuration for C code generation |
函数
主题
配置基础
- Code Definition and Mapping Limitations and Considerations
Restrictions, constraints, and considerations that apply to code definitions and code mappings. - Manage Multiple Code Mappings for a Model
Design models that are platform-neutral and ready to deploy to different run-time environments. - How Generated Code Exchanges Data with an Environment
The generated code exchanges signal, state, and parameter data with the calling environment through a data interface.
可调用函数配置
- Periodic and Aperiodic Function Interfaces
Generate callable entry-point functions for the algorithm represented by a top model.
服务接口配置
- Service Interfaces
Generate C service interface code for components that interact with target environment resources. - Configure Sender and Receiver Service Interfaces for Model Inports and Outports
Configure sender and receiver service interfaces for model Inports and Outports. - Configure Data Transfer Service Interfaces for Data Transfer Signals
Configure data transfer service interfaces for signals representing data transfers between functions. - Configure Parameter and Parameter Argument Tuning Service Interfaces for Model Parameters and Model Parameter Arguments
Configure parameter and parameter argument tuning service interfaces for model parameters and model parameter arguments. - Configure Measurement Service Interfaces for Signals, States, and Data Stores
Configure measurement services for signals, states, and data stores. - Configure Timer Service Interfaces
Configure timer services for export functions.
数据访问和初始化
- Reuse Parameter Data in Different Data Type Contexts
Reuse parameter data by creating aSimulink.Parameter
object or numeric MATLAB® variable that you can use in different data type contexts. - Limitations for Block Parameter Tunability in Generated Code
Limitations can prevent a block parameter from appearing in the generated code as tunable, which means you cannot interact with the parameter value after compiling the code. - Access Signal, State, and Parameter Data During Execution
As you iteratively develop a model, capture output signal and state data that model execution generates. Tune parameter values during execution to observe results on the outputs. - 在仿真和代码执行期间在参数值集之间切换
通过将相同模块参数的独立值集存储在结构体数组中,在这些值集之间进行切换。 - Configure Packaging of Parameter Arguments in Generated Code
Customize the implementation of parameter arguments in generated code. - Control Signal and State Initialization in the Generated Code
Generate code that enables you to store tunable initial conditions in memory, for example, for modeling a system that shuts down and restarts. - Initialization of Signal, State, and Parameter Data in the Generated Code
To match the numerics of a simulation in Simulink®, the generated code assigns initial values to global data, especially for block states and parameters. - Compile Code Conditionally for All Values of Variant Parameters with Same and Different Dimensions
This example shows how to generate a C code that contains all the active and inactive values of variant parameters.