ModelAdvisor.ResultDetail class

Package: ModelAdvisor

Defines result detail objects

Description

As part of the check callback function, ModelAdvisor.ResultDetail objects are created for each block that the find_system() API returns as violating the check. To associate these objects with the ModelAdvisor.Check object, use the setResultDetails method. The ModelAdvisor.ResultDetail objects are saved as the ResultDetails property of the ModelAdvisor.Check class.

Properties

expand all

Simulink Identifier (SID) for each block that violates the check. In the check callback function, specify the identifier by passing a handle to the block to the setData method.

Data Types: char

Simulink Identifier (SID) is the default data type of the ModelAdvisor.ResultDetail object.

Data Types: enum

Provides informational content.

Data Types: logical

Provides informational content and a recommended action message for fixing the issues.

Data Types: logical

Specify a message that describes the result. This text is presented in the Model Advisor result pane.

Data Types: char

Specify a title for the result. This text is presented in the Model Advisor result pane.

Data Types: char

Specify a message that provides additional information about the result. This text is presented in the Model Advisor result pane.

Data Types: char

Specify a status message for the result. The text is presented in the Model Advisor result pane.

Data Types: char

Specify a recommended action message for the result. The text is presented in the Model Advisor result pane.

Data Types: char

Methods

setDataAssociate Simulink Identifier with ModelAdvisor.ResultDetail object

Examples

This example shows result details that correspond to the execution of check Check whether block names appear below blocks in the AdvisorCustomizationExample model. To view the files in this example, see Create and Deploy a Model Advisor Custom Configuration.

Define a Collection of Result Detail Objects

The defineDetailStyleCheck check definition function contains the DetailStyleCallback check callback function. To return model elements in the system that meet a specified criteria, the DetailStyleCallback function uses the find_system() API. In this example, the find_system() API returns blocks whose name does not appear below the block (violationBlks).

% find all blocks whose name does not appear below blocks
violationBlks = find_system('System','Type','block','NamePlacement','alternate','ShowName', 'on');

ModelAdvisor.ResultDetail creates ResultDetailObjs for each model element returned by the find_system API. When violationBlks is empty, the ElementResults collection consists of a single object. The Name,Value pairs define the collection for a nonviolated check. For this type of collection, the Simulink.ModelAdvisor.setCheckResultStatus(true) method specifies that the check is not violated and displays Passed on the Model Advisor.

In this code sample, the find_system API does not identify blocks whose name appears below the block, therefore ElementResults provides information content only.

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);                

When the find_system API returns a list of model elements that meet specified criteria, the ModelAdvisor.ResultDetail class creates a ResultDetailObjs object for each element in violationBlks. The Name,Value pairs define ElementResults as a collection of objects that violate the check. For this collection, the Simulink.ModelAdvisor.setCheckResultStatus(false) method specifies that the check is violated and displays Warning or Failed on the Model Advisor. The Simulink.ModelAdvisor.setActionEnable(true) method enables the ability to fix the check violation issue from the Model Advisor.

In this code sample, the find_system API returns a list of blocks whose name appears below the block. ElementResults includes each ResultDetailObjs object that violates the check and provides a recommended action message for fixing the check violation.

else
    ElementResults(1,numel(violationBlks))=ModelAdvisor.ResultDetail;
    for i=1:numel(ElementResults)
        ElementResults(i).setData(violationBlks{i});  
        ElementResults.Description = 'Identify blocks where the name is not displayed below the block.';  
        ElementResults.Status = 'The following blocks have names that do not display below the blocks:';   
        ElementResults.RecAction = 'Change the location such that the block name is below the block.'; 
    end                
    mdladvObj.setCheckResultStatus(false);  
    mdladvObj.setActionEnable(true);          
 

The ModelAdvisor.Check.setResultDetails method associates the results with the check (CheckObj).

CheckObj.setResultDetails(ElementResults);   
 

After executing the check, you can view the results in the Model Advisor as a collection, such as by recommended action, block, or subsystem. To define this report style, specify 'DetailStyle' as the callback style in the ModelAdvisor.Check.setCallbackFcn method.

% Create ModelAdvisor.Check object and set properties.
rec = ModelAdvisor.Check('com.mathworks.sample.detailStyle');
rec.Title = 'Check whether block names appear below blocks';  
rec.TitleTips = 'Check position of block names';
rec.setCallbackFcn(@DetailStyleCallback,'None','DetailStyle');
    

Introduced in R2018b