tango.pyaml.device_factory#
Shared cache of Tango device proxies.
Classes
Singleton factory to build PyAML elements with future compatibility logic. |
- class tango.pyaml.device_factory.DeviceFactory#
Bases:
objectSingleton factory to build PyAML elements with future compatibility logic.
The factory caches one
tango.DeviceProxyper device name so that everyAttributeof the same device shares the same connection. It also holds the client timeout applied to every proxy it creates.- _instance#
The unique instance, created on first call.
- Type:
DeviceFactory or None
- _lock#
Lock protecting the instance creation.
- Type:
threading.Lock
- _elements#
Cache of device proxies indexed by device name.
- Type:
dict of str to tango.DeviceProxy
- _timeout#
Client timeout in milliseconds applied to new proxies.
- Type:
int
- set_timeout_ms(timeout)#
Set the timeout applied to newly created device proxies.
- get_timeout_ms()#
Return the timeout applied to device proxies.
- get_device(device_name)#
Return the cached device proxy for a device, creating it if needed.
- clear()#
Drop all cached device proxies.
Return the unique factory instance.
No matter how many times you call
DeviceFactory(), it will be created only once.- Returns:
DeviceFactory – The singleton instance.
- clear()#
Drop all cached device proxies.
- get_device(device_name)#
Return the cached device proxy for a device, creating it if needed.
- Parameters:
device_name (str) – Tango device name (
domain/family/member), optionally prefixed by//host:port/.- Returns:
tango.DeviceProxy – Device proxy configured with the factory timeout.
- Raises:
tango.DevFailed – If the device proxy cannot be created.
- Return type:
DeviceProxy
- get_timeout_ms()#
Return the timeout applied to device proxies.
- Returns:
int – Timeout in milliseconds.
- Return type:
int
- set_timeout_ms(timeout)#
Set the timeout applied to newly created device proxies.
Proxies already in the cache keep their current timeout.
- Parameters:
timeout (int) – Timeout in milliseconds.