Main Content

C 服务接口

将模型元素和函数映射到在 Embedded Coder 字典中定义的服务接口
自 R2022b 起

当从使用 C 服务代码接口配置的组件模型生成代码时,您需要将模型数据元素映射到服务接口。服务接口为目标平台服务所需的生成代码指定函数原型信息和数据通信方法(直接访问、执行期外或执行期间)。代码生成器在生成服务接口代码时应用约束,以便更轻松地集成代码以用于特定目标环境。可用于映射的服务接口列表由在连接到模型的共享 Embedded Coder 字典中定义的接口确定。如果字典默认服务接口符合您的目标平台服务要求,则您不需要进行映射更改,并且可以跳到生成和检查组件接口代码。

工具

代码映射编辑器 - 服务接口Associate model elements with code interface definitions

对象

coder.mapping.api.CodeMapping用于 C 代码生成的模型数据和函数接口配置

函数

全部展开

model_initializeGenerated C/C++ entry-point function that contains initialization code for a Simulink model
model_resetGenerated C/C++ entry-point function that contains reset code for a Simulink model
model_stepGenerated C/C++ entry-point function that contains execution code for each step in a Simulink model
model_terminateGenerated C/C++ entry-point function that contains termination code for a Simulink model

创建和查找代码映射

coder.mapping.api.getGet code mappings for model
coder.mapping.utils.createCreate code mappings object for configuring data and function interface for C and C++ code generation
findGet model elements for the category of model code mappings

函数配置

getFunctionGet code configuration from code mappings for model function
setFunctionSet coder mapping information for model function

根级输入端口和输出端口配置

getInportGet code and calibration configuration from code mappings for root-level inport
getOutportGet code and calibration configuration from code mappings for root-level outport
getDeploymentTypeGet deployment type of model
setInportConfigure root-level inports for code and calibration file (a2l) generation
setOutportConfigure root-level outport for code and calibration file (a2l) generation
setDeploymentTypeSet deployment type of model

参数配置

getModelParameterGet code and calibration configuration from code mappings for model parameters
setModelParameterConfigure model parameter for code and calibration file (a2l) generation

信号、状态和数据存储配置

addSignalAdd block output signal to model code mappings
getDataStoreGet code and calibration configuration from code mappings for local or shared local data store
getSignalGet code and calibration configuration from code mappings for block output signal
getStateGet code and calibration configuration from code mappings for block state
removeSignalRemove block output signal from model code mappings
setDataStoreConfigure local or shared local data store for code and calibration file (a2l) generation
setSignalConfigure block signal data for code and calibration file (a2l) generation
setStateConfigure block states for code and calibration file (a2l) generation

数据传输配置

getDataTransferGet code configuration from code mappings for signal representing data transfer
setDataTransferSet code configuration in code mappings for signal representing data transfer

主题

配置基础

可调用函数配置

服务接口配置

数据访问和初始化

相关信息