Main Content

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 variantComponent. Use this syntax if the variant control mode of the Variant Component block is label and has only Model blocks and Create and Use Referenced Subsystems in Models 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 variantComponent. Use this syntax if the variant control mode of the Variant Component block is expression or has at least one Subsystem block 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,SubsystemFilesFolderPath=pwd)
variantAssemblyComp = 
  VariantComponent with properties:

           Architecture: [1x1 systemcomposer.arch.Architecture]
                   Name: 'Controller'
                 Parent: [1x1 systemcomposer.arch.Architecture]
                  Ports: [0x0 systemcomposer.arch.ComponentPort]
             OwnedPorts: [0x0 systemcomposer.arch.ComponentPort]
      OwnedArchitecture: [1x1 systemcomposer.arch.Architecture]
             Parameters: [0x0 systemcomposer.arch.Parameter]
               Position: [280 349 380 422]
                  Model: [1x1 systemcomposer.arch.Model]
         SimulinkHandle: 218.0032
    SimulinkModelHandle: 152.0033
                   UUID: '2d0c60a2-cce7-4329-a22f-5da651c3b8bd'
            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.

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

           Architecture: [1x1 systemcomposer.arch.Architecture]
                   Name: 'Controller'
                 Parent: [1x1 systemcomposer.arch.Architecture]
                  Ports: [0x0 systemcomposer.arch.ComponentPort]
             OwnedPorts: [0x0 systemcomposer.arch.ComponentPort]
      OwnedArchitecture: [1x1 systemcomposer.arch.Architecture]
             Parameters: [0x0 systemcomposer.arch.Parameter]
               Position: [280 349 380 422]
                  Model: [1x1 systemcomposer.arch.Model]
         SimulinkHandle: 218.0031
    SimulinkModelHandle: 152.0032
                   UUID: 'ae4d71ec-17b1-4167-83cd-17b4ef9f86ce'
            ExternalUID: ''

Input Arguments

collapse all

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

Name-Value Arguments

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,SubsystemFilesFolderPath = pwd,VariantControlVariableName=vcvName,EnumerationClassFilePath=enumClassFilePath)

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: SubsystemFilesFolderPath = 'ControllerChoices'

Dependencies

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

Data Types: char | string

Output Arguments

collapse all

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

Limitations

  • Only Variant Component blocks with the 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 software architecture and AUTOSAR architecture.

More About

collapse all

Definitions

TermDefinitionApplicationMore Information
architecture

A System Composer™ architecture represents a system of components and how they interface with each other structurally and behaviorally.

Different types of architectures describe different aspects of systems. You can use views to visualize a subset of components in an architecture. You can define parameters on the architecture level using the Parameter Editor.

root

A root is at the top of an architecture hierarchy. A root architecture has a boundary defined by its architecture ports that surround the system of interest.

The root architecture has a system boundary surrounding your architecture model. You can add architecture ports that define interfaces across the boundary.

Compose Architectures Visually

model

A System Composer model is the file that contains architectural information, such as components, ports, connectors, interfaces, and behaviors.

Perform operations on a model:

  • Extract root-level architecture.

  • Apply profiles.

  • Link interface data dictionaries.

  • Generate instances from model architecture.

A System Composer model is stored as an SLX file.

Create Architecture Model with Interfaces and Requirement Links
component

A component is a replaceable part of a system that fulfills a clear function in the context of an architecture. A component defines an architectural element, such as a function, another system, hardware, software, or other conceptual entity. A component can also be a subsystem or subfunction.

Represented as a block, a component is a part of an architecture model that can be separated into reusable artifacts. Transfer information between components with:

Compose Architectures Visually

port

A port is a node on a component or architecture that represents a point of interaction with its environment. A port permits the flow of information to and from other components or systems.

  • Component ports are interaction points on the component to other components.

  • Architecture ports are ports on the boundary of the system, whether the boundary is within a component or the overall architecture model. The root architecture has a boundary defined by its ports.

Compose Architectures Visually

connector

Connectors are lines that provide connections between ports. Connectors describe how information flows between components or architectures.

A connector allows two components to interact without defining the nature of the interaction. Set an interface on a port to define how the components interact.

Compose Architectures Visually

TermDefinitionApplicationMore Information
variant

A variant is one of many structural or behavioral choices in a variant component.

Use variants to quickly swap different architectural designs for a component while performing analysis.

Create Variants
variant control

A variant control is a string that controls the active variant choice.

Set the variant control programmatically to control which variant is active.

Set Variant Control Condition

Alternatives

You can convert a Variant Component block to a Variant Assembly Component block through the block dialog. For more information, see Convert Variant Component to Variant Assembly Component.

Version History

Introduced in R2023b

expand all