主要内容

Slcoverage。Filter class

Package:Slcoverage

Coverage filter set

Description

使用一个对象Slcoverage。Filterclass to filter out unsatisfied coverage objectives by creating rules using theSlcoverage。FilterRuleclass.

TheSlcoverage。Filter班级是handleclass.

Creation

Description

菲尔特= slcoverage.Filter()creates anSlcoverage。Filter目的。

菲尔特= slcoverage.Filter(菲尔特erFile)creates anSlcoverage。Filter包含保存在的过滤器规则的对象菲尔特erFile

Input Arguments

expand all

CVF格式的过滤文件,指定为文件名的路径名的字符数组,或字符数组的单元格数组。您无需包括文件扩展名。

Example:'myfilt','filters\myfilt',{'myfilt1', 'myfilt2'}

方法

expand all

Examples

collapse all

This example shows how to add a rule to a coverage filter file.

Create a filter object and use theBlockSelector类来创建aBlockSelector饱和块的对象slvnvdemo_covfilt模型。

菲尔特= slcoverage.Filter; blockSel = slcoverage.BlockSelector(slcoverage.BlockSelectorType.BlockInstance,。。。'slvnvdemo_covfilt/饱和');

Create a rule to filter the Saturation block usingSlcoverage。FilterRule将选择器作为第一个输入和基本原理作为第二输入。

rule = slcoverage.FilterRule(blockSel,'Edge case');

Use theaddRulemethod of theSlcoverage。Filter类将规则添加到过滤器对象。

addrule(filt,规则);

Save the filter with the new rule to a filter file using thesavemethod of theSlcoverage。Filterclass.

save(filt,'myFilterFile')

This example shows how to create a filter object and add a rule to exclude a subsystem from coverage analysis.

Open theslvnvdemo_covfilt模型。用一个SimulationInputobject to enable coverage recording and specify coverage settings.

modelName ='slvnvdemo_covfilt';load_system(modelName)simin = s金宝appimulink.simulationInput(modelName);simin = setModelParameter(simin,'CovEnable','on');simin = setModelParameter(simin,“ covmetricsstructurallevel”,'MCDC');simin = setModelParameter(simin,'CovSaveSingleToWorkspaceVar','on');simin = setModelParameter(simin,'CovSaveName','covData');

Simulate the model. The coverage data is stored in the value supplied for theCovSaveNameproperty.

simout = sim(simin);covData = simOut.covData;

You can filter a block by using theslcoverage.blockselectorclass. To exclude the Switchable config subsystem, useslcoverage.blockselettype.subsystemallcontentas the first input.

subsysSel = slcoverage.BlockSelector(。。。slcoverage.blockselettype.subsystemallcontent,。。。'slvnvdemo_covfilt/Switchable config');

Create the filter rule by passing the selector, rationale, and the exclude filter mode as inputs.

rule = slcoverage.FilterRule(subsysSel,。。。'Unused configuration',。。。slcoverage.filtermode.exclude);

Create anSlcoverage。Filter对象,然后将规则添加到其中。

菲尔特= slcoverage.Filter; addRule(filt,rule);

Save the filter to a file calledblockFilter.cvf。要创建使用此覆盖过滤器的报告,请将过滤器文件作为值添加到菲尔特erproperty ofcovData,并创建一个名为的报告coverageData.htmlusingcovData

save(filt,'blockFilter') covData.filter ='blockFilter';cvhtml('coverageData',covData)

如果您有多个包含自己的规则集的过滤文件,则可以通过创建过滤器文件名或路径名的单元格数组将其应用于覆盖范围结果。在此示例中,您将两个过滤文件应用于一个cvdataobject and then view the report to see that the filters are applied.

加载slvnvdemo_covfiltmodel into memory.

modelName ='slvnvdemo_covfilt';load_system(modelName)

Set the coverage settings by using aSimulink.SimulationInputobject and simulate the model usingsim

simin = 金宝appsimulink.simulationInput(modelName);simin = setModelParameter(simin,'CovEnable','on');simin = setModelParameter(simin,“ covmetricsstructurallevel”,'MCDC');simin = setModelParameter(simin,'CovSaveSingleToWorkspaceVar','on');simin = setModelParameter(simin,'CovSaveName','covData');simout = sim(simin);

Apply the two filters to thecvdata将它们分配给过滤器属性作为单元格数组来对象。

covData.filter = {'filter_1','filter_2'}; cvhtml('twoFiltersCovData',covData);

You can see the applied coverage filters in theObjects Filtered from Coverage Analysissection of the coverage report.

Version History

Introduced in R2017b