Main Content

Configure AUTOSAR Adaptive Elements and Properties

In Simulink®, you can use the AUTOSAR Dictionary and the Code Mappings editor separately or together to graphically configure an AUTOSAR adaptive software component and map Simulink model elements to AUTOSAR component elements. For more information, see AUTOSAR Component Configuration.

Use the AUTOSAR Dictionary to configure AUTOSAR elements from an AUTOSAR perspective. Using a tree format, the AUTOSAR Dictionary displays a mapped AUTOSAR adaptive component and its elements, communication interfaces, and XML options. Use the tree to select AUTOSAR elements and configure their properties. The properties that you modify are reflected in exported ARXML descriptions and potentially in generated AUTOSAR-compliant C++ code.

AUTOSAR Elements Configuration Workflow

To configure AUTOSAR component elements for the Adaptive Platform in Simulink:

  1. Open a model for which AUTOSAR system target file autosar_adaptive.tlc is selected.

  2. Create or open a mapped view of the AUTOSAR model. In the model window, do one of the following:

    • From the Apps tab, open the AUTOSAR Component Designer app.

    • Click the perspective control in the lower-right corner and select Code.

    If the model has not yet been mapped to an AUTOSAR software component, the AUTOSAR Component Quick Start opens. Work through the quick-start procedure and click Finish. For more information, see Create Mapped AUTOSAR Component with Quick Start.

    The model opens in the AUTOSAR code perspective. This perspective displays a help panel, a Property Inspector dialog box, and, directly under the model, the Code Mappings editor.

  3. Open the AUTOSAR Dictionary. Either click the AUTOSAR Dictionary button in the Code Mappings editor or, on the AUTOSAR tab, select Code Interface > AUTOSAR Dictionary.

  4. To configure AUTOSAR elements and properties, navigate the AUTOSAR Dictionary tree. You can add elements, remove elements, or select elements to view and modify their properties. Use the Filter Contents field (where available) to selectively display some elements, while omitting others, in the current view.

  5. After configuring AUTOSAR adaptive elements and properties, open the Code Mappings editor. Use Code Mapping tabs to map Simulink elements to new or modified AUTOSAR elements.

  6. To validate the AUTOSAR component configuration, click the Validate button . If errors are reported, address them and then retry validation.

Configure AUTOSAR Adaptive Software Components

AUTOSAR adaptive software components contain AUTOSAR elements defined in the AUTOSAR standard, such as required ports and provided ports. In the AUTOSAR Dictionary, component elements appear in a tree format under the component that owns them. To access component elements and their properties, you expand the component name.

To configure AUTOSAR adaptive software component elements and properties:

  1. Open a model for which a mapped AUTOSAR adaptive software component has been created. For more information, see Component Creation.

  2. From the Apps tab, open the AUTOSAR Component Designer app.

  3. Open the AUTOSAR Dictionary. Either click the AUTOSAR Dictionary button in the Code Mappings editor or, on the AUTOSAR tab, select Code Interface > AUTOSAR Dictionary.

  4. In the leftmost pane of the AUTOSAR Dictionary, under AUTOSAR, select AdaptiveApplications.

    The adaptive applications view in the AUTOSAR Dictionary displays adaptive software components. You can rename an AUTOSAR adaptive component by clicking its name and then editing the name text.

  5. In the leftmost pane of the AUTOSAR Dictionary, expand AdaptiveApplications and select an AUTOSAR adaptive component.

    The component view in the AUTOSAR Dictionary displays the name and type of the selected component, and component options for ARXML file export. You can modify the AUTOSAR package to be generated for the component.

    To specify the AUTOSAR package path, you can do either of the following:

    • Enter a package path in the Package parameter field. Package paths can use an organizational naming pattern, such as /CompanyName/Powertrain.

    • To open the AUTOSAR Package Browser, click the button to the right of the Package field. Use the browser to navigate to an existing package or create a package. When you select a package in the browser and click Apply, the component Package parameter value is updated with your selection. For more information about the AUTOSAR Package Browser, see Configure AUTOSAR Package for Component, Interface, CompuMethod, or SwAddrMethod.

    For more information about component XML options, see Configure AUTOSAR Packages.

Configure AUTOSAR Required and Provided Ports

An AUTOSAR adaptive software component contains service communication ports defined in the AUTOSAR standard, including required and provided ports. In the AUTOSAR Dictionary, communication ports appear in a tree format under the component that owns them and under a port type name. To access port elements and their properties, you expand the component name and expand the port type name.

The AUTOSAR Dictionary views of required and provided ports support modeling AUTOSAR service interface communication in Simulink. You use the AUTOSAR Dictionary to configure AUTOSAR required and provided ports, service interfaces, service interface events, and C++ namespaces in your model. For more information, see Model AUTOSAR Adaptive Service Communication.

