Device Proxy
This module implements a base device proxy for Sat LMC devices.
- class SatDeviceProxy(fqdn, logger, connect=True, pass_through=True)
This class implements a base device proxy for Sat LMC devices.
At present it supports:
deferred connection: we can create the proxy without immediately trying to connect to the proxied device.
a :py:meth:
connect
method, for establishing that connection latera :py:meth:
check_initialised
method, for checking that / waiting until the proxied device has transitioned out of INIT state.Ability to subscribe to change events via the :py:meth:
add_change_event_callback
method.
- __init__(fqdn, logger, connect=True, pass_through=True)
Create a new instance.
- Parameters:
fqdn (
str
) – fqdn of the device to be proxiedlogger (
Logger
) – a logger for this proxy to useconnect (
bool
) – whether to connect immediately to the device. If False, then the device may be connected later by calling theconnect()
method.pass_through (
bool
) – whether to pass unrecognised attribute accesses through to the underlying connection. Defaults toTrue
but this will likely change in future once our proxies are more mature.
- add_change_event_callback(attribute_name, callback, stateless=True)
Register a callback for change events being pushed by the device.
- check_initialised(max_time=120.0)
Check that the device has completed initialisation.
That is, check that the device is no longer in state INIT.
- Parameters:
max_time (
float
) – the (optional) maximum time, in seconds, to wait for the device to complete initialisation. The default is 120.0 i.e. two minutes. If set to 0 or None, the device is checked once and the call returns immediately.- Return type:
- Returns:
whether the device is initialised yet
- connect(max_time=120.0)
Establish a connection to the device that we want to proxy.
- classmethod set_default_connection_factory(connection_factory)
Set the default connection factory for this class.
This is super useful for unit testing: we can mock out
tango.DeviceProxy
altogether, by simply setting this class’s default connection factory to a mock factory.- Parameters:
connection_factory (
Callable
[[str
],DeviceProxy
]) – default factory to use to establish a connection to the device- Return type: