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: 7584b02d6638
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: 44a1efa60167
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on Feb 8, 2016

  1. Copy the full SHA
    4733c4b View commit details
  2. Copy the full SHA
    1a2596d View commit details
  3. Copy the full SHA
    67327b1 View commit details
  4. Copy the full SHA
    44a1efa View commit details
Showing with 36 additions and 53 deletions.
  1. +1 −1 artiq/applets/big_number.py
  2. +1 −0 artiq/applets/plot_hist.py
  3. +1 −0 artiq/applets/plot_xy.py
  4. +1 −1 artiq/applets/plot_xy_hist.py
  5. +19 −40 artiq/applets/simple.py
  6. +12 −10 artiq/gui/applets.py
  7. +1 −1 examples/master/repository/histograms.py
2 changes: 1 addition & 1 deletion artiq/applets/big_number.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3.5

from quamash import QtWidgets
from PyQt5 import QtWidgets

from artiq.applets.simple import SimpleApplet

1 change: 1 addition & 0 deletions artiq/applets/plot_hist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3.5

import numpy as np
import PyQt5 # make sure pyqtgraph imports Qt5
import pyqtgraph

from artiq.applets.simple import SimpleApplet
1 change: 1 addition & 0 deletions artiq/applets/plot_xy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3.5

import numpy as np
import PyQt5 # make sure pyqtgraph imports Qt5
import pyqtgraph

from artiq.applets.simple import SimpleApplet
2 changes: 1 addition & 1 deletion artiq/applets/plot_xy_hist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3.5

import numpy as np
from quamash import QtWidgets
from PyQt5 import QtWidgets
import pyqtgraph

from artiq.applets.simple import SimpleApplet
59 changes: 19 additions & 40 deletions artiq/applets/simple.py
Original file line number Diff line number Diff line change
@@ -79,24 +79,20 @@ def __init__(self, main_widget_class, cmd_description=None,
help="time to wait after a mod (buffering other mods) "
"before updating (default: %(default).2f)")

self._arggroup_datasets = self.argparser.add_argument_group("datasets")

subparsers = self.argparser.add_subparsers(dest="mode")
subparsers.required = True

parser_sa = subparsers.add_parser("standalone",
help="run standalone, connect to master directly")
parser_sa.add_argument(
group = self.argparser.add_argument_group("standalone mode (default)")
group.add_argument(
"--server", default="::1",
help="hostname or IP to connect to")
parser_sa.add_argument(
help="hostname or IP of the master to connect to "
"for dataset notifications "
"(ignored in embedded mode)")
group.add_argument(
"--port", default=3250, type=int,
help="TCP port to connect to")

parser_em = subparsers.add_parser("embedded",
help="embed into GUI")
parser_em.add_argument("ipc_address",
help="address for pipe_ipc")
self.argparser.add_argument("--embed", default=None,
help="embed into GUI", metavar="IPC_ADDRESS")

self._arggroup_datasets = self.argparser.add_argument_group("datasets")

self.dataset_args = set()

@@ -121,23 +117,13 @@ def quamash_init(self):
asyncio.set_event_loop(self.loop)

def ipc_init(self):
if self.args.mode == "standalone":
# nothing to do
pass
elif self.args.mode == "embedded":
self.ipc = AppletIPCClient(self.args.ipc_address)
if self.args.embed is not None:
self.ipc = AppletIPCClient(self.args.embed)
self.loop.run_until_complete(self.ipc.connect())
else:
raise NotImplementedError

def ipc_close(self):
if self.args.mode == "standalone":
# nothing to do
pass
elif self.args.mode == "embedded":
if self.args.embed is not None:
self.ipc.close()
else:
raise NotImplementedError

def create_main_widget(self):
self.main_widget = self.main_widget_class(self.args)
@@ -149,7 +135,7 @@ def create_main_widget(self):
# 4. applet shows the widget
# Doing embedding the other way around (using QWindow.setParent in the
# applet) breaks resizing.
if self.args.mode == "embedded":
if self.args.embed is not None:
self.ipc.set_close_cb(self.main_widget.close)
win_id = int(self.main_widget.winId())
self.loop.run_until_complete(self.ipc.embed(win_id))
@@ -160,7 +146,7 @@ def sub_init(self, data):
return data

def filter_mod(self, mod):
if self.args.mode == "embedded":
if self.args.embed is not None:
# the parent already filters for us
return True

@@ -192,24 +178,17 @@ def sub_mod(self, mod):
self.main_widget.data_changed(self.data, [mod])

def subscribe(self):
if self.args.mode == "standalone":
if self.args.embed is None:
self.subscriber = Subscriber("datasets",
self.sub_init, self.sub_mod)
self.loop.run_until_complete(self.subscriber.connect(
self.args.server_notify, self.args.port_notify))
elif self.args.mode == "embedded":
self.ipc.subscribe(self.datasets, self.sub_init, self.sub_mod)
self.args.server, self.args.port))
else:
raise NotImplementedError
self.ipc.subscribe(self.datasets, self.sub_init, self.sub_mod)

def unsubscribe(self):
if self.args.mode == "standalone":
if self.args.embed is None:
self.loop.run_until_complete(self.subscriber.close())
elif self.args.mode == "embedded":
# nothing to do
pass
else:
raise NotImplementedError

def run(self):
self.args_init()
22 changes: 12 additions & 10 deletions artiq/gui/applets.py
Original file line number Diff line number Diff line change
@@ -137,15 +137,15 @@ async def restart(self):

_templates = [
("Big number", "{python} -m artiq.applets.big_number "
"embedded {ipc_address} NUMBER_DATASET"),
"--embed {ipc_address} NUMBER_DATASET"),
("Histogram", "{python} -m artiq.applets.plot_hist "
"embedded {ipc_address} COUNTS_DATASET "
"--embed {ipc_address} COUNTS_DATASET "
"--x BIN_BOUNDARIES_DATASET"),
("XY", "{python} -m artiq.applets.plot_xy "
"embedded {ipc_address} Y_DATASET --x X_DATASET "
"--embed {ipc_address} Y_DATASET --x X_DATASET "
"--error ERROR_DATASET --fit FIT_DATASET"),
("XY + Histogram", "{python} -m artiq.applets.plot_xy_hist "
"embedded {ipc_address} X_DATASET "
"--embed {ipc_address} X_DATASET "
"HIST_BIN_BOUNDARIES_DATASET "
"HISTS_COUNTS_DATASET"),
]
@@ -248,9 +248,10 @@ def on_dock_closed(self, dock):
del self.dock_to_checkbox[dock]
checkbox_item.setCheckState(QtCore.Qt.Unchecked)

def new(self):
uid = next(iter(set(range(len(self.applet_uids) + 1))
- self.applet_uids))
def new(self, uid=None):
if uid is None:
uid = next(iter(set(range(len(self.applet_uids) + 1))
- self.applet_uids))
self.applet_uids.add(uid)

row = self.table.rowCount()
@@ -301,16 +302,17 @@ async def stop(self):
def save_state(self):
state = []
for row in range(self.table.rowCount()):
uid = self.table.item(row, 0).applet_uid
enabled = self.table.item(row, 0).checkState() == QtCore.Qt.Checked
name = self.table.item(row, 1).text()
command = self.table.item(row, 2).text()
state.append((enabled, name, command))
state.append((uid, enabled, name, command))
return state

def restore_state(self, state):
self.workaround_pyqtgraph_bug = True
for enabled, name, command in state:
row = self.new()
for uid, enabled, name, command in state:
row = self.new(uid)
item = QtWidgets.QTableWidgetItem()
item.setText(name)
self.table.setItem(row, 1, item)
2 changes: 1 addition & 1 deletion examples/master/repository/histograms.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import numpy as np

from artiq import *
from artiq.experiment import *


class Histograms(EnvExperiment):