Step Editor: Action
Previous Top Next

graphic

The step editor's action tab has several boxes you can check to control the step's action:

      Reset Device - Resets the GP3. Note that in compiled code, this restarts everything. When not complied, this simply resets the GP3 to its power on state.
      Reset Counter - Resets the GP3 hardware counter.
      Output - Sets output bits on the GP3. Note that if you set any bit to X (don't care) then any bits you set to 0 or 1 will be forced to be outputs, but it will be less efficient than setting all the bits. If you set all the bits to either 1 or 0, the execution will be more efficient, but only the bits selected as outputs (see the Set I/O field in the Condition tab) will actually be affected. Note that the Set I/O command stays in force until overridden, so once you set the I/O you don't need to set it on every step that has output.
      Pulse - Sets the specified pin to be an output (if it isn't already) and then inverts its state for the specified number of microseconds.
      Set PWM - Sets the GP3's hardware PWM to a duty cycle from 0 to 255 (0 to 100%). Note that as of version 1.3 you can also specify the frequency from 1 to about 32kHz.
      Frequency - Sets the specified pin to be an output (if it isn't already) and then generates the specified frequency for the specified duration in milliseconds.
      Set Loop - Allows you to initialize one of the three loop counters (A, B, or C). The value can range from 0 to 8191.
      Disable step - Disable a step in the script (this step can even be the current step). This allows you to set a timed condition and then disable it so the step only executes once.
      Enable step - Enables a step in the script.
      Execute - Run an external program, document, DLL, or custom message. If you use an external program or document, you can optionally wait for it to complete before proceeding.

The execute choice has several types of external item to execute in the drop down box:

      Prog - A regular executable program
      Doc - A document (such as a WAV file, a video, or a Web URL)
      DLL - A special DLL (see below)
      Msg - A registered Windows message
      Comp - Compile time external serial transmission (this is the only external action that will compile)
      New File - Starts a new file and writes the following (delimited by commas): Date and time, step value, step name or number, and current state.
      Add File - Similar to new file but appends the data to an existing file.
      GP3UI - This sends the data to a remote program using the TCP Server. The text is the GP3UI tag to associate with the data. See the section on TCP Server for more details.

In place of an executable program or document in the Execute boxes in the condition and action tabs, you can call an external DLL. To do this, the DLL must export a CDECL function that accepts a char * argument and returns an integer (the integer is ignored for the action).

Suppose you build test.dll with the following code:


#include <windows.h>
extern "C" {
__declspec(dllexport) int Prompt(char *s);
}


int Prompt(char *s)
{
int rv;
rv=MessageBox(NULL,s,"From GP3EZ DLL",MB_YESNO);
return rv!=IDYES;
}
You can call this by placing the following in the external box:

c:\path_to_dll\test.dll#Prompt#Would you like to continue

If you use a registered message named GP3EZCTL to a Window titled Controller you'd use this entry:

Controller#GP3EZCTL#<optional integer>

The Windows message is sent with wParam = the optional integer supplied and lParam=to the step value (see below). If the wait box is checked the message is sent with SendMessage, otherwise it is sent with PostMessage.

Note that GP3EZ ignores any return code from a custom action.

In an action, an external program, DLL, or message can receive the step's "value." The value is the counter, digital, or analog value that allowed the step to trigger (if an analog condition uses two analog channels, the first one -- the one to the left -- sets the step value). If this doesn't apply to the current step, the value is the value of the last step that was triggered by one of these events. So if the condition is a digital input of XXXXXXX1 and the input bits were 00001001 (which is 9 in decimal) then the step's value is 9. To use this, place a single & in the external box which will be replaced by the value. If you need to actually send the & character to the DLL or program, double it. That is, && is interpreted as a single &. Note that the value will remain active until another step changes it, so it is possible to use && in other steps to refer to the last value set. This will also work in an external condition, although in that case, the value is always one that was previously set.

You can also include the current state by using $ (use $$ to get a single $ into the command line). Note that if the current step changes the state, that state change will not occur until the end of the step, so the $ will report the "old" state, not the new one.

When the step value is an analog quantity, it will be sent as a string representation of the floating point voltage for programs and DLLs. For custom messages, the number of counts (where 1023 counts is 5V) is sent in lParam.

If you select Comp in the external action, this will only apply to compiled scripts. When executed, the GP3 will transmit a single character you provide in the box followed by 4 hex digits that correspond to step value (see above). In addition, a single carriage return is sent.

Also note that the boxes used to set bits will respond to keys 0 to 7 to alter each bit (in addition to the mouse). So to toggle bit 0 you can either click on the rightmost box or press 0.