Main Content

数据接口和函数接口

将模型数据元素和函数映射到代码定义

为了遵守代码标准和规范,并配置模型数据元素的表示和代码生成的入口函数,请将模型数据元素和函数映射到预定义的代码定义。

有关介绍,请参阅C Data Code Interface Configuration for Model Interface Elements

工具

代码映射编辑器将模型元素与代码接口定义相关联 (自 R2020b 起)

对象

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

函数

全部展开

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 (自 R2020b 起)
coder.mapping.utils.createCreate code mappings object for configuring data and function interface for C and C++ code generation (自 R2020b 起)
findGet model elements for the category of model code mappings (自 R2020b 起)

默认配置

getDataDefaultGet default storage class or storage class property setting for model data category (自 R2020b 起)
setDataDefaultSet default storage class and storage class property values for model data category (自 R2020b 起)

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

getInportGet code and calibration configuration from code mappings for root-level inport (自 R2020b 起)
getOutportGet code and calibration configuration from code mappings for root-level outport (自 R2020b 起)
setInportConfigure root-level inports for code and calibration file (a2l) generation (自 R2020b 起)
setOutportConfigure root-level outport for code and calibration file (a2l) generation (自 R2020b 起)

参数配置

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

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

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

主题

配置基础

数据配置

函数配置

数据访问和初始化

精选示例