Main Content

Author Service Interfaces for Client-Server Communication

You can model client-server connections between software components in software architectures in System Composer™ using client ports and server ports and associating service interfaces with these ports.

To expose services performed by a software component, create a server port on that component. To access those services from within another software component, create a client port on the second component and connect the two ports. The ball and socket icons represent server and client ports, respectively. You can also author client and server ports at the composition level, with client-server lines crossing multiple hierarchies.

System Composer canvas, with 2 software components. The port creation quick menu is shown on both components. On one of them, the menu option "Client" is highlighted. On the other, the menu option "Server" is highlighted.

System Composer canvas with two software components. One component is named Sensor and has a client port. The other component is named RTE and has a server port. The ports are connected to each other.

A service interface defines the functional interface between client and server components. Each service interface consists of one or more function elements. Use the Interface Editor to author and edit service interfaces.

Interface Editor, with "Add New Interface" dropdown menu open, and menu option "Service Interface" highlighted.

Interface Editor with a service interface definition displayed. The service interface has 2 function elements, with function signatures "y = f0(u)" and "y = f1(u)". The button to add an element to selected interface is highlighted in the toolbar at the top.

Edit the function signature to change the number and names of inputs and outputs. Edit function element properties as you would edit other interface element properties. Function argument types can include built-in types as well as bus objects.

Interface Editor with a service interface definition displayed. The service interface has a function elements with function signature "[y1,y2] = f0(u1,u2)".

Once you have defined a service interface in the Interface Editor, you can assign it to client and server ports using the Property Inspector. You can also use the Property Inspector to assign stereotypes to service interfaces.

To implement function behavior for components with client or server ports using referenced Simulink® models, right-click a component and select Create Simulink behavior, or use the createSimulinkBehavior function. System Composer creates a new export-function model and links the component to the new model.

For a component with a server port, the model contains a Function Element block and a port-scoped Simulink Function block for each function element of the service interface associated with the server port. The Simulink Function blocks are preconfigured with a function interface specification to match each function element of the service interface. The Function Element block creates an exporting function port in the Simulink model. The attributes of the port are based on the service interface definition.

Simulink canvas with 2 port-scoped Simulink Function blocks and 2 Function Element blocks.

To implement the desired algorithm for each server function, open the Simulink Function blocks and add and connect the needed blocks and other modeling elements.

For a component with a client port, the model contains a Function Element Call block and a Function-Call Subsystem block containing a Function Caller block for each function element of the service interface associated with the client port. The Function Caller blocks are preconfigured with a Function prototype and argument specifications to match each function element of the service interface. The Function Element Call block creates an invoking function port in the Simulink model. The attributes of the port are based on the service interface definition.

Simulink canvas with 2 Function Element Call blocks and 2 Function-Call Subsystem blocks. Inside each function-call subsystem there is a Function Caller block.

See Also

| | |

Related Topics