[PREVIOUS] [NEXT] [UP]

Control operations

Besides simple execution of units, there is for many units the possibility to send them special control calls to alter their state or behavior:

About control calls

Many NST units can be controlled in various ways by sending them a control call. For example, if a unit owns a window, it may respond to control calls to close or open the window. Generally, th set of control calls that are useful for a particular unit must be looked up in its manual page. Here is a short list of frequently useful NST control calls (for a full listing, see the header file nst0.h)
 
NST_RESET reset the unit (e.g., a counter) to some default state
NST_INIT initialize the unit (usually into the state that would be obtained after creation; watch out for exceptions among the adaptive units, which may be caused to store a number of training examples after NST_INIT)
NST_W_CLOSE close a window pertaining to a unit
NST_W_OPEN open a window pertaining to a unit
NST_W_CLEAR clear a window pertaining to a unit
NST_EXEC "pseudo" control call: execute a unit
NST_ADAPT adapt a unit (more about adaptive units can be found here)

How to send control calls from Neo

Neo provides two different ways to send control calls to particular units. The Control command allows to send the most frequent NST control calls to a selected unit or circuit by selecting a button.

How to send control calls with the ctrl_op unit

At the programming level, there is the ctrl_op unit that allows to send the most frequent NST control calls to other units. It is an operator that does not execute its operands (except if you specify the special "control" call EXEC), but instead - when executed - sends to each operand the control calls that you specify its (the ctrl_op's) creation dialog window.

In addition, the ctrl_op can be used to receive one or several control calls ("trigger modes") and react with sending one or several other control calls to its operands. The set of trigger modes has to be specified in the first (large) creation dialog entry, the set of response modes in the second entry. When the ctrl_op receives any of the trigger calls, it will react by applying all response calls to its operands. For convenience, all specifications can omit the initial NST_ part of the control call.

Unlike most other operator units, the ctrl_op can also act backward, i.e., have operands to its left (specify a negative position offset to reach them).

Example#1 illustrates how the ctrl_op can be used to control a plot_xy unit in various ways (first execute the for_op in order to add a few marker points to the plot). As a remark, we mention that specifying the option %H or %h in the plot_xy creation dialog window will create the plot_xy with its window hidden initially. Similar as for the input_window unit, a %h-hidden window will open on the first exec, while a %H hidden window is "more firmly hidden": it will only open when a W_OPEN control call is applied.
 

Control calls and the prog_unit

The prog_unit can also send control calls to other units. For example, the command

   ctrl_opnd (NST_W_CLEAR,"foo");

will send the control call NST_W_CLEAR to the named unit "foo" (all NST control mode names are predefined variables in the prog_unit). Instead of the name string "foo", you also may supply an integer parameter to specify a relative position (e.g., 2 for the second successor, -1 for the immediate predecessor of the prog_unit, etc.).

Conversely, the prog_unit can also react to the control calls NST_INIT, NST_RESET,NST_CLEAR, NST_ADAPT and NST_EXEC (currently, it is restricted to these five). For each of them, there is a predefined jump label whose name is the part without the NST_, i.e, writing code such as

INIT:  printf("response to NST_INIT!\n");
       ...
       return;
RESET: printf("response to NST_RESET!\n");
       ...
       return;
EXEC:  // this is the default
       ...
       return;

you can make the prog_unit execute different code portions for each of the five above control modes (execution will start at the label that pertains to the received control mode and then just continue to the end or the first return statement encountered.
Example#2 illustrates this with a left prog_unit that sends an NST_INIT call to its successor, which is another prog_unit that also will react to exec and adapt calls.


[PREVIOUS] [NEXT] [UP]