Main Content

addValueType

Add value type to Simulink interface dictionary

Since R2022b

In R2023b the Architectural Data section of data dictionaries was introduced. When managing interfaces, data types, constants, and software address methods consider using the Simulink.dictionary.ArchitecturalData programmatic interfaces instead. For more information, see Programmatically Manage AUTOSAR Architectural Data.

Description

dataType = addValueType(dictObj,dtName) adds a Simulink.ValueType with the specified name to the interface dictionary.

example

dataType = addValueType(dictObj,dtName, SimulinkValueType=valueTypeObj) adds a value type, specified as dataType, with the specified name, dtName, based on the specified Simulink.ValueType valueTypeObj to the interface dictionary.

example

Examples

collapse all

To add a Simulink.ValueType with the specified name to the dictionary, use the addValueType function. For an example that shows more of the workflow for related functions, see Create and Configure Interface Dictionary.

% 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;

This example adds a value type that mirrors an existing Simulink.ValueType to the Simulink interface dictionary, 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]

Input Arguments

collapse all

Interface dictionary, specified as a Simulink.interface.Dictionary object. Before you use this function, create or open dictObj by using Simulink.interface.dictionary.create or Simulink.interface.dictionary.open.

DataType definition name in DataTypes property array of dictObj, specified as a character vector or a string scalar.

Example: "airSpeed"

Value type object, specified as a Simulink.ValueType object.

Output Arguments

collapse all

Value type object, returned as Simulink.interface.dictionary.ValueType object.

Version History

Introduced in R2022b

collapse all

R2023b: Simulink.interface.Dictionary object replaced by Simulink.dictionary.ArchitecturalData object

Starting in R2023b, use the Simulink.dictionary.ArchitecturalData object to programmatically manage architectural data instead of the Simulink.interface.Dictionary object.