Main Content

metric.config.Configuration

R2026b

Modify and manage custom threshold configurations

Since R2026b

    Description

    A metric.config.Configuration object represents a custom threshold configuration that contains threshold sets, threshold rules, and classifications. To make custom thresholds appear in the Model Testing, SIL Code Testing, and PIL Code Testing dashboards, use this object to copy and modify a shipping threshold set. Then, save and register the configuration. For more information, see Adjust Dashboard Thresholds to Match Your Testing Criteria.

    Example of custom threshold set in threshold settings for a dashboard

    Creation

    To create a metric.config.Configuration object, either:

    Threshold customization uses a hierarchy of objects:

    Properties

    expand all

    Path to configuration file, specified as a string.

    When you save and register the configuration, saveAndRegister reads this property and saves the file to the location. You must set this property before you can successfully save and register a new configuration.

    Example: fullfile(currentProject().RootFolder,"MyConfig.json")

    Configuration name, specified as a string.

    Example: "MyConfig"

    This property is read-only.

    Threshold sets in the configuration, returned as an array of metric.threshold.ThresholdSet objects. Each threshold set defines a named collection of threshold rules that specify compliance criteria for metrics.

    Copy or remove threshold sets in a configuration using metric.config.Configuration.copyThresholdSet and removeThresholdSet.

    This property is read-only.

    Threshold rules in the configuration, returned as an array of metric.threshold.ThresholdRule objects. Each rule associates a metric with a set of classifications that define compliance criteria.

    Add or remove threshold rules in a configuration using addThresholdRule and removeThresholdRule.

    Object Functions

    expand all

    metric.config.Configuration.copyThresholdSetCopy thresholds from shipping threshold set into new configuration
    getThresholdSetGet threshold set from configuration by identifier
    removeThresholdSetRemove threshold set from configuration
    addThresholdRuleAdd threshold rule to configuration
    getThresholdRuleGet threshold rule from configuration
    removeThresholdRuleRemove threshold rule from configuration
    saveSave configuration to file without registering
    saveAndRegisterSave configuration and register for use in dashboards
    validateCheck configuration for errors without saving

    Examples

    collapse all

    Create a new configuration by copying a shipping threshold set. Modify a threshold rule, then save and register the configuration for use in the testing dashboards.

    The shipping threshold sets include threshold sets for "Testing" and "ReqBasedTesting". Copy one of these shipping threshold sets.

    config = metric.config.Configuration.copyThresholdSet( ...
        SourceThresholdSetId="ReqBasedTesting", ...
        TargetThresholdSetId="MyTestingThresholds")
    config =
    
      Configuration with properties:
    
                             FileName: []
                                 Name: ''
                        ThresholdSets: [1x1 metric.threshold.ThresholdSet]
                              Metrics: [0x0 metric.config.MetricDefinition]
                         TableMetrics: [0x0 metric.config.TableMetricDefinition]
        MetricDefinitionSchemaVersion: "0.3.0"
                       ThresholdRules: [1x32 metric.threshold.ThresholdRule]
               ThresholdSchemaVersion: "0.2.0"

    Set a display name for the custom threshold set and get a threshold rule to modify.

    config.ThresholdSets.Name = "My Customized Thresholds";
    
    rule = getThresholdRule(config, ...
        ThresholdSetId="MyTestingThresholds", ...
        MetricId="modeltesting.TestResultAnalysis[slcomp.TestStatusDistribution]", ...
        ThresholdRuleId="NotRun");
    rule.Classifications(2).Category = "Warning";

    To make the custom threshold set appear in the dashboard, save and register the configuration.

    proj = currentProject;
    p = proj.RootFolder;
    config.FileName = fullfile(p,"MyConfig.json");
    saveAndRegister(config,ResourcesLocation=p)

    "Not Run" widget showing a warning overlay when there are tests that have not run yet

    Version History

    Introduced in R2026b