Main Content

Map Calibration Data for Submodels Referenced from AUTOSAR Component Models

In a Simulink® implementation of an AUTOSAR design, model references allow you to organize and manage large or numerous AUTOSAR components hierarchically. You can define an algorithm in a submodel and reference it repeatedly. Referenced models compile independently from the models that use them, which allows modular development, reuse and sharing of algorithms across multiple components and designs, and incremental code generation.

For any model in an AUTOSAR model reference hierarchy, you can configure the model data for run-time calibration. In submodels referenced from AUTOSAR software component models, you can use the Code Mappings editor or equivalent functions to map parameters, data stores, signals, and states. Submodel mapped internal data can be used in memory sections, and is available for software-in-the-loop (SIL) and processor-in-the-loop (PIL) testing from the top model or calibration in the AUTOSAR run-time environment.

Submodel Data Mapping Workflow

To map Simulink submodel elements to AUTOSAR software component elements:

  • Configure the submodel as a model referenced from an AUTOSAR software component model. Use the AUTOSAR Component Quick Start or the AUTOSAR function autosar.api.create.

  • In the AUTOSAR code perspective, use the Code Mappings editor to configure the submodel internal data.

  • To generate C code and AUTOSAR XML (ARXML) files that support run-time calibration of the submodel internal data, open and build the component model that references the submodel.

For this example, select a model that is referenced from an AUTOSAR software component model. This example uses mAutosarSubModel, which is referenced twice in the AUTOSAR component model mAutosarTopModel. You can copy the models from matlabroot/help/toolbox/autosar/examples (cd to folder) to a working folder.

Open the submodel standalone, that is, in a separate model window. In the model window, from the Apps tab, open the AUTOSAR Component Designer app. If the submodel is mapped, it opens in the AUTOSAR code perspective.

If the submodel is unmapped, the AUTOSAR Component Quick Start opens. Work through the quick-start procedure. In the Set Component pane, select Model referenced from AUTOSAR software component model

When you complete the quick-start procedure and click Finish, the submodel opens in the AUTOSAR code perspective.

In the AUTOSAR code perspective, use the Code Mappings editor to:

  • Map individual parameters to PerInstanceParameters.

  • If block signals that must be mapped to AUTOSAR variables are not displayed in the Code Mappings editor, select the signals and add them to the mapping table.

  • Map individual signals, states, and data stores to ArTypedPerInstanceMemorys.

  • After setting the Mapped To property for a parameter, signal, state, or data store, use the Property Inspector to set code and calibration attributes.

If you have Simulink Coder™ and Embedded Coder® software, you can build the component model that references the submodel. When you build, the exported ARXML files and generated C code support run-time calibration of the submodel internal data. The ARXML files exported for the top model include descriptions of the submodel parameters, signals, states, and data stores, as well as software address methods used in the submodel. The generated C code references the submodel internal data. The model build also generates macros that provide access to the submodel data for SIL and PIL testing and calibration in the AUTOSAR run-time environment. For more information, see Generate Submodel Data Macros for Verification and Deployment.

To programmatically configure a submodel as a model referenced from an AUTOSAR software component model, call the AUTOSAR function autosar.api.create and specify the name-value pair argument 'ReferencedFromComponentModel',true. For example:

hModel = 'mAutosarSubModel';
open_system(hModel);
autosar.api.create(hModel,'default','ReferencedFromComponentModel',true);

To programmatically add shared definitions of software address methods to use with the submodel, call the AUTOSAR importer function updateModel and specify the name of an AUTOSAR XML (ARXML) file containing the shared definitions. For example:

ar = arxml.importer('SwAddrMethods.arxml');
updateModel(ar,hModel);

Map Submodel Parameters to AUTOSAR Component Parameters

On the Parameters tab of the Code Mappings editor, you can map Simulink submodel parameters to AUTOSAR per-instance parameters for AUTOSAR run-time calibration. Examples of model workspace parameters you can map include:

  • Simulink parameter objects

  • Simulink lookup table objects

  • Simulink breakpoint objects

