2015-07-22 05:13:50 +08:00
|
|
|
import asyncio
|
|
|
|
|
2015-07-23 23:06:37 +08:00
|
|
|
from quamash import QtGui, QtCore
|
2015-05-24 00:38:30 +08:00
|
|
|
from pyqtgraph import dockarea
|
|
|
|
|
2015-07-22 05:13:50 +08:00
|
|
|
from artiq.protocols.sync_struct import Subscriber
|
|
|
|
from artiq.gui.tools import ListSyncModel
|
|
|
|
|
|
|
|
|
|
|
|
class _LogModel(ListSyncModel):
|
|
|
|
def __init__(self, parent, init):
|
|
|
|
ListSyncModel.__init__(self,
|
|
|
|
["RID", "Message"],
|
|
|
|
parent, init)
|
|
|
|
|
|
|
|
def convert(self, v, column):
|
|
|
|
return v[column]
|
|
|
|
|
2015-05-24 00:38:30 +08:00
|
|
|
|
|
|
|
class LogDock(dockarea.Dock):
|
|
|
|
def __init__(self):
|
|
|
|
dockarea.Dock.__init__(self, "Log", size=(1000, 300))
|
2015-07-22 05:13:50 +08:00
|
|
|
|
|
|
|
self.log = QtGui.QTableView()
|
|
|
|
self.log.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
|
2015-07-23 22:36:52 +08:00
|
|
|
self.log.horizontalHeader().setResizeMode(
|
|
|
|
QtGui.QHeaderView.ResizeToContents)
|
2015-07-23 23:06:37 +08:00
|
|
|
self.log.setHorizontalScrollMode(
|
|
|
|
QtGui.QAbstractItemView.ScrollPerPixel)
|
|
|
|
self.log.setShowGrid(False)
|
|
|
|
self.log.setTextElideMode(QtCore.Qt.ElideNone)
|
2015-07-22 05:13:50 +08:00
|
|
|
self.addWidget(self.log)
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def sub_connect(self, host, port):
|
|
|
|
self.subscriber = Subscriber("log", self.init_log_model)
|
|
|
|
yield from self.subscriber.connect(host, port)
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def sub_close(self):
|
|
|
|
yield from self.subscriber.close()
|
|
|
|
|
|
|
|
def init_log_model(self, init):
|
|
|
|
table_model = _LogModel(self.log, init)
|
|
|
|
self.log.setModel(table_model)
|
|
|
|
return table_model
|