Main Content


Manage interface dictionary


    The Simulink.interface.Dictionary object provides methods that help you manage the interface dictionary.


    To create a Simulink Interface Dictionary and return an object representing the dictionary, use the Simulink.interface.dictionary.create function.

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


    expand all

    Data types defined in dictionary, specified as an array of DataType objects with properties: Name and Owner.

    File name of SLDD file associated with the dictionary.

    Interfaces defined in dictionary, specified as an array of DataInterface objects with properties: Name, Description, Elements, and Owner.

    Object Functions

    addAliasTypeAdd a Simulink alias type to Simulink Interface Dictionary
    addDataInterfaceAdd a data interface to Simulink Interface Dictionary
    addEnumTypeAdd an enum type to Simulink Interface Dictionary
    addPlatformMappingAdd AUTOSARClassic mapping to Simulink interface dictionary
    addStructTypeAdd a structure type represented by Simulink.Bus in the Simulink interface dictionary
    addValueTypeAdd a value type to Simulink Interface Dictionary
    closeClose open connections to Simulink Interface Dictionary
    getDataTypeGet data type in Simulink Interface Dictionary
    getDataTypeNamesGet names of data types in Simulink Interface Dictionary
    getInterfaceGet interface object for an interface in a Simulink Interface Dictionary
    getInterfaceNamesGet cell array of interface names in Simulink Interface Dictionary
    getPlatformMappingGet platform mapping object for platform in dictionary
    importFromBaseWorkspaceImport Simulink object definitions
    importFromFileImport Simulink object definitions
    isDirtyCheck whether there are unsaved changes in Simulink interface dictionary
    removeDataTypeRemove a Simulink data type from Simulink Interface Dictionary
    removeInterfaceRemove an interface from Simulink Interface Dictionary
    saveSave changes to Simulink Interface Dictionary
    showView contents of Simulink Interface Dictionary in standalone viewer
    showChangesView changes to contents of Simulink Interface Dictionary in comparison viewer


    collapse all

    This example creates a Simulink.interface.dictionary object and configures the dictionary contents. This example also shows how to manage AUTOSAR Classic platform-related elements.

    Create interface dictionary.

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

    Add data types.

    %% Alias Types
    myAliasType1 = addAliasType(dictAPI, 'aliasType', BaseType='single');
    myAliasType1.Name = 'myAliasType1';
    myAliasType1.BaseType = 'fixdt(1,32,16)';
    myAliasType2 = addAliasType(dictAPI, 'myAliasType2');
    % can also use interface dict type objs
    myAliasType2.BaseType = myAliasType1;
    %% Enum Types
    myEnumType1 = addEnumType(dictAPI,'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 = addAliasType(dictAPI, 'myAliasType3');
    myAliasType3.BaseType = myEnumType1;
    %% ValueType
    myValueType1 = addValueType(dictAPI, '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 = 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';
    %% Nested StructType
    myStructType2 = addStructType(dictAPI, 'myStructType2');
    myStructType2.Description = 'I am a nested structure';
    structElement = myStructType2.addElement('Element');
    structElement.Dimensions = '5';
    structElement.Type = myStructType1;
    % or
    structElement.Type = 'Bus: myStructType1';

    Add some interfaces, configure design data on data elements.

    dataInterface1 = addDataInterface(dictAPI, 'DataInterface');
    dataElm1 = addElement(dataInterface1, 'DE1');
    dataElm1.Type = myValueType1;
    dataElm2 = addElement(dataInterface1, '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 = addElement(dataInterface1, 'DE3');
    dataElm3.Type.DataType = 'single';
    dataElm3.Type.Dimensions = '10';
    dataElm3.Type.Minimum = '-5';
    dataInterface2 = addDataInterface(dictAPI,'DataInterface2');

    Add AUTOSAR Classic mapping.

    platformMapping = addPlatformMapping(dictAPI, 'AUTOSARClassic');

    Set platform properties.

    setPlatformProperty(platformMapping, dataInterface1,...
        'Package', '/Interface2', 'InterfaceKind', 'NvDataInterface');

    Get the platform properties.

    [pNames, pValues] = getPlatformProperties(platformMapping, dataInterface1);

    Export dictionary content to code and ARXML.


    Manage AUTOSAR Classic platform related elements. These element do not have mapping to Simulink.

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

    Version History

    Introduced in R2022b