setResultDetails
将结果详细信息与检查对象相关联
语法
setResultDetails(ElementResults)
说明
在检查回调函数中,使用 setResultDetails(
将 ElementResults
)ElementResults
与检查 (CheckObj
) 相关联。
ElementResults
是 ModelAdvisor.ResultDetail
类的实例的集合。
输入参数
ElementResults |
|
示例
此示例显示了在 AdvisorCustomizationExample
模型中执行检查模块名称是否出现在模块下方检查对应的结果详细信息。在代码末尾,CheckObj.setResultDetails(ElementResults);
将结果与检查对象相关联。有关详细信息,请参阅创建和部署模型顾问自定义配置。
% ----------------------------- % This callback function uses the DetailStyle CallbackStyle type. % ----------------------------- function DetailStyleCallback(system, CheckObj) % Get the Model Advisor object. mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system); % Find the blocks whose names do not appear below the block. violationBlks = find_system(system, 'Type','block',... 'NamePlacement','alternate',... 'ShowName', 'on'); if isempty(violationBlks) ElementResults = ModelAdvisor.ResultDetail; ElementResults.ViolationType = 'info'; ElementResults.Description = 'Identify blocks where the name is not displayed below the block.'; ElementResults.Status = 'All blocks have names displayed below the block.'; mdladvObj.setCheckResultStatus(true); else for i=1:numel(violationBlks) ElementResults(1,i) = ModelAdvisor.ResultDetail; end for i=1:numel(ElementResults) ModelAdvisor.ResultDetail.setData(ElementResults(i), 'SID',violationBlks{i}); ElementResults(i).Description = 'Identify blocks where the name is not displayed below the block.'; ElementResults(i).Status = 'The following blocks have names that do not display below the block:'; ElementResults(i).RecAction = 'Change the location such that the block name is below the block.'; end mdladvObj.setCheckResultStatus(false); mdladvObj.setActionEnable(true); end CheckObj.setResultDetails(ElementResults); end
版本历史记录
在 R2018b 中推出