Control AUTOSAR Variants with Predefined Value Combinations
为了定义控制AutoSar软件组件中变化点的值,组件使用以下AutoSar元素:
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 defineSwSystemconst
s for automobile features, such asTransmission
,他叫dlight
,Sunroof
, andTurbocharge
. Then aPredefinedVariant
can map feature combinations to automobile model variants, such asBasic
,Economy
,Senior
,Sportive
, andJunior
.
Suppose that you have an ARXML specification of an AUTOSAR software component. If the ARXML files also define aPredefinedVariant
orSwsystemConstantValueset
s for controlling variation points in the component, you can resolve the variation points at model creation time. Specify aPredefinedVariant
orSwsystemConstantValueset
s with which the importer can initializeSwSystemconst
data.
Typical steps include:
Get a list of the
PredefinedVariant
s orSwsystemConstantValueset
s defined in the ARXML file.>> obj = arxml.importer('myswc.arxml');>> find(obj,'/',“ predecinedvariant”,“ pathtype','flufliqualified');ans ='/pkg/body/variants/basic'''/pkg/body/variants/variants/variants'''/pkg/body/variants/senior''/pkg/body/variants/sportive/sportive''/pkg/pkg/body/variants/variants/variants/variants/variants/variants/初级'
>> obj = arxml.importer('myswc.arxml');>> find(obj,'/','systemConstvalueset','pathype','fluflyqualified')ans ='/pkg/pkg/body/system constantvalues/a'''/pkg/pkg/posssconconstantvalues/b'SystemConstantValues/c''/pkg/body/systemConstantValues/d'
Create a model from the ARXML file, and specify a
PredefinedVariant
or one or moreSwsystemConstantValueset
s.This example specifies
PredefinedVariant
Senior, which describes a combination of values forTransmission
,他叫dlight
,Sunroof
, andTurbocharge
.>> createComponentAsModel(obj,compNames{1},'ModelPeriodicRunnablesAs','AtomicSubsystem',... 'PredefinedVariant','/pkg/body/Variants/Senior');
This example specifies
SwsystemConstantValueset
s A and B, which together provide values forSwSystemconst
s in the AUTOSAR software component.>> createComponentAsModel(obj,compNames{1},'ModelPeriodicRunnablesAs','AtomicSubsystem',... 'SystemConstValueSets',{'/pkg/body/SystemConstantValues/A','/pkg/body/SystemConstantValues/B'});
在模型创建期间,ARXML进口商创建
AUTOSAR.Parameter
data objects, with存储类set toSystemConstant
. The importer initializes the system constant data with values based on the specifiedPredefinedVariant
orSwsystemConstantValueset
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 theSwSystemconst
data that controls variation points without recreating the model. Call the AUTOSAR property functioncreateSystemConstants
,并指定其他导入的PredefinedVariant
or a different cell array ofSwsystemConstantValueset
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 importedPredefinedVariant
'/pkg/body/Variants/Economy'
.
arProps = autosar.api.getAUTOSARProperties(hModel); createSystemConstants(arProps,'/pkg/body/Variants/Economy');
Building the model exports previously importedPredefinedVariant
s andSwsystemConstantValueset
s to ARXML code.