Main Content

addComponentConfiguration

Associate top-model variant configuration with variant configuration of referenced model

Since R2022b

    Description

    Consider a variant model that has predefined variant configurations and also has a referenced model in its model hierarchy. In Variant Manager, a variant configuration for a top-level model must also define the variant control variables used by any referenced components in the model hierarchy, such as referenced models. If the referenced component defines its own variant configurations, you can use them to set up the control variables in the top-level configuration.

    Use the addComponentConfiguration function to associate a variant configuration of the referenced model with a variant configuration of the top-level model. This operation adds the control variables present in the specified component configuration to the top-level model configuration. This function thus allows you to author a top-model configuration using referenced component configurations. For more information on this workflow, see Compose Variant Configurations and Constraints for Top Model Using Referenced Component Configurations.

    Note

    This function requires Variant Manager for Simulink®.

    addComponentConfiguration(vcdtop,ConfigurationName=topconfig,ComponentName=refmdl,ComponentConfigurationName=refconfig) associates the variant configuration refconfig of the referenced model refmdl with the top-level variant configuration topconfig that is present in the variant configuration data object vcdtop.

    This operation populates topconfig with variant control variables from refconfig. That is, topconfig contains all variant control variables that are in refconfig, these variables are set to the same values as in refconfig, and they are also marked as read-only in the top-level configuration. You cannot modify or remove the control variables populated using a component configuration from the top-model configuration. To populate variant control variables, refmdl is loaded. The operation also checks that there are no conflicts in existing variant control variable definitions of topconfig if it is associated with other referenced model configurations.

    example

    addComponentConfiguration(___,PopulateControlVariables=false) associates refconfig with topconfig using input arguments in the previous syntax, but it does not populate topconfig with variant control variables from refconfig, and the variables are not marked as read-only. Use this syntax if you do not want to update existing control variable values in topconfig but only want to indicate that they come from refconfig. By default, PopulateControlVariables is set to true.

    example

    Examples

    collapse all

    Consider the slexVariantManagement model, which is associated with the variant configuration object vcd. The model has a referenced model named slexVariantManagementExternalPlantMdlRef in its hierarchy that has a predefined variant configuration named LowFid.

    This command associates LowFid with the variant configuration named NonLinExterLowFid present in vcd and populates NonLinExterLowFid with the variant control variables from LowFid.

    addComponentConfiguration(vcd,ConfigurationName="NonLinExterLowFid",...
        ComponentName="slexVariantManagementExternalPlantMdlRef",ComponentConfigurationName="LowFid");

    This command associates LowFid with NonLinExterLowFid but does not update existing control variable values in NonLinExterLowFid.

    addComponentConfiguration(vcd,ConfigurationName="NonLinExterLowFid",...
        ComponentName="slexVariantManagementExternalPlantMdlRef",...
        ComponentConfigurationName="LowFid",...
        PopulateControlVariables=false);

    Input Arguments

    collapse all

    Variant configuration data of the top-level model, specified as a Simulink.VariantConfigurationData object.

    Name of the top-level variant configuration present in vcdtop to which the referenced component configuration refconfig is associated, specified as a character vector or string scalar.

    Example: "LinInterExpNoNoise"

    Data Types: char | string

    Name of the referenced component, such as a referenced model, specified as a character vector or string scalar.

    Example: "slexVariantManagementExternalPlantMdlRef"

    Data Types: char | string

    Name of the referenced component configuration to associate with the top-level configuration topconfig, specified as a character vector or string.

    Example: "HighFid"

    Data Types: char | string

    Option to populate variant control variable values from referenced configuration to top-level configuration, specified as a numeric or logical 1 (true) or 0 (false).

    Data Types: logical

    Version History

    Introduced in R2022b

    expand all