Convert Configurable Subsystem to Variant Subsystem
Note
Configurable Subsystem will be removed in a future release. The Configurable Subsystem blocks in existing models must be converted to Variant Subsystem blocks.
Variant Subsystems offer more capabilities than Configurable Subsystems, with these advantages:
Feature | Configurable Subsystem | Variant Subsystem |
---|---|---|
Library | You need a Simulink library to create a template block in library to create instance of a configurable subsystem. | You do not need to create a library to create an instance of the variant subsystem. |
Variant Control | You do not need variant controls to control Configurable subsystem blocks. | You can control variant blocks through label modes and other modes. Variant subsystem is a superset. |
Code Generation | The generated code contains only the block choice. | The generated code can contain either the active choice of all the variants. |
Model blocks and Subsystem blocks as choices. | You cannot mix Model blocks and Subsystem blocks as choices. | You can mix Model blocks and Subsystem blocks as variant choices. |
Nested Workflows | It is not easy to control block choices in nested configurable subsystem hierarchy | Nested variant subsystem workflow is easy and not problematic. |
Variant Manager | No centralized system to manage configurable subsystem blocks | Advanced variant management capabilities through the variant manager |
You can convert Configurable Subsystem block to a Variant Subsystem block in one of the four ways:
Convert Configurable Subsystem Blocks to Variant Subsystem Blocks Using Upgrade Advisor Programmatically
Configurable Subsystem blocks in a model can be converted to
Variant Subsystem blocks programmatically using the
upgradeadvisor
function.
Perform these steps to convert Configurable Subsystem blocks in a model to Variant Subsystem blocks:
Open a model containing Configurable Subsystem block.
Convert the library template blocks to Variant Subsystem blocks using the
upgradeadvisor
function. Create an object forupgradeadvisor
, and run the methodupgrade
with theupgrader
object output.upgrader = upgradeadvisor(bdroot); upgrader.upgrade
For information on how to use the
upgradeadvisor
function. See Programmatically Analyze and Upgrade Model . A report with the status of the block conversion is generated.
Convert Configurable Subsystem Blocks to Variant Subsystem Blocks Using Upgrade Advisor
Convert Configurable Subsystem blocks in a model to Variant Subsystem blocks using Upgrade Advisor.
When you compile a model containing Configurable Subsystem blocks, a warning is displayed which will instruct you to convert the Configurable Subsystem block to a Variant Subsystem block.
Consider a model with Configurable Subsystem block. When you compile this model, a warning is displayed in the Diagnostic Viewer.
Note
When you create a new Configurable Subsystem block, an upgrade advisor alert is displayed to convert the Configurable Subsystem block to Variant Subsystem block.
In the Diagnostic Viewer, click Open in the Suggested Actions section.
In the Upgrade Advisor, select Identify configurable subsystem blocks for converting to variant subsystem blocks and then click Run This Check. A list of all the Configurable Subsystem blocks in the model and recommended action to be performed is displayed.
Note
To upgrade Configurable Subsystem instances created by Model discretizer in the model or subsystem level, perform the Recommended Action. The recommended action ensures that the information regarding discretization is retained.
To convert to Variant Subsystem, right click on each of the Configurable Subsystem instances provided in the list and select Subsystem and Model Reference >Convert to>Variant Subsystem.
In the model, perform the Recommended Action of running the Analyze model hierarchy and continue upgrade sequence to convert the configurable subsystem template blocks to update the listed configurable subsystem blocks. Upgrade Advisor guides you through the recommended sequence of steps to upgrade your models. Click Continue Upgrade Sequence to open the libraries in a sequence.
In the library, run the Identify configurable subsystem blocks for converting to variant subsystem blocks again. Click the Convert All button to convert all the configurable subsystem blocks in the libraries in the sequence. You must run the Identify configurable subsystem blocks for converting to variant subsystem blocks check as many times as the number of libraries.
Convert Configurable Subsystem Blocks to Variant Subsystem Blocks Programmatically Using convertToVariant
Configurable Subsystem blocks in a model can be converted to
Variant Subsystem blocks programmatically using
convertToVariant
method.
When a Configurable Subsystem is converted to a Variant
Subsystem block, the Block choice of Configurable
Subsystem block is changed to LabelModeActiveChoice
in the Variant Subsystem block.c
If the Block choice of the Configurable Subsystem template block is linked, then the block is copied to the Variant Subsystem graph and the copied blocks will have its links retained. If the Block choice of the Configurable Subsystem template block is not linked, then the block is copied to the Variant Subsystem graph and the block in the Configurable Subsystem library is linked to it.
Perform these steps to convert Configurable Subsystem blocks in a model to Variant Subsystem blocks:
Open a model containing Configurable Subsystem block.
In the command-line, enter the
find_system
command to find all the Configurable Subsystem blocks in the model:find_system(bdroot, 'Regexp', 'on', 'LookUnderMasks', 'on','FollowLinks', 'on', 'Variants', 'AllVariants', 'TemplateBlock', '.')
The Configurable Subsystem blocks present in the model are listed:
{'mconfigsub/config_sub'} {'mconfigsub/nested config'}
Find the library template blocks from the list using
get_param
command.get_param('mconfigsub/nested config','TemplateBlock') ans = 'mconfiglib/nested config' get_param('mconfigsub/config_sub','TemplateBlock') ans = 'mconfiglib/Subsystem/config_sub'
Convert the library template blocks to Variant Subsystem blocks using
convertToVariant
.Simulink.VariantManager.convertToVariant('mconfiglib/nested config') Simulink.VariantManager.convertToVariant('mconfiglib/Subsystem/config_sub')
Save the libraries. You can use
save_system
command to save the libraries.Close and open the model again. The Configurable Subsystem blocks in the model will be converted to Variant Subsystem blocks.
Convert Configurable Subsystem Blocks to Variant Subsystem Blocks Through the Dialog
Open a model containing Configurable Subsystem block.
Right-click the Configurable Subsystem block and in the context menu, select Subsystem & Model Reference > Convert to > Variant Subsystem.
By default, the Copy without creating links to the configurable subsystem library check box is selected. This creates variant choices without creating links to library.
Click OK. The Configurable Subsystem block is converted to Variant Subsystem block and is displayed in a new window.
Note
When Configurable Subsystem block is converted to a Variant Subsystem block, the Block choice of Configurable Subsystem block is changed to
LabelModeActiveChoice
in Variant Subsystem block.Manually replace the Configurable Subsystem block with the converted Variant Subsystem block in the original model.
Changing Active Variant
When Configurable Subsystem block is converted to a Variant Subsystem block, the Block Choice of Configurable Subsystem block is changed to Label mode active choice in Variant Subsystem block.
To change the active variant, perform one of these steps:
Right-click the badge on the Variant Subsystem block and select Block Parameters (Subsystem). In the block parameters dialog box, select the active variant from
Label mode active choice
drop-down list.Right-click the badge on the Variant Subsystem block and select Label Mode Active Choice.
Note
When a Configurable Subsystem block with a mask is
converted to Variant Subsystem block, the Label
mode active choice
option and all other parameters in
block parameters dialog box is disabled. To change the active variant,
right-click the badge on the Variant Subsystem block and
select Label Mode Active Choice.
See Also
Variant Subsystem, Variant Model