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.
A service interface defines the functional interface between client and server components. Each service interface consists of one or more function elements.
A function element describes the attributes of a function in a client-server interface.
Use the Interface Editor to author and edit service interfaces.
Edit the function prototype on a function element to change the number and names of inputs and outputs of the function. 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. You can specify function elements to support:
Synchronous execution — When the client calls the server, the function runs immediately and returns the output arguments to the client.
Asynchronous execution — When the client makes a request to call the server, the function is executed asynchronously based on the priority order defined in the Functions Editor and Schedule Editor and returns the output arguments to the client.
For asynchronous simulation, for the function element on the Interface Editor, select the Asynchronous check box.
A function argument describes the attributes of an input or output argument in a function element.
You can set the properties of a function argument in the Interface Editor just as you would any value type:
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
behavior, or use the
createSimulinkBehavior function. System Composer creates a new export-function model and links the component to the new
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.
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.
Synchronous Client-Server Simulink Behavior
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.
Asynchronous Client-Server Simulink Behavior
You can model asynchronous execution if you select the Asynchronous check box on the Interface Editor for your function element.
The export-function model for the Simulink behavior for the client model now has a Function Caller block with a message output port consistent with the number of output arguments for the Simulink Function.
If there is one function output argument, the output argument becomes the message payload.
If there is more than one function output argument, the Function Caller block bundles the output arguments as a structure that becomes the message payload.
Function Element | Function Element Call | Simulink Function | Function
Caller | Function-Call Subsystem | Message
Triggered Subsystem |