Main Content

Simulink.dictionary.archdata.DataInterface

Data interface in Architectural Data section of Simulink data dictionary

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.

    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

    Specify the C++ namespace for the data interface. When this property is specified, the generated C++ code places the definition of the data interface within the specified namespace. If no namespace is specified, the definition of the data interface is placed in the global namespace.

    This property requires an Embedded Coder® license.

    Example: myCompany::engine

    Data Types: char | string

    Data type definition behavior in generated code, specified as 'Auto', 'Imported', or 'Exported'. The table describes the behavior of generated code for each value.

    ValueAction
    'Auto' (default)

    If you do not specify the property HeaderFile, export the data type definition to model_types.h, where model is the model name.

    If you specify HeaderFile, import the data type definition from the specified header file.

    'Exported'

    Export the data type definition to a separate header file.

    If you do not specify the property HeaderFile, the header file name defaults to type.h, where type is the data type name.

    'Imported'

    Import the data type definition to a separate header file.

    If you do not specify the property HeaderFile, the header file name defaults to types.h, where type is the data type name.

    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.

    Name of the header file that defines the enumerated data type in generated code, specified as a character vector. Use a .h extension to specify the file name.

    If you do not specify HeaderFile, generated code uses a default header file name that depends on the value of the DataScope property.

    Example: 'myTypeIncludeFile.h'

    Data Types: char

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

    Data Types: char | string

    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")

    Limitations

    • Data interfaces cannot have elements that are typed by more than one interface when using an AUTOSAR platform mapping.

    Version History

    Introduced in R2023b

    expand all