Defining Custom Tasks

About Custom Tasks

Custom tasks provide a method for adding checks to the Model Advisor tree. You define custom tasks in one or more functions that specify the properties of each instance of the ModelAdvisor.Task class. You must define one instance of this class for each custom task that you want to add to the Model Advisor, and register the custom task as described in Registering Custom Checks, Tasks, and Groups. The sections that follow describe how to define custom tasks.

Properties of Custom Tasks

The following table describes the properties of the ModelAdvisor.Task class:

PropertyData TypeDefault ValueDescription
DisplayNameString'' (null string)Name of the task as it should appear in Model Advisor.
IDString'' (null string)Permanent, unique identifier for the task. The Model Advisor automatically assigns a string toID if you do not specify it.

    Caution  

    • The value of ID must remain constant.

    • The Model Advisor generates an error if ID is not unique.

    • Groups should refer to tasks by ID.

DescriptionString'' (null string)Description of the task, which Model Advisor displays in the Analysis box.
VisibleBooleantrueShow or hide task?
  • true = Display task in Model Advisor

  • false = Hide task

EnableBooleantrueCan user enable and disable task?
  • true = Display check box control for task

  • false = Hide check box control for task

ValueBooleantrueInitial status:
  • true = Task is enabled

  • false = Task is disabled

LicenseNameCell array{ } (empty cell array)Cell array of names of product licenses required to enable the check. Model Advisor does not display the check if license requirements are not met.

If ModelAdvisor.Check LicenseName is specified, the Model Advisor displays the check when the union of both properties is true.

    Tip   To find the correct text for license strings, type help license at the MATLAB command line.

MAObjSimulink.
ModelAdvisor
object
Handle to Simulink.
ModelAdvisor
object
The Model Advisor object you are working on.

How Visible, Enable, and Value Properties Interact for Tasks

These properties interact the same way for tasks as for checks (see How Visible, Enable, and Value Properties Interact).

Defining Where Tasks Appear

You can specify where the Model Advisor places tasks within the Model Advisor tree using the following guidelines.

Code Example: Task Definition Function

The following is an example of a task definition function. This function defines three tasks. See Code Example: Group Definition for an example of placing these tasks into a custom group.

function defineTaskAdvisor
mdladvRoot = ModelAdvisor.Root;

MAT1 = ModelAdvisor.Task('com.mathworks.sample.TaskSample1');
MAT1.DisplayName='Example task with input parameter and auto-fix ability';
MAT1.setCheck('com.mathworks.sample.Check1');
mdladvRoot.register(MAT1);

MAT2 = ModelAdvisor.Task('com.mathworks.sample.TaskSample2');
MAT2.DisplayName='Example task 2';
MAT2.setCheck('com.mathworks.sample.Check2');
mdladvRoot.register(MAT2);

MAT3 = ModelAdvisor.Task('com.mathworks.sample.TaskSample3');
MAT3.DisplayName='Example task 3';
MAT3.setCheck('com.mathworks.sample.Check3');
mdladvRoot.register(MAT3);
  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS