Contenuto principale

getAlwaysActiveBlocks

List of blocks that are always active across named variant configurations

    Description

    Add-On Required: This feature requires the Variant Manager for Simulink add-on.

    Use this function to identify blocks that are always active across one or more named variant configurations for a model. Before calling the getAlwaysActiveBlocks function, you must create a Simulink.VariantConfigurationAnalysis object for the model and use it to analyze the desired variant configurations.

    alwaysActiveBlocks = getAlwaysActiveBlocks(varConfigAnalysisObj) returns a list of blocks that remain active across all named variant configurations analyzed using the Simulink.VariantConfigurationAnalysis object varConfigAnalysisObj.

    example

    Examples

    collapse all

    This example shows how to use the Simulink.VariantConfigurationAnalysis object to analyze variant configurations programmatically.

    To analyze variant configurations using Variant Manager, see Analyze Variant Configurations in Models Containing Variant Blocks.

    Open the model slexVariantConfigurationAnalysis.

    open_system("slexVariantConfigurationAnalysis"); 

    You can provide either a list of named variant configurations or the variable groups to the creation function for the Simulink.VariantConfigurationAnalysis object. The operation returns a variant configuration analysis object for the model.

    varConfigObjNamedConfig = Simulink.VariantConfigurationAnalysis("slexVariantConfigurationAnalysis",...
                              NamedConfigurations={"VendorACtrlLinear",...
                               "VendorACtrlNonLinear","VendorACtrlFuzzy"})
    varConfigObjNamedConfig = 
      VariantConfigurationAnalysis with properties:
    
             ModelName: 'slexVariantConfigurationAnalysis'
        Configurations: {'VendorACtrlFuzzy'  'VendorACtrlLinear'  'VendorACtrlNonLinear'}
    
    

    You can use the variant configuration analysis object to analyze the variant configurations using different functions specified in the following steps. This example analyzes the named configurations.

    Get the list of active blocks in the variant configuration VendorACtrlLinear.

    activeblocks = getActiveBlocks(varConfigObjNamedConfig,"VendorACtrlLinear");

    Get the list of blocks that are always active across all the named variant configurations that have been analyzed.

    alwaysActiveBlocks = getAlwaysActiveBlocks(varConfigObjNamedConfig);

    Get the list of blocks that are active in some of the analyzed variant configurations and inactive in other configurations.

    blockDifferences = getBlockDifferences(varConfigObjNamedConfig);

    Get the list of dependent libraries for a variant configuration.

    dependentLibraries = getDependentLibraries(varConfigObjNamedConfig,"VendorACtrlNonLinear");

    Get the list of dependent models for a variant configuration.

    dependentModels = getDependentModels(varConfigObjNamedConfig,"VendorACtrlFuzzy");

    Get the list of blocks that are inactive in all the named variant configurations that have been analyzed.

    neverActiveBlocks = getNeverActiveBlocks(varConfigObjNamedConfig);

    Get the variant condition on a block in a named variant configuration.

    variantCondition = getVariantCondition(varConfigObjNamedConfig,"VendorACtrlNonLinear",...
    "slexVariantConfigurationAnalysis/Controller/NonLinear");

    Show the variant configuration analysis report for a model after analyzing it.

    showUI(varConfigObjNamedConfig);

    Hide the variant configuration analysis report for a model after analyzing it.

    hideUI(varConfigObjNamedConfig);

    Alternatively, use this syntax to specify a list of variable groups to analyze. You can use the variant configuration analysis object functions to analyze the configurations represented by these variable groups.

    varConfigObjVarGroup = Simulink.VariantConfigurationAnalysis("slexVariantConfigurationAnalysis",...
        VariableGroups=[struct('Name', 'VendorANonLinear',...
        'VariantControls', {{'CONTROLLER', 1, 'EXTERNAL_SENSOR', 1, 'ORDER', 1, 'SATURATE', 1, 'VENDOR', 1}}),...
        struct('Name', 'VendorALinear',...
        'VariantControls', {{'CONTROLLER', 0, 'EXTERNAL_SENSOR', 1, 'ORDER', 1, 'SATURATE', 1, 'VENDOR', 1}})]);

    Input Arguments

    collapse all

    Variant configuration analysis data from which you want to get the list of blocks that are always active, specified as a Simulink.VariantConfigurationAnalysis object.

    Output Arguments

    collapse all

    List of blocks that are active across the named variant configurations that were analyzed, returned as a cell array of character vectors.

    Version History

    Introduced in R2019a