PXC Family

Datasheet (PDF)

Manual & Guide

Application Notes

Driver Updates

Example Source Code

Compatible Image Processing Software

Product FAQ

Home Page


Feedback at:
CSinfo@cyberoptics.com or
1-800-366-9131

WaitAnyEvent()
This discussion is a supplement to the PXC200A User's Guide.
Syntax long WaitAnyEvent(long fgh, long ioh, unsigned long mask, unsigned long state, short flags);
fgh: Frame grabber handle.
ioh: IO handle -- should match the frame grabber handle
mask: Shows which lines you are interested in
state: Shows what state you want any line to have when processing continues
Return Value A queued operation handle if successful.
0 on failure.
Description

Pauses processing of the queue until an I/O event occurs.

WaitAnyEvent() examines the I/O lines as if by the expression:
((ReadIO(ioh) ^ ~state) & mask).
While the expression is zero, the queue is paused. If the expression is non-zero, the state for the highest I/O line that was set is cleared, the switch is set to that I/O line number, and processing of the queue resumes.

Example

If you wanted to watch for either trigger line 0 or 1 to go high, you would code that as follows.

WaitAnyEvent(fgh, fgh 0x3, 0x3, QUEUED);

Explanation

Since the trigger lines are inputs, they are numbered 0 thru 3 (output lines are 4 thru 7). You set the mask parameter to 0x3 (0011) to indicate an interest in trigger lines 0 and 1.

Your objective is to wait for either line to go high, so you set the state parameter to 0x3 (0011). If you wanted to wait for the lines to go low, you would set the state parameter to 0.

In the simplest terms, WaitAnyEvent() will pause processing of the queue until either trigger line 0 or 1 is high. In other words, the queue will be paused until the result of reading the IO (ReadIO(ioh)) is 0001, 0010 or 0011.

The IO lines are read ONLY at each vertical blank. Either line has to be high when the reading is taken.

Assuming that trigger 0 goes high before trigger 1 and Evaluating the above expression we get the following.

ReadIO(ioh) 0001
^
!State      1100
----------------
            1101
&
Mask        0011
----------------
            0001

When ReadIO(ioh) is 0x1, the value of the expression will be non-zero and queue processing will proceed.

This function will fail when mask = 0 or when mask has any bits set that represent invalid I/O lines or lines that are output-only.

The parameter flags is a set of flag bits that can specify modes of operation for this function. If flags is 0, the default modes will be used.

See Also GetSwitch(), SetIOType(), SwitchCamera(), SwitchGrab(), WaitAllEvents()