Contenu principal

makeVariantAssembly

Convert variant component to variant assembly component

Since R2023b

Description

variantAssemblyComp = makeVariantAssembly(variantComponent) converts the Variant Component block variantComponent to a Variant Assembly Component block and returns the Variant Assembly Component block object variantAssemblyComp. Use this syntax if the variant control mode of the Variant Component block is label and has only Model blocks and Subsystem Reference blocks as its variant choices.

example

variantAssemblyComp = makeVariantAssembly(variantComponent,Name=Value) converts the Variant Component block variantComponent to a Variant Assembly Component block as specified by one or more Name-Value arguments and returns the Variant Assembly Component block object variantAssemblyComp. Use this syntax if the variant control mode of the Variant Component block is expression or has at least one inline component as its variant choice.

example

Examples

collapse all

This example explains how to convert a Variant Component block in label mode to a Variant Assembly Component using the makeVariantAssembly function.

Create a model, get its root architecture, and create a variant component in label model.

model = systemcomposer.createModel("VariantComponentInLabelMode");
systemcomposer.openModel("VariantComponentInLabelMode");
arch = get(model,"Architecture");
variantComp = addVariantComponent(arch,'Controller');

Set the variant control mode of the Controller block to label.

vacBlockHandle = variantComp.SimulinkHandle;
set_param(vacBlockHandle,'VariantControlMode','label');

Convert the Variant Component to a Variant Assembly Component using the makeVariantAssembly function.

variantAssemblyComp = makeVariantAssembly(variantComp,ReferenceFilesFolderPath=pwd)
variantAssemblyComp = 
  VariantComponent with properties:

           Architecture: [1×1 systemcomposer.arch.Architecture]
                   Name: 'Controller'
                 Parent: [1×1 systemcomposer.arch.Architecture]
                  Ports: [0×0 systemcomposer.arch.ComponentPort]
             OwnedPorts: [0×0 systemcomposer.arch.ComponentPort]
      OwnedArchitecture: [1×1 systemcomposer.arch.Architecture]
             Parameters: [0×0 systemcomposer.arch.Parameter]
               Position: [280 349 380 422]
                  Model: [1×1 systemcomposer.arch.Model]
         SimulinkHandle: 215.0500
    SimulinkModelHandle: 149.2601
                   UUID: '03ea3bbc-f27e-4935-b286-d71a63d968e7'
            ExternalUID: ''

This example explains how to convert a Variant Component block in expression mode to a Variant Assembly Component using the makeVariantAssembly function.

Create a model, get its root architecture, and create a variant component in expression model.

model = systemcomposer.createModel("VariantComponentInExpressionMode");
systemcomposer.openModel("VariantComponentInExpressionMode");
arch = get(model,"Architecture");
variantComp = addVariantComponent(arch,'Controller');

Set the variant control mode of the Controller block to expression.

vacBlockHandle = variantComp.SimulinkHandle;
set_param(vacBlockHandle,'VariantControlMode','expression');

Convert the Variant Component to Variant Assembly Component using the makeVariantAssembly function. During the conversion process:

  • The current configuration of Variant Component is validated.

  • Any inline component choices are converted to Subsystem Reference choices.

  • An inline component with architecture type composition is converted to a Subsystem Reference component with composition. A new architecture subsystem file is created in this process.

  • An inline component with architecture type Simulink® behavior is converted to a Subsystem Reference component with Simulink behavior. A new Simulink subsystem file is created in this process.

ReferenceFilesFolderPath = pwd;
vcvName = 'EngType';
enumClassFilePath = 'controllerClass.m';
variantAssemblyComp = makeVariantAssembly(variantComp,ReferenceFilesFolderPath = pwd,VariantControlVariableName=vcvName,EnumerationClassFilePath=enumClassFilePath)
variantAssemblyComp = 
  VariantComponent with properties:

           Architecture: [1×1 systemcomposer.arch.Architecture]
                   Name: 'Controller'
                 Parent: [1×1 systemcomposer.arch.Architecture]
                  Ports: [0×0 systemcomposer.arch.ComponentPort]
             OwnedPorts: [0×0 systemcomposer.arch.ComponentPort]
      OwnedArchitecture: [1×1 systemcomposer.arch.Architecture]
             Parameters: [0×0 systemcomposer.arch.Parameter]
               Position: [280 349 380 422]
                  Model: [1×1 systemcomposer.arch.Model]
         SimulinkHandle: 215.0236
    SimulinkModelHandle: 149.2085
                   UUID: 'ce1bdc5a-80b1-4b69-a843-7505063fcd6b'
            ExternalUID: ''

Input Arguments

collapse all

Variant component, specified as a systemcomposer.arch.VariantComponent object.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: makeVariantAssembly(variantComp,ReferenceFilesFolderPath=pwd,VariantControlVariableName=vcvName,EnumerationClassFilePath=enumClassFilePath,ReferenceComponentType="SubsystemReference")

Valid MATLAB variable name or structure field name to be created, specified as a string scalar or a character vector. For the naming rules, see Variable Names and Generate Field Names from Variables.

During simulation, Simulink® uses the value of this parameter to determine the active variant choice of the converted Variant Assembly Component block.

Example: 'EngType'

Dependencies

Use this argument if the VariantControlMode parameter of the Variant Component block is set to 'expression'.

Data Types: char | string

Absolute or relative path to the MATLAB class file to be created, specified as a string scalar or a character vector. During the block conversion, Simulink defines an enumeration class in the specified enumeration class file with the variant choices of the converted Variant Assembly Component block as its members.

Example: 'ControllerType.m'

Dependencies

Use this argument if the VariantControlMode parameter of the Variant Component block is set to 'expression'.

Data Types: char | string

Absolute or relative folder path where the subsystem reference choices of the converted Variant Assembly Component block must be saved as subsystem files, specified as a string scalar or a character vector.

Example: ReferenceFilesFolderPath = "ControllerChoices"

Dependencies

Use this argument if the Variant Component block has at least one inline component as its variant choice.

Data Types: char | string

Choice of model or subsystem reference component after conversion to Variant Assembly Component block. To convert inline components to architecture models or software architecture models, specify "ModelReference". To convert inline components to an architecture subsystem reference or Simulink subsystem reference, specify "SubsystemReference".

Note

The default reference component type for software architecture models is "ModelReference" and cannot be changed because these models do not support subsystem files.

Example: ReferenceComponentType="ModelReference"

Data Types: char | string

Output Arguments

collapse all

Variant assembly component, returned as a systemcomposer.arch.VariantComponent object.

Limitations

  • Only Variant Component blocks with Variant control mode set to label or expression can be converted to a Variant Assembly Component block.

  • The conversion from Variant Component to Variant Assembly Component is not supported for AUTOSAR architecture.

More About

collapse all

Alternatives

You can convert a Variant Component block to a Variant Assembly Component block interactively, through the Block Parameters dialog box, or programmatically. For more information, see Convert Variant Component to Variant Assembly Component.

Version History

Introduced in R2023b

expand all