主要内容

Configure AUTOSAR Adaptive Software Component Ports and Interfaces

R2026b

After you create an AUTOSAR Adaptive software component model in Simulink® (see Create AUTOSAR Adaptive Software Component Model), you configure software component ports, interfaces, and services. AUTOSAR Blockset software reduces the effort of configuring AUTOSAR Adaptive software components by providing the AUTOSAR Component Quick Start tool.

Configure AUTOSAR Adaptive Software Component Model

Configure the model as an AUTOSAR Adaptive software component by using the AUTOSAR Component Quick Start tool. Open your saved version of model my_autosar_LaneGuidance, and from the Apps tab, open the AUTOSAR Component Designer app. When you open the app for a model that uses autosar_adaptive.tlc system target file but has no AUTOSAR information saved for the model, then the AUTOSAR Component Quick Start tool runs.

AUTOSAR Component Quick Start tool AUTOSAR Platform pane. AUTOSAR Adaptive Platform is selected.

Advance through the steps of the AUTOSAR Component Quick Start tool. Each step prompts you for input that the tool uses to define your software component configuration. For this tutorial, use the defaults. After you click Finish, the tool:

  • Creates an initial software component service interface defining software component communication and execution behavior at run-time.

  • Opens the model in the AUTOSAR software component perspective. The AUTOSAR software component perspective shows an explicit boundary between the model algorithm and the boundary of the software component. Required and provided ports are created on the software component boundary.

  • Maps software component required and provided ports to root-level bus element ports in the model.

For example, In Bus Element blocks with the same port name, such as LeftSensor.LaneDistance, LeftSensor.TurnIndicator, LeftSensor.CarInBlindSpot all map to required port LeftSensor.

my_autosar_LaneGuidance model in the AUTOSAR software component perspective after running AUTOSAR Component Quick Start. LeftSensor, RightSensor, and HazardIndicator ports are visible on the software component boundary.

Configure AUTOSAR Adaptive Software Component Port Interface

An AUTOSAR Adaptive software component communicates with other software components through its provided and required ports. A required port consumes a service from its communication partners, and a provided port provides a service to its communication partners. Each software component port has a communication interface called an AUTOSAR Adaptive Service Interface, based on functional requirements of the component. You view AUTOSAR Adaptive Service Interfaces in the AUTOSAR Dictionary.

In Simulink, you define data port interfaces with Simulink.dictionary.archdata.DataInterface objects in the Architectural Data section of a data dictionary. You configure Simulink.dictionary.archdata.DataInterface objects for AUTOSAR code generation by specifying C++ namespaces and other code generation properties in the Architectural Data Editor. For more information about defining AUTOSAR Adaptive software component ports and interfaces, see Model AUTOSAR Adaptive Component and Elements in Simulink.

In this example, the PortInterfaces data dictionary already contains the interfaces used in this tutorial. Link the dictionary to the model, assign port interfaces, and configure C++ namespaces.

Link the data dictionary to my_autosar_LaneGuidance by using the set_param function. Then assign data interfaces to the appropriate ports by using set_param with the Bus: prefix.

set_param("my_autosar_LaneGuidance","DataDictionary","PortInterfaces.sldd");
set_param("my_autosar_LaneGuidance/LeftSensor","OutDataTypeStr","Bus: SensorInterface");
set_param("my_autosar_LaneGuidance/RightSensor","OutDataTypeStr","Bus: SensorInterface");
set_param("my_autosar_LaneGuidance/HazardIndicator","OutDataTypeStr","Bus: HazardInterface");

Next, configure C++ namespaces for the data interfaces in the Architectural Data Editor.

  1. Open the Architectural Data Editor by entering archdataeditor in the MATLAB® Command Window. Then, open the PortInterfaces data dictionary.

  2. In the Interfaces tab, select SensorInterface. In the right pane of the Architectural Data Editor, expand the Code Generation pane.

  3. Set C++ Namespace to company::chassis::perception. Set Header file to impl_type_interfaces.h.

  4. In the Interfaces tab, select HazardInterface and expand the Code Generation pane.

  5. Set C++ Namespace to company::chassis::actuation. Set Header file to impl_type_interfaces.h.

    Architectural Data Editor. PortInterfaces data dictionary is open showing Code Generation settings with the C++ Namespace and Header file properties set. .

Save and close the data dictionary. Save the model.

Configure AUTOSAR Service Interface and Communication Error Handling

Add and configure status elements for bus element ports in Simulink by using the Property Inspector or Service Mappings Editor. The Service Mappings Editor displays AUTOSAR required and provided ports in the Simulink model in a tabbed table format.

  1. First, copy the contents of the LaneGuidanceAlgorithm subsystem in example model autosar_LaneGuidance to replace the LaneGuidanceAlgorithm subsystem in my_autosar_LaneGuidance. This adds four inputs to the subsystem and disconnects existing ports in the model. Use the Service Mappings Editor to create status elements and map them to bus element ports.

  2. Open the Service Mappings Editor, from the Apps tab open the AUTOSAR Component Designer app, in the Prepare section click Service Mappings. Below the model the Service Mappings Editor opens. Select the Receivers tab, and verify that for each Source element, the editor shows these properties and values:

    • Receiver Service — Default: Queued

    • Status element — <None>

    • Initial value — 0

  3. Add a status element for LeftSensor.CarInBlindSpot by expanding the LeftSensor row and setting Status element to <Add Status Element>. The tool adds a new bus element port LeftSensor.CarInBlindSpot_status with a status badge to the Simulink canvas.

  4. Click the CarInBlindSpot row in the Service Mappings Editor and open the Property Inspector. Receiver port LeftSensor now contains elements CarInBlindSpot and CarInBlindSpot_status.

    In the Property Inspector, select bus element port CarInBlindSpot. On the Service tab, Status element is set to LeftSensor.CarInBlindSpot_status. In addition to Receiver service, Status element, and Initial value, you can edit these service communication and execution properties in the Property Inspector: Queue capacity, Timeout, and Sample time.

    Model my_autosar_LaneGuidance. The Service Mappings Editor and Property Inspector are open.

  5. Add status elements for LeftSensor.LaneDistance, RightSensor.LaneDistance, and RightSensor.CarInBlindSpot. Connect the bus element ports and status elements to the LaneGuidanceAlgorithm subsystem.

  6. Save the model.

Next, see Simulate AUTOSAR Adaptive Software Component Model and Generate Code.

See Also

Topics