Create Procedures

What Is a Procedure?

A procedure is a series of checks. The checks in a procedure depend on passing the previous checks. If Check A is the first check in a procedure and Check B follows, the Model Advisor does not run Check B until Check A passes. Checks A and B can be either custom or provided by MathWorks®.

You create procedures with the ModelAdvisor.Procedure class API. You first add the checks to tasks, which are wrappers for the checks. The tasks are added to procedures.

When creating procedural checks, be aware of potential conflicts with the checks. Verify that it is possible to pass both checks.

Create Procedures Using the Procedures API

You use the ModelAdvisor.Procedure class to create procedural checks.

  1. Add each check to a task using the ModelAdvisor.Task.setCheck method. The task is a wrapper for the check. You cannot add checks directly to procedures.

  2. Add each task to a procedure using the ModelAdvisor.Procedure.addTask method.

Define Procedures

You define procedures in a procedure definition function that specifies the properties of each instance of the ModelAdvisor.Procedure class. Define one instance of the procedure class for each procedure that you want to add to the Model Advisor. Then register the procedure using the ModelAdvisor.Root.register method.

Add Subprocedures and Tasks to Procedures

You can add subprocedures or tasks to a procedure. The tasks are wrappers for checks.

  • Use the ModelAdvisor.Procedure.addProcedure method to add a subprocedure to a procedure.

  • Use the ModelAdvisor.Procedure.addTask method to add a task to a procedure.

Define Where Procedures Appear

You can specify where the Model Advisor places a procedure using the ModelAdvisor.Group.addProcedure method.

Procedure Definition

The following code example adds procedures to a group:

%Create three procedures
MAP1=ModelAdvisor.Procedure('com.mathworks.sample.myProcedure1');
MAP2=ModelAdvisor.Procedure('com.mathworks.sample.myProcedure2');
MAP3=ModelAdvisor.Procedure('com.mathworks.sample.myProcedure3');

%Create a group
MAG = ModelAdvisor.Group('com.mathworks.sample.myGroup');

%Add the three procedures to the group
addProcedure(MAG, MAP1);
addProcedure(MAG, MAP2);
addProcedure(MAG, MAP3);

%register the group and procedures
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(MAG);
mdladvRoot.register(MAP1);
mdladvRoot.register(MAP2);
mdladvRoot.register(MAP3);

The following code example adds subprocedures to a procedure:

%Create a procedure
MAP = ModelAdvisor.Procedure('com.mathworks.example.Procedure');

%Create 3 sub procedures
MAP1=ModelAdvisor.Procedure('com.mathworks.example.procedure_sub1');
MAP2=ModelAdvisor.Procedure('com.mathworks.example.procedure_sub2');
MAP3=ModelAdvisor.Procedure('com.mathworks.example.procedure_sub3');

%Add sub procedures to procedure
addProcedure(MAP, MAP1);
addProcedure(MAP, MAP2);
addProcedure(MAP, MAP3);

%register the procedures
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(MAP);
mdladvRoot.register(MAP1);
mdladvRoot.register(MAP2);
mdladvRoot.register(MAP3);

The following code example adds tasks to a procedure:

%Create three tasks
MAT1=ModelAdvisor.Task('com.mathworks.tasksample.myTask1');
MAT2=ModelAdvisor.Task('com.mathworks.tasksample.myTask2');
MAT3=ModelAdvisor.Task('com.mathworks.tasksample.myTask3');

%Create a procedure
MAP = ModelAdvisor.Procedure('com.mathworks.tasksample.myProcedure');

%Add the three tasks to the procedure
addTask(MAP, MAT1);
addTask(MAP, MAT2);
addTask(MAP, MAT3);

%register the procedure and tasks
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(MAP);
mdladvRoot.register(MAT1);
mdladvRoot.register(MAT2);
mdladvRoot.register(MAT3);

See Also

| | | |

Related Examples

More About