slcoverage.Selector - Get selectors of all types - MATLAB (original) (raw)
Main Content
Namespace: slcoverage
Get selectors of all types
Description
Use the slcoverage.Selector
class with theallSelectors
method to return all types of the selectors for a model object.
The slcoverage.Selector
class is a handle class.
Properties
Code used to create this selector object, returned as a character vector.
Attributes:
GetAccess | public |
---|---|
SetAccess | protected |
Description of the selector, returned as a character vector. Simulink® Coverage™ creates the description based on the selector.
Attributes:
GetAccess | public |
---|---|
SetAccess | protected |
Identifier of the model element, returned as character vector of the Simulink ID or a handle.
Attributes:
GetAccess | public |
---|---|
SetAccess | protected |
Selector type, returned as a selector type of the corresponding selector.
Attributes:
GetAccess | public |
---|---|
SetAccess | protected |
Methods
Examples
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.
Load the model and set coverage settings
modelName = 'slvnvdemo_covfilt'; load_system(modelName); set_param(modelName,'CovEnable','on','CovMetricStructuralLevel','MCDC');
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 =
1×10 heterogeneous Selector (BlockSelector, MetricSelector) array with properties:
Description
Type
Id
ConstructorCode
The block has ten selectors. You can index into each one to see their contents. In this example, you want to justify the sixth selector.
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');
Version History
Introduced in R2017b