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

조회 수: 3 (최근 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