Convert Configurable Subsystem to Variant Subsystem
Note
Configurable Subsystem will be removed in a future release. Convert Configurable Subsystem blocks in existing models to Variant Subsystem blocks.
Variant Subsystems have the following advantages over Configurable Subsystems:
Feature | Configurable Subsystem | Variant Subsystem |
---|---|---|
Library | You need to create a template block in a Simulink library to create an 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
mode and other modes. |
Code Generation | Generated code contains only the active block choice. | Generated code can contain both the active and inactive choices. |
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 | There is no centralized system to manage configurable subsystem blocks. | Variant Manager has advanced variant management capabilities. |
You can convert a Configurable Subsystem block to a Variant Subsystem block in these ways:
Using Upgrade Advisor interactively
Using Upgrade Advisor programmatically
Using the
convertToVariantSubsystem
methodUsing the context menu of the Configurable Subsystem block
Using Upgrade Advisor interactively
When you compile a model containing Configurable Subsystem blocks, a warning is displayed in the Diagnostic Viewer to convert the Configurable Subsystem block to a Variant Subsystem block.
In the Diagnostic Viewer, click Open in the Suggested Actions section. This opens the Upgrade Advisor. For more information on Upgrade Advisor, see Consult the Upgrade Advisor.
Run the Identify configurable subsystem blocks for converting to variant subsystem blocks check by clicking Run This Check. Upgrade Advisor displays a list of all the Configurable Subsystem blocks in the model and the Recommended Action.
In the model, perform the Recommended Action of running Analyze model hierarchy and continue upgrade sequence check. 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 Convert All 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.
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 information regarding discretization is retained. To convert to Variant Subsystem block, right-click each of the Configurable Subsystem instances provided in the list and select Subsystem and Model Reference > Convert to> Variant Subsystem.
Using Upgrade Advisor Programmatically
Use the upgradeadvisor
function to convert
Configurable Subsystem blocks in a model to Variant
Subsystem blocks programmatically.
Open a model containing a Configurable Subsystem block.
Convert the library template blocks to Variant Subsystem blocks using the
upgradeadvisor
function. Create an object forupgradeadvisor
and run theupgrade
method with theupgrader
object.upgrader = upgradeadvisor(bdroot); upgrader.upgrade
A report with the status of the block conversion is generated. For information on how to use the
upgradeadvisor
function, see Programmatically Analyze and Upgrade Model.
Using convertToVariantSubsystem
Method
Use the convertToVariantSubsystem
method to
convert Configurable Subsystem blocks in a model to Variant
Subsystem blocks.
Perform these steps to convert Configurable Subsystem blocks in a model to Variant Subsystem blocks:
Open a model containing a Configurable Subsystem block.
In the Command Window, use the
find_system
command to find all Configurable Subsystem blocks in the model:find_system(bdroot, 'Regexp', 'on',... 'LookUnderMasks', 'on','FollowLinks', 'on',... 'Variants', 'AllVariants', 'TemplateBlock', '.')
{'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 the
convertToVariantSubsystem
method.Simulink.VariantUtils.convertToVariantSubsystem('mconfiglib/nested config') Simulink.VariantUtils.convertToVariantSubsystem('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.
Using Context Menu of Configurable Subsystem Block
Open a model containing a Configurable Subsystem block.
Right-click the Configurable Subsystem block. In the context menu, select Subsystem & Model Reference > Convert to > Variant Subsystem.
By default, Copy without creating links to the configurable subsystem library is selected. This creates variant choices without creating links to a library.
Click OK. The Configurable Subsystem block is converted to a Variant Subsystem block and is displayed in a new window.
Manually replace the Configurable Subsystem block with the converted Variant Subsystem block in the original model.
Changing Active Variant
When you convert a Configurable Subsystem to a Variant Subsystem block, Block Choice of the Configurable Subsystem block is changed to Label mode active choice in the Variant Subsystem block.
If the Block choice of the Configurable Subsystem template block is linked, then the block is copied to the Variant Subsystem and the copied blocks will have their links retained. If the Block choice of the Configurable Subsystem template block is not linked, then the block is copied to the Variant Subsystem and the block in the Configurable Subsystem library is linked to it.
To change the active variant:
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 are 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