slcoverage.SFcnSelector class

Package: slcoverage

Select S-function criterion for filtering rule

Description

Specify S-function selection criteria for a filter rule.

Construction

sel = slcoverage.SFcnSelector(type,element) specifies the type of selector to use for the selected model element.

sel = slcoverage.SFcnSelector(type,element,file) creates the selector based on the specified C or C++ file.

sel = slcoverage.SFcnSelector(type,element,file,function) creates the selector based on the specified C or C++ function in the specified file.

sel = slcoverage.SFcnSelector(type,element,file,function, expression,index) creates the selector based on the specified index of the specified decision expression.

Input Arguments

expand all

Type of S-function to select, specified as one of these values:

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

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

  • slcoverage.SFcnSelectorType.SFcnInstanceCppFunction selects an instance of a C or C++ function. Use with the file and function arguments.

  • slcoverage.SFcnSelectorType.SFcnInstanceCppCondition selects a condition outcome of the specified code. Use with file, function, expression, and index arguments.

  • slcoverage.SFcnSelectorType.SFcnInstanceCppDecision selects a decision outcome of the specified. Use with file, function, expression, and index arguments.

Model element to select, specified as a property name of the element, its handle, or its Simulink® identifier. Use a handle or ID for selector types that select an instance. Use a property name, such as the value of a block's 'BlockType' property, to select multiple model elements.

Example: 'sldemo_lct_bus:18', 'RelationalOperator'

C or C++ file to select, specified as a character vector or string.

Example: 'myfile.c'

C or C++ function to select, specified as a character vector or string.

Example: 'counterbusFcn'

Decision expression to select, specified as a character vector or string.

Example: 'inputGElower'

Matrix position of expression to select, specified as an integer.

Example: 2

Outputs

expand all

Selector object, returned as an slcoverage.SFcnSelector object or array of slcoverage.SFcnSelector objects.

Properties

expand all

This property is read-only.

Code used to create this selector object, returned as a character vector.

This property is read-only.

Description of the selector, returned as a character vector. Simulink Coverage™ creates the description based on the selector.

This property is read-only.

Decision expression for this selector, returned as a character vector.

This property is read-only.

C or C++ file for selector, returned as a character vector or string.

This property is read-only.

C or C++ function name for this selector, returned as a character vector.

This property is read-only.

Identifier of the model element, returned as character vector of the Simulink ID, model element property, or handle. This property is empty for the slcoverage.CodeSelector class.

Selector type, returned as one of these slcoverage.SFcnSelectorType values:

  • SFcnName

  • SFcnInstanceCppFileName

  • SFcnInstanceCppFunction

  • SFcnInstanceCppCondition

  • SFcnInstanceCppDecision

Methods

allSelectorsSelectors for model or code element

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

collapse all

Open and set up the model for S-function code coverage.

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

def = legacy_code('initialize');
def.SFunctionName = 'sldemo_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.IncPaths      = {'sldemo_lct_src'};
def.SrcPaths      = {'sldemo_lct_src'};
def.Options.supportCoverageAndDesignVerifier = true;

legacy_code('generate_for_sim',def);

Get the S-function selectors from the sldemo_sfun_counterbus block. Examine the constructor code property value for all the selectors.

sel = slcoverage.SFcnSelector.allSelectors('sldemo_lct_bus/TestCounter/sldemo_sfun_counterbus');
sel.ConstructorCode
ans =

    'slcoverage.SFcnSelector(slcoverage.SFcnSelectorType.SFcnName,'sldemo_sfun_counterbus')'


ans =

    'slcoverage.SFcnSelector(slcoverage.SFcnSelectorType.SFcnInstanceCppFileName,'sldemo_lct_bus:15',
'counterbus.c')'


ans =

    'slcoverage.SFcnSelector(slcoverage.SFcnSelectorType.SFcnInstanceCppFunction,'sldemo_lct_bus:15',
'counterbus.c','counterbusFcn')'


ans =

    'slcoverage.SFcnSelector(slcoverage.SFcnSelectorType.SFcnInstanceCppDecision,'sldemo_lct_bus:15',
'counterbus.c','counterbusFcn','(u1->limits.upper_saturation_limit >= limit) && inputGElower', 1)'


ans =

    'slcoverage.SFcnSelector(slcoverage.SFcnSelectorType.SFcnInstanceCppDecision,'sldemo_lct_bus:15',
'counterbus.c','counterbusFcn','inputGElower',2)'


ans =

    'slcoverage.SFcnSelector(slcoverage.SFcnSelectorType.SFcnInstanceCppCondition,'sldemo_lct_bus:15',
'counterbus.c','counterbusFcn','limit >= u1->limits.lower_saturation_limit',1)'

Create a filter object. Create a rule based on one of selectors by indexing into the selector object.

filt = slcoverage.Filter;
rule = slcoverage.FilterRule(sel(6),'OK to exclude',slcoverage.FilterMode.Exclude);
filt.addRule(rule);

Save the filter as sffilter. Simulate the model for code coverage. Add the filter file as the value to the filter property of the resulting cvdata object. Then generate the coverage report.

filt.save('sffilter');
csim = cvsim(modelName);
csim.filter = 'sffilter';
cvhtml('cov',csim);

Review the report. Click the sldemo_sfun_counterbus link and find the filter rule that you added under Objects Filtered from Coverage Analysis.

Introduced in R2017b