User`s guide
25 Create Model Advisor Checks
25-60
setRecAction(ft,'Connect the specified blocks.');
% Create a list of handles to problem objects
setListObj(ft,modelObj);
ResultStatus = false;
end
% Pass the list template object to the Model Advisor
ResultDescription{end+1} = ft;
% Set overall check status
mdladvObj.setCheckResultStatus(ResultStatus);
Check With Subchecks and Actions
Here is an example of a callback function for a custom check that finds and reports
optimization settings. The check consists of two subchecks. The first reviews the Block
reduction optimization setting, and the second reviews the Conditional input branch
execution optimization setting.
A check with subchecks includes the following items in the results:
• A description of what the overall check is reviewing.
• A title for the subcheck.
• A description of what the subcheck is reviewing.
• 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 settings
function ResultDescription = OptmizationSettingCallback(system)
% Initialize variables
system =getfullname(system);
mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system);
mdladvObj.setCheckResultStatus(false); % Default check status is 'Warning'
ResultDescription = {};
system = bdroot(system);
% Format results in a list using Model Advisor Result Template API
% Create a list template object for first subcheck
ft1 = ModelAdvisor.FormatTemplate('ListTemplate');
% Description of check in results
setCheckText(ft1,['Check model configuration for optimization settings that'...
'can impact safety.']);