Main Content

Simulink.dictionary.archdata.DataInterface

Edit data interface in Simulink data dictionary programmatically

Since R2023b

    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 not be composite when using an AUTOSAR platform mapping.

    Creation

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

    dataInterfaceObj = addDataInterface(archDataObj,"DataInterface")
    dataInterfaceObj = 
    
      DataInterface with properties:
    
               Name: 'DataInterface'
        Description: ''
           Elements: [0×0 Simulink.dictionary.archdata.DataElement]
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Properties

    expand all

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

    Data Types: char | string

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

    Data Types: char | string

    Elements belonging to the Architectural Data object, specified as an array of Simulink.dictionary.archdata.DataElement objects.

    Architectural Data object of the data dictionary containing the data interface, specified as a Simulink.dictionary.ArchitecturalData object.

    Object Functions

    addElementAdd data element to data interface
    destroyDelete data element and remove from data interface
    getElementGet data element from data interface
    removeElementRemove data element from data interface
    showView architectural data of Simulink data dictionary in Architectural Data Editor

    Examples

    collapse all

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

    Open an existing data dictionary. This creates a Simulink.dictionary.ArchitecturalData object, archDataObj.

    archDataObj = Simulink.dictionary.archdata.open("MyInterfaces.sldd")
    archDataObj = 
    
      ArchitecturalData with properties:
    
        DictionaryFileName: 'MyInterfaces.sldd'
                Interfaces: [1×1 Simulink.dictionary.archdata.DataInterface]
                 DataTypes: [1×2 Simulink.dictionary.archdata.DataType]
                 Constants: [1×1 Simulink.dictionary.archdata.Constant]

    The archDataObj contains a data interface.

    interfaceObj = getInterface(archDataObj,"DataInterface")
    interfaceObj = 
    
      DataInterface with properties:
    
               Name: 'DataInterface'
        Description: ''
           Elements: [1×2 Simulink.dictionary.archdata.DataElement]
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Data interfaces are composed of data elements that describe parts of a data interface. This interface definition contains two data elements.

    interfaceObj.Elements(1)
    ans = 
    
      DataElement with properties:
    
               Name: 'Element1'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]
    interfaceObj.Elements(2)
    ans = 
    
      DataElement with properties:
    
               Name: 'Element2'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]

    Use the addElement function to add a new data element to the data interface.

    dataElem3 = addElement(interfaceObj,"Element3")
    dataElem3 = 
    
      DataElement with properties:
    
               Name: 'Element3'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]

    You can get an existing data element using the getElement function.

    dataElem3 = getElement(interfaceObj,"Element3")
    dataElem3 = 
    
      DataElement with properties:
    
               Name: 'Element3'
               Type: [1×1 Simulink.dictionary.archdata.ValueType]
        Description: ''
         Dimensions: '1'
              Owner: [1×1 Simulink.dictionary.archdata.DataInterface]

    Remove a data element from an interface using the removeElement function.

    removeElement(interfaceObj, 'Element3')

    Version History

    Introduced in R2023b