Main Content

Simulink.interface.dictionary.DataInterface

Data interface

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

    Data interfaces represent information that is shared through a connector and enters or exits a component through a port. Data interfaces are composed of data elements that describe the structure of the transmitted data. Data interfaces can be composite and can reference other data interfaces.

    Creation

    To create a Simulink.interface.dictionary.DataInterface object, add a data interface to an existing Simulink.interface.Dictionary object using the addDataInterface function.

    dataInterfaceObj = addDataInterface(interfaceDictionaryObj,"interface1")

    Properties

    expand all

    Name of the data interface, specified as a character vector.

    Data Types: char | string

    Description of the data interface, specified as a character vector or a string scalar.

    Data Types: char | string

    Elements belonging to the data interface object, specified as an array of Simulink.interface.dictionary.DataElement objects.

    Interface dictionary containing the data interface, specified as a Simulink.interface.Dictionary object.

    Object Functions

    addElementAdd data element to data interface
    destroyDestroy data interface and remove from interface dictionary
    getElementGet data element from data interface
    removeElementRemove data element from data interface
    showShow data interface in the Interface Editor

    Examples

    Add and Remove Data Elements From a Data Interface

    This example shows how to access, add, and remove data elements from a data interface.

    1. Open an existing interface dictionary. This creates a Simulink.interface.Dictionary object, interfaceDictObj.

      interfaceDictObj = Simulink.interface.dictionary.open('myInterfaceDict.sldd')
      interfaceDictObj = 
        ArchitecturalData with properties:
      
          DictionaryFileName: 'myInterfaceDict.sldd'
                  Interfaces: [1x1 Simulink.dictionary.archdata.DataInterface]
                   DataTypes: [0x0 Simulink.dictionary.archdata.DataType]
                   Constants: [0x0 Simulink.dictionary.archdata.Constant]
      
      
    2. This interface dictionary contains one data interface definition.

      interfaceObj = interfaceDictObj.Interfaces
      interfaceObj = 
        DataInterface with properties:
      
                 Name: 'interface1'
          Description: ''
             Elements: [1x2 Simulink.dictionary.archdata.DataElement]
                Owner: [1x1 Simulink.dictionary.ArchitecturalData]
      
      
    3. Data interfaces are composed of data elements which describe portions of a data interface. This interface definition contains two data elements.

      interfaceObj.Elements(1)
      ans = 
        DataElement with properties:
      
                 Name: 'element1'
                 Type: [1x1 Simulink.dictionary.archdata.ValueType]
          Description: ''
           Dimensions: '1'
                Owner: [1x1 Simulink.dictionary.archdata.DataInterface]
      
      
      interfaceObj.Elements(2)
      ans = 
        DataElement with properties:
      
                 Name: 'element2'
                 Type: [1x1 Simulink.dictionary.archdata.ValueType]
          Description: ''
           Dimensions: '1'
                Owner: [1x1 Simulink.dictionary.archdata.DataInterface]
      
      
    4. Use the addElement function to add a new data element to the data interface.

      dataElem1 = addElement(interfaceObj, 'element3')
      dataElem1 = 
        DataElement with properties:
      
                 Name: 'element3'
                 Type: [1x1 Simulink.dictionary.archdata.ValueType]
          Description: ''
           Dimensions: '1'
                Owner: [1x1 Simulink.dictionary.archdata.DataInterface]
      
      
    5. You can access an existing data element using the getElement function.

      dataElem3 = getElement(interfaceObj, 'element3')
      dataElem3 = 
        DataElement with properties:
      
                 Name: 'element3'
                 Type: [1x1 Simulink.dictionary.archdata.ValueType]
          Description: ''
           Dimensions: '1'
                Owner: [1x1 Simulink.dictionary.archdata.DataInterface]
      
      
    6. Remove a data element from an interface using the removeElement function.

      removeElement(interfaceObj, 'element3')

    Version History

    Introduced in R2022b