allSelectors

Class: slcoverage.BlockSelector, slcoverage.CodeSelector, slcoverage.Selector, slcoverage.MetricSelector, slcoverage.SFcnSelector
Package: slcoverage

Selectors for model or code element

Syntax

sel = slcoverage.Selector.allSelectors(element)
sel = slcoverage.BlockSelector.allSelectors(element)
sel = slcoverage.CodeSelector.allSelectors(element)
sel = slcoverage.CodeSelector.allSelectors(element,Name,Value)
sel = slcoverage.MetricSelector.allSelectors(element)
sel = slcoverage.SFcnSelector.allSelectors(element)
sel = slcoverage.Selector.allSelectors(element,Name,Value)

Description

sel = slcoverage.Selector.allSelectors(element) returns all the selectors for the model element.

sel = slcoverage.BlockSelector.allSelectors(element) returns all the block selectors for element.

sel = slcoverage.CodeSelector.allSelectors(element) returns all the custom C/C++ code selectors for element.

sel = slcoverage.CodeSelector.allSelectors(element,Name,Value) , where element is a model and Name,Value specifies the simulation mode, returns all the custom C/C++ code selectors for the model in the specified simulation mode.

sel = slcoverage.MetricSelector.allSelectors(element) returns all the metric selectors for element.

sel = slcoverage.SFcnSelector.allSelectors(element) returns all the S-function selectors for element.

sel = slcoverage.Selector.allSelectors(element,Name,Value) returns selectors for element, with additional options specified by one or more Name,Value pair arguments.

Input Arguments

expand all

Model element to select, specified as a handle or the model element Simulink® identifier.

Example: 'sldemo_lct_bus:18'

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Type',slcoverage.BlockSelectorType.BlockInstance,'Description','F outcome'

Selector type refinement specified as one of the slcoverage.BlockSelectorTypeslcoverage.CodeSelectorType, slcoverage.MetricSelectorType, or slcoverage.SFcnSelectorType values. Possible values:

  • Block selector types:

    • slcoverage.BlockSelectorType.BlockInstance — An instance of a block.

    • slcoverage.BlockSelectorType.BlockType — All blocks of the specified block type.

    • slcoverage.BlockSelectorType.Chart — A Stateflow® chart.

    • slcoverage.BlockSelectorType.MaskType — Blocks that use the specified mask type.

    • slcoverage.BlockSelectorType.State — A Stateflow state.

    • slcoverage.BlockSelectorType.StateAllContent — Stateflow state and its contents.

    • slcoverage.BlockSelectorType.StateflowFunction — A Stateflow function.

    • slcoverage.BlockSelectorType.Subsystem — A subsystem block.

    • slcoverage.BlockSelectorType.SubsystemAllContent — A subsystem and its contents.

    • slcoverage.BlockSelectorType.TemporalEvent — A Stateflow temporal event.

    • slcoverage.BlockSelectorType.Transition — A Stateflow transition.

  • Code selector types:

    • slcoverage.CodeSelectorType.File — Custom C/C++ code file name.

    • slcoverage.CodeSelectorType.Function — Custom C/C++ code function name.

    • slcoverage.CodeSelectorType.Decision — A custom C/C++ code decision.

    • slcoverage.CodeSelectorType.Condition — A custom C/C++ code condition.

  • Metric selector types:

    • slcoverage.MetricSelectorType.ConditionOutcome selects outcome metrics related to block inputs.

    • slcoverage.MetricSelectorType.DecisionOutcome selects outcome metrics related to block outputs.

    • slcoverage.MetricSelectorType.RelationalBoundaryOutcome selects outcome metrics related to relational boundary outcomes.

    • slcoverage.MetricSelectorType.SaturationOverflowOutcome selects outcome metrics related to saturation on integer overflow outcomes.

  • S-function selector types:

    • slcoverage.SFcnSelectorType.SFcnName selects the specified S-function.

    • slcoverage.SFcnSelectorType.SFcnInstanceCppFileName selects the coverage data in the generated code file for this block.

    • slcoverage.SFcnSelectorType.SFcnInstanceCppFunction selects a function.

    • slcoverage.SFcnSelectorType.SFcnInstanceCppCondition selects a condition outcome of the S-function block.

    • slcoverage.SFcnSelectorType.SFcnInstanceCppDecision selects a decision outcome of the S-function block.

Description text to match for the selector that you want to return, specified as a character vector or string. For example, if you want to return only the selectors that include the text F outcome in the description, use this syntax:

s = slcoverage.Selector.allSelectors(id,'Description','F outcome')

Simulation mode to run when selecting code filters, entered as one of the following:

Object SpecificationDescription

'normal' (default)

Extract code selectors for custom code in normal simulation, such as custom code called from a C Caller block or a Stateflow chart.

'sil'

Extract code selectors for code generated in Simulation-in-the-Loop (SIL) mode and code selectors for the top model code interface

'pil'

Extract code selectors for code generated in Processor-in-the-Loop (PIL) mode and code selectors for the top model code interface

'xil'

If SIL-mode code exists, extract code selectors for code generated in SIL mode and extract code selectors for the top model code interface; otherwise, extract code selectors for code generated in PIL mode and extract code selectors for the top model code interface

'modelrefsil'

Extract code selectors for the model reference code interface in SIL mode

'modelrefpil'

Extract code selectors for the model reference code interface in PIL mode

'modelrefxil'

If SIL-mode code exists, extract code selectors for the model reference code interface in SIL mode, if the model is in SIL mode; otherwise,extract code selectors for the model reference code interface in PIL mode

Output Arguments

expand all

Selectors for the model or code element, returned as an array of Selector objects.

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);

Get a particular metric selector.

Open the model and turn on code coverage.

modelName = 'sldemo_lct_bus';
open_system(modelName);
set_param(modelName,'CovMetricSettings','dcme','RecordCoverage','on');

Get the condition selectors for the And block whose description includes the text F outcome.

id = Simulink.ID.getSID('sldemo_lct_bus/slCounter/And');
s = slcoverage.Selector.allSelectors(id,...
  'Type',slcoverage.MetricSelectorType.ConditionOutcome,'Description','F outcome')
s = 

  1×2 MetricSelector array with properties:

    ObjectiveIndex
    OutcomeIndex
    Description
    Type
    Id
    ConstructorCode

Look at the constructor code for the two selectors that were returned.

s.ConstructorCode
ans =

    'slcoverage.MetricSelector(slcoverage.MetricSelectorType.ConditionOutcome,'sldemo_lct_bus:23',1,2)'


ans =

    'slcoverage.MetricSelector(slcoverage.MetricSelectorType.ConditionOutcome,'sldemo_lct_bus:23',2,2)'

Introduced in R2017b