mirror of https://github.com/m-labs/artiq.git
gui: RT results overview
This commit is contained in:
parent
55cd41444e
commit
21e8596d8c
|
@ -14,6 +14,7 @@ from artiq.protocols.file_db import FlatFileDB
|
|||
from artiq.protocols.pc_rpc import AsyncioClient
|
||||
from artiq.gui.explorer import ExplorerDock
|
||||
from artiq.gui.moninj import MonInj
|
||||
from artiq.gui.results import ResultsDock
|
||||
from artiq.gui.parameters import ParametersDock
|
||||
from artiq.gui.schedule import ScheduleDock
|
||||
from artiq.gui.log import LogDock
|
||||
|
@ -70,12 +71,18 @@ def main():
|
|||
args.server, args.port_notify))
|
||||
atexit.register(lambda: loop.run_until_complete(d_explorer.sub_close()))
|
||||
|
||||
d_results = ResultsDock()
|
||||
loop.run_until_complete(d_results.sub_connect(
|
||||
args.server, args.port_notify))
|
||||
atexit.register(lambda: loop.run_until_complete(d_results.sub_close()))
|
||||
|
||||
d_ttl_dds = MonInj()
|
||||
loop.run_until_complete(d_ttl_dds.start(args.server, args.port_notify))
|
||||
atexit.register(lambda: loop.run_until_complete(d_ttl_dds.stop()))
|
||||
area.addDock(d_ttl_dds.dds_dock, "top")
|
||||
area.addDock(d_ttl_dds.ttl_dock, "above", d_ttl_dds.dds_dock)
|
||||
area.addDock(d_explorer, "above", d_ttl_dds.ttl_dock)
|
||||
area.addDock(d_results, "above", d_ttl_dds.ttl_dock)
|
||||
area.addDock(d_explorer, "above", d_results)
|
||||
|
||||
d_params = ParametersDock()
|
||||
area.addDock(d_params, "right", d_explorer)
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
import asyncio
|
||||
|
||||
from quamash import QtGui, QtCore
|
||||
from pyqtgraph import dockarea
|
||||
from pyqtgraph import LayoutWidget
|
||||
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.gui.tools import DictSyncModel
|
||||
|
||||
|
||||
def _fmt_type(v):
|
||||
t = type(v)
|
||||
r = t.__name__
|
||||
if t is list or t is dict or t is set:
|
||||
r += " ({})".format(len(v))
|
||||
return r
|
||||
|
||||
|
||||
class ResultsModel(DictSyncModel):
|
||||
def __init__(self, parent, init):
|
||||
DictSyncModel.__init__(self, ["Result", "Type"],
|
||||
parent, init)
|
||||
|
||||
def sort_key(self, k, v):
|
||||
return k
|
||||
|
||||
def convert(self, k, v, column):
|
||||
if column == 0:
|
||||
return k
|
||||
elif column == 1:
|
||||
return _fmt_type(v)
|
||||
else:
|
||||
raise ValueError
|
||||
|
||||
|
||||
class ResultsDock(dockarea.Dock):
|
||||
def __init__(self):
|
||||
dockarea.Dock.__init__(self, "Results", size=(1500, 500))
|
||||
|
||||
grid = LayoutWidget()
|
||||
self.addWidget(grid)
|
||||
|
||||
self.table = QtGui.QTableView()
|
||||
self.table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
grid.addWidget(self.table, 0, 0)
|
||||
|
||||
add_display_box = QtGui.QGroupBox("Add display")
|
||||
grid.addWidget(add_display_box, 0, 1)
|
||||
display_grid = QtGui.QGridLayout()
|
||||
add_display_box.setLayout(display_grid)
|
||||
|
||||
for n, name in enumerate(["Number", "XY", "Histogram"]):
|
||||
btn = QtGui.QPushButton(name)
|
||||
display_grid.addWidget(btn, n, 0)
|
||||
|
||||
@asyncio.coroutine
|
||||
def sub_connect(self, host, port):
|
||||
self.subscriber = Subscriber("rt_results", self.init_results_model)
|
||||
yield from self.subscriber.connect(host, port)
|
||||
|
||||
@asyncio.coroutine
|
||||
def sub_close(self):
|
||||
yield from self.subscriber.close()
|
||||
|
||||
def init_results_model(self, init):
|
||||
table_model = ResultsModel(self.table, init)
|
||||
self.table.setModel(table_model)
|
||||
return table_model
|
Loading…
Reference in New Issue