Main Content

slcoverage.Selector class

Package: slcoverage

Get selectors of all types

Description

Use the slcoverage.Selector class with the allSelectors method to return all types of the selectors for a block.

Properties

expand all

This property is read-only.

Code used to create this selector object, returned as a character vector.

This property is read-only.

Description of the selector, returned as a character vector. Simulink® Coverage™ creates the description based on the selector.

This property is read-only.

Identifier of the model element, returned as character vector of the Simulink ID or a handle.

This property is read-only.

Selector type, returned as a selector type of the corresponding selector.

Methods

allSelectorsSelectors for model or code element

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.

Examples

collapse all

This example shows how to get all the selectors for an And block and then add a rule to justify or exclude a selector. Metric selectors can only be justified.

Move the current MATLAB® directory to the location that contains the example files.

openExample('slcoverage/GetAllSelectorsExample');

Load the model and set coverage settings

modelName = 'slvnvdemo_covfilt';
load_system(modelName);
set_param(modelName,'CovEnable','on','CovMetricSettings','dcme');

First, get the block handle for the And block.

id = getSimulinkBlockHandle([modelName,'/Saturation']);

Get the selectors using the block handle.

sel = slcoverage.Selector.allSelectors(id)
sel = 

  1x10 heterogeneous Selector (BlockSelector, MetricSelector) array with properties:

    Description
    Type
    Id
    ConstructorCode

The block has eight selectors. You can index into each one to see their contents. In this example, you want to justify the sixth selector.

sel(6)
ans = 

  MetricSelector with properties:

     ObjectiveIndex: 2
       OutcomeIndex: 2
        Description: 'T outcome of input >= upper limit in Saturate block "Saturation"'
               Type: DecisionOutcome
                 Id: 'slvnvdemo_covfilt:5'
    ConstructorCode: 'slcoverage.MetricSelector(slcoverage.MetricSelectorType.DecisionOutcome, 'slvnvdemo_covfilt:5', 2, 2)'

Create a justify rule, then create a filter object and add the rule to it.

rule = slcoverage.FilterRule(sel(6),'Expected result');
filt = slcoverage.Filter;
filt.addRule(rule);

Save the filter and generate a coverage report.

filt.save('metrfilter');
csim = cvsim(modelName);
csim.filter = 'metrfilter';
cvhtml('cov',csim,'-sRT=0');
Introduced in R2017b