| Simulink® Verification and Validation™ | ![]() |
| On this page… |
|---|
Custom checks allow you to create a new check to use in the Model Advisor. You define custom checks in one or more functions that specify the properties of each instance of the ModelAdvisor.Check class. You must define one instance of this class for each custom check that you want to add to the Model Advisor, and register the custom check as described in Registering Custom Checks, Tasks, and Groups. The sections that follow describe how to define custom checks.
The following table describes the properties of the ModelAdvisor.Check class:
| Property | Data Type | Default Value | Description | |
|---|---|---|---|---|
| Title | String | '' (null string) | Name of the check as it should appear in the Model Advisor. | |
| ID | String | '' (null string) | Permanent, unique identifier for the check that you must specify. | |
| TitleTips | String | '' (null string) | Description of the check, which the Model Advisor displays in its right pane when you view details about the check. | |
| CallbackHandle | Function handle | [] (empty handle) | Handle to the callback function for the check. | |
| CallbackContext | Enumeration | 'None' | Context for checking the model or subsystem:
| |
| CallbackStyle | Enumeration | 'StyleOne' | Type of callback function:
| |
| Visible | Boolean | true | Show or hide check?
| |
| Enable | Boolean | true | Can user enable and disable check?
| |
| Value | Boolean | true | Initial status:
| |
| LicenseName | Cell array | { } (empty cell array) | Cell array of names of product licenses required to enable the check. The Model Advisor does not display the check if license requirements are not met. | |
| Result | Cell array | { } (empty cell array) | Cell array used for storing the results returned by the callback
function referenced by CallbackHandle.
| |
| ListViewVisible | Boolean | false | A boolean value that sets the status of the Explore Result button.
|
Typically, you modify the behavior of the Visible, Enable, and Value properties in a process callback function (see Defining a Process Callback Function). The following chart illustrates how these properties interact:

You can specify where the Model Advisor places custom checks within the Model Advisor tree using the following guidelines.
To place a check in a new folder in the Model Advisor Task Manager, use the ModelAdvisor.Group class. See Defining Custom Groups.
To place a check in a new folder in the By Task folder, use the ModelAdvisor.FactoryGroup class. See Defining Custom Groups.
To place a check in the By Product folder, use the ModelAdvisor.Root.publish method.
When you add a check using the ModelAdvisor.Root.publish method, the Model Advisor creates a ModelAdvisor.Task object for the check. You use the ModelAdvisor.Task object when you specify an action callback function for the check. See Action Callback Function.
The following is an example of a function that defines the custom checks associated with the callback functions described in Creating Callback Functions for Checks. The check definition function returns a cell array of custom checks to be added to the Model Advisor.
function defineModelAdvisorChecks
mdladvRoot = ModelAdvisor.Root;
% --- sample check 1
rec = ModelAdvisor.Check('com.mathworks.sample.Check1');
rec.Title = 'Check Simulink block font';
rec.TitleTips = 'Example style three callback';
rec.setCallbackFcn(@SampleStyleThreeCallback,'None','StyleThree');
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;
inputParam2.Name = 'Standard font size';
inputParam2.Value='12';
inputParam2.Type='String';
inputParam2.Description='sample tooltip';
inputParam2.setRowSpan([2 2]);
inputParam2.setColSpan([1 1]);
inputParam3 = ModelAdvisor.InputParameter;
inputParam3.Name='Valid font';
inputParam3.Type='Combobox';
inputParam3.Description='sample tooltip';
inputParam3.Entries={'Arial', 'Arial Black'};
inputParam3.setRowSpan([2 2]);
inputParam3.setColSpan([2 2]);
rec.setInputParameters({inputParam1,inputParam2,inputParam3});
% define action (fix) operation
myAction = ModelAdvisor.Action;
myAction.setCallbackFcn(@sampleActionCB);
myAction.Name='Fix block fonts';
myAction.Description=...
'Click the button to update all blocks with specified font';
rec.setAction(myAction);
% add 'Explore Result' button
rec.ListViewVisible = true;
% publish check into By Product > Demo group.
mdladvRoot.publish(rec, 'Demo');
% --- sample check 2
rec = ModelAdvisor.Check('com.mathworks.sample.Check2');
rec.Title = 'Check Simulink window screen color';
rec.TitleTips = 'Example style one callback';
rec.setCallbackFcn(@SampleStyleOneCallback,'None','StyleOne');
% define action (fix) operation
myAction2 = ModelAdvisor.Action;
myAction2.setCallbackFcn(@sampleActionCB2);
myAction2.Name='Fix window screen color';
myAction2.Description=...
'Click the button to change Simulink window screen color to white';
rec.setAction(myAction2);
% publish check into By Product > Demo group.
mdladvRoot.publish(rec, 'Demo');
% --- sample check 3
rec = ModelAdvisor.Check('com.mathworks.sample.Check3');
rec.Title = 'Check model optimization settings';
rec.TitleTips = 'Example style two callback';
rec.setCallbackFcn(@SampleStyleTwoCallback,'None','StyleTwo');
% define action (fix) operation
myAction3 = ModelAdvisor.Action;
myAction3.setCallbackFcn(@sampleActionCB3);
myAction3.Name='Fix model optimization settings';
myAction3.Description='Click the button to turn on model optimization settings';
rec.setAction(myAction3);
% publish check into By Product > Demo group.
mdladvRoot.publish(rec, 'Demo');
![]() | Creating Callback Functions for Checks | Defining Check Input Parameters | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |