User`s guide
25 Create Model Advisor Checks
25-58
Basic Check with Pass/Fail Status
Here is an example of a callback function for a custom basic check that finds and reports
unconnected lines, input ports, and output ports.
A basic check includes the following items in the results:
• A description of what the check is reviewing.
• References to standards, if applicable.
• The status of the check.
• A description of the status.
• Results for the check.
• The recommended actions to take when the check does not pass.
A basic check does not include the following items in the results:
• Subcheck results.
• A line below the results.
% Sample Check 2 Callback Function: Basic Check with Pass/Fail Status
% Find and report unconnected lines, input ports, and output ports
function ResultDescription = unconnectedObjectsCallbackUsingFT(system)
mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system);
% Initialize variables
mdladvObj.setCheckResultStatus(false);
ResultDescription ={};
ResultStatus = false; % Default check status is 'Warning'
system = getfullname(system);
isSubsystem = ~strcmp(bdroot(system), system);
% Format results in a list using Model Advisor Result Template API
% Create a list template object
ft = ModelAdvisor.FormatTemplate('ListTemplate');
% Description of check in results
if isSubsystem
checkDescStr = ['Identify unconnected lines, input ports, and ' ...
'output ports in the subsystem.'];
else
checkDescStr = ['Identify unconnected lines, input ports, and ' ...
'output ports in the model.'];
end
setCheckText(ft,checkDescStr);
% Add See Also section with references to applicable standards
checkStdRef = 'IEC 61508-3, Table A.3 (3) ''Language subset'' ';
docLinkSfunction{1} = {checkStdRef};
setRefLink(ft,docLinkSfunction);