Skip to Main Content Skip to Search
Product Documentation

Creating 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. See Creating Procedures Using the Procedures API.

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

Creating 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. For more information, see Defining Custom Tasks.

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

Defining 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.

Adding Subprocedures and Tasks to Procedures

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

Defining Where Procedures Appear

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

Model Advisor Code Example: 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 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 procedures
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);
  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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