EventListener

Inheritance diagram of EventListener
class EventListener[source]

A class that listens for an event with a specific value

Note: Since this class stores for each event value the last timestamp when it occured, it should only be used for events for which the event value domain (possible values) is limited and well known (ex: an enum)

Import from taurus.core.util.event as:

from taurus.core.util.event import EventListener
clearEventSet()[source]

Clears the internal event buffer

fireEvent(v)[source]

Notifies that a given event has arrived This function is protected inside with the object’s lock. Do NOT call this function when you have the lock acquired on this object.

Parameters:

v (object) – event value

lock()[source]

Locks this event listener

unlock()[source]

Unlocks this event listener

waitEvent(val, after=0, equal=True)[source]

Wait for an event with the given value. You MUST protect this function with this object’s lock before calling this method and always unlock it afterward, of course:

from taurus.core.util.event import EventListener

class MyEvtListener(EventListener):
    # Your specific listener code here
    pass

evt_listener = EventListener()
try:
    evt_listener.lock()
    t = time.time()
    go()
    evt_listener.waitEvent(Stop, t)
finally:
    evt_listener.unlock()
Parameters:
  • val (object) – value to compare

  • after (float) – timestamp. wait for events comming after the given time. default value is 0 meaning any event after Jan 1, 1970

  • equal (bool) – compare for equality. equal=True means an event with the given value, equal=False means any event which as a different value