Main Content

Simulink.dictionary.archdata.ServiceInterface

Service interface

Since R2023b

    Description

    A ServiceInterface object represents the structure of a service interface.

    Creation

    Create a ServiceInterface object using the addServiceInterface function.

    ServInterfaceObj = addServiceInterface(archDataObj,"ServInterface");

    Properties

    expand all

    Service interface name, specified as a character vector or string scalar.

    Data Types: char | string

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

    Data Types: char | string

    Function elements in the service interface, specified as an array of Simulink.dictionary.archdata.FunctionElement objects.

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

    Object Functions

    addElementAdd function element to service interface
    getElementGet function element from service interface
    removeElementRemove element from service interface
    moveToDictionaryMove architectural data of Simulink data dictionary to another data dictionary
    moveToDesignDataMove interfaces, data types, and constants in Architectural Data section of Simulink data dictionary to design data
    showView architectural data of Simulink data dictionary in Architectural Data Editor

    Examples

    collapse all

    To configure function elements of a service interface, use the addElement, getElement, and removeElement functions.

    In this example, the dictionary MyInterfaces.sldd contains one service interface.

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

    Get the service interface object using the getInterface function. The service interface object contains two function element objects.

    servInterfaceObj = getInterface(archDataObj,"myServiceInterface")
    servInterfaceObj = 
    
      ServiceInterface with properties:
    
               Name: 'myServiceInterface'
        Description: ''
           Elements: [1×2 Simulink.dictionary.archdata.FunctionElement]
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    To create a physical element object and add it to the physical interface, use the addElement function.

    funcElemObj3 = addElement(servInterfaceObj,"servElem3")
    funcElemObj3 = 
    
      FunctionElement with properties:
    
        FunctionPrototype: 'y = servElem3(u)'
             Asynchronous: 0
        FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                     Name: 'servElem3'
                    Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]

    To access an existing physical element, use the getElement function.

    funcElemObj2 = getElement(servInterfaceObj,"funcElem2")
    funcElemObj2 = 
    
      FunctionElement with properties:
    
        FunctionPrototype: 'y = funcElem2(u)'
             Asynchronous: 0
        FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                     Name: 'funcElem2'
                    Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]

    To remove a function element from a function interface, use the removeElement function.

    removeElement(servInterfaceObj,"funcElem1");

    The service interface object now contains only two function elements, funcElem2 and funcElem3

    servInterfaceObj.Elements(1)
    ans = 
    
      FunctionElement with properties:
    
        FunctionPrototype: 'y = funcElem2(u)'
             Asynchronous: 0
        FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                     Name: 'funcElem2'
                    Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]
    servInterfaceObj.Elements(2)
    ans = 
    
      FunctionElement with properties:
    
        FunctionPrototype: 'y = servElem3(u)'
             Asynchronous: 0
        FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                     Name: 'servElem3'
                    Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]

    Version History

    Introduced in R2023b