Skip to content

Commit 2f06574

Browse files
committedFeb 5, 2015
ddb: controller support
1 parent 776381a commit 2f06574

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed
 

Diff for: ‎artiq/master/db.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import h5py
66

77
from artiq.protocols.sync_struct import Notifier
8+
from artiq.protocols.pc_rpc import Client
89

910

1011
_type_to_hdf5 = {
@@ -72,9 +73,15 @@ def write_hdf5(self, f):
7273

7374

7475
def _create_device(desc, dbh):
75-
module = importlib.import_module(desc["module"])
76-
device_class = getattr(module, desc["class"])
77-
return device_class(dbh, **desc["arguments"])
76+
ty = desc["type"]
77+
if ty == "local":
78+
module = importlib.import_module(desc["module"])
79+
device_class = getattr(module, desc["class"])
80+
return device_class(dbh, **desc["arguments"])
81+
elif ty == "controller":
82+
return Client(desc["host"], desc["port"], desc["target_name"])
83+
else:
84+
raise ValueError("Unsupported type in device DB: " + ty)
7885

7986

8087
class DBHub:
@@ -112,5 +119,7 @@ def close(self):
112119
113120
"""
114121
for dev in reversed(list(self.active_devices.values())):
115-
if hasattr(dev, "close"):
122+
if isinstance(dev, Client):
123+
dev.close_rpc()
124+
elif hasattr(dev, "close"):
116125
dev.close()

Diff for: ‎examples/ddb.pyon

+20
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,77 @@
11
{
22
"comm": {
3+
"type": "local",
34
"module": "artiq.coredevice.comm_serial",
45
"class": "Comm",
56
"arguments": {}
67
},
78
"core": {
9+
"type": "local",
810
"module": "artiq.coredevice.core",
911
"class": "Core",
1012
"arguments": {}
1113
},
1214

1315
"led": {
16+
"type": "local",
1417
"module": "artiq.coredevice.gpio",
1518
"class": "GPIOOut",
1619
"arguments": {"channel": 0}
1720
},
1821

1922
"pmt0": {
23+
"type": "local",
2024
"module": "artiq.coredevice.rtio",
2125
"class": "RTIOIn",
2226
"arguments": {"channel": 0}
2327
},
2428
"pmt1": {
29+
"type": "local",
2530
"module": "artiq.coredevice.rtio",
2631
"class": "RTIOIn",
2732
"arguments": {"channel": 1}
2833
},
2934

3035
"ttl0": {
36+
"type": "local",
3137
"module": "artiq.coredevice.rtio",
3238
"class": "RTIOOut",
3339
"arguments": {"channel": 2}
3440
},
3541
"ttl1": {
42+
"type": "local",
3643
"module": "artiq.coredevice.rtio",
3744
"class": "RTIOOut",
3845
"arguments": {"channel": 3}
3946
},
4047
"ttl2": {
48+
"type": "local",
4149
"module": "artiq.coredevice.rtio",
4250
"class": "RTIOOut",
4351
"arguments": {"channel": 4}
4452
},
4553

4654
"dds0": {
55+
"type": "local",
4756
"module": "artiq.coredevice.dds",
4857
"class": "DDS",
4958
"arguments": {"reg_channel": 0, "rtio_switch": 5}
5059
},
5160
"dds1": {
61+
"type": "local",
5262
"module": "artiq.coredevice.dds",
5363
"class": "DDS",
5464
"arguments": {"reg_channel": 1, "rtio_switch": 6}
5565
},
5666
"dds2": {
67+
"type": "local",
5768
"module": "artiq.coredevice.dds",
5869
"class": "DDS",
5970
"arguments": {"reg_channel": 2, "rtio_switch": 7}
6071
},
6172

6273
"electrodes": {
74+
"type": "local",
6375
"module": "artiq.devices.pdq2",
6476
"class": "CompoundPDQ2",
6577
"arguments": {
@@ -70,6 +82,14 @@
7082
"comment": "Conflicts with dds2 and ttl0-2"
7183
},
7284

85+
"lda": {
86+
"type": "controller",
87+
"host": "::1",
88+
"port": 3253,
89+
"target_name": "lda",
90+
"command": "lda_controller -p {port} -d sim"
91+
},
92+
7393
"pmt": "pmt0",
7494
"bd": "dds0",
7595
"bdd": "dds1"

0 commit comments

Comments
 (0)
Please sign in to comment.