# `EventGenerator`

digraph inheritance7dc734c271 { bgcolor=transparent; rankdir=UD; ratio=compress; size="8.0, 12.0"; "EventGenerator" [URL="#taurus.core.util.event.EventGenerator",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top",tooltip="Base class capable of firing events"]; "Object" -> "EventGenerator" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Object" [URL="taurus.core.util.object-Object.html#taurus.core.util.object.Object",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top"]; }

class EventGenerator(name, events_active=True)

  Base class capable of firing events

  Import from `taurus.core.util.event` as:

      from taurus.core.util.event import EventGenerator

  WaitTimeout = 0.1
  fireEvent(val=None, event_val=None)

    Fires an event.

    Parameters:

      val (object) – event value

  getEventsActive()

    Determines is events are active :return: True if events are active or False otherwise :rtype: bool

  isSubscribed(cb, data=None)

    Determines if the given callback is registered for this event.

    Parameters:

      - cb (callable) – a callable object

      - data (object) – extra data to send each time an event is triggered on the given callback. Default is None

    Returns:

      True if callback is registered or False otherwise

    Return type:

      bool

  lock()

    Locks this event generator

  read()

    Read the last event

    Returns:

      the last event value

    Return type:

      object

  setEventsActive(events_active)

    (De)activates events on this event generator.

    Parameters:

      events_active (bool) – activate/deactivate events

  subscribeEvent(cb, data=None, with_first_event=True)

    Subscribes to the event

    Parameters:

      - cb (callable) – a callable object

      - data (boolean) – extra data to send each time an event is triggered on the given callback. Default is None.

      - with_first_event – whether call the callback with the first event value (the most recent value) during the subscription process. Default is True.

  unlock()

    Unlocks this event generator

  unsubscribeDeletedEvent(cb_ref)

    for internal usage only

  unsubscribeEvent(cb, data=None)

    Unsubscribes the given callback from the event. If the callback is not a listener for this event a debug message is generated an nothing happens.

    Parameters:

      - cb (callable) – a callable object

      - data (object) – extra data to send each time an event is triggered on the given callback. Default is None

  waitEvent(val=None, equal=True, any=False, timeout=None, stack=None)

    Waits for an event to occur

    Parameters:

      - val (object) – event value

      - equal (bool) – check for equality. Default is True

      - any (bool) – if True unblock after first event, not matter what value it has. Default is False.

      - timeout (float) – maximum time to wait (seconds). Default is None meaning wait forever.

      - stack – For internal usage only.

    Returns:

      the value of the event that unblocked the wait

    Return type:

      object