allSelectors
Class: slcoverage.BlockSelector, slcoverage.CodeSelector, slcoverage.Selector, slcoverage.MetricSelector, slcoverage.SFcnSelector
Namespace: 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
returns all the selectors for the model element.sel
= slcoverage.Selector.allSelectors(element
)
returns all the block selectors for
sel
= slcoverage.BlockSelector.allSelectors(element
)element
.
returns all the custom C/C++ code selectors for
sel
= slcoverage.CodeSelector.allSelectors(element
)element
.
, where sel
= slcoverage.CodeSelector.allSelectors(element
,Name,Value
)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.
returns all the metric selectors for
sel
= slcoverage.MetricSelector.allSelectors(element
)element
.
returns all the S-function selectors for
sel
= slcoverage.SFcnSelector.allSelectors(element
)element
.
returns selectors for sel
= slcoverage.Selector.allSelectors(element
,Name,Value
)element
, with additional options specified by
one or more Name,Value
pair arguments.
Input Arguments
element
— Model element to select
handle | Simulink® ID
Model element to select, specified as a handle or the model element Simulink identifier.
Example: 'sldemo_lct_bus:18'
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'Type',slcoverage.BlockSelectorType.BlockInstance,'Description','F
outcome'
Type
— Selector type refinement
slcoverage.BlockSelectorType
value | slcoverage.CodeSelectorType
value | slcoverage.MetricSelectorType
value | slcoverage.SFcnSelectorType
value
Selector type refinement specified as one of the
slcoverage.BlockSelectorType
slcoverage.CodeSelectorType
,
slcoverage.MetricSelectorType
, or
slcoverage.SFcnSelectorType
values. Possible
values:
Block selector types:
slcoverage.BlockSelectorType.BlockInstance
— An instance of a block or an external MATLAB function called by a MATLAB function 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
— A custom C or C++ code file name.slcoverage.CodeSelectorType.Function
— A custom C or C++ code function name.slcoverage.CodeSelectorType.Decision
— A custom C or C++ code decision.slcoverage.CodeSelectorType.Condition
— A custom C or C++ code condition.slcoverage.CodeSelectorType.DecisionOutcome
— A custom C or C++ code decision outcome.slcoverage.CodeSelectorType.ConditionOutcome
— A custom C or C++ code condition outcome.slcoverage.CodeSelectorType.MCDCOutcome
— A custom C or C++ code MCDC outcome.slcoverage.CodeSelectorType.RelationalBoundaryOutcome
— A custom C or C++ code relational boundary outcome.
Metric selector types:
slcoverage.MetricSelectorType.ConditionOutcome
objects select condition metric objective outcomes.slcoverage.MetricSelectorType.DecisionOutcome
objects select decision metric objective outcomes.slcoverage.MetricSelectorType.MCDCOutcome
objects select MCDC metric objective outcomes.slcoverage.MetricSelectorType.RelationalBoundaryOutcome
objects select outcome metrics related to relational boundary outcomes.slcoverage.MetricSelectorType.SaturationOverflowOutcome
objects select 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
— Description text to match
character vector or string
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')
SimulationMode
— Simulation mode
character vector or string
Simulation mode to run when selecting code filters, entered as one of the following:
Object Specification | Description |
---|---|
| Extract code selectors for custom code in normal simulation, such as custom code called from a C Caller block or a Stateflow chart. |
| Extract code selectors for code generated in Simulation-in-the-Loop (SIL) mode and code selectors for the top model code interface |
| Extract code selectors for code generated in Processor-in-the-Loop (PIL) mode and code selectors for the top model code interface |
| 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 |
| Extract code selectors for the model reference code interface in SIL mode |
| Extract code selectors for the model reference code interface in PIL mode |
| 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
sel
— Selectors for the model or code element
array of Selector
objects
Selectors for the model or code element, returned as an array of
Selector
objects.
Examples
Get All Selectors
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 = 1x10 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.
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');
Get Selector by Type and Description
This example shows how to get a selector by type and description. In this example, you get all selectors for the False outcomes of the And block whose type is ConditionOutcome
.
Load the model into memory.
modelName = 'slcoverage_lct_bus'; load_system(modelName); load slcoverage_lct_data.mat
The slcoverage_lct_bus model has an S-Function. Build the S-Function by using legacy_code.
def = legacy_code('initialize'); def.SFunctionName = 'slcoverage_sfun_counterbus'; def.OutputFcnSpec = ... ['void counterbusFcn(COUNTERBUS u1[1], '... 'int32 u2, COUNTERBUS y1[1], int32 y2[1])']; def.HeaderFiles = {'counterbus.h'}; def.SourceFiles = {'counterbus.c'}; def.Options.supportCoverage = true; legacy_code('generate_for_sim', def);
### Start Compiling slcoverage_sfun_counterbus mex -I/tmp/Bdoc24b_2725827_4120569/tpe5ea69f8/slcoverage-ex13162396 -c /tmp/Bdoc24b_2725827_4120569/tp7b826a93_7f96_4ea0_a08f_0a453cc6dced/counterbus.c -outdir /tmp/Bdoc24b_2725827_4120569/tpd0491913_fc03_413c_a0ac_d942ff403b59 Building with 'gcc'. MEX completed successfully. mex -I/tmp/Bdoc24b_2725827_4120569/tpe5ea69f8/slcoverage-ex13162396 /tmp/Bdoc24b_2725827_4120569/tp7b826a93_7f96_4ea0_a08f_0a453cc6dced/tp782f5b82_4810_42ba_bc6f_2e36accf34ad.c /tmp/Bdoc24b_2725827_4120569/tpd0491913_fc03_413c_a0ac_d942ff403b59/counterbus.o -L/mathworks/devel/bat/filer/batfs2566-0/Bdoc24b.2725827/build/runnable/matlab/bin/glnxa64 -lmwsl_sfcn_cov_bridge -output slcoverage_sfun_counterbus Building with 'gcc'. MEX completed successfully. mex -I/tmp/Bdoc24b_2725827_4120569/tpe5ea69f8/slcoverage-ex13162396 -c /tmp/Bdoc24b_2725827_4120569/tpe5ea69f8/slcoverage-ex13162396/counterbus.c -outdir /tmp/Bdoc24b_2725827_4120569/tpd0491913_fc03_413c_a0ac_d942ff403b59 Building with 'gcc'. MEX completed successfully. mex -I/tmp/Bdoc24b_2725827_4120569/tpe5ea69f8/slcoverage-ex13162396 /tmp/Bdoc24b_2725827_4120569/tp7b826a93_7f96_4ea0_a08f_0a453cc6dced/slcoverage_sfun_counterbus.c /tmp/Bdoc24b_2725827_4120569/tp7b826a93_7f96_4ea0_a08f_0a453cc6dced/tp89f45314_49a1_4cc3_83bc_f9fe29fccb27.c /tmp/Bdoc24b_2725827_4120569/tp7b826a93_7f96_4ea0_a08f_0a453cc6dced/tp76b6a94d_ac7f_406a_b398_ed2c8466731f.c /tmp/Bdoc24b_2725827_4120569/tpd0491913_fc03_413c_a0ac_d942ff403b59/counterbus.o -L/mathworks/devel/bat/filer/batfs2566-0/Bdoc24b.2725827/build/runnable/matlab/bin/glnxa64 -lmwsl_sfcn_cov_bridge -output slcoverage_sfun_counterbus Building with 'gcc'. MEX completed successfully. ### Finish Compiling slcoverage_sfun_counterbus ### Exit
Get the false outcome condition selectors for the And block by searching for descriptions that include F
.
id = getSimulinkBlockHandle([modelName,'/slCounter/And']); sel = slcoverage.Selector.allSelectors(id, ... 'Type',slcoverage.MetricSelectorType.ConditionOutcome, ... 'Description','F')
sel = 1x2 MetricSelector array with properties: ObjectiveIndex OutcomeIndex Description Type Id ConstructorCode
Look at the constructor code for the two selectors that were returned.
sel.ConstructorCode
ans = 'slcoverage.MetricSelector(slcoverage.MetricSelectorType.ConditionOutcome, 'slcoverage_lct_bus:23', 1, 2)' ans = 'slcoverage.MetricSelector(slcoverage.MetricSelectorType.ConditionOutcome, 'slcoverage_lct_bus:23', 2, 2)'
Version History
Introduced in R2017b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)