taurus.core.util.eventfilters

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

Classes

class EventValueMap[source]

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[source]

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=())[source]

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)[source]

Will discard all events

IGNORE_CHANGE(s, t, v)[source]

Config events are discarded

IGNORE_CHANGE_AND_PERIODIC(s, t, v)[source]

Config events are discarded

IGNORE_CONFIG(s, t, v)[source]

Config events are discarded

IGNORE_FAKE(s, t, v)[source]

Only events with actual value (!=None) pass

ONLY_CHANGE(s, t, v)[source]

Only change events pass

ONLY_CHANGE_AND_PERIODIC(s, t, v)[source]

Only change events pass

ONLY_CONFIG(s, t, v)[source]

Only config events pass

ONLY_VALID(s, t, v)[source]

Only events whose quality is VALID pass