TSequencer.Wait
Previous  Top  Next

Wait(ctBlocks, fCondition, [oArgs=()], [dwTimeout=INFINITE])

Wait for one of the events (block arrivals) specified in the event list (ctBlocks) to be signaled. Evaluate the condition and return if the condition evalutates to true. If the condition evaluates to false go back and wait for the next block arrival, if it evaluates to true return from the function call. If the function gets aborted by the user through a Stop() command raise a TSeqAbortError. If an optional timeout value is specified and the timer expires before the condition evaluates to true raise a TSeqTimeoutError.

ParameterDescription     
ctBlocksThe block(s) to trigger on. If one of these blocks arrives the condition is evaluated. A single block can simply be passed in as is. Multiple blocks have to be wrapped in a tuple.     
fConditionThe condition to evaluate when any of the above blocks arrives. If true the Wait() function finishes, otherwise it will block until the next arrival of a trigger block. The condition function must take an according number of parameters depending on oArgs. I.e. if you pass three values in the oArgs tuple fCondition() needs to have three argument parameters.  
oArgs:Optional. A tuple with command arguments that get passed to the condition function.  
dwTimeout Optional, timeout value in seconds. A TSeqTimeoutError is raised if the timeout value is met before the condition evaluates to true.     

Returns
None

Comments
Oftentimes it is convenient to use a lambda function for a simple condition instead of defining a separate condition handler.

Example
Delete the Sequencer from the above example:

def fMySeq(oSeq):
  try:
    oSeq.Wait([BINCOMMAND], lambda: BINCOMMAND.byChan == 123, (), 20)

  except GseosSequencer.TSeqTimeoutError, oX:
    print 'Did not receive a command on channel 123 in the last 20 seconds'
    return

  print 'Got a command on channel 123'

# Now remove our object reference
del oMySeq