makeVariantAssembly - Convert variant component to variant assembly component - MATLAB (original) (raw)

Convert variant component to variant assembly component

Since R2023b

Syntax

Description

[variantAssemblyComp](#mw%5F6acfb94d-68de-4c90-9138-237b06833038) = makeVariantAssembly([variantComponent](#mw%5F2d0761da-40ae-4288-b9e4-a405a03c5693%5Fsep%5Fmw%5Fdc134891-6ed2-4ed7-8511-0d8e13eb5044)) 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 islabel and has only Model blocks and Create and Use Referenced Subsystems in Models blocks as its variant choices.

example

[variantAssemblyComp](#mw%5F6acfb94d-68de-4c90-9138-237b06833038) = makeVariantAssembly([variantComponent](#mw%5F2d0761da-40ae-4288-b9e4-a405a03c5693%5Fsep%5Fmw%5Fdc134891-6ed2-4ed7-8511-0d8e13eb5044),[Name=Value](#namevaluepairarguments)) 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 objectvariantComponent. Use this syntax if the variant control mode of theVariant 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: [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: 219.0032
SimulinkModelHandle: 153.0031
               UUID: 'eb7cf36c-d000-45c6-bbb4-403bbf6bbb64'
        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:

SubsystemFilesFolderPath = pwd; vcvName = 'EngType'; enumClassFilePath = 'controllerClass.m'; variantAssemblyComp = makeVariantAssembly(variantComp,SubsystemFilesFolderPath = 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: 219.0031
SimulinkModelHandle: 153.0029
               UUID: '5784df87-7467-406c-97e4-b4accb038863'
        ExternalUID: ''

Input Arguments

Name-Value Arguments

collapse all

Specify optional pairs of arguments asName1=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 oneSubsystem block as its variant choice.

Data Types: char | string

Output Arguments

Limitations

More About

collapse all

Term Definition Application More 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. Compose Architectures VisuallyAuthor Parameters in System Composer Using 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 including extracting root-level architecture, applying profiles, linking interface data dictionaries, or generating 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 port interfaces using the Interface Editor, and parameters using the Parameter Editor. 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
Term Definition Application More 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

Version History

Introduced in R2023b

See Also

Blocks

Objects

Functions

Topics