Main Content

addStructType

Add structure type represented by Simulink.Bus in 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 = addStructType(dictObj,dtName) adds a Simulink.Bus type with the specified name to the dictionary.

example

dataType = addStructType(dictObj,dtName, SimulinkBus=busObj) adds a structure type with the specified name, dtName, that mirrors the specified Simulink.Bus object, busObj, to the dictionary.

example

Examples

collapse all

To add a Simulink.Bus type with the specified name to the dictionary, use the addStructType 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
myEnumType1 = addEnumType(dictAPI,'myColor');
myEnumType1.addEnumeral('RED', '0', 'Solid Red');
myEnumType1.addEnumeral('BLUE', '1', 'Solid Blue');
myEnumType1.StorageType = 'int16';

% add a value type that uses the enum type as its data type
myValueType1 = addValueType(dictAPI, 'myValueType1');
myValueType1.DataType = 'int32';
myValueType1.Dimensions = '[2 3]';
myValueType1.DataType = myEnumType1;

%% add a structured type 
myStructType1 = addStructType(dictAPI, 'myStructType1');
structElement1 = myStructType1.addElement('Element1');
structElement1.Type.DataType = 'single';
structElement1.Type.Dimensions = '3';
structElement2 = myStructType1.addElement('Element2');
structElement2.Type = myValueType1;
% or
structElement2.Type = 'ValueType: myValueType1';

This example adds a StructType type that mirrors an existing Simulink.Bus object to the Simulink interface dictionary, MyInterfaces.sldd.

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

% create Simulink.Bus object and add elements
simBusObj = Simulink.Bus;
busElement1 = Simulink.BusElement;
busElement1.Name = 'MyBusElement1';
busElement1.DataType = 'single';
simBusObj.Elements(1) = busElement1;
busElement2 = Simulink.BusElement;
busElement2.Name = 'MyBusElement2';
simBusObj.Elements(2) = busElement2;

% add structure type based on simBusObj
myNewStructType = addStructType(dictAPI,'StructFromSimBus',SimulinkBus=simBusObj)
myNewStructType = 
  StructType with properties:
           Name: 'StructFromSimBus'
    Description: ''
       Elements: [1×2 Simulink.interface.dictionary.StructElement]
          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"

Bus type object, specified as a Simulink.Bus object.

Output Arguments

collapse all

Structure type object, returned as Simulink.interface.dictionary.StructType object containing elements, with Simulink.Bus as the underlying implementation.

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.