Main Content

setSubResultStatus

Add status to the check or subcheck result

Syntax

setSubResultStatus(ft_obj, 'status')

Description

setSubResultStatus(ft_obj, 'status')is an optional method that displays the status in the result. Use this method to display the status of the check or subcheck in the result.ft_objis a handle to a template object.statusis a character vector identifying the status of the check:

Pass: Check did not identify issues.
D-Pass: Dependent on configuration parameter. Check did not identify issues.
Warn: Check has identified issues.
Fail: Check fails to execute.

Examples

This example shows how to create a callback function for a custom check that finds and reports optimization settings. The check consists of two subchecks. The first reviews theBlock reductionoptimization setting and the second reviews theConditional input branch executionoptimization setting.

Acheck with subchecksincludes the following items in the results:

  • A description of what the overall check is reviewing.

  • A title for the subcheck.

  • 的描述subcheck正在审查。

  • References to standards, if applicable.

  • The status of the subcheck.

  • A description of the status.

  • Results for the subcheck.

  • Recommended actions to take when the subcheck does not pass.

  • A line between the subcheck results.

% Sample Check 3 Callback Function: Check with Subchecks and Actions% Find and report optimization settingsfunctionResultDescription = OptmizationSettingCallback(system)% Initialize variablessystem =getfullname(system); mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system); mdladvObj.setCheckResultStatus(false);% Default check status is 'Warning'ResultDescription = {};% Format results in a list using Model Advisor Result Template API% Create a list template object for first subcheckft1 = ModelAdvisor.FormatTemplate('ListTemplate');% Description of check in resultssetCheckText(ft1,'Check optimization settings');% Title and description of first subchecksetSubTitle(ft1,'Verify Block reduction optimization setting'); setInformation(ft1,['Check to confirm that the Block reduction '...'check box is cleared.']);% Add See Also section with references to applicable standardsdocLinks{1} = {['Reference DO331 Section MB.6.3.4.e - Source code '...'is traceable to low-level requirements']};% Review 'Block reduction' optimizationsetRefLink(ft1,docLinks);ifstrcmp(get_param(system,'BlockReduction'),'off')% 'Block reduction' is cleared% Set subresult status to 'Pass' and display text describing the statussetSubResultStatus(ft1,'Pass'); setSubResultStatusText(ft1,['The ''Block reduction'' '...'check box is cleared']); ResultStatus = true;else% 'Block reduction' is selected% Set subresult status to 'Warning' and display text describing the statussetSubResultStatus(ft1,'Warn'); setSubResultStatusText(ft1,['The Block reduction '...'check box is selected.']); setRecAction(ft1,['Clear the ''Optimization > Block reduction'''...' check box in the Configuration Parameters dialog box.']); ResultStatus = false;endResultDescription{end+1} = ft1;% Title and description of second subcheckft2 = ModelAdvisor.FormatTemplate('ListTemplate'); setSubTitle(ft2,'Verify Conditional input branch execution setting'); setInformation(ft2,['Check to confirm that the ''Conditional input branch '...'execution'' check box is cleared.'])% Add See Also section and references to applicable standardsdocLinks{1} = {['Reference DO331 Section MB.6.4.4.2 - Test coverage '...'of software structure is achieved']}; setRefLink(ft2,docLinks);% Last subcheck, supress linesetSubBar(ft2,0);% Check status of the 'Conditional input branch execution' check boxifstrcmp(get_param(system,'ConditionallyExecuteInputs'),'off')% The 'Conditional input branch execution' check box is cleared% Set subresult status to 'Pass' and display text describing the statussetSubResultStatus(ft2,'Pass'); setSubResultStatusText(ft2,['The ''Conditional input branch '...'execution'' check box is cleared.']);else% 'Conditional input branch execution' is selected% Set subresult status to 'Warning' and display text describing the statussetSubResultStatus(ft2,'Warn'); setSubResultStatusText(ft2,['The ''Conditional input branch '...“执行”复选框被选中。”]); setRecAction(ft2,['Clear the ''Optimization > Conditional input branch '...'execution'' check box in the Configuration Parameters dialog box.']); ResultStatus = false;endResultDescription{end+1} = ft2;% Pass list template object to Model AdvisormdladvObj.setCheckResultStatus(ResultStatus);% Set overall check status% Enable Modify Settings button when check failsmdladvObj.setActionEnable(~ResultStatus);