makeVariantAssembly
Syntax
Description
converts the Variant Component block variantAssemblyComp
= makeVariantAssembly(variantcomponent
)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 Subsystem Reference blocks as its variant
choices.
converts the Variant Component block variantAssemblyComp
= makeVariantAssembly(variantcomponent
,Name=Value
)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.
Examples
Convert Variant Component Block with Labels to Variant Assembly Component Block Programmatically
This example explains how to convert a Variant Component block in lable 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 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: 55.0020 SimulinkModelHandle: 0.0018 UUID: 'f6d724eb-8f9b-4b7f-b608-528e49b8729f' ExternalUID: ''
Convert Variant Component Block with Expressions to Variant Assembly Component Block Programmatically
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: 55.0018 SimulinkModelHandle: 0.0017 UUID: '061c0285-83f0-403d-8012-6761cff223ad' ExternalUID: ''
Input Arguments
variantcomponent
— Component
variant component object
Variant component to be converted to variant assembly 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)
VariantControlVariableName
— Valid MATLAB® variable name or structure field name
character vector | string scalar
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
EnumerationClassFilePath
— Absolute or relative path to MATLAB class file
character vector | string scalar
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
SubsystemFilesFolderPath
— Absolute or relative folder path
character vector | string scalar
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
variantAssemblyComp
— Variant assembly component
variant assembly component object
Variant assembly component, returned as a systemcomposer.arch.VariantComponent
object.
Limitations
Only Variant Component blocks with the Variant control mode set to
label
orexpression
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
Definitions
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. | |
model | A System Composer model is the file that contains architectural information, including components, ports, connectors, interfaces, and behaviors. |
Perform operations on a model:
A System Composer model is stored as an SLX file. | Create Architecture Model with Interfaces and Requirement Links |
component | A component is a nontrivial, nearly independent, and 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, a 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:
| Components |
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. |
These are different types of ports:
| Ports |
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. | Connections |
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 to programmatically 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 R2023bR2023b: Convert Variant Component to Variant Assembly Component
Use the makeVariantAssembly
function of the systemcomposer.arch.VariantComponent
object to programmatically convert to a
Variant Assembly Component block.
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)