Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4166f4e92891
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fa89e165b23b
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Nov 11, 2015

  1. Copy the full SHA
    62c0eb8 View commit details
  2. Copy the full SHA
    11fbea4 View commit details
  3. Copy the full SHA
    fa89e16 View commit details
Showing with 30 additions and 18 deletions.
  1. +2 −8 artiq/frontend/artiq_gui.py
  2. +19 −4 artiq/gui/console.py
  3. +1 −3 artiq/gui/datasets.py
  4. +8 −3 artiq/protocols/sync_struct.py
10 changes: 2 additions & 8 deletions artiq/frontend/artiq_gui.py
Original file line number Diff line number Diff line change
@@ -120,14 +120,8 @@ def main():
d_log = log.LogDock(sub_clients["log"])
smgr.register(d_log)

def _set_dataset(k, v):
asyncio.ensure_future(rpc_clients["dataset_db"].set(k, v))
def _del_dataset(k):
asyncio.ensure_future(rpc_clients["dataset_db"].delete(k))
d_console = console.ConsoleDock(
d_datasets.get_dataset,
_set_dataset,
_del_dataset)
d_console = console.ConsoleDock(sub_clients["datasets"],
rpc_clients["dataset_db"])

area.addDock(d_console, "bottom")
area.addDock(d_log, "above", d_console)
23 changes: 19 additions & 4 deletions artiq/gui/console.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import asyncio

from pyqtgraph import console, dockarea


@@ -12,12 +14,25 @@
"""

class ConsoleDock(dockarea.Dock):
def __init__(self, get_dataset, set_dataset, del_dataset):
def __init__(self, dataset_sub, dataset_ctl):
dockarea.Dock.__init__(self, "Console", size=(1000, 300))
self.dataset_sub = dataset_sub
self.dataset_ctl = dataset_ctl
ns = {
"get_dataset": get_dataset,
"set_dataset": set_dataset,
"del_dataset": del_dataset
"get_dataset": self.get_dataset,
"set_dataset": self.set_dataset,
"del_dataset": self.del_dataset
}
c = console.ConsoleWidget(namespace=ns, text=_help)
self.addWidget(c)

def get_dataset(self, k):
if self.dataset_sub.model is None:
raise IOError("Datasets not available yet")
return self.dataset_sub.model.backing_store[k][1]

def set_dataset(self, k, v):
asyncio.ensure_future(self.dataset_ctl.set(k, v))

def del_dataset(self, k):
asyncio.ensure_future(self.dataset_ctl.delete(k))
4 changes: 1 addition & 3 deletions artiq/gui/datasets.py
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ def __init__(self, dialog_parent, dock_area, datasets_sub):

self.table_model = Model(dict())
datasets_sub.add_setmodel_callback(self.set_model)
datasets_sub.notify_cbs.append(self.on_mod)

add_display_box = QtGui.QGroupBox("Add display")
grid.addWidget(add_display_box, 1, 1)
@@ -84,9 +85,6 @@ def _search_datasets(self):
self.table_model_filter.setFilterFixedString(
self.search.displayText())

def get_dataset(self, key):
return self.table_model.backing_store[key][1]

def set_model(self, model):
self.table_model = model
self.table_model_filter = QSortFilterProxyModel()
11 changes: 8 additions & 3 deletions artiq/protocols/sync_struct.py
Original file line number Diff line number Diff line change
@@ -51,11 +51,16 @@ class Subscriber:
:param notify_cb: An optional function called every time a mod is received
from the publisher. The mod is passed as parameter. The function is
called after the mod has been processed.
A list of functions may also be used, and they will be called in turn.
"""
def __init__(self, notifier_name, target_builder, notify_cb=None):
self.notifier_name = notifier_name
self.target_builder = target_builder
self.notify_cb = notify_cb
if notify_cb is None:
notify_cb = []
if not isinstance(notify_cb, list):
notify_cb = [notify_cb]
self.notify_cbs = notify_cb

async def connect(self, host, port, before_receive_cb=None):
self.reader, self.writer = \
@@ -97,8 +102,8 @@ async def _receive_cr(self):
else:
process_mod(target, mod)

if self.notify_cb is not None:
self.notify_cb(mod)
for notify_cb in self.notify_cbs:
notify_cb(mod)


class Notifier: