slcoverage.Selector 类
命名空间: slcoverage
获取所有类型的选择器
属性
ConstructorCode
— 用于创建此选择器对象的代码
字符数组
用于创建此选择器对象的代码,以字符向量形式返回。
属性:
GetAccess | public |
SetAccess | 受保护 |
Description
— 选择器的描述
字符向量
选择器的描述,以字符向量形式返回。Simulink® Coverage™ 根据选择器创建描述。
属性:
GetAccess | public |
SetAccess | 受保护 |
Id
— 元素标识符
Simulink ID (默认) | 句柄
模型元素的标识符,以 Simulink ID 的字符向量或句柄形式返回。
属性:
GetAccess | public |
SetAccess | 受保护 |
Type
— 选择器类型
选择器类型值
选择器类型,以相应选择器的选择器类型返回。
属性:
GetAccess | public |
SetAccess | 受保护 |
方法
公共方法
allSelectors | 模型或代码元素的选择器 |
示例
获取所有选择器
此示例显示如何获取 And 模块的所有选择器,然后添加规则来申述或排除选择器。度量选择器只能申述。
加载模型并设置覆盖率设置
modelName = 'slvnvdemo_covfilt'; load_system(modelName); set_param(modelName,'CovEnable','on','CovMetricStructuralLevel','MCDC');
首先,获取 And 模块的模块句柄。
id = getSimulinkBlockHandle([modelName,'/Saturation']);
使用模块句柄获取选择器。
sel = slcoverage.Selector.allSelectors(id)
sel = 1x10 heterogeneous Selector (BlockSelector, MetricSelector) array with properties: Description Type Id ConstructorCode
该模块有十个选择器。您可以对每个内容进行索引以查看其内容。在此示例中,您想要对第六个选择器进行申述。
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)'
创建一个申述规则,然后创建一个过滤对象并将该规则添加到其中。
rule = slcoverage.FilterRule(sel(6),'Expected result');
filt = slcoverage.Filter;
filt.addRule(rule);
保存过滤器并生成覆盖率报告。
filt.save('metrfilter'); csim = cvsim(modelName); csim.filter = 'metrfilter'; cvhtml('cov',csim,'-sRT=0');
版本历史记录
在 R2017b 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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)