Programmatically Manage Shared Interfaces, Data Types, and Constants of Architecture Models
The Architectural Data section of a Simulink® data dictionary enables interfaces, data types, constants and AUTOSAR-specific data to be authored, managed, and shared between AUTOSAR components and compositions modeled in Simulink. The Architectural Data section provides scalability for system-level and multicomponent designs by containing these shared elements in a central location.
You can programmatically configure architectural data and apply your changes to your model using this basic workflow:
Create or open a data dictionary.
Design interfaces, data types, and constants with the
Simulink.dictionary.ArchitecturalData
programmatic interfaces.Link the data dictionary containing architectural data to a Simulink or architecture model.
Apply architectural data to a model programmatically.
Create or Open Simulink Data Dictionary Programmatically
To create a new data dictionary, use the
Simulink.dictionary.archdata.create
function.dictName = "MyInterfaces.sldd"; archDataObj = Simulink.dictionary.archdata.create(dictName);
To open an existing data dictionary use the
Simulink.dictionary.archdata.open
function.archDataObj2 = Simulink.dictionary.archdata.open("OtherDictionary.sldd");
These functions return Architectural Data objects that you can edit using the Simulink.dictionary.ArchitecturalData
programmatic interfaces.
Design Data Types, Interfaces, and Constants Programmatically
To programmatically create, configure, and manage architectural data in your data dictionary, use the programmatic interfaces for the
Simulink.dictionary.ArchitecturalData
object.dictName = "myDataDictionary.sldd"; archDataObj = Simulink.dictionary.archdata.create(dictName);
Use type-specific functions to add alias types and enumerations to the data dictionary.
myAliasType1Obj = addAliasType(archDataObj,"aliasType",BaseType="single"); myAliasType1Obj.Name = "myAliasType1"; myAliasType1Obj.BaseType = "fixdt(1,32,16)"; myAliasType2Obj = addAliasType(archDataObj,"myAliasType2"); myAliasType2Obj.BaseType = myAliasType1Obj; myEnumType1Obj = addEnumType(archDataObj,"myColor"); myEnumType1Obj.DefaultValue = "BLUE"; myEnumType1Obj.Description = "I am a Simulink Enumeration"; myEnumType1Obj.StorageType = "int16";
You can set the base type of the created alias type to be the created enumeration data type
myColor
.myAliasType3Obj = addAliasType(archDataObj,"myAliasType3"); myAliasType3Obj.BaseType = myEnumType1Obj;
Use the
addNumericType
function to add numeric types to the data dictionary.myNumericType1Obj = addNumericType(archDataObj,"myNumericType1"); myNumericType1Obj.DataTypeMode = "Single";
Use the
addValueType
to add value types to the data dictionary. You can also set the data type of the value types to be pre-existing data types or created enumeration data types.myValueType1Obj = addValueType(archDataObj,"myValueType1"); myValueType1Obj.DataType = 'int32'; myValueType1Obj.Dimensions = '[2 3]'; myValueType1Obj.Description = "I am a Simulink ValueType";
Use the
addStructType
function to add struct types to the data dictionary.myStructType1Obj = addStructType(archDataObj,"myStructType1"); structElement1 = myStructType1Obj.addElement("Element1"); structElement1.Type.DataType = 'single'; structElement1.Type.Dimensions = '3'; structElement2 = addElement(myStructType1Obj,"Element2"); structElement3 = addElement(myStructType1Obj,"Element3");
You can set the data type of a struct element by using the data type object or by using the name of the data type, specified as a string scalar or character vector.
structElement2.Type = myValueType1Obj; % or structElement3.Type = "ValueType: myValueType1";
You can add constants using the
addConstant
function.myConstantObj = addConstant(archDataObj, "myConst", Value=4);
You can add communication interfaces and their data elements using the functions of the
Simulink.dictionary.archdata.DataInterface
object.nvInterface1 = addDataInterface(archDataObj,"NV1"); dataElm1 = addElement(nvInterface1,"DE1"); dataElm1.Type = myValueType1Obj; dataElm2 = addElement(nvInterface1,"DE3"); dataElm2.Type.DataType = 'single'; dataElm2.Type.Dimensions = '10'; dataElm2.Type.Minimum = '-5'; srInterface2 = addDataInterface(archDataObj,"SR1");
Add AUTOSAR Classic platform mapping using the
addPlatformMapping
function. You can get and set properties using thesetPlatformProperty
andgetPlatformProperties
functions.platformMapping = addPlatformMapping(archDataObj,"AUTOSARClassic"); setPlatformProperty(platformMapping,nvInterface1,... "Package", "/Interface2", "InterfaceKind", "NvDataInterface"); [pNames, pValues] = getPlatformProperties(platformMapping,nvInterface1);
Programmatically manage AUTOSAR Classic platform related elements that do not have mappings to Simulink. See
autosar.api.getAUTOSARProperties
for information regarding related workflows.arPropsObj = autosar.api.getAUTOSARProperties(dictName); arPropsObj.addPackageableElement("SwAddrMethod","/SwAddressMethods","VAR1","SectionType","Var"); setPlatformProperty(platformMapping,dataElm1,... "SwAddrMethod","VAR1","SwCalibrationAccess","ReadWrite","DisplayFormat","%.3f");
Link Data Dictionary Programmatically
To link a dictionary to a model programmatically use the linkDictionary
function.
Create or open a Simulink data dictionary. In this example you create a new data dictionary
MyInterfaces.sldd
.dictName = "MyInterfaces.sldd"; archDataObj = Simulink.dictionary.archdata.create(dictName);
Create an AUTOSAR architecture model and link it to a simulink data dictionary.
archModel = autosar.arch.createModel("myTopArchModel"); linkDictionary(archModel,dictName);
Apply Data Changes Programmatically
Once your data dictionary is linked to an architecture model, you can apply the
changes to your modeled application programmatically by using the Simulink.dictionary.ArchitecturalData
object.
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.
Create or open a Simulink data dictionary. In this example you create a new data dictionary
MyInterfaces.sldd
.dictName = 'MyInterfaces.sldd'; archDataObj = Simulink.dictionary.archdata.create(dictName);
Create an AUTOSAR architecture model.
archModel = autosar.arch.createModel('myTopComposition');
Add a data interface to the Architectural Data of the AUTOSAR architecture model.
srInterface2 = addDataInterface(archDataObj,'SR1');
Link a data dictionary to the AUTOSAR architecture model.
linkDictionary(archModel,dictName);
Add a port and set the interface of the port.
pport = archModel.addPort("Sender", 'PPort'); setInterface(pport,srInterface2);
Limitations
Some limitations for AUTOSAR mapped data dictionaries include:
Data dictionary reference hierarchies are not supported for data dictionaries mapped to the AUTOSAR Classic Platform.
The Interface Editor 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, use the AUTOSAR component dictionary.
The data dictionary does not support the import of AUTOSAR information from an ARXML file.
See Also
Simulink.dictionary.ArchitecturalData
| autosar.dictionary.ARClassicPlatformMapping
| exportDictionary
| getPlatformProperties
| getPlatformProperty
| setPlatformProperty
| Simulink.dictionary.archdata.create
| Simulink.dictionary.archdata.open
Related Topics
- Graphically Manage Shared Interfaces, Data Types, and Constants
- 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 Compositions and Components in Architecture Model