From 2f06574381e90e5bc0d75f481f25afba1cb3f06d Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 5 Feb 2015 22:53:31 +0800 Subject: [PATCH] ddb: controller support --- artiq/master/db.py | 17 +++++++++++++---- examples/ddb.pyon | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/artiq/master/db.py b/artiq/master/db.py index e8d4c9c7c..7ee2735a8 100644 --- a/artiq/master/db.py +++ b/artiq/master/db.py @@ -5,6 +5,7 @@ import numpy import h5py from artiq.protocols.sync_struct import Notifier +from artiq.protocols.pc_rpc import Client _type_to_hdf5 = { @@ -72,9 +73,15 @@ class ResultDB: def _create_device(desc, dbh): - module = importlib.import_module(desc["module"]) - device_class = getattr(module, desc["class"]) - return device_class(dbh, **desc["arguments"]) + ty = desc["type"] + if ty == "local": + module = importlib.import_module(desc["module"]) + device_class = getattr(module, desc["class"]) + return device_class(dbh, **desc["arguments"]) + elif ty == "controller": + return Client(desc["host"], desc["port"], desc["target_name"]) + else: + raise ValueError("Unsupported type in device DB: " + ty) class DBHub: @@ -112,5 +119,7 @@ class DBHub: """ for dev in reversed(list(self.active_devices.values())): - if hasattr(dev, "close"): + if isinstance(dev, Client): + dev.close_rpc() + elif hasattr(dev, "close"): dev.close() diff --git a/examples/ddb.pyon b/examples/ddb.pyon index dfde1c55c..4d55f30f1 100644 --- a/examples/ddb.pyon +++ b/examples/ddb.pyon @@ -1,65 +1,77 @@ { "comm": { + "type": "local", "module": "artiq.coredevice.comm_serial", "class": "Comm", "arguments": {} }, "core": { + "type": "local", "module": "artiq.coredevice.core", "class": "Core", "arguments": {} }, "led": { + "type": "local", "module": "artiq.coredevice.gpio", "class": "GPIOOut", "arguments": {"channel": 0} }, "pmt0": { + "type": "local", "module": "artiq.coredevice.rtio", "class": "RTIOIn", "arguments": {"channel": 0} }, "pmt1": { + "type": "local", "module": "artiq.coredevice.rtio", "class": "RTIOIn", "arguments": {"channel": 1} }, "ttl0": { + "type": "local", "module": "artiq.coredevice.rtio", "class": "RTIOOut", "arguments": {"channel": 2} }, "ttl1": { + "type": "local", "module": "artiq.coredevice.rtio", "class": "RTIOOut", "arguments": {"channel": 3} }, "ttl2": { + "type": "local", "module": "artiq.coredevice.rtio", "class": "RTIOOut", "arguments": {"channel": 4} }, "dds0": { + "type": "local", "module": "artiq.coredevice.dds", "class": "DDS", "arguments": {"reg_channel": 0, "rtio_switch": 5} }, "dds1": { + "type": "local", "module": "artiq.coredevice.dds", "class": "DDS", "arguments": {"reg_channel": 1, "rtio_switch": 6} }, "dds2": { + "type": "local", "module": "artiq.coredevice.dds", "class": "DDS", "arguments": {"reg_channel": 2, "rtio_switch": 7} }, "electrodes": { + "type": "local", "module": "artiq.devices.pdq2", "class": "CompoundPDQ2", "arguments": { @@ -70,6 +82,14 @@ "comment": "Conflicts with dds2 and ttl0-2" }, + "lda": { + "type": "controller", + "host": "::1", + "port": 3253, + "target_name": "lda", + "command": "lda_controller -p {port} -d sim" + }, + "pmt": "pmt0", "bd": "dds0", "bdd": "dds1"