Commit bf69e503 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

[CLIENT] Support dynamic server connection/disconnection

parent f6a66528
......@@ -522,6 +522,7 @@ class Detector:
self.__state_events = {'State': {}, 'NotState': {}}
self.__state_follower = None
self.__event_ids = {}
self.__attrs = {}
if not recv_devs:
raise ValueError('Must provide at least one receiver')
......@@ -531,7 +532,8 @@ class Detector:
for d in self._getDevs():
d.set_timeout_millis(int(timeout * 1000))
def __del__(self):
for q in self.__state_queues:
......@@ -541,8 +543,21 @@ class Detector:
def det_info(self):
return json.loads(self.__ctrl.det_info)
def checkConnection(self):
if not self.__attrs:
return True
return False
def _getAttrs(self):
if not self.checkConnection():
raise RuntimeError("Connection error")
return self.__attrs
def _initAttrs(self):
self.__attrs = {}
for d in self._getDevs()[:2]:
tango_db = d.get_device_db()
tango_class =
......@@ -573,6 +588,9 @@ class Detector:
def __get__(self, obj, objtype=None):
if obj is None:
return self
# Descriptors are class-based, ensure instance attrs are inited
if hash(obj) not in self.__attr:
return self.__attr[hash(obj)]['value']
def __set__(self, obj, value):
self.__attr[hash(obj)]['value'] = value
......@@ -582,10 +600,15 @@ class Detector:
desc.addDeviceAttrData(self, attr_data)
setattr(self.__class__, n, desc)
def ping(self):
for d in self._getDevs():
def getAttrTypeData(self, name):
if name not in self.__attrs:
attrs = self._getAttrs()
if name not in attrs:
raise ValueError(f'Could not find TypeData for attribute {name}')
return self.__attrs[name]['type_data']
return attrs[name]['type_data']
def _updateAttrs(self):
for d in self._getDevs():
......@@ -597,7 +620,7 @@ class Detector:
def _getAttrs4Dev(self, dev):
attrs = {n: attr_data['value']
for n, attr_data in self.__attrs.items()
for n, attr_data in self._getAttrs().items()
for attr in dev.attribute_list_query() if == n}
if 'acq_params' in attrs:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment