Configure AUTOSAR Shared or Per-Instance Parameters
You can model AUTOSAR shared parameters (SharedParameter
s) and
per-instance parameters (PerInstanceParameter
s) for use in AUTOSAR
software components that potentially are instantiated multiple times. Shared parameter
values are shared among all instances of a component. Per-instance parameter values are
unique and private to each component instance. In the AUTOSAR run-time environment,
calibration tools can access SharedParameter
s and
PerInstanceParameter
s for calibration and measurement.
To model AUTOSAR shared or per-instance parameters, import parameter definitions from ARXML files or create parameter content in Simulink®. For information about the high-level shared and per-instance parameters workflow, see Shared and Per-Instance Parameters.
To model AUTOSAR parameters in Simulink, you use model workspace parameters.
Configure Model Workspace Parameters as AUTOSAR Shared Parameters
To model AUTOSAR shared parameters in Simulink:
Open an AUTOSAR model that contains a model workspace parameter for which you want to generate an AUTOSAR
SharedParameter
. This example uses modelautosar_swc_counter
.To model an AUTOSAR shared parameter in Simulink, configure a model workspace parameter that is not a model argument (that is, not unique to each instance of a multi-instance model). For example, in the Model Explorer view of the parameter, clear the Argument property. In example model
autosar_swc_counter
, clear the Argument property for parameter K. Leave the parameter StorageClass set toAuto
.In the AUTOSAR Code perspective, open the Code Mappings editor and select the Parameters tab. In the list of available parameters, select
K
. In the Mapped To drop-down list, select parameter typeSharedParameter
. To view and modify AUTOSAR attributes for the shared parameter, click the icon. For more information about parameter code and calibration attributes, see Map Model Workspace Parameters to AUTOSAR Component Parameters.
When you generate code:
Exported ARXML files contain
SHARED-PARAMETERS
descriptions for parameters that you configured asSharedParameter
.Generated C code contains
Rte_CData
calls where shared parameters are used.autosar_swc_counter_B.Gain = Rte_CData_K() * Rte_IRead_Runnable_Step_RPort_InData();
Configure Model Workspace Parameters as AUTOSAR Per-Instance Parameters
To model AUTOSAR per-instance parameters in Simulink:
Open an AUTOSAR model that contains a model workspace parameter for which you want to generate an AUTOSAR
PerInstanceParameter
. This example uses modelautosar_swc_throttle_sensor
. This model is part of AUTOSAR composition modelautosar_composition
, which contains two instances ofautosar_swc_throttle_sensor
.To model an AUTOSAR per-instance parameter in Simulink, configure a model workspace parameter that is a model argument (that is, unique to each instance of a multi-instance model). For example, in the Model Explorer view of the parameter, select the Argument property. In example model
autosar_swc_throttle_sensor
, select the Argument property for parameterTPSPercent_LkupTbl
. Leave the parameter StorageClass set toAuto
.In the AUTOSAR Code perspective, open the Code Mappings editor and select the Parameters tab. Select parameter
TPSPercent_LkupTbl
. In the Mapped To drop-down list, select parameter typePerInstanceParameter
. To view and modify AUTOSAR attributes for the per-instance parameter, click the icon. For more information about parameter code and calibration attributes, see Map Model Workspace Parameters to AUTOSAR Component Parameters. If you are mapping parameters in a submodel referenced by a component, see Map Submodel Parameters to AUTOSAR Component Parameters.
AUTOSAR example model autosar_composition
is a composition
model that contains several components, including two instances of component model
autosar_swc_throttle_sensor
.
If you open autosar_composition
, you can right-click the
Model blocks that represent instances of
autosar_swc_throttle_sensor
. If you open up each
Model block dialog box, Instance Parameters
tab, and view them together, notice that each Model block uses a
different value for the per-instance parameter.
When you generate code:
Exported ARXML files contain
PER-INSTANCE-PARAMETERS
descriptions for parameters that you configured asPerInstanceParameter
.Generated C code contains
Rte_CData
calls where per-instance parameters are used.Rte_IWrite_Runnable_Step_TPS_Percent_Value(self, look1_iflf_linlcpw((float32) rtb_DataTypeConversion, (Rte_CData_TPSPercent_LkupTbl(self))->BP1, (Rte_CData_TPSPercent_LkupTbl(self))->Table, 10U));
See Also
Related Examples
- Map Model Workspace Parameters to AUTOSAR Component Parameters
- Map Submodel Parameters to AUTOSAR Component Parameters
- Model AUTOSAR Component Behavior