Device Monitor

This module contains TangoDeviceMonitor that monitors attributes on Tango devices.

class SubscriptionTracker(event_queue, logger)[source]

Thread safe way to track which attributes are subscribed.

__init__(event_queue, logger)[source]

Keep track of which attributes have been subscribed to.

Set communication_state to ESTABLISHED only when all are subscribed. Set NOT_ESTABLISHED otherwise.

Parameters:
  • event_queue (Queue) – the store for change events emitted by the device

  • logger (logging.Logger) – Logger

clear_subscriptions(device_proxy)[source]

Set all attrs as not subscribed.

Parameters:

device_proxy (tango.DeviceProxy) – a client to the device

Return type:

None

setup_event_subscription(attribute_name, device_proxy)[source]

Subscribe to change events on the device.

Parameters:
  • attribute_name (str) – The attribute name

  • device_proxy (tango.DeviceProxy) – a client to the device

Return type:

None

property subscribed_attrs: list

Get the list of attributes with change events.

Returns:

list of attribute names

subscription_started(attribute_name, subscription_id)[source]

Mark attr as subscribed.

Parameters:
  • attribute_name (str) – The attribute name

  • subscription_id (int) – The subscription descriptor

Return type:

None

subscription_stopped(attribute_name)[source]

Mark attr as unsubscribed.

Parameters:

attribute_name (str) – The attribute name

Return type:

None

class TangoDeviceMonitor(tango_fqdn, device_proxy_factory, monitored_attributes, event_queue, logger)[source]

Connects to and monitors a Tango device.

Creates a device proxy in a thread to subscribe to change events on specified attributes

__init__(tango_fqdn, device_proxy_factory, monitored_attributes, event_queue, logger)[source]

Create the TangoDeviceMonitor.

Param:

tango_fqdn: Tango device name

Parameters:
  • device_proxy_factory (DeviceProxyManager) – A factory which creates and manages tango device proxies

  • monitored_attributes (Tuple[str]) – Tuple of attributes to monitor

  • event_queue (Queue) – Queue where events are sent

  • logger (logging.Logger) – logger

monitor()[source]

Kick off device monitoring.

This method is idempotent. When called the existing (if any) monitoring threads are removed and recreated.

Return type:

None

stop_monitoring()[source]

Close all live attribute subscriptions.

Return type:

None