From 0d7d584f0893d3919f9c718d10b414b512144f71 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 24 Mar 2016 00:46:39 +0800 Subject: [PATCH] master/worker_db: add controller_aux_target device_db entry type --- artiq/master/worker_db.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/artiq/master/worker_db.py b/artiq/master/worker_db.py index fd41647b3..c68c24f6f 100644 --- a/artiq/master/worker_db.py +++ b/artiq/master/worker_db.py @@ -102,6 +102,13 @@ def _create_device(desc, device_mgr): if target_name is None: target_name = AutoTarget return cls(desc["host"], desc["port"], target_name) + elif ty == "controller_aux_target": + controller = device_mgr.get_desc(desc["controller"]) + if desc.get("best_effort", controller.get("best_effort", False)): + cls = BestEffortClient + else: + cls = Client + return cls(controller["host"], controller["port"], desc["target_name"]) else: raise ValueError("Unsupported type in device DB: " + ty) @@ -118,6 +125,13 @@ class DeviceManager: """Returns the full contents of the device database.""" return self.ddb.get_device_db() + def get_desc(self, name): + desc = self.ddb.get(name) + while isinstance(desc, str): + # alias + desc = self.ddb.get(desc) + return desc + def get(self, name): """Get the device driver or controller client corresponding to a device database entry.""" @@ -126,11 +140,7 @@ class DeviceManager: if name in self.active_devices: return self.active_devices[name] else: - desc = self.ddb.get(name) - while isinstance(desc, str): - # alias - desc = self.ddb.get(desc) - dev = _create_device(desc, self) + dev = _create_device(self.get_desc(name), self) self.active_devices[name] = dev return dev