主要内容

addValueType

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

自 R2022b 起

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

说明

dataType = addValueType(dictObj,dtName) 将具有指定名称的 Simulink.ValueType 添加到接口字典。

示例

dataType = addValueType(dictObj,dtName, SimulinkValueType=valueTypeObj) 将具有指定名称 dtName 的值类型(指定为 dataType)添加到接口字典,该值类型基于指定的 Simulink.ValueType valueTypeObj

示例

示例

全部折叠

要将具有指定名称的 Simulink.ValueType 添加到字典,请使用 addValueType 函数。有关显示相关函数工作流的更多信息的示例,请参阅创建和配置接口字典

% open interface dictionary
dictName = 'MyInterfaces.sldd';
dictAPI = Simulink.interface.dictionary.open(dictName);

% add an enumerated type to be used as data type of value type
myEnumType1 = addEnumType(dictAPI,'myColor');
myEnumType1.addEnumeral('RED', '0', 'Solid Red');
myEnumType1.addEnumeral('BLUE', '1', 'Solid Blue');
myEnumType1.StorageType = 'int16';

% add value type
myValueType1 = addValueType(dictAPI, 'myValueType1');
myValueType1.DataType = 'int32';
myValueType1.Dimensions = '[2 3]';
myValueType1.Description = 'I am a Simulink ValueType';
myValueType1.DataType = myEnumType1;

此示例将镜像现有 Simulink.ValueType 的值类型添加到 Simulink 接口字典 MyInterfaces.sldd

% open interface dictionary
dictName = 'MyInterfaces.sldd';
dictAPI = Simulink.interface.dictionary.open(dictName);

% create a Simulink value type 
simValueType = Simulink.ValueType;
simValueType.DataType = 'single';
simValueType.Min = 11;
simValueType.Max = 17;
simValueType.Dimensions = [2 4 3];
simValueType.Description = 'Simulink value type';

% add value type based on Simulink value type
myNewValueType1 = addValueType(dictAPI, 'MyNewValueType',...
   SimulinkValueType=simValueType)
myNewValueType1 = 
  ValueType with properties:
           Name: 'MyNewValueType'
       DataType: 'single'
        Minimum: '11'
        Maximum: '17'
           Unit: ''
     Complexity: 'real'
     Dimensions: '[2 4 3]'
    Description: 'Simulink value type'
          Owner: [1×1 Simulink.interface.Dictionary]

输入参数

全部折叠

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

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

示例: "airSpeed"

值类型对象,指定为 Simulink.ValueType 对象。

输出参量

全部折叠

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

版本历史记录

在 R2022b 中推出

全部折叠