User`s guide
Model Advisor Code Examples
25-53
% Defines actions to execute at startup and post-execution
function [checkCellArray taskCellArray] = ...
ModelAdvisorProcessFunction(stage, system, checkCellArray, taskCellArray)
switch stage
% Specify the appearance of the Model Advisor window at startup
case 'configure'
for i=1:length(checkCellArray)
% Hide all checks that do not belong to custom folder
if isempty(strfind(checkCellArray{i}.ID, 'mathworks.example'))
checkCellArray{i}.Visible = false;
checkCellArray{i}.Value = false;
end
end
% Specify actions to perform after the Model Advisor completes execution
case 'process_results'
for i=1:length(checkCellArray)
% Print message if check does not pass
if checkCellArray{i}.Selected && (strcmp(checkCellArray{i}.Title, ...
'Check Simulink window screen color'))
mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system);
% Verify whether the check was run and if it failed
if mdladvObj.verifyCheckRan(checkCellArray{i}.ID)
if ~mdladvObj.getCheckResultStatus(checkCellArray{i}.ID)
% Display text in MATLAB Command Window
disp(['Example message from Model Advisor Process'...
' callback.']);
end
end
end
end
end
Input Parameter Definition
The following is an example of defining input parameters that you add to a custom
check. You must include input parameter definitions inside a custom check definition
(see “Check Definition Function” on page 25-34). The following code, when included in a
custom check definition, creates three input parameters.
rec = ModelAdvisor.Check('com.mathworks.sample.Check1');
rec.setInputParametersLayoutGrid([3 2]);
% define input parameters
inputParam1 = ModelAdvisor.InputParameter;
inputParam1.Name = 'Skip font checks.';
inputParam1.Type = 'Bool';
inputParam1.Value = false;
inputParam1.Description = 'sample tooltip';
inputParam1.setRowSpan([1 1]);
inputParam1.setColSpan([1 1]);
inputParam2 = ModelAdvisor.InputParameter;