Main Content

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

  1. Create a new AUTOSAR architecture model.

  2. Add three Classic Component blocks to the canvas and name them SensorManager, Sensor, and Monitor.

  3. Add a server port to the SensorManager Component block.

    1. Select the edge of the block and pause over the inport.

    2. Select Server from the options that appear.

      Server port selection on component block.

    3. Name the server port FrontSensorConfig.

  4. Add another server port to the SensorManager Component block.

    1. Select the edge of the block and pause over the inport.

    2. Select Server from the options that appear.

    3. Name the server port RearSensorConfig.

  5. In a similar way, add a client port named SensorConfig to the Sensor Component block.

    Client port selection on component block.

  6. Add an output port named SensorData to the Sensor Component block.

  7. Select the Sensor Component block and open the Property Inspector. From the Kind list, select SensorActuator.

    Component Sensor is selected, and in the Kind property in the Property Inspector is highlighted and set to SensorActuator.

  8. Add two input ports named FrontSensor and RearSensor and one output port named SensorData to the Monitor Component block.

  9. Draw a signal out of SensorData that exits the architecture on the edge of the canvas.

    An AUTOSAR architecture with three component blocks with client, server, input, and output ports.

Create and Assign Service Interfaces to Client-Server Ports

  1. 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.

  2. In the Architectural Data Editor select New to create a new data dictionary. Name the data dictionary ProximityInterfaces.

    Architectural Data Editor with ProximityInterfaces.sldd open.

  3. Add a service interface by selecting Service Interface from the Create section of the Architectural Data Editor toolstrip. Name the interface SensorConfig.

    Service interface option in the Design section.

  4. 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().

    The Interfaces tab in the Architectural Data Editor with AllData and SensorConfig expanded.

  5. Add a data interface to the dictionary and name it SensorData.

  6. Save the dictionary, and then close the Architectural Data Editor and return to the architecture canvas.

  7. 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.

  8. Assign the interfaces to the ports of the architecture model by using the Interface Editor (System Composer).

    1. Expand the ProximityInterfaces.sldd dictionary.

    2. Select the FrontSensorConfig port, and then right-click the SensorConfig interface in the Interface Editor.

    3. Click Assign to selected port(s) to assign SensorConfig as the interface for the FrontSensorConfig port.

    4. Similarly assign the SensorConfig service interface as the interface for the RearSensorConfig server port.

    5. Assign the SensorData data interface to the SensorData output ports on the Sensor and Monitor Component blocks.

    6. Assign the SensorData data interface to the input ports FrontSensor and RearSensor on the Monitor Component block. Save the model.

    The FrontSensorConfig port is highlighted and the SensorConfig Interface is highlighted in the Interface Editor, with the Assign to selected port(s) object highlighted.

  9. Connect the ports of the Component blocks.

    1. Connect the FrontSensorConfig server port to the SensorConfig client port on the Sensor Component block.

    2. Connect the SensorData output port of the Sensor Component block to the FrontSensor input port on the Monitor Component block.

  10. 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.

  11. Duplicate the Sensor Component block.

    The Sensor block is right clicked and Simulink behavior is created, right-clicking the Sensor block again, and holding the right mouse button the Sensor component is dragged and dropped on the canvas, creating a reference component block.

  12. Rename the original Sensor Component block as FrontProximitySensor, and rename the new Sensor1 Component block as RearProximitySensor.

  13. Connect the server ports of the Component blocks.

    1. Connect the RearSensorConfig server port to the SensorConfig client port on the RearProximitySensor Component block.

    2. Connect the output port SensorData of the RearProximitySensor Component block to the RearSensor input port on the Monitor Component block.

      The final architecture model, with all ports connected and simulink behavior for all four components.

  14. Save and export the architecture.

  15. Inspect the generated ARXML. Server ports are tagged by PROVIDER-IREF and client ports are tagged by REQUESTER-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

| (System Composer)

Related Examples

More About