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_2679053_1176531/tp86e8c320/slcoverage-ex13162396 -c /tmp/Bdoc24b_2679053_1176531/tp8ecc74b4_b608_40ba_b742_f34e53298977/counterbus.c -outdir /tmp/Bdoc24b_2679053_1176531/tp6d0bd7c3_b132_47d9_b025_ed8c689a7fea Building with 'gcc'. MEX completed successfully. mex -I/tmp/Bdoc24b_2679053_1176531/tp86e8c320/slcoverage-ex13162396 /tmp/Bdoc24b_2679053_1176531/tp8ecc74b4_b608_40ba_b742_f34e53298977/tpbd947a01_a606_4f04_9ca9_a05aa42e84b7.c /tmp/Bdoc24b_2679053_1176531/tp6d0bd7c3_b132_47d9_b025_ed8c689a7fea/counterbus.o -L/mathworks/devel/bat/filer/batfs2561-0/Bdoc24b.2679053/build/runnable/matlab/bin/glnxa64 -lmwsl_sfcn_cov_bridge -output slcoverage_sfun_counterbus Building with 'gcc'. MEX completed successfully. mex -I/tmp/Bdoc24b_2679053_1176531/tp86e8c320/slcoverage-ex13162396 -c /tmp/Bdoc24b_2679053_1176531/tp86e8c320/slcoverage-ex13162396/counterbus.c -outdir /tmp/Bdoc24b_2679053_1176531/tp6d0bd7c3_b132_47d9_b025_ed8c689a7fea Building with 'gcc'. MEX completed successfully. mex -I/tmp/Bdoc24b_2679053_1176531/tp86e8c320/slcoverage-ex13162396 /tmp/Bdoc24b_2679053_1176531/tp8ecc74b4_b608_40ba_b742_f34e53298977/slcoverage_sfun_counterbus.c /tmp/Bdoc24b_2679053_1176531/tp8ecc74b4_b608_40ba_b742_f34e53298977/tpfda46de5_da48_466e_8ff7_62c3992145f7.c /tmp/Bdoc24b_2679053_1176531/tp8ecc74b4_b608_40ba_b742_f34e53298977/tp95f1da3f_60eb_4a86_ab39_1d8c7796e8b8.c /tmp/Bdoc24b_2679053_1176531/tp6d0bd7c3_b132_47d9_b025_ed8c689a7fea/counterbus.o -L/mathworks/devel/bat/filer/batfs2561-0/Bdoc24b.2679053/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)