Main Content

Simulink.dictionary.archdata.FunctionElement

Function in client-server interface

Since R2023b

Description

A FunctionElement object describes the attributes of a function in a client-server interface. The client-server interface is a Simulink.dictionary.archdata.ServiceInterface.

Creation

Create a FunctionElement object using the addElement function.

functionElement = addElement(serviceInterface,"f0")

Properties

expand all

Function prototype to define the function name, and input and output arguments, specified as a character vector or string scalar.

Data Types: char | string

Whether the function element is asynchronous, specified as a logical.

Data Types: logical

Function arguments, specified as an array of Simulink.dictionary.archdata.FunctionArgument objects.

Function element name, specified as a character vector or string scalar.

Data Types: char | string

Service interface containing the function element, specified as a Simulink.dictionary.archdata.ServiceInterface object.

Object Functions

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
destroyDelete data element and remove from data interface

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.

serviceInterfaceObj = getInterface(archDataObj, "ServiceInterface1")
serviceInterfaceObj = 

  ServiceInterface with properties:

           Name: 'ServiceInterface1'
    Description: ''
       Elements: [1×2 Simulink.dictionary.archdata.FunctionElement]
          Owner: [1×1 Simulink.dictionary.ArchitecturalData]

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

funcElemObj3 = addElement(serviceInterfaceObj, "functionElement3")
funcElemObj3 = 

  FunctionElement with properties:

    FunctionPrototype: 'y = functionElement3(u)'
         Asynchronous: 0
    FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                 Name: 'functionElement3'
                Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]

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

funcElemObj2 = getElement(serviceInterfaceObj, "functionElement2")
funcElemObj2 = 

  FunctionElement with properties:

    FunctionPrototype: 'y = functionElement2(u)'
         Asynchronous: 0
    FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                 Name: 'functionElement2'
                Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]

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

removeElement(serviceInterfaceObj, "functionElement1")

The service interface object now contains only two function elements, functionElement2 and functionElement3.

serviceInterfaceObj.Elements(1)
ans = 

  FunctionElement with properties:

    FunctionPrototype: 'y = functionElement2(u)'
         Asynchronous: 0
    FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                 Name: 'functionElement2'
                Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]
serviceInterfaceObj.Elements(2)
ans = 

  FunctionElement with properties:

    FunctionPrototype: 'y = functionElement3(u)'
         Asynchronous: 0
    FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                 Name: 'functionElement3'
                Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]

To modify the function prototype of a function element, edit the FunctionPrototype property of the function element.

Access an existing function element using the getElement function.

funcElem1 = getElement(serviceInterfaceObj,"functionElement1")
funcElemObj1 = 

  FunctionElement with properties:

    FunctionPrototype: 'y = functionElement1(u)'
         Asynchronous: 0
    FunctionArguments: [1×2 Simulink.dictionary.archdata.FunctionArgument]
                 Name: 'functionElement1'
                Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]

To modify the function prototype, for example to add an input argument, modify the FunctionPrototype property of the FunctionElement object.

funcElemObj1.FunctionPrototype = "y = functionElement1(u,v)"
funcElemObj1 = 

  FunctionElement with properties:

    FunctionPrototype: 'y = functionElement1(u,v)'
         Asynchronous: 0
    FunctionArguments: [1×3 Simulink.dictionary.archdata.FunctionArgument]
                 Name: 'functionElement1'
                Owner: [1×1 Simulink.dictionary.archdata.ServiceInterface]

The function element now contains three function argument objects.

Version History

Introduced in R2023b