WAIT.EVENT program instruction If the timeout parameter is omitted (or has a negative or zero value), this instruction suspends program execution indefinitely until the specified event occurs. If both mask and timeout are zero or omitted, this instruction does nothing. WAIT.EVENT 1 waits for an event to be signaled for a task. Events are signaled by either a SET.EVENT program instruction, or by a pending no-wait I/O instruction when the I/O operation is completed. In general, there is no way to tell why the event was set. It may have been set by an I/O operation, a SET.EVENT program instruction, or an internal system process (such as a triggered REACT condition).
For this reason, it is necessary to test for the desired condition after executing the WAIT.EVENT. For I/O, repeat the no-wait I/O operation or use the IOSTAT () function. For SET.EVENT issued by other tasks, define and check a global variable. To avoid race conditions where the event is set or cleared between testing and waiting, use the following loop in the waiting task (the statement order is critical). 1. CLEAR.EVENT 2. Issue no-wait I/O if appropriate. 3. Check I/O status or check global variable. 4. Exit loop if operation complete. 5. WAIT.EVENT 1 6. GOTO step 1 If using SET.EVENT to signal another task, use the following sequence (the statement order is critical). 1.
Set the global variable. 2. SET.EVENT for the appropriate task. Examples Suspend program execution for 5.5 seconds: WAIT.EVENT , 5.5 Suspend program execution until the completion of any system input/output, or until another program task sets events using the SET.EVENT instruction: WAIT.EVENT 1 Suspend program execution for five seconds, until the completion of any system input/output, or until another program task uses the SET.EVENT instruction to set events. (The current program should use the GET.EVENT function to decide whether an event has occurred or five seconds has elapsed.) eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 563