Main Content

Simulink.dictionary.ArchitecturalData

Edit architectural data in a Simulink data dictionary programmatically

Since R2023b

    Description

    The Simulink.dictionary.ArchitecturalData object represents the Architectural Data section of a Simulink® data dictionary. The Architectural Data object allows you to programmatically access shared definitions across Simulink and architecture models of port interfaces, data types, system wide constants, and their platform properties. You can also use the Architectural Data Editor to manage architectural data.

    Creation

    You can create a new data dictionary using the Simulink.dictionary.archdata.create function. This function returns the Simulink.dictionary.ArchitecturalData object.

    dictName = "MyInterfaces.sldd";
    archDataObj = Simulink.dictionary.archdata.create(dictName);

    If you already created a data dictionary, you can create the Architectural Data object using the Simulink.dictionary.archdata.open function.

    dictName = "MyInterfaces.sldd";
    archDataObj = Simulink.dictionary.archdata.open(dictName);

    Properties

    expand all

    File name of data dictionary, specified as a character vector or string scalar. The name must include the .sldd extension and must be a valid MATLAB® identifier.

    Defined interfaces, specified as an array of Simulink.dictionary.archdata.DataInterface and Simulink.dictionary.archdata.ServiceInterface objects with properties: Name, Description, Elements, and Owner.

    Defined data types, specified as an array of Simulink.dictionary.archdata.DataType objects with properties: Name and Owner.

    Defined constants, specified as an array of Simulink.dictionary.archdata.Constant objects with properties: Name, BaseType, Description, and Owner.

    Object Functions

    addAliasTypeAdd Simulink alias type to Architectural Data section of Simulink data dictionary
    addConstantAdd constant to the Architectural Data section of Simulink data dictionary
    addDataInterfaceAdd data interface to Architectural Data section of Simulink data dictionary
    addEnumTypeAdd enumerated type to Architectural Data section of Simulink data dictionary
    addNumericTypeAdd Simulink numeric type to Architectural Data section of Simulink data dictionary
    addPlatformMappingAdd AUTOSAR Classic mapping to Architectural Data section of Simulink data dictionary
    addReferenceAdd data dictionary reference to Architectural Data section of Simulink data dictionary
    addServiceInterfaceAdd service interface to Architectural Data section of Simulink data dictionary
    addStructTypeAdd structure type to Architectural Data section of Simulink data dictionary
    addValueTypeAdd value type to Architectural Data section of Simulink data dictionary
    closeClose any open connections to Simulink data dictionary
    discardChangesDiscard changes to Simulink data dictionary
    findEntryByNameGet object by name in Architectural Data section of Simulink data dictionary
    getConstantGet constant in Architectural Data section of Simulink data dictionary
    getConstantNamesGet constant names in Architectural Data section of Simulink data dictionary
    getDataTypeGet data type in Architectural Data section of Simulink data dictionary
    getDataTypeNamesGet names of data types in Architectural Data section of Simulink data dictionary
    getInterfaceGet interface object for interface in Architectural Data section of Simulink data dictionary
    getInterfaceNamesGet interface names in Architectural Data section of Simulink data dictionary
    getPlatformMappingGet platform mapping object for platform of Simulink data dictionary
    getReferencesGet full paths of Simulink data dictionaries referenced by another Simulink data dictionary
    importFromBaseWorkspaceImport Simulink object definitions from base workspace to Architectural Data section of Simulink data dictionary
    importFromFileImport Simulink object definitions from file to Architectural Data section of data dictionary
    isDirtyCheck for unsaved changes in Simulink data dictionary
    moveToDesignDataMove interfaces, data types, and constants in Architectural Data section of Simulink data dictionary to design data
    moveToDictionaryMove architectural data of Simulink data dictionary to another data dictionary
    removeConstantRemove constant from Architectural Data section of Simulink data dictionary
    removeDataTypeRemove data type from Architectural Data section of Simulink data dictionary
    removeInterfaceRemove interface from Architectural Data section of Simulink data dictionary
    removeReferenceRemove Simulink data dictionary reference of another Simulink data dictionary
    saveSave changes to Architectural Data section of Simulink data dictionary
    showView architectural data of Simulink data dictionary in Architectural Data Editor
    showChangesView changes to architectural data of Simulink data dictionary in Comparison Tool

    Examples

    collapse all

    Create the Simulink data dictionary and return the associated Architectural Data object.

    dictName = "MyArchitecturalData.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");
    addEnumeral(myEnumType1Obj,"RED",'0',"Red Sunset");
    addEnumeral(myEnumType1Obj,"BLUE",'1',"Blue Skies");
    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 using the data type object, or 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.

    dataInterface1Obj = addDataInterface(archDataObj,"DataInterface");
     
    dataElm1 = addElement(dataInterface1Obj,"DE1");
    dataElm1.Type = myValueType1Obj;
     
    dataElm2 = addElement(dataInterface1Obj,"DE2");
    dataElm2.Type = myStructType1Obj;
    dataElm2.Dimensions = "4";
    dataElm2.Description = "I am a data element with datatype = array of struct type";
     
    dataElm3 = addElement(dataInterface1Obj,"DE3");
    dataElm3.Type.DataType = "single";
    dataElm3.Type.Dimensions = "10";
    dataElm3.Type.Minimum = "-5";

    Add AUTOSAR Classic mapping using the addPlatformMapping function.

    platformMapping = addPlatformMapping(archDataObj,"AUTOSARClassic");

    Get and set the AUTOSAR communication interface and package properties, using the getPlatformProperties and setPlatformProperty functions.

    setPlatformProperty(platformMapping, dataInterface1Obj,...
        "Package","/Interface2","InterfaceKind","NvDataInterface");
    [pNames, pValues] = getPlatformProperties(platformMapping,dataInterface1Obj);

    You can now generate ARXML code for the data dictionary content.

    exportedFolder = exportDictionary(platformMapping);
    Exporting dictionary, please wait...
    Exported dictionary ARXML files are located in: C:\work\MyArchitecturalData.

    Manage AUTOSAR Classic platform-related elements, software address method and calibration properties. These elements do not have mappings to Simulink.

    arProps = autosar.api.getAUTOSARProperties(dictName);
    addPackageableElement(arProps,"SwAddrMethod", ... 
        "/SwAddressMethods","VAR1","SectionType","Var");
    setPlatformProperty(platformMapping,dataElm1, ...
        SwAddrMethod="VAR1",SwCalibrationAccess="ReadWrite",... 
         DisplayFormat="%.3f");

    Version History

    Introduced in R2023b