Manage Shared Interfaces and Data Types for AUTOSAR Architecture Models
Interface dictionaries enable interfaces, data types, and AUTOSAR-specific design data to be authored, managed, and shared between AUTOSAR components and compositions modeled in Simulink®. Interface dictionaries provide scalability for system-level and multicomponent designs by containing these shared elements in a central location.
You can programmatically or graphically configure the attributes and contents of an interface dictionary and apply them to an architecture model using this basic workflow:
Create an interface dictionary.
Design interface and data types with the interface dictionary API or the standalone Interface Editor.
Link the interface dictionary to an architecture model.
Apply the interfaces to the architecture model in the Simulink environment.
Deploy the interface dictionary shared interface and data type content in the final application.
To migrate data stored in the base workspace or in a data dictionary hierarchy to the
interface dictionary associated with an architecture model, use the interface dictionary
Migrator
object.
Create Interface Dictionary
To create an interface dictionary programmatically, use the Simulink.interface.dictionary.create
function.
% create new interface dictionary dictName = 'MyInterfaces.sldd'; dictAPI = Simulink.interface.dictionary.create(dictName);
Alternatively, to create an interface dictionary from the AUTOSAR architecture model toolstrip, on the Modeling tab, open the Design menu and select New Interface Dictionary from the Interfaces and Types section.
Design Data Types and Interfaces by Using Interface Dictionary
Once you create your interface dictionary, you can add design data programmatically by using the interface dictionary API or interactively by using the standalone Interface Editor. These tools allow you to author shared elements outside of the context of a particular component or composition and allow multiple team members to share in the definition and management of these elements.
Add Design Data Programmatically
To programmatically create, configure, and manage interfaces and data types in
your interface dictionary, use the functions for the Simulink.interface.Dictionary
object.
Here, use type-specific functions to add alias types, numeric types, value types, structured types, and enumerations to the interface dictionary.
% add DataTypes %% AliasTypes myAliasType1 = dictAPI.addAliasType('aliasType', BaseType='single'); myAliasType1.Name = 'myAliasType1'; myAliasType1.BaseType = 'fixdt(1,32,16)'; myAliasType2 = dictAPI.addAliasType('myAliasType2'); % can also use interface dict type objs myAliasType2.BaseType = myAliasType1; %% EnumType myEnumType1 = dictAPI.addEnumType('myColor'); myEnumType1.addEnumeral('RED', '0', 'RED BLOOD'); myEnumType1.addEnumeral('BLUE', '1', 'Blue Skies'); myEnumType1.DefaultValue = 'BLUE'; myEnumType1.Description = 'I am a Simulink Enumeration'; myEnumType1.StorageType = 'int16'; % set base type of an alias type to be this enum object myAliasType3 = dictAPI.addAliasType('myAliasType3'); myAliasType3.BaseType = myEnumType1; %% NumericType myNumericType1 = addNumericType(dictAPI, 'myNumericType1'); myNumericType1.DataTypeMode = "Single"; %% ValueType myValueType1 = dictAPI.addValueType('myValueType1'); myValueType1.DataType = 'int32'; myValueType1.Dimensions = '[2 3]'; myValueType1.Description = 'I am a Simulink ValueType'; myValueType1.DataType = myEnumType1; % can also use interface dict type objs %% StructType myStructType1 = dictAPI.addStructType('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'; %% Nested StructType myStructType2 = dictAPI.addStructType('myStructType2'); myStructType2.Description = 'I am a nested structure'; structElement = myStructType2.addElement('Element'); structElement.Dimensions = '5'; structElement.Type = myStructType1; % or structElement.Type = 'Bus: myStructType1';
Add communication interfaces and their data elements.
nvInterface1 = dictAPI.addDataInterface('NV1'); dataElm1 = nvInterface1.addElement('DE1'); dataElm1.Type = myValueType1; dataElm2 = nvInterface1.addElement('DE2'); dataElm2.Type = myStructType2; dataElm2.Dimensions = '4'; dataElm2.Description = 'I am a data element with datatype = array of struct type'; % data element with owned type dataElm3 = nvInterface1.addElement('DE3'); dataElm3.Type.DataType = 'single'; dataElm3.Type.Dimensions = '10'; dataElm3.Type.Minimum = '-5'; srInterface2 = dictAPI.addDataInterface('SR1');
Then, create, configure, and manage platform-specific properties.
% now add AUTOSARClassic mapping platformMapping = dictAPI.addPlatformMapping('AUTOSARClassic'); % set platform properties platformMapping.setPlatformProperty(nvInterface1,... 'Package', '/Interface2', 'InterfaceKind', 'NvDataInterface'); % get the platform properties [pNames, pValues] = platformMapping.getPlatformProperties(nvInterface1); % managing AUTOSAR Classic platform related elements (these don't have mapping to Simulink) arObj = autosar.api.getAUTOSARProperties(dictName); arObj.addPackageableElement('SwAddrMethod','/SwAddressMethods', 'VAR1', 'SectionType', 'Var'); platformMapping.setPlatformProperty(dataElm1,... 'SwAddrMethod', 'VAR1', 'SwCalibrationAccess', 'ReadWrite', 'DisplayFormat', '%.3f');
Add Design Data Using Standalone Editor
Alternatively, you can add design data by using the standalone Interface Editor. To open the editor from outside of the context of a model:
Double-click the
.sldd
file from the MATLAB® Current Folder browser.Use the
show
function of the interface dictionary object.Enter
interfaceeditor
at the MATLAB command prompt.
To open the standalone editor from a model:
In the Simulink editor of an AUTOSAR architecture model, on the Modeling tab, open the Design menu and select Edit Interface Dictionary.
In the Model Explorer, under the External Data node for the model, select the interface dictionary, then click Open Interface Editor from the Dialog pane.
With the standalone Interface Editor, you can create, configure, and manage design data.
Create — On the toolstrip, in the Create section, add data type definitions and interfaces. Data types and interfaces each have a dedicated tab for data management.
Configure — In the right panel, use the Details pane to configure your data. The Details pane can also display platform-specific properties. For example, when you set the deployment platform to AUTOSAR Classic, Details displays AUTOSAR interface communication properties such as InterfaceKind, IsService, and Package. Setting these properties under Details sets them in the generated interface dictionary
.sldd
file.Manage — You can filter, sort, and search data on the Interfaces and Data Types tabs.
In addition to the Interfaces and Data Types tabs, the Interface Editor displays platform-specific software address method data for the AUTOSAR Classic Platform in the SwAddrMethods tab.
For more information on using the standalone editor, see Interface Editor.
Link Interface Dictionary to Architecture Model
Once you have a saved interface dictionary, you can link it to your architecture model. Link a dictionary to a model programmatically as follows.
% open a previously defined interface dictionary dictName = 'MyInterfaces.sldd'; dictAPI = Simulink.interface.dictionary.open(dictName); % create AUTOSAR arch model and link interface dictionary archModel = autosar.arch.createModel('myTopArchModel'); archModel.linkDictionary(dictName);
Use Data Dictionary with Interface Dictionary
The design also allows regular data dictionaries to coexist with an interface dictionary. This approach allows for proper scoping and encapsulation of the data in your model hierarchy.
Model workspace — Contains parameters and signal definitions that are scoped to the model.
Data dictionary — Contains configuration sets, values, and variants that can be shared with other components but should be separate from interface definitions.
Interface dictionary — Contains interface and data type definitions that can be shared across components.
To use both dictionaries, first link a data dictionary to a component model, then reference the interface dictionary from the data dictionary.
Create an empty model.
In the Simulink Editor, on the model canvas, right-click and select Model Properties.
In the Model Properties dialog box, create a new data dictionary or link to an existing dictionary.
Click the model data badge in the bottom left corner of the model, then click the External Data link.
In the Model Explorer Model Hierarchy pane, under the External Data node, select the node for the data dictionary.
In the Dialog pane, in the Referenced Dictionaries section, add your interface dictionary as a referenced dictionary.
Apply Interfaces to Architecture Model in Simulink Environment
Once your interface dictionary is linked to an AUTOSAR architecture model, you can apply the interfaces to your modeled AUTOSAR application programmatically by using the AUTOSAR architecture model API, or by using the Interface Editor in the Simulink editor window.
Here, you link a dictionary with an AUTOSAR Classic platform mapping to an
architecture model then map a SenderPort
to an interface in that
dictionary.
% open previously created interface dictionary dictName = 'MyInterfaces.sldd'; dictAPI = Simulink.interface.dictionary.open(dictName); % link interface dictionary to an AUTOSAR arch model archModel = autosar.arch.createModel('myTopComposition'); archModel.linkDictionary(dictName); pport = archModel.addPort("Sender", 'PPort'); pport.setInterface(srInterface2);
Alternatively, you can apply the interfaces to your AUTOSAR architecture model by using the Interface Editor or Property Inspector. In the AUTOSAR architecture model toolstrip, on the Modeling tab, open the Design menu and select Interface Editor. The editor opens as a pane in the current Simulink Editor window.
The primary focus of this model-centric editor is applying interfaces to ports. It displays the available interfaces in the linked interface dictionary. By using Interface Editor you can:
Right-click on an interface to assign the interface to a selected port on the canvas.
Trace between ports and interfaces
Focus on a particular interface by using the Port Interface View
Use the Property Inspector to view and configure a selected interface
Add data interfaces in the AUTOSAR architecture model. These interfaces can be mapped to
SenderReceiverInterface
,ModeSwitchInterface
, orNvDataInterface
by using the Property Inspector.
Deploy Interface Dictionary
Finally, to deploy an interface dictionary to a particular platform, you must provide a mapping of the dictionary elements to the platform. When you build an AUTOSAR architecture model, the build process exports an interface dictionary that is linked to the model as ARXML into a folder with the interface dictionary name. This ensures that the interfaces and types defined in the dictionary are included in the ARXML. In addition, the created ZIP file includes the ARXML files that come out of the dictionary.
You can also export an interface dictionary independently of an architecture model by using the standalone Interface Editor or the interface dictionary API. In the Interface Editor, in the Share section, select Export > Export to ARXML. To export programmatically, use the following commands.
platformMapping = dictAPI.getPlatformMapping('AUTOSARClassic');
exportDictionary(platformMapping);
Limitations
Some limitations for the interface dictionary include:
An AUTOSAR classic component model cannot reference multiple interface dictionaries.
Interface dictionary reference hierarchies are not supported for interface dictionaries mapped to the AUTOSAR Classic Platform.
The editor for the interface dictionary can only view and edit data interfaces. To author and view other kinds of interfaces for AUTOSAR workflows, such as client/server, parameter and trigger interfaces, open the AUTOSAR component dictionary.
The interface dictionary does not support the import of AUTOSAR information from an ARXML.
See Also
Simulink.interface.Dictionary
| autosar.dictionary.ARClassicPlatformMapping
| exportDictionary
| getPlatformProperties
| getPlatformProperty
| setPlatformProperty
| Simulink.interface.dictionary.create
| Simulink.interface.dictionary.open
| Migrator
| Interface
Editor
Related Topics
- Create AUTOSAR Architecture Models
- Add and Connect AUTOSAR Classic Components and Compositions
- Define AUTOSAR Component Behavior by Creating or Linking Models
- Generate and Package AUTOSAR Composition XML Descriptions and Component Code
- Author AUTOSAR Classic Compositions and Components in Architecture Model