By mapping lookup table and breakpoint objects to AUTOSAR internal calibration parameters, you can model AUTOSAR parameters for integrated and distributed lookups. For more information, see Configure Lookup Tables for AUTOSAR Measurement and Calibration.

After creating model workspace parameters in your model, for example, using Model Explorer, open the Code Mappings editor and select the Parameters tab. Select Simulink model workspace parameters and map them to AUTOSAR component per-instance parameters.

For more information, see Configure Model Workspace Parameters as AUTOSAR Per-Instance Parameters.

The Parameters tab lists each Simulink model workspace parameter that you can map to an AUTOSAR parameter. You can:

  • Map a parameter by selecting it and then selecting a menu value for an AUTOSAR parameter type: PerInstanceParameter or Auto. To accept software mapping defaults, specify Auto.

    For example, here is the Parameters tab for submodel mAutosarSubModel. AUTOSAR software component model mAutosarTopModel contains two instances of mAutosarSubModel.

  • If you select parameter type PerInstanceParameter, use the Property Inspector to view or modify other code and calibration attributes for the parameter.

    AttributePurpose
    SwAddrMethodSelect a SwAddrMethod name from the names listed as valid for the AUTOSAR parameter. Code generation uses the SwAddrMethod name to group AUTOSAR parameters in a memory section for access by measurement and calibration tools. For more information, see Configure SwAddrMethod.
    SwCalibrationAccessSpecify how measurement and calibration tools can access the AUTOSAR parameter. Valid access values include ReadOnly, ReadWrite, and NotAccessible. For more information, see Configure SwCalibrationAccess.
    DisplayFormatSpecify display format for the AUTOSAR parameter. AUTOSAR display format specifications control the width and precision display for measurement and calibration data. For more information, see Configure DisplayFormat.

Map Submodel Data Stores to AUTOSAR Variables

On the Data Stores tab of the Code Mappings editor, you can map Simulink submodel data store memory blocks to AUTOSAR-typed per-instance memory elements for AUTOSAR run-time calibration.

After creating data store memory blocks in your model, open the Code Mappings editor and select the Data Stores tab. Select data stores and map them to AUTOSAR-typed per-instance memory elements. For more information, see Configure AUTOSAR Per-Instance Memory.

The Data Stores tab lists each Simulink data store that you can map to an AUTOSAR variable. You can:

  • Map a data store by selecting the data store, and then selecting a menu value for an AUTOSAR variable type: ArTypedPerInstanceMemory or Auto. To accept software mapping defaults, specify Auto.

    For example, here is the Local Data Stores tab for submodel mAutosarSubModel. AUTOSAR software component model mAutosarTopModel contains two instances of mAutosarSubModel.

  • If you select variable type ArTypedPerInstanceMemory, use the Property Inspector to view or modify other code and calibration attributes for the variable.

    AttributePurpose
    ShortName

    Specify short name for the AUTOSAR variable. If unspecified, ARXML export generates a short name.

    SwAddrMethodSelect a SwAddrMethod name from the names listed as valid for the AUTOSAR variable. Code generation uses the SwAddrMethod name to group AUTOSAR variables in a memory section for access by measurement and calibration tools. For more information, see Configure SwAddrMethod.
    SwCalibrationAccessSpecify how measurement and calibration tools can access the AUTOSAR variable. Valid access values include ReadOnly, ReadWrite, and NotAccessible. For more information, see Configure SwCalibrationAccess.
    DisplayFormatSpecify display format for the AUTOSAR variable. AUTOSAR display format specifications control the width and precision display for measurement and calibration data. For more information, see Configure DisplayFormat.

Map Submodel Signals and States to AUTOSAR Variables

On the Signals/States tab of the Code Mappings editor, you can map Simulink submodel block signals and states to AUTOSAR-typed per-instance memory elements for AUTOSAR run-time calibration.

In the Code Mappings editor, Simulink block states that correspond to state owner blocks are available for mapping.

