Main Content

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:

FeatureConfigurable SubsystemVariant 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 ControlYou do not need variant controls to control Configurable Subsystem blocks.You can control variant blocks through label mode and other modes.
Code GenerationGenerated 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 WorkflowsIt is not easy to control block choices in nested configurable subsystem hierarchyNested variant subsystem workflow is easy and not problematic.
Variant ManagerThere 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 method

  • Using 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.

  1. In the Diagnostic Viewer, click Open in the Suggested Actions section. This opens the Upgrade Advisor. For more information on Upgrade Advisor, see Upgrade Models Using Upgrade Advisor.

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

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

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

  1. Open a model containing a Configurable Subsystem block.

  2. Convert the library template blocks to Variant Subsystem blocks using the upgradeadvisor function. Create an object for upgradeadvisor and run the upgrade method with the upgrader 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:

  1. Open a model containing a Configurable Subsystem block.

  2. 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',...
     'MatchFilter', @Simulink.match.allVariants, 'TemplateBlock', '.')
    {'mconfigsub/config_sub'}
    {'mconfigsub/nested config'}
  3. 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'
    
  4. 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')
  5. Save the libraries. You can use save_system command 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.

Using Context Menu of Configurable Subsystem Block

  1. Open a model containing a Configurable Subsystem block.

  2. Right-click the Configurable Subsystem block. In the context menu, select Subsystem & Model Reference > Convert to > Variant Subsystem.

  3. By default, Copy without creating links to the configurable subsystem library is selected. This creates variant choices without creating links to a library.

  4. Click OK. The Configurable Subsystem block is converted to a Variant Subsystem block and is displayed in a new window.

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

Related Topics