Main Content

rules

Class: slcoverage.Filter
Namespace: slcoverage

Rules for filter

Syntax

fr = rules(filter)
fr = rules(filter,element)

Description

fr = rules(filter) returns all the rules assigned to the filter.

fr = rules(filter,element) returns only the rules for the specified model element.

Input Arguments

expand all

Filter object whose rules to return, specified as an slcoverage.Filter object.

This property is read-only.

Identifier of the model element whose rules to return, specified as a character vector or string of the Simulink ID, model element property, or handle.

Output Arguments

expand all

Filter rules, returned as an slcoverage.FilterRule object or an array of slcoverage.FilterRule objects.

Examples

expand all

Open a model. Specify coverage settings and turn on coverage recording.

modelName = 'slcoverage_lct_bus';
open_system(modelName);
set_param(modelName,'CovMetricStructuralLevel','MCDC','RecordCoverage','on');

Create a BlockSelector object, bl. Create a filter object, create a rule, and add the rule to the filter.

bl = slcoverage.BlockSelector(slcoverage.BlockSelectorType.BlockType,'RelationalOperator');
filt = slcoverage.Filter;
rule = slcoverage.FilterRule(bl,'Tested elsewhere',slcoverage.FilterMode.Exclude);
filt.addRule(rule);

Create another rule and add it to the filter object.

id = Simulink.ID.getSID('slcoverage_lct_bus/slCounter/And');
bl = slcoverage.BlockSelector(slcoverage.BlockSelectorType.BlockInstance,id);
rule = slcoverage.FilterRule(bl,'Value is never greater than 0');
filt.addRule(rule);

Use rules to return the filter rules. View first rule in the array.

fi = filt.rules
fi(1)
fi = 

  1×2 FilterRule array with properties:

    Selector
    Mode
    Rationale

ans = 

  FilterRule with properties:

     Selector: [1×1 slcoverage.BlockSelector]
         Mode: Exclude
    Rationale: 'Tested elsewhere'

Use rules to return the rule only for the And block.

filt.rules(id)
ans = 

  FilterRule with properties:

     Selector: [1×1 slcoverage.BlockSelector]
         Mode: Justify
    Rationale: 'Value is never greater than 0'

Version History

Introduced in R2017b