Main Content

convertToDataInterface

Convert struct type to data interface object

Since R2023b

    Description

    example

    dataInterfaceObj = convertToDataInterface(structTypeObj) converts the struct type object structTypeObj to a Simulink.dictionary.archdata.DataInterface object.

    Examples

    collapse all

    To convert a struct type to a data interface in a data dictionary, use the convertToDataInterface function.

    In this example, the dictionary MyInterfaces.sldd contains one struct type.

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

    The struct type contains two struct elements.

    structTypeObj = archDataObj.DataTypes
    structTypeObj = 
    
      StructType with properties:
    
               Name: 'StructType1'
        Description: ''
           Elements: [1×2 Simulink.dictionary.archdata.StructElement]
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    To convert the struct type to a data interface, use the convertToDataInterface function.

    interfaceObj = convertToDataInterface(structTypeObj)
    
    interfaceObj = 
    
      DataInterface with properties:
    
               Name: 'StructType1'
        Description: ''
           Elements: [1×2 Simulink.dictionary.archdata.DataElement]
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    The output data interface contains two data elements corresponding to the two struct elements of the input struct type.

    The architectural data object now contains no struct types, and one data interface.

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

    Input Arguments

    collapse all

    Struct type object, specified as a Simulink.dictionary.archdata.StructType object.

    Output Arguments

    collapse all

    Data interface object, returned as a Simulink.dictionary.archdata.DataInterface object. The data interface object contains DataElement objects corresponding to the StructElement objects contained in the input struct type, structTypeObj.

    Version History

    Introduced in R2023b