To define the values that control variation points in an AUTOSAR software component, components use the following AUTOSAR elements:
SwSystemconst
— Defines a system constant that
serves as an input to control a variation point.
SwSystemconstantValueSet
— Specifies a set of system
constant values to apply to an AUTOSAR software component.
PredefinedVariant
— Describes a combination of
system constant values, among potentially multiple valid combinations, to apply
to an AUTOSAR software component.
For example, in ARXML code, you can define
SwSystemconst
s for automobile features, such as
Transmission
, Headlight
,
Sunroof
, and Turbocharge
. Then a
PredefinedVariant
can map feature combinations to automobile
model variants, such as Basic
, Economy
,
Senior
, Sportive
, and
Junior
.
Suppose that you have an ARXML specification of an AUTOSAR software
component. If the ARXML files also define a
PredefinedVariant
or SwSystemconstantValueSet
s
for controlling variation points in the component, you can resolve the variation points
at model creation time. Specify a PredefinedVariant
or
SwSystemconstantValueSet
s with which the importer can initialize
SwSystemconst
data.
Typical steps include:
Get a list of the PredefinedVariant
s or
SwSystemconstantValueSet
s defined in the
ARXML file.
>> obj = arxml.importer('mySWC.arxml'); >> find(obj,'/','PredefinedVariant','PathType','FullyQualified'); ans = '/pkg/body/Variants/Basic' '/pkg/body/Variants/Economy' '/pkg/body/Variants/Senior' '/pkg/body/Variants/Sportive' '/pkg/body/Variants/Junior'
>> obj = arxml.importer('mySWC.arxml'); >> find(obj,'/','SystemConstValueSet','PathType','FullyQualified') ans = '/pkg/body/SystemConstantValues/A' '/pkg/body/SystemConstantValues/B' '/pkg/body/SystemConstantValues/C' '/pkg/body/SystemConstantValues/D'
Create a model from the ARXML file, and specify a
PredefinedVariant
or one or more
SwSystemconstantValueSet
s.
This example specifies PredefinedVariant
Senior, which
describes a combination of values for Transmission
,
Headlight
, Sunroof
, and
Turbocharge
.
>> createComponentAsModel(obj,compNames{1},'ModelPeriodicRunnablesAs','AtomicSubsystem',... 'PredefinedVariant','/pkg/body/Variants/Senior');
This example specifies SwSystemconstantValueSet
s A and B,
which together provide values for SwSystemconst
s in the
AUTOSAR software component.
>> createComponentAsModel(obj,compNames{1},'ModelPeriodicRunnablesAs','AtomicSubsystem',... 'SystemConstValueSets',{'/pkg/body/SystemConstantValues/A','/pkg/body/SystemConstantValues/B'});
During model creation, the ARXML importer creates
AUTOSAR.Parameter
data objects, with Storage
class set to SystemConstant
. The
importer initializes the system constant data with values based on the specified
PredefinedVariant
or
SwSystemconstantValueSet
s.
After model creation, you can run simulations and generate code based on the combination of variation point input values that you specified.
In Simulink®, you can redefine the SwSystemconst
data that controls
variation points without recreating the model. Call the AUTOSAR property function
createSystemConstants
, and specify a different imported
PredefinedVariant
or a different cell array of
SwSystemconstantValueSet
s. The function creates a set of system
constant data objects with the same names as the original objects. You can run
simulations and generate code based on the revised combination of variation point input
values.
This example creates a set of system constant data objects with names and values based
on imported PredefinedVariant
'/pkg/body/Variants/Economy'
.
arProps = autosar.api.getAUTOSARProperties(hModel); createSystemConstants(arProps,'/pkg/body/Variants/Economy');
Building the model exports previously imported PredefinedVariant
s
and SwSystemconstantValueSet
s to ARXML
code.