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

[CLIENT] Support multiple detector instances

parent a2b77a8e
......@@ -515,8 +515,17 @@ class Detector:
return self.__queue.__iter__()
def __init__(self, ctrl_dev, *recv_devs, timeout=DefaultTimeout):
self.__fsm = self.FSM(self)
self.__tasks = {}
self.__events = []
self.__state_queues = []
self.__state_events = {'State': {}, 'NotState': {}}
self.__state_follower = None
self.__event_ids = {}
if not recv_devs:
raise ValueError('Must provide at least one receiver')
self.__ctrl = tango.DeviceProxy(ctrl_dev)
self.__recvs = [tango.DeviceProxy(r) for r in recv_devs]
for d in self._getDevs():
......@@ -524,14 +533,6 @@ class Detector:
d.set_timeout_millis(int(timeout * 1000))
self._initAttrs()
self.__fsm = self.FSM(self)
self.__tasks = {}
self.__events = []
self.__state_queues = []
self.__state_events = {'State': {}, 'NotState': {}}
self.__state_follower = None
self.__event_ids = {}
def __del__(self):
for q in self.__state_queues:
q.put(StopIteration)
......@@ -562,15 +563,20 @@ class Detector:
return (cpp_2_python_name(n), attr_data['type_data'].klass)
self.__dict__.update([GetKlassData(n, attr_data)
for n, attr_data in attrs.items()])
# The descriptors returning the dynamic params' attrs for each detector
class Descriptor:
def __init__(self):
self.__attr = {}
def addDeviceAttrData(self, dev, attr):
self.__attr[hash(dev)] = attr
def __get__(self, obj, objtype=None):
if obj is None:
return self
return self.__attr[hash(obj)]['value']
def __set__(self, obj, value):
self.__attr[hash(obj)]['value'] = value
for n, attr_data in self.__attrs.items():
desc = getattr(self.__class__, n, Descriptor())
desc.addDeviceAttrData(self, attr_data)
......
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