forked from M-Labs/artiq
master/worker_db: add controller_aux_target device_db entry type
This commit is contained in:
parent
befbab5571
commit
0d7d584f08
|
@ -102,6 +102,13 @@ def _create_device(desc, device_mgr):
|
||||||
if target_name is None:
|
if target_name is None:
|
||||||
target_name = AutoTarget
|
target_name = AutoTarget
|
||||||
return cls(desc["host"], desc["port"], target_name)
|
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:
|
else:
|
||||||
raise ValueError("Unsupported type in device DB: " + ty)
|
raise ValueError("Unsupported type in device DB: " + ty)
|
||||||
|
|
||||||
|
@ -118,6 +125,13 @@ class DeviceManager:
|
||||||
"""Returns the full contents of the device database."""
|
"""Returns the full contents of the device database."""
|
||||||
return self.ddb.get_device_db()
|
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):
|
def get(self, name):
|
||||||
"""Get the device driver or controller client corresponding to a
|
"""Get the device driver or controller client corresponding to a
|
||||||
device database entry."""
|
device database entry."""
|
||||||
|
@ -126,11 +140,7 @@ class DeviceManager:
|
||||||
if name in self.active_devices:
|
if name in self.active_devices:
|
||||||
return self.active_devices[name]
|
return self.active_devices[name]
|
||||||
else:
|
else:
|
||||||
desc = self.ddb.get(name)
|
dev = _create_device(self.get_desc(name), self)
|
||||||
while isinstance(desc, str):
|
|
||||||
# alias
|
|
||||||
desc = self.ddb.get(desc)
|
|
||||||
dev = _create_device(desc, self)
|
|
||||||
self.active_devices[name] = dev
|
self.active_devices[name] = dev
|
||||||
return dev
|
return dev
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue