Configure Client-Server Communication in AUTOSAR Architectures Using Service Interfaces
In Simulink® you can model AUTOSAR client-server communication for simulation and code generation. Use this workflow to define client-server communication starting at the architecture level by using client-server ports and service interfaces sourced from the Architectural Data section of a linked data dictionary.
For a bottom-up workflow using Simulink blocks, AUTOSAR clients and servers, and Simulink functions, see Configure AUTOSAR Client-Server Communication.
Connect Architecture Components Using Client-Server Ports
Create a new AUTOSAR architecture model.
Add three Classic Component blocks to the canvas and name them
SensorManager
,Sensor
, andMonitor
.Add a server port to the
SensorManager
Component block.Select the edge of the block and pause over the inport.
Select Server from the options that appear.
Name the server port
FrontSensorConfig
.
Add another server port to the
SensorManager
Component block.Select the edge of the block and pause over the inport.
Select Server from the options that appear.
Name the server port
RearSensorConfig
.
In a similar way, add a client port named
SensorConfig
to theSensor
Component block.Add an output port named
SensorData
to theSensor
Component block.Select the
Sensor
Component block and open the Property Inspector. From the Kind list, selectSensorActuator
.Add two input ports named
FrontSensor
andRearSensor
and one output port namedSensorData
to theMonitor
Component block.Draw a signal out of
SensorData
that exits the architecture on the edge of the canvas.
Create and Assign Service Interfaces to Client-Server Ports
In the modeling toolstrip of your AUTOSAR architecture, navigate to the Modeling tab and in the Design section, select Architectural Data Editor to open the Architectural Data Editor.
In the Architectural Data Editor select New to create a new data dictionary. Name the data dictionary
ProximityInterfaces
.Add a service interface by selecting Service Interface from the Create section of the Architectural Data Editor toolstrip. Name the interface
SensorConfig
.Edit the function of the
SensorConfig
service interface by double-clicking the function and typing in the cell. Replace the function with[enabled,scanDepth,blkSize] = getSnsrCfg()
.Add a data interface to the dictionary and name it
SensorData
.Save the dictionary, and then close the Architectural Data Editor and return to the architecture canvas.
On the Modeling tab of the toolstrip, in the Design section, select Link Existing Dictionary. Select the
ProximityInterfaces.sldd
in the File name list and clock open. The Interface Editor appears below the canvas.Assign the interfaces to the ports of the architecture model by using the Interface Editor (System Composer).
Expand the
ProximityInterfaces.sldd
dictionary.Select the
FrontSensorConfig
port, and then right-click theSensorConfig
interface in the Interface Editor.Click
Assign to selected port(s)
to assignSensorConfig
as the interface for theFrontSensorConfig
port.Similarly assign the
SensorConfig
service interface as the interface for theRearSensorConfig
server port.Assign the
SensorData
data interface to theSensorData
output ports on theSensor
andMonitor
Component blocks.Assign the
SensorData
data interface to the input portsFrontSensor
andRearSensor
on theMonitor
Component block. Save the model.
Connect the ports of the Component blocks.
Connect the
FrontSensorConfig
server port to theSensorConfig
client port on theSensor
Component block.Connect the
SensorData
output port of theSensor
Component block to theFrontSensor
input port on theMonitor
Component block.
Right-click the
Sensor
Component block and select Create Simulink Behavior. In the Create Simulink Model dialog box, click OK and Simulink creates a model to represent the client-server communication structure. Create Simulink behavior in the same way for the remaining Component blocks.Duplicate the
Sensor
Component block.Rename the original
Sensor
Component block asFrontProximitySensor
, and rename the newSensor1
Component block asRearProximitySensor
.Connect the server ports of the Component blocks.
Connect the
RearSensorConfig
server port to theSensorConfig
client port on theRearProximitySensor
Component block.Connect the output port
SensorData
of theRearProximitySensor
Component block to theRearSensor
input port on theMonitor
Component block.
Save and export the architecture.
Inspect the generated ARXML. Server ports are tagged by
PROVIDER-IREF
and client ports are tagged byREQUESTER-IREF
.<SHORT-NAME>SensorManager_FrontSensorConfig_FrontProximitySnsr_SensorConfig</SHORT-NAME> <PROVIDER-IREF> <CONTEXT-COMPONENT-REF DEST="SW-COMPONENT-PROTOTYPE">/Components/myWorkflowCSServiceArch/SensorManager</CONTEXT-COMPONENT-REF> <TARGET-P-PORT-REF DEST="P-PORT-PROTOTYPE">/Components/SensorManager/FrontSensorConfig</TARGET-P-PORT-REF> </PROVIDER-IREF> <REQUESTER-IREF> <CONTEXT-COMPONENT-REF DEST="SW-COMPONENT-PROTOTYPE">/Components/myWorkflowCSServiceArch/FrontProximitySnsr</CONTEXT-COMPONENT-REF> <TARGET-R-PORT-REF DEST="R-PORT-PROTOTYPE">/Components/FrontProximitySnsr/SensorConfig</TARGET-R-PORT-REF> </REQUESTER-IREF>
The service interfaces are tagged with
CLIENT-SERVER-INTERFACE
and contain their operations and arguments.<CLIENT-SERVER-INTERFACE UUID="..."> <SHORT-NAME>SensorConfig</SHORT-NAME> <IS-SERVICE>false</IS-SERVICE> <OPERATIONS> <CLIENT-SERVER-OPERATION UUID="..."> <SHORT-NAME>getSnsrCfg</SHORT-NAME> <ARGUMENTS> <ARGUMENT-DATA-PROTOTYPE UUID="..."> <SHORT-NAME>enabled</SHORT-NAME> <CATEGORY>VALUE</CATEGORY> <SW-DATA-DEF-PROPS> <SW-DATA-DEF-PROPS-VARIANTS> <SW-DATA-DEF-PROPS-CONDITIONAL> <SW-CALIBRATION-ACCESS>READ-ONLY</SW-CALIBRATION-ACCESS> <SW-IMPL-POLICY>STANDARD</SW-IMPL-POLICY> </SW-DATA-DEF-PROPS-CONDITIONAL> </SW-DATA-DEF-PROPS-VARIANTS> </SW-DATA-DEF-PROPS> <TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/DataTypes/float64</TYPE-TREF> <DIRECTION>OUT</DIRECTION> </ARGUMENT-DATA-PROTOTYPE> <ARGUMENT-DATA-PROTOTYPE UUID="..."> <SHORT-NAME>scanDepth</SHORT-NAME> <CATEGORY>VALUE</CATEGORY> <SW-DATA-DEF-PROPS> <SW-DATA-DEF-PROPS-VARIANTS> <SW-DATA-DEF-PROPS-CONDITIONAL> <SW-CALIBRATION-ACCESS>READ-ONLY</SW-CALIBRATION-ACCESS> <SW-IMPL-POLICY>STANDARD</SW-IMPL-POLICY> </SW-DATA-DEF-PROPS-CONDITIONAL> </SW-DATA-DEF-PROPS-VARIANTS> </SW-DATA-DEF-PROPS> <TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/DataTypes/float64</TYPE-TREF> <DIRECTION>OUT</DIRECTION> </ARGUMENT-DATA-PROTOTYPE> <ARGUMENT-DATA-PROTOTYPE UUID="..."> <SHORT-NAME>blkSize</SHORT-NAME> <CATEGORY>VALUE</CATEGORY> <SW-DATA-DEF-PROPS> <SW-DATA-DEF-PROPS-VARIANTS> <SW-DATA-DEF-PROPS-CONDITIONAL> <SW-CALIBRATION-ACCESS>READ-ONLY</SW-CALIBRATION-ACCESS> <SW-IMPL-POLICY>STANDARD</SW-IMPL-POLICY> </SW-DATA-DEF-PROPS-CONDITIONAL> </SW-DATA-DEF-PROPS-VARIANTS> </SW-DATA-DEF-PROPS> <TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/DataTypes/float64</TYPE-TREF> <DIRECTION>OUT</DIRECTION> </ARGUMENT-DATA-PROTOTYPE> </ARGUMENTS> </CLIENT-SERVER-OPERATION> </OPERATIONS> </CLIENT-SERVER-INTERFACE>
See Also
Architectural Data Editor | Interface Editor (System Composer)
Related Examples
- Configure AUTOSAR Client-Server Communication
- Programmatically Configure AUTOSAR Client-Server Communication
- Graphically Manage AUTOSAR Architectural Data