Home Examples Custom Control of the Trial Protocol Order
Coding Tips

Custom Control of the Trial Protocol Order

Normally, Dexterit-E manages and controls the order in which Trial Protocols (TPs) execute based on what is defined in the block table of the Task Protocol (see the Dexterit-E User Guide for more details). However, if your task requires online decision making to determine the next TP to run, then it is possible to modify your Task Program so that it can have full control of TP execution order.

There are some important caveats and usage notes for custom TP ordering. These are, as follows:

  • If you would like to use your existing Trial_Control Stateflow block to control the TP sequence, make sure the initial value for the first TP is set before the first Stateflow state in Trial_Control is entered. The Trial_Control block does not enter its first Stateflow state until the task starts; the GUI Control block needs the ID of the first TP before this. In practice, this is addressed by setting the initial value of the Stateflow output variable for the Next TP row using the Model Explorer.
  • The task will stop immediately if the TP value entered via Next TP row is either less than or equal to zero or is larger than the size of your table.
  • The Next TP row input must be updated/specified at least one kinematic frame before the e_End_Trial signal is sent to the GUI Control When the e_End_Trial signal is received by the GUI Control block, the value of the Next TP row is used immediately to choose the next TP. In practice, set the Next TP row in one Stateflow state and the next Stateflow state can send the e_End_trial signal.

Figure 10.36: Custom Trial Protocol Order

To allow your Task Program to control the TP order:

  1. Double-click on the GUI Control
  2. Check Provide custom TP See Figure: 10.36.

This option creates a new input on the GUI Control block called Next TP row. The block table in the Task Protocol is ignored.

Related Tasks

Coding Tips
Persistent Variables
Persistent variables are ones that hold their value between calls to the embedded MATLAB code they are defined in.
Coding Tips
Show Time Remaining in a Task
If your task runs for a known (or calculable) amount of time, then it is possible to display the amount of time remaining in Dexterit-E.