Documentation

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 how the selector is constructed.

This property is read-only.

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

This property is read-only.

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

Methods

allSelectorsSelectors for model element

Copy Semantics

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

Examples

expand all

Get all the selectors for the block. Then you can add a rule to exclude or justify a selector. (You can only justify metric selectors.)

Open the model and turn on coverage recording. Get all the selectors for the And block.

modelName = 'sldemo_lct_bus';
open_system(modelName);
set_param(modelName,'CovMetricSettings','dcme','RecordCoverage','on');
id = Simulink.ID.getSID('sldemo_lct_bus/slCounter/And');
sel = slcoverage.Selector.allSelectors(id)
s = 

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

    Description
    Type
    Id
    ConstructorCode

The block has six selectors. You can index into each one to see the content. The sixth selector is the metric selector that you want to justify.

sel(6)
ans = 

  MetricSelector with properties:

     ObjectiveIndex: 2
       OutcomeIndex: 2
        Description: 'F outcome of input port 2 in Logic block "And"'
               Type: ConditionOutcome
                 Id: 'sldemo_lct_bus:23'
    ConstructorCode: 'slcoverage.MetricSelector(slcoverage.MetricSelectorType.ConditionOutcome,'sldemo_lct_bus:23',2,2)'

Create a justify rule for the selector. Create a filter object and add the rule to it.

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

Save and run the filter.

filt.save('metrfilter');
csim = cvsim(modelName);
csim.filter = 'metrfilter';
cvhtml('cov',csim);

Introduced in R2017b

Was this topic helpful?