Main Content

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 defineSwSystemconsts for automobile features, such asTransmission,他叫dlight,Sunroof, andTurbocharge. Then aPredefinedVariantcan 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 aPredefinedVariantorSwsystemConstantValuesets for controlling variation points in the component, you can resolve the variation points at model creation time. Specify aPredefinedVariantorSwsystemConstantValuesets with which the importer can initializeSwSystemconstdata.

Typical steps include:

  1. Get a list of thePredefinedVariants orSwsystemConstantValuesets 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'
  2. Create a model from the ARXML file, and specify aPredefinedVariantor one or moreSwsystemConstantValuesets.

    This example specifiesPredefinedVariantSenior, which describes a combination of values forTransmission,他叫dlight,Sunroof, andTurbocharge.

    >> createComponentAsModel(obj,compNames{1},'ModelPeriodicRunnablesAs','AtomicSubsystem',... 'PredefinedVariant','/pkg/body/Variants/Senior');

    This example specifiesSwsystemConstantValuesets A and B, which together provide values forSwSystemconsts in the AUTOSAR software component.

    >> createComponentAsModel(obj,compNames{1},'ModelPeriodicRunnablesAs','AtomicSubsystem',... 'SystemConstValueSets',{'/pkg/body/SystemConstantValues/A','/pkg/body/SystemConstantValues/B'});
  3. 在模型创建期间,ARXML进口商创建AUTOSAR.Parameterdata objects, with存储类set toSystemConstant. The importer initializes the system constant data with values based on the specifiedPredefinedVariantorSwsystemConstantValuesets.

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 theSwSystemconstdata that controls variation points without recreating the model. Call the AUTOSAR property functioncreateSystemConstants,并指定其他导入的PredefinedVariantor a different cell array ofSwsystemConstantValuesets. 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 importedPredefinedVariants andSwsystemConstantValuesets to ARXML code.

Related Examples

More About