Main Content

Convert Configurable Subsystem to Variant Subsystem

Note

Configurable Subsystemwill be removed in a future release. TheConfigurable Subsystemblocks in existing models must be converted toVariant Subsystemblocks.

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.
Modelblocks andSubsystemblocks as choices. You cannot mixModelblocks andSubsystemblocks as choices. You can mixModelblocks andSubsystemblocks 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 通过t高级管理功能变体he variant manager

You can convertConfigurable Subsystemblock to aVariant Subsystemblock in one of the four ways:

Convert Configurable Subsystem Blocks to Variant Subsystem Blocks Using Upgrade Advisor Programmatically

Configurable Subsystemblocks in a model can be converted toVariant Subsystemblocks programmatically usingupgradeadvisor.

Perform these steps to convertConfigurable Subsystemblocks in a model toVariant Subsystemblocks:

  1. Open a model containingConfigurable Subsystemblock.

  2. Convert the library template blocks to Variant Subsystem blocks usingupgradeadvisor. Create an object forupgradeadvisor, and run the methodupgradewith theupgraderobject output.

    upgrader = upgradeadvisor(bdroot); upgrader.upgrade

    For information on using this method, seeupgradeadvisor. A report with the status of the block conversion is generated.

Convert Configurable Subsystem Blocks to Variant Subsystem Blocks Using Upgrade Advisor

ConvertConfigurable Subsystemblocks in a model toVariant Subsystemblocks usingUpgrade Advisor.

When you compile a model containingConfigurable Subsystemblocks, a warning is displayed which will instruct you to convert theConfigurable Subsystemblock to aVariant Subsystemblock.

  1. Consider a model withConfigurable Subsystemblock. When you compile this model, a warning is displayed in theDiagnostic Viewer.

    Note

    When you create a new Configurable Subsystem block, an upgrade advisor alert is displayed to convert theConfigurable Subsystemblock toVariant Subsystemblock.

  2. In theDiagnostic Viewer, clickOpenin theSuggested Actionssection.

  3. In theUpgrade Advisor, selectIdentify configurable subsystem blocks for converting to variant subsystem blocksand then clickRun This Check. A list of all theConfigurable Subsystemblocks 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 theRecommended 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 selectSubsystem and Model Reference>Convert to>Variant Subsystem.

  4. In the model, perform theRecommended Actionof running theAnalyze model hierarchy and continue upgrade sequenceto convert the configurable subsystem template blocks to update the listed configurable subsystem blocks.Upgrade Advisorguides you through the recommended sequence of steps to upgrade your models. ClickContinue Upgrade Sequenceto open the libraries in a sequence.

  5. In the library, run theIdentify configurable subsystem blocks for converting to variant subsystem blocksagain. Click theConvert All按钮将所有可配置子系统blocks in the libraries in the sequence. You must run theIdentify configurable subsystem blocks for converting to variant subsystem blockscheck as many times as the number of libraries.

Convert Configurable Subsystem Blocks to Variant Subsystem Blocks Programmatically UsingconvertToVariant

Configurable Subsystemblocks in a model can be converted toVariant Subsystemblocks programmatically usingconvertToVariantmethod.

When aConfigurable Subsystemis converted to aVariant Subsystemblock, the Block choice ofConfigurable Subsystemblock is changed toLabelModeActiveChoicein theVariant Subsystemblock.c

If the Block choice of theConfigurable Subsystemtemplate block is linked, then the block is copied to theVariant Subsystemgraph and the copied blocks will have its links retained. If the Block choice of theConfigurable Subsystemtemplate block is not linked, then the block is copied to theVariant Subsystemgraph and the block in theConfigurable Subsystemlibrary is linked to it.

Perform these steps to convertConfigurable Subsystemblocks in a model toVariant Subsystemblocks:

  1. Open a model containingConfigurable Subsystemblock.

  2. In the command-line, enter thefind_systemcommand to find all theConfigurable Subsystemblocks in the model:

    find_system(bdroot, 'Regexp', 'on', 'LookUnderMasks', 'on','FollowLinks', 'on', 'Variants', 'AllVariants', 'TemplateBlock', '.')

    TheConfigurable Subsystemblocks present in the model are listed:

    {'mconfigsub/config_sub'} {'mconfigsub/nested config'}
  3. Find the library template blocks from the list usingget_paramcommand.

    get_param('mconfigsub/nested config','TemplateBlock') ans = 'mconfiglib/nested config' get_param('mconfigsub/config_sub','TemplateBlock') ans = 'mconfiglib/Subsystem/config_sub'
  4. Convert the library template blocks to Variant Subsystem blocks usingconvertToVariant.

    Simulink.VariantManager.convertToVariant('mconfiglib/nested config') Simulink.VariantManager.convertToVariant('mconfiglib/Subsystem/config_sub')
  5. Save the libraries. You can usesave_systemcommand to save the libraries.

  6. 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

  1. Open a model containing Configurable Subsystem block.

  2. Right-click theConfigurable Subsystemblock and in the context menu, selectSubsystem & Model Reference>Convert to>Variant Subsystem.

  3. By default, theCopy without creating links to the configurable subsystem librarycheck box is selected. This creates variant choices without creating links to library.

  4. ClickOK. The Configurable Subsystemblock is converted toVariant Subsystemblock and is displayed in a new window.

    Note

    WhenConfigurable Subsystemblock is converted to aVariant Subsystemblock, the Block choice ofConfigurable Subsystemblock is changed toLabelModeActiveChoicein Variant Subsystem block.

  5. Manually replace theConfigurable Subsystemblock with the convertedVariant Subsystemblock in the original model.

Changing Active Variant

WhenConfigurable Subsystemblock is converted to aVariant Subsystemblock, the Block Choice ofConfigurable Subsystemblock 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 theVariant Subsystemblock and selectBlock Parameters (Subsystem). In the block parameters dialog box, select the active variant fromLabel mode active choicedrop-down list.

  • Right-click the badge on theVariant Subsystemblock and selectLabel Mode Active Choice.

Note

When aConfigurable Subsystemblock with a mask is converted toVariant Subsystemblock, theLabel mode active choiceoption and all other parameters in block parameters dialog box is disabled. To change the active variant, right-click the badge on theVariant Subsystemblock and selectLabel Mode Active Choice.

See Also

Related Topics