# `taurus.core.util.eventfilters`

event filters library to be used with `taurus.qt.qtgui.base.TaurusBaseComponent.setFilters()`

Classes

class EventValueMap

  A filter destined to change the original value into another one according to a given map. Example:

  > filter = EventValueMap({1:”OPEN”, 2:”CHANGING”, 3:”CLOSED”})

  this will create a filter that changes the integer value of the event into a string. The event type is changed according to the python type in the map value.

  For now it only supports simple types: str, int, long, float, bool

  (more info)

class RepeatedEventFilter

  The instances of this class will be callables that can be used as filters of repeated-value events. If the event type is Change or Periodic, it will only pass when its evt_value.value is different from that of the last event received from the same source and type. If evt_value.value is not available in the current event, the whole evt_value is used for comparison and as a future reference.

  This is useful to avoid processing repetitive events.

  Note that you cannot use this class as a filter: you need to use an instance of it.

  Note 2: Use a different instance each time you insert this filter into a different widget unless you really know what you are doing.

  Example of usage:

      filters = [RepeatedEventFilter(), IGNORE_CONFIG]
      filterEvent(s, t, v, filters)

  (more info)

Functions

filterEvent(evt_src=-1, evt_type=-1, evt_value=-1, filters=())

  The event is processed by each and all filters in strict order unless one of them returns None (in which case the event is discarded)

  Parameters:

    - evt_src (object) – object that triggered the event

    - evt_type (TaurusEventType) – type of event

    - evt_value (object) – event value

    - filters (sequence<callable>) – a sequence of callables, each returning either None (to discard the event) or the tuple (with possibly transformed values) of (evt_src, evt_type, evt_value)

  Returns:

    The result of piping the event through the given filters.

  Return type:

    None or tuple

IGNORE_ALL(s, t, v)

  Will discard all events

IGNORE_CHANGE(s, t, v)

  Config events are discarded

IGNORE_CHANGE_AND_PERIODIC(s, t, v)

  Config events are discarded

IGNORE_CONFIG(s, t, v)

  Config events are discarded

IGNORE_FAKE(s, t, v)

  Only events with actual value (!=None) pass

ONLY_CHANGE(s, t, v)

  Only change events pass

ONLY_CHANGE_AND_PERIODIC(s, t, v)

  Only change events pass

ONLY_CONFIG(s, t, v)

  Only config events pass

ONLY_VALID(s, t, v)

  Only events whose quality is VALID pass