forked from M-Labs/artiq
gui: add console
This commit is contained in:
parent
f210e0dcd6
commit
ef8b09d9bc
|
@ -18,6 +18,7 @@ from artiq.gui.results import ResultsDock
|
|||
from artiq.gui.parameters import ParametersDock
|
||||
from artiq.gui.schedule import ScheduleDock
|
||||
from artiq.gui.log import LogDock
|
||||
from artiq.gui.console import ConsoleDock
|
||||
|
||||
|
||||
data_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
|
||||
|
@ -109,7 +110,19 @@ def main():
|
|||
args.server, args.port_notify))
|
||||
atexit.register(lambda: loop.run_until_complete(d_log.sub_close()))
|
||||
|
||||
area.addDock(d_log, "bottom")
|
||||
pdb = AsyncioClient()
|
||||
loop.run_until_complete(pdb.connect_rpc(
|
||||
args.server, args.port_control, "master_pdb"))
|
||||
atexit.register(lambda: pdb.close_rpc())
|
||||
def _get_parameter(k, v):
|
||||
asyncio.async(pdb.set(k, v))
|
||||
d_console = ConsoleDock(
|
||||
d_params.get_parameter,
|
||||
_get_parameter,
|
||||
d_results.get_result)
|
||||
|
||||
area.addDock(d_console, "bottom")
|
||||
area.addDock(d_log, "above", d_console)
|
||||
area.addDock(d_schedule, "above", d_log)
|
||||
|
||||
win.show()
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
from pyqtgraph import console, dockarea
|
||||
|
||||
|
||||
_help = """
|
||||
The following functions are available:
|
||||
get_parameter(key)
|
||||
set_parameter(key, value) [asynchronous update]
|
||||
get_result(key) [real-time results only]
|
||||
|
||||
"""
|
||||
|
||||
class ConsoleDock(dockarea.Dock):
|
||||
def __init__(self, get_parameter, set_parameter, get_result):
|
||||
dockarea.Dock.__init__(self, "Console", size=(1000, 300))
|
||||
ns = {
|
||||
"get_parameter": get_parameter,
|
||||
"set_parameter": set_parameter,
|
||||
"get_result": get_result
|
||||
}
|
||||
c = console.ConsoleWidget(namespace=ns, text=_help)
|
||||
self.addWidget(c)
|
|
@ -34,7 +34,7 @@ class ParametersDock(dockarea.Dock):
|
|||
|
||||
self.search = QtGui.QLineEdit()
|
||||
self.search.setPlaceholderText("search...")
|
||||
self.search.editingFinished.connect(self.search_parameters)
|
||||
self.search.editingFinished.connect(self._search_parameters)
|
||||
grid.addWidget(self.search, 0, 0)
|
||||
|
||||
self.table = QtGui.QTableView()
|
||||
|
@ -43,7 +43,10 @@ class ParametersDock(dockarea.Dock):
|
|||
QtGui.QHeaderView.ResizeToContents)
|
||||
grid.addWidget(self.table, 1, 0)
|
||||
|
||||
def search_parameters(self):
|
||||
def get_parameter(self, key):
|
||||
return self.table_model.backing_store[key]
|
||||
|
||||
def _search_parameters(self):
|
||||
model = self.table.model()
|
||||
parentIndex = model.index(0, 0)
|
||||
numRows = model.rowCount(parentIndex)
|
||||
|
@ -66,6 +69,6 @@ class ParametersDock(dockarea.Dock):
|
|||
yield from self.subscriber.close()
|
||||
|
||||
def init_parameters_model(self, init):
|
||||
table_model = ParametersModel(self.table, init)
|
||||
self.table.setModel(table_model)
|
||||
return table_model
|
||||
self.table_model = ParametersModel(self.table, init)
|
||||
self.table.setModel(self.table_model)
|
||||
return self.table_model
|
||||
|
|
|
@ -55,6 +55,9 @@ class ResultsDock(dockarea.Dock):
|
|||
|
||||
self.displays = dict()
|
||||
|
||||
def get_result(self, key):
|
||||
return self.table_model.backing_store[key]
|
||||
|
||||
@asyncio.coroutine
|
||||
def sub_connect(self, host, port):
|
||||
self.subscriber = Subscriber("rt_results", self.init_results_model,
|
||||
|
|
Loading…
Reference in New Issue