How do I create a coverage filter for all Simulink blocks with a given Tag?

1 次查看(过去 30 天)
I would like to create a model coverage filter for all Simulink blocks with a given Tag.
I didn't see a way to do this with the BlockSelector workflow.

采纳的回答

Pat Canny
Pat Canny 2019-11-1
One way to do this is to use find_system to build a list of all Simulink blocks with a given tag.
Then, you can use BlockSelector and FilterRule to add a rule for each block.
modelName = 'filter_by_tag_test';
load_system(modelName)
%% Find blocks with given tag
tag_to_search = 'SOME_TAG';
% Find blocks with tag
blocks_with_tag = find_system(bdroot,'Tag',tag_to_search);
%% Enable coverage collection
set_param(modelName,'CovMetricSettings','dcme','RecordCoverage','on');
%% Iterate through blocks_with_tag, adding a filter for each block
filt = slcoverage.Filter; % instantiate Filter object
num_blocks = length(blocks_with_tag);
for i=1:num_blocks
id = Simulink.ID.getSID(blocks_with_tag{i});
bl = slcoverage.BlockSelector(slcoverage.BlockSelectorType.BlockInstance,id);
rule = slcoverage.FilterRule(bl,'Edge case');
filt.addRule(rule);
end
filt.save('blfilter');
%% Simulate with coverage enabled, generate report
csim = cvsim(modelName);
csim.filter = 'blfilter';
cvhtml('filter_by_tag_report',csim);
%% Clean up
close_system(modelName)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Address Missing Coverage 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by