To configure AUTOSAR required and provided port elements, open a model for which a mapped AUTOSAR adaptive software component has been created and open the AUTOSAR Dictionary.

  1. In the leftmost pane of the AUTOSAR Dictionary, expand the component name and select RequiredPorts.

    The required ports view in the AUTOSAR Dictionary lists required ports and their properties. You can:

    • Select an AUTOSAR required port, and view and optionally reselect its associated service interface.

    • Rename an AUTOSAR required port by clicking its name and then editing the name text.

    • To configure adaptive service instance identification for a port, select the port and view its Manifest attributes. Based on the service instance form selected in XML options, examine the value for Instance Specifier or Instance Identifier. You can enter a value or accept an existing value. For more information, see Configure AUTOSAR Adaptive Service Instance Identification.

    • To configure the adaptive service discovery behavior for a required port, select the port and view its Service Discovery Mode. You can select mode OneTime or DynamicDiscovery. For more information, see Configure AUTOSAR Adaptive Service Discovery Modes.

    • To add a port, click the Add button and use the Add Ports dialog box.

    • To remove a port, select the port and then click the Delete button .

    The Add Ports dialog box lets you add a required port and associate it with an existing service interface. To add the port and return to the required ports view, click Add.

  2. In the leftmost pane of the AUTOSAR Dictionary, select ProvidedPorts.

    The provided ports view in the AUTOSAR Dictionary lists provided ports and their properties. You can:

    • Select an AUTOSAR provided port, and view and optionally reselect its associated service interface.

    • Rename an AUTOSAR provided port by clicking its name and then editing the name text.

    • To configure adaptive service instance identification for a port, select the port and view its Manifest attributes. Based on the service instance form selected in XML options, examine the value for Instance Specifier or Instance Identifier. You can enter a value or accept an existing value. For more information, see Configure AUTOSAR Adaptive Service Instance Identification.

    • To add a port, click the Add button and use the Add Ports dialog box.

    • To remove a port, select the port and then click the Delete button .

    The Add Ports dialog box lets you add a provided port and associate it with an existing service interface. To add the port and return to the provided ports view, click Add.

Configure AUTOSAR Service Communication Interfaces

An AUTOSAR software component uses communication interfaces defined in the AUTOSAR standard, including adaptive service interfaces. In the AUTOSAR Dictionary, communication interfaces appear in a tree format under the interface type name. To access interface elements and their properties, you expand the interface type name.

The Service Interfaces view in the AUTOSAR Dictionary supports modeling AUTOSAR adaptive service communication in Simulink. You use the AUTOSAR Dictionary to configure AUTOSAR required and provided ports, service interfaces, service interface events, and C++ namespaces in your model. For more information, see Model AUTOSAR Adaptive Service Communication.

To configure AUTOSAR service interface elements and properties, open a model for which a mapped AUTOSAR adaptive software component has been created and open the AUTOSAR Dictionary.

  1. In the leftmost pane of the AUTOSAR Dictionary, select Service Interfaces.

    The service interfaces view in the AUTOSAR Dictionary lists AUTOSAR service interfaces and their properties. You can:

    • Select a service interface and rename it by editing its name text.

    • To add one or more service interfaces, click the Add button and use the Add Interfaces dialog box.

    • To remove a service interface, select the interface and then click the Delete button .

    In the Add Interfaces dialog box, specify the name of the interface, the number of associated events it contains, and the path of the Interface package. To add the interface and return to the service interfaces view, click Add.

  2. In the leftmost pane of the AUTOSAR Dictionary, expand Service Interfaces and select a service interface from the list.

    The service interface view in the AUTOSAR Dictionary displays the name of the selected service interface and the AUTOSAR package to be generated for the interface.

    To modify the AUTOSAR package for the interface, you can do either of the following:

    • Enter a package path in the Package parameter field.

    • To open the AUTOSAR Package Browser, click the button to the right of the Package field. Use the browser to navigate to an existing package or create a package. When you select a package in the browser and click Apply, the interface Package parameter value is updated with your selection. For more information about the AUTOSAR Package Browser, see Configure AUTOSAR Package for Component, Interface, CompuMethod, or SwAddrMethod.

  3. In the leftmost pane of the AUTOSAR Dictionary, expand the selected interface and select Events.

    The events view in the AUTOSAR Dictionary lists AUTOSAR service interface events and their properties. You can:

    • Select a service interface event and edit the name value.

    • Specify the level of measurement and calibration tool access to service interface events. Select an event and set its SwCalibrationAccess value to ReadOnly, ReadWrite, or NotAccessible.

    • Optionally specify the format to be used by measurement and calibration tools to display the event. In the DisplayFormat field, enter an ANSI® C printf format specifier string. For example, %2.1d specifies a signed decimal number. The number has a minimum width of two characters and a maximum precision of one digit, producing a displayed value such as 12.2. For more information about constructing a format specifier string, see Configure DisplayFormat.

    • To add an event, click the Add button .

    • To remove an event, select the event and then click the Delete button .

  4. In the leftmost pane of the AUTOSAR Dictionary, below Events, select Namespaces.

    The namespaces view in the AUTOSAR Dictionary allows you to define a unique namespace for each service interface. The code generator uses the defined namespace when producing C++ code for the interface. To modify or construct a namespace specification, you can:

    • Select a namespace element and edit the name value.

    • To add a namespace element to the namespace specification, click the Add button .

    • To remove a namespace element, select the element and then click the Delete button .

    For example, this namespaces view defines namespace company::chassis::provided for service interface ProvidedInterface.

