主要内容

addNumericType

将 Simulink 数值类型添加到 Simulink 接口字典

自 R2023a 起

在 R2023b 中,引入了数据字典的“架构数据”部分。当管理接口、数据类型、常量和软件寻址方法时,请考虑改用 Simulink.dictionary.ArchitecturalData 编程接口。有关详细信息,请参阅Programmatically Manage AUTOSAR Architectural Data

说明

dataType = addNumericType(dictObj,dtName) 将具有指定名称的 Simulink.NumericType 添加到字典。

示例

dataType = addNumericType(dictObj,dtName,SimulinkNumericType=numericTypeObj) 将具有指定名称且与指定 Simulink.NumericType 对象 numericTypeObj 具有相同属性值的 Simulink.NumericType 添加到字典。

.

示例

示例

全部折叠

要将具有指定名称的 Simulink.NumericType 添加到字典,请使用 addNumericType 函数。

dictAPI = Simulink.interface.dictionary.open('MyInterfaces.sldd');
myNumericType = addNumericType(dictAPI,'myNumericType1')
myNumericType = 

  NumericType with properties:

                Name: 'myNumericType1'
        DataTypeMode: 'Double'
    DataTypeOverride: 'Inherit'
             IsAlias: 0
         Description: ''
               Owner: [1×1 Simulink.interface.Dictionary]

要将与现有 Simulink.NumericType 具有相同属性值的 Simulink.NumericType 添加到字典,请使用具有 SimulinkNumericType 参数的 addNumericType 函数。

exampleNumericTypeObj = Simulink.NumericType;
exampleNumericTypeObj.DataTypeMode = 'Single';
exampleNumericTypeObj.Description = 'This is my example numeric type';

dictAPI = Simulink.interface.dictionary.open('MyInterfaces.sldd');
myNumericType2 = addNumericType(dictAPI,'myNumericType2',...
   SimulinkNumericType=exampleNumericTypeObj)
myNumericType2 = 

  NumericType with properties:

                Name: 'myNumericType2'
        DataTypeMode: 'Single'
    DataTypeOverride: 'Inherit'
             IsAlias: 0
         Description: 'This is my example numeric type'
               Owner: [1×1 Simulink.interface.Dictionary]

输入参数

全部折叠

接口字典,指定为 Simulink.interface.Dictionary 对象。在使用此函数之前,请使用 Simulink.interface.dictionary.createSimulink.interface.dictionary.open 创建或打开 dictObj

dictObjDataTypes 属性数组中的 DataType 定义名称,指定为字符向量或字符串标量。

示例: "airSpeed"

Simulink 数值类型,指定为先前定义的 Simulink.NumericType 对象。

示例: SimulinkNumericType=exampleSimulinkNumericTypeObj

输出参量

全部折叠

数值类型,以 Simulink.interface.dictionary.NumericType 对象形式返回。

版本历史记录

在 R2023a 中推出

全部折叠