Configure Subcomponent Data for AUTOSAR Calibration and Measurement
For any model in an AUTOSAR model reference hierarchy, you can configure the model data for run-time calibration and measurement. In submodels referenced from AUTOSAR software component models, you can map parameters, data stores, signals, and states to AUTOSAR parameters and variables. Submodel mapped internal data can be used in AUTOSAR 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.
Open the example model.
open_system('autosar_component');
In this example, AUTOSAR component model autosar_component
contains two instances of autosar_subcomponent
.
Each instance of autosar_subcomponent
receives a separate set of parameter values, which you can view in the Instance parameters tab of the Model block parameters dialog box.
To configure subcomponent data for run-time calibration and measurement, open the submodel standalone, that is, in a separate model window. Use the Code Mappings editor to:
Map submodel parameters to AUTOSAR component
PerInstanceParameter
s.Map submodel signals, states, and data stores to AUTOSAR
ArTypedPerInstanceMemory
variables.Set AUTOSAR code and calibration attributes for 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.
Map Submodel Parameters to AUTOSAR Component PerInstanceParameter
s
Open the example model autosar_subcomponent
.
open_system('autosar_subcomponent');
At the top level is a Simulink Function, for which the top model provides per-instance parameters. Open the Simulink Function.
From the Apps tab, open the AUTOSAR Component Designer app. Open the Code Mappings editor and select the Parameters tab. The example submodel has four model workspace parameters, including a lookup table parameter. To map each Simulink parameter to an AUTOSAR per-instance parameter, select each parameter and, in the Mapped To drop-down list, select PerInstanceParameter
.
Select the parameter engine_speed
. To view and modify additional AUTOSAR attributes for the per-instance parameter, click the icon. A properties dialog box opens.
For each AUTOSAR PerInstanceParameter
, you can modify the SwAddrMethod
(AUTOSAR memory section), the calibration data access, and the calibration data display format. For more information about parameter code and calibration attributes, see Map Submodel Parameters to AUTOSAR Component Parameters.
When you generate code from the component model that references the submodel:
Exported ARXML files contain PER-INSTANCE-PARAMETERS descriptions for submodel parameters that you configured as AUTOSAR component
PerInstanceParameter
s, and descriptions of theSwAddrMethod
s referenced in the submodel.Generated C code references the submodel AUTOSAR per-instance parameters.
The model build generates macros that provide access to the submodel data for SIL and PIL testing and calibration in the AUTOSAR run-time environment.
Map Submodel Data Stores to AUTOSAR ArTypedPerInstanceMemory
Variables
If they are not already open, open the example model autosar_subcomponent
, the top-level Simulink Function, the AUTOSAR Component Designer app, and the Code Mappings editor.
In the Code Mappings editor, select the Data Stores tab. The example submodel has a Data Store Memory block named DSM_local
. To map the Simulink data store to an AUTOSAR-typed per-instance memory variable, select DSM_local
. Selecting a data store highlights the Data Store Memory block in the model diagram. In the Mapped To drop-down list, select ArTypedPerInstanceMemory
.
To view and modify additional AUTOSAR attributes for the per-instance memory, click the icon. A properties dialog box opens.
For each AUTOSAR ArTypedPerInstanceMemory
variable, you can modify the ARXML short name, the SwAddrMethod
(AUTOSAR memory section), the calibration data access, and the calibration data display format. For more information about data store code and calibration attributes, see Map Submodel Data Stores to AUTOSAR Variables.
When you generate code from the component model that references the submodel:
Exported ARXML files contain AR-TYPED-PER-INSTANCE-MEMORYS descriptions for submodel data stores that you configured as
ArTypedPerInstanceMemory
variables, and descriptions of theSwAddrMethods
referenced in the submodel.Generated C code references the submodel AUTOSAR-typed per-instance memory variables.
The model build generates macros that provide access to the submodel data for SIL and PIL testing and calibration in the AUTOSAR run-time environment.
Map Submodel Signals and States to AUTOSAR ArTypedPerInstanceMemory
Variables
If they are not already open, open the example model autosar_subcomponent
, the top-level Simulink Function, the AUTOSAR Component Designer app, and the Code Mappings editor.
In the Code Mappings editor, select the Signals/States tab. The Signals/States tab lists each Simulink block signal and state that you can map to an AUTOSAR variable. The example submodel has three mappable signals and one state. To map each Simulink signal and state to an AUTOSAR-typed per-instance memory variable, select each signal or state. Selecting a signal or state highlights the element in the model diagram. In the Mapped To drop-down list, select ArTypedPerInstanceMemory
.
To make additional 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.
In the Code Mappings editor, select the signal lutOutSig
. To view and modify additional AUTOSAR attributes for the per-instance memory, click the icon. A properties dialog box opens.
For each AUTOSAR ArTypedPerInstanceMemory
variable, you can modify the ARXML short name, the SwAddrMethod
(AUTOSAR memory section), the calibration data access, and the calibration data display format. For more information about signal and state code and calibration attributes, see Map Submodel Signals and States to AUTOSAR Variables.
Build and Generate Code
Build and generate code from the component model autosar_component
that references the submodel.
Exported ARXML files contain AR-TYPED-PER-INSTANCE-MEMORYS descriptions for submodel signals and states that you configured as
ArTypedPerInstanceMemory
, and descriptions of theSwAddrMethod
s referenced in the submodel.
Generated C code references the submodel AUTOSAR-typed per-instance memory variables.
The model build generates macros that provide access to the submodel data for SIL and PIL testing and calibration in the AUTOSAR run-time environment.