ddb: controller support

This commit is contained in:
Sebastien Bourdeauducq 2015-02-05 22:53:31 +08:00
parent 776381a332
commit 2f06574381
2 changed files with 33 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import numpy
import h5py import h5py
from artiq.protocols.sync_struct import Notifier from artiq.protocols.sync_struct import Notifier
from artiq.protocols.pc_rpc import Client
_type_to_hdf5 = { _type_to_hdf5 = {
@ -72,9 +73,15 @@ class ResultDB:
def _create_device(desc, dbh): def _create_device(desc, dbh):
module = importlib.import_module(desc["module"]) ty = desc["type"]
device_class = getattr(module, desc["class"]) if ty == "local":
return device_class(dbh, **desc["arguments"]) 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: class DBHub:
@ -112,5 +119,7 @@ class DBHub:
""" """
for dev in reversed(list(self.active_devices.values())): 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() dev.close()

View File

@ -1,65 +1,77 @@
{ {
"comm": { "comm": {
"type": "local",
"module": "artiq.coredevice.comm_serial", "module": "artiq.coredevice.comm_serial",
"class": "Comm", "class": "Comm",
"arguments": {} "arguments": {}
}, },
"core": { "core": {
"type": "local",
"module": "artiq.coredevice.core", "module": "artiq.coredevice.core",
"class": "Core", "class": "Core",
"arguments": {} "arguments": {}
}, },
"led": { "led": {
"type": "local",
"module": "artiq.coredevice.gpio", "module": "artiq.coredevice.gpio",
"class": "GPIOOut", "class": "GPIOOut",
"arguments": {"channel": 0} "arguments": {"channel": 0}
}, },
"pmt0": { "pmt0": {
"type": "local",
"module": "artiq.coredevice.rtio", "module": "artiq.coredevice.rtio",
"class": "RTIOIn", "class": "RTIOIn",
"arguments": {"channel": 0} "arguments": {"channel": 0}
}, },
"pmt1": { "pmt1": {
"type": "local",
"module": "artiq.coredevice.rtio", "module": "artiq.coredevice.rtio",
"class": "RTIOIn", "class": "RTIOIn",
"arguments": {"channel": 1} "arguments": {"channel": 1}
}, },
"ttl0": { "ttl0": {
"type": "local",
"module": "artiq.coredevice.rtio", "module": "artiq.coredevice.rtio",
"class": "RTIOOut", "class": "RTIOOut",
"arguments": {"channel": 2} "arguments": {"channel": 2}
}, },
"ttl1": { "ttl1": {
"type": "local",
"module": "artiq.coredevice.rtio", "module": "artiq.coredevice.rtio",
"class": "RTIOOut", "class": "RTIOOut",
"arguments": {"channel": 3} "arguments": {"channel": 3}
}, },
"ttl2": { "ttl2": {
"type": "local",
"module": "artiq.coredevice.rtio", "module": "artiq.coredevice.rtio",
"class": "RTIOOut", "class": "RTIOOut",
"arguments": {"channel": 4} "arguments": {"channel": 4}
}, },
"dds0": { "dds0": {
"type": "local",
"module": "artiq.coredevice.dds", "module": "artiq.coredevice.dds",
"class": "DDS", "class": "DDS",
"arguments": {"reg_channel": 0, "rtio_switch": 5} "arguments": {"reg_channel": 0, "rtio_switch": 5}
}, },
"dds1": { "dds1": {
"type": "local",
"module": "artiq.coredevice.dds", "module": "artiq.coredevice.dds",
"class": "DDS", "class": "DDS",
"arguments": {"reg_channel": 1, "rtio_switch": 6} "arguments": {"reg_channel": 1, "rtio_switch": 6}
}, },
"dds2": { "dds2": {
"type": "local",
"module": "artiq.coredevice.dds", "module": "artiq.coredevice.dds",
"class": "DDS", "class": "DDS",
"arguments": {"reg_channel": 2, "rtio_switch": 7} "arguments": {"reg_channel": 2, "rtio_switch": 7}
}, },
"electrodes": { "electrodes": {
"type": "local",
"module": "artiq.devices.pdq2", "module": "artiq.devices.pdq2",
"class": "CompoundPDQ2", "class": "CompoundPDQ2",
"arguments": { "arguments": {
@ -70,6 +82,14 @@
"comment": "Conflicts with dds2 and ttl0-2" "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", "pmt": "pmt0",
"bd": "dds0", "bd": "dds0",
"bdd": "dds1" "bdd": "dds1"