setResultDetails

Class: ModelAdvisor.Check
Package: ModelAdvisor

Associates result details with a check object

Syntax

setResultDetails(ElementResults)

Description

In the check callback function, use setResultDetails(ElementResults) to associate ElementResults with the check (CheckObj).

ElementResults is a collection of instances of the ModelAdvisor.ResultDetail class.

Input Arguments

ElementResults

Collection of ResultDetailObjs objects

Examples

This example shows the result details that correspond to the execution of check "Check whether block names appear below blocks" in the slvnvdemo_mdladv example model. At the end of the code, CheckObj.setResultDetails(ElementResults); associates the results with the check object.

% -----------------------------
% Sample new check style callback function, used for check 
% Check whether block names appear below blocks  
% -----------------------------
function SampleNewCheckStyleCallback(system, CheckObj)
mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system); % get object

% find all blocks whose name does not appear below blocks
violationBlks = find_system(system, 'Type','block',...
                           'NamePlacement','alternate',...
                           'ShowName', 'on');
if isempty(violationBlks)
    ElementResults = ModelAdvisor.ResultDetail;
    ElementResults.IsInformer = true;
    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
    ElementResults(1,numel(violationBlks))=ModelAdvisor.ResultDetail;
    for i=1:numel(ElementResults)
        ElementResults(i).setData(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 blocks:';
        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);

Introduced in R2018b