Configure AUTOSAR Adaptive XML Options

To configure AUTOSAR adaptive XML options for ARXML export, open a model for which a mapped AUTOSAR adaptive software component has been created and open the AUTOSAR Dictionary. Select XML Options.

The XML options view in the AUTOSAR Dictionary displays XML export parameters and their values. You can configure:

  • XML file packaging for AUTOSAR elements created in Simulink

  • AUTOSAR package paths

  • Aspects of exported AUTOSAR XML content

Exported XML File Packaging

In the XML options view, you can specify the granularity of XML file packaging for AUTOSAR elements created in Simulink. (Imported AUTOSAR XML files retain their file structure, as described in Round-Trip Preservation of AUTOSAR XML File Structure and Element Information.) Select one of the following values for Exported XML file packaging.

  • Single file — Exports XML into a single file, modelname.arxml.

  • Modular — Exports XML into multiple files, named according to the type of information contained.

    Exported File NameBy Default Contains...
    modelname_component.arxml

    Adaptive software components, including required and provided ports.

    This is the main ARXML file exported for the Simulink model. In addition to software components, the component file contains packageable elements that the exporter does not move to data type or interface files based on AUTOSAR element category.

    modelname_datatype.arxml

    Data types and related elements, including:

    • Application data types

    • Standard Cpp implementation data types

    • Constant specifications

    • Physical data constraints

    • Units and unit groups

    • Software record layouts

    modelname_interface.arxmlAdaptive interfaces, including required and provided service interfaces with namespaces and events.

Alternatively, you can programmatically configure exported XML file packaging by calling the AUTOSAR set function. For property ArxmlFilePackaging, specify either SingleFile or Modular. For example:

arProps = autosar.api.getAUTOSARProperties(hModel);
set(arProps,'XmlOptions','ArxmlFilePackaging','SingleFile');

For the Adaptive Platform, model builds also generate XML manifests for AUTOSAR executables and service instances. For more information, see Generate AUTOSAR Adaptive C++ and XML Files.

AUTOSAR Package Paths

In the XML options view, you can configure AUTOSAR packages (AR-PACKAGEs), which contain groups of AUTOSAR elements and reside in a hierarchical AR-PACKAGE structure. (The AR-PACKAGE structure for a component is logically distinct from the ARXML file partitioning selected with the XML option Exported XML file packaging or imported from AUTOSAR XML files.) For more information about AUTOSAR packages, see Configure AUTOSAR Packages.

Inspect and modify the AUTOSAR package paths grouped under the headings Package Paths and Additional Packages.

Alternatively, you can programmatically configure an AUTOSAR package path by calling the AUTOSAR set function. Specify a package property name and a package path. For example:

arProps = autosar.api.getAUTOSARProperties(hModel);
set(arProps,'XmlOptions','ApplicationDataTypePackage',...
    '/Company/Powertrain/DataTypes/ApplDataTypes');

For more information about AUTOSAR package property names and defaults, see Configure AUTOSAR Packages and Paths.

Additional XML Options

In the XML options view, under the heading Additional Options, you can configure aspects of exported AUTOSAR XML content.

You can:

  • Optionally override the default behavior for generating AUTOSAR application data types in ARXML code. To force generation of an application data type for each AUTOSAR data type, change the value of ImplementationDataType Reference from Allowed to NotAllowed. For more information, see Control Application Data Type Generation.

  • Control the default value of the SwCalibrationAccess property of generated AUTOSAR measurement variables, calibration parameters, and signal and parameter data objects. Select one of the following values for SwCalibrationAccess DefaultValue:

    • ReadOnly — Read access only.

    • ReadWrite (default) — Read and write access.

    • NotAccessible — Not accessible with measurement and calibration tools.

    For more information, see Configure SwCalibrationAccess.

  • Optionally override the default behavior for generating internal data constraint information for AUTOSAR implementation data types in ARXML code. To force export of internal data constraints for implementation data types, select the option Internal DataConstraints Export. For more information, see Configure AUTOSAR Internal Data Constraints Export.

  • Specify the form in which to generate adaptive service instance information. Set Identify Service Instance Using to InstanceIdentifier or InstanceSpecifier. The form that you select is used to identify service instances in generated Proxy and Skeleton functions. For more information, see Configure AUTOSAR Adaptive Service Instance Identification.

Alternatively, you can programmatically configure the additional XML options by calling the AUTOSAR set function. Specify a property name and value. The valid property names are ImplementationTypeReference, SwCalibrationAccessDefault, InternalDataConstraintExport, and IdentifyServiceInstance. For example:

arProps = autosar.api.getAUTOSARProperties(hModel);
set(arProps,'XmlOptions','ImplementationTypeReference','NotAllowed');
set(arProps,'XmlOptions','SwCalibrationAccessDefault','ReadOnly');
set(arProps,'XmlOptions','InternalDataConstraintExport',true);
set(arProps,'XmlOptions','IdentifyServiceInstance','InstanceSpecifier')

Related Examples

More About