To make Simulink block signals available for mapping, use a Code Mappings editor button or a model cue:

  • In the model canvas, select one or more signals. Open the Code Mappings editor, Signals/States tab, and click the Add button .

  • In the model canvas, select a signal. Place your cursor over the displayed ellipsis and select model cue Add selected signals to code mappings.

Alternatively, call MATLAB® function addSignal.

After selectively adding block signals to AUTOSAR signal mapping, open the Code Mappings editor and select the Signals/States tab. Select block signals and states and map them to AUTOSAR-typed per-instance memory elements. For more information, see Configure AUTOSAR Per-Instance Memory.

The Signals/States tab lists each Simulink block signal and state that you can map to an AUTOSAR variable. You can:

  • Map a Simulink signal or state by selecting the signal or state, and then selecting a menu value for an AUTOSAR variable type: ArTypedPerInstanceMemory or Auto. To accept software mapping defaults, specify Auto.

    For example, here is the Signals/States tab for submodel mAutosarSubModel. AUTOSAR software component model mAutosarTopModel contains two instances of mAutosarSubModel.

  • If you select variable type ArTypedPerInstanceMemory, use the Property Inspector to view or modify other code and calibration attributes for the variable.

    AttributePurpose
    ShortName

    Specify short name for the AUTOSAR variable. If unspecified, ARXML export generates a short name.

    • For signals, the auto-generated short name can differ from the signal name.

    • For states, the auto-generated short name is based on the state name if one exists. If the state is unnamed, the generated name can differ from the block name.

    SwAddrMethodSelect a SwAddrMethod name from the names listed as valid for the AUTOSAR variable. Code generation uses the SwAddrMethod name to group AUTOSAR variables in a memory section for access by measurement and calibration tools. For more information, see Configure SwAddrMethod.
    SwCalibrationAccessSpecify how measurement and calibration tools can access the AUTOSAR variable. Valid access values include ReadOnly, ReadWrite, and NotAccessible. For more information, see Configure SwCalibrationAccess.
    DisplayFormatSpecify display format for the AUTOSAR variable. AUTOSAR display format specifications control the width and precision display for measurement and calibration data. For more information, see Configure DisplayFormat.

To remove Simulink block signals from AUTOSAR signal mapping, use a Code Mappings editor button or a model cue:

  • In the model canvas or on the Signals/States tab, select one or more signals. On the Signals/States tab, click the Remove button .

  • In the model canvas, select a signal. Place your cursor over the displayed ellipsis and select model cue Remove selected signals from code mappings.

Alternatively, call MATLAB function removeSignal.

Generate Submodel Data Macros for Verification and Deployment

When you build an AUTOSAR software component model that references a submodel, the exported ARXML files and generated C code support run-time calibration of the submodel internal data.

  • The ARXML files exported for the top model include descriptions of the submodel parameters, signals, states, and data stores, as well as software address methods used in the submodel.

  • The generated C code references the submodel internal data.

The model build also generates macros that provide access to the submodel mapped internal data for SIL and PIL testing from the referencing component model, and calibration in the AUTOSAR run-time environment. If an AUTOSAR component model build encompasses a referenced model with mapped internal data, the generated submodel header file references these macros:

  • INCLUDE_RTE_HEADER — Flag indicating whether to include an RTE component header.

  • RTE_COMPONENT_HEADER — Name of a header file containing definitions for submodel internal parameters, signals, states, and data stores.

For example, if you build AUTOSAR software component model mAutosarTopModel, which contains two instances of mAutosarSubModel, the generated file mAutosarSubModel.h contains this code.

#ifdef INCLUDE_RTE_HEADER
#include RTE_COMPONENT_HEADER
#endif

If you run top-model SIL or PIL testing from an AUTOSAR software component model that references a mapped submodel, the SIL or PIL model build automatically picks up the submodel internal data definitions.

When you integrate the generated code into an AUTOSAR run-time environment, you must configure the INCLUDE_RTE_HEADER and RTE_COMPONENT_HEADER macros to include the submodel internal data definitions.

See Also

|

Related Examples

More About