forked from M-Labs/artiq
waveform: updates
This commit is contained in:
parent
70f374c293
commit
c14964b36d
@ -29,35 +29,35 @@ DISPLAY_HIGH = 1
|
|||||||
DISPLAY_MID = 0.5
|
DISPLAY_MID = 0.5
|
||||||
|
|
||||||
|
|
||||||
class _CursorTimeControl(QtWidgets.QLineEdit):
|
#class _CursorTimeControl(QtWidgets.QLineEdit):
|
||||||
submit = QtCore.pyqtSignal(float)
|
# submit = QtCore.pyqtSignal(float)
|
||||||
PRECISION = 15
|
# PRECISION = 15
|
||||||
|
#
|
||||||
def __init__(self, parent, state):
|
# def __init__(self, parent, state):
|
||||||
QtWidgets.QLineEdit.__init__(self, parent=parent)
|
# QtWidgets.QLineEdit.__init__(self, parent=parent)
|
||||||
self._value = 0
|
# self._value = 0
|
||||||
self._state = state
|
# self._state = state
|
||||||
self.display_value(0)
|
# self.display_value(0)
|
||||||
self.textChanged.connect(self._on_text_change)
|
# self.textChanged.connect(self._on_text_change)
|
||||||
self.returnPressed.connect(self._on_return_press)
|
# self.returnPressed.connect(self._on_return_press)
|
||||||
|
#
|
||||||
def _on_text_change(self, text):
|
# def _on_text_change(self, text):
|
||||||
try:
|
# try:
|
||||||
self._value = pg.siEval(text) * (1e12 / self._state["timescale"])
|
# self._value = pg.siEval(text) * (1e12 / self._state["timescale"])
|
||||||
except Exception:
|
# except Exception:
|
||||||
# invalid text entry is ignored, resets to valid value on return pressed
|
# # invalid text entry is ignored, resets to valid value on return pressed
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
def display_value(self, val):
|
# def display_value(self, val):
|
||||||
t = pg.siFormat(val * 1e-12 * self._state["timescale"], suffix="s",
|
# t = pg.siFormat(val * 1e-12 * self._state["timescale"], suffix="s",
|
||||||
allowUnicode=False,
|
# allowUnicode=False,
|
||||||
precision=self.PRECISION)
|
# precision=self.PRECISION)
|
||||||
self.setText(t)
|
# self.setText(t)
|
||||||
|
#
|
||||||
def _on_return_press(self):
|
# def _on_return_press(self):
|
||||||
self.submit.emit(self._value)
|
# self.submit.emit(self._value)
|
||||||
self.display_value(self._value)
|
# self.display_value(self._value)
|
||||||
self.clearFocus()
|
# self.clearFocus()
|
||||||
|
|
||||||
|
|
||||||
class Model(DictSyncTreeSepModel):
|
class Model(DictSyncTreeSepModel):
|
||||||
@ -114,7 +114,7 @@ class _AddChannelDialog(QtWidgets.QDialog):
|
|||||||
key = self._channel_model.index_to_key(select)
|
key = self._channel_model.index_to_key(select)
|
||||||
if key is not None:
|
if key is not None:
|
||||||
width, ty = self._channel_model[key].ref
|
width, ty = self._channel_model[key].ref
|
||||||
channels.append((key, width, ty, []))
|
channels.append((key, ty, width, []))
|
||||||
self.accepted.emit(channels)
|
self.accepted.emit(channels)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ class _WaveformView(QtWidgets.QWidget):
|
|||||||
|
|
||||||
def setModel(self, model):
|
def setModel(self, model):
|
||||||
self._model = model
|
self._model = model
|
||||||
self._model.dataChanged.connect(self.onDataChanged)
|
self._model.dataChanged.connect(self.onDataChange)
|
||||||
self._model.rowsInserted.connect(self.onInsert)
|
self._model.rowsInserted.connect(self.onInsert)
|
||||||
self._model.rowsRemoved.connect(self.onRemove)
|
self._model.rowsRemoved.connect(self.onRemove)
|
||||||
self._model.rowsMoved.connect(self.onMove)
|
self._model.rowsMoved.connect(self.onMove)
|
||||||
@ -454,26 +454,27 @@ class _WaveformView(QtWidgets.QWidget):
|
|||||||
self._splitter.widget(i).onDataChange(data)
|
self._splitter.widget(i).onDataChange(data)
|
||||||
|
|
||||||
def onInsert(self, parent, first, last):
|
def onInsert(self, parent, first, last):
|
||||||
|
logger.info("inserting widget")
|
||||||
for i in range(first, last + 1):
|
for i in range(first, last + 1):
|
||||||
w = self._create_waveform(self.index(i, 0))
|
w = self._create_waveform(i)
|
||||||
self.splitter.insertWidget(i, w)
|
self._splitter.insertWidget(i, w)
|
||||||
self._resize()
|
self._resize()
|
||||||
|
|
||||||
def onRemove(self, parent, first, last):
|
def onRemove(self, parent, first, last):
|
||||||
for i in reversed(range(first, last + 1)):
|
for i in reversed(range(first, last + 1)):
|
||||||
w = self.splitter.widget(i)
|
w = self._splitter.widget(i)
|
||||||
w.deleteLater()
|
w.deleteLater()
|
||||||
self.splitter.refresh()
|
self._splitter.refresh()
|
||||||
self._resize()
|
self._resize()
|
||||||
|
|
||||||
def onMove(self, src_parent, src_start, src_end, dest_parent, dest_row):
|
def onMove(self, src_parent, src_start, src_end, dest_parent, dest_row):
|
||||||
w = self.splitter.widget(src_start)
|
w = self._splitter.widget(src_start)
|
||||||
self.splitter.insertWidget(dest_row, w)
|
self._splitter.insertWidget(dest_row, w)
|
||||||
|
|
||||||
def _create_waveform(self, row):
|
def _create_waveform(self, row):
|
||||||
name = self._model.data(self.index(row, 0))
|
name = self._model.data(self._model.index(row, 0))
|
||||||
ty = self._model.data(self.index(row, 1))
|
ty = self._model.data(self._model.index(row, 1))
|
||||||
width = self._model.data(self.index(row, 2))
|
width = self._model.data(self._model.index(row, 2))
|
||||||
waveform_cls = {
|
waveform_cls = {
|
||||||
WaveformType.BIT: BitWaveform,
|
WaveformType.BIT: BitWaveform,
|
||||||
WaveformType.VECTOR: BitVectorWaveform,
|
WaveformType.VECTOR: BitVectorWaveform,
|
||||||
@ -493,15 +494,15 @@ class _WaveformModel(QtCore.QAbstractTableModel):
|
|||||||
self.headers = ["name", "type", "width", "data"]
|
self.headers = ["name", "type", "width", "data"]
|
||||||
QtCore.QAbstractTableModel.__init__(self)
|
QtCore.QAbstractTableModel.__init__(self)
|
||||||
|
|
||||||
def rowCount(self):
|
def rowCount(self, parent=QtCore.QModelIndex()):
|
||||||
return len(self.backing_struct)
|
return len(self.backing_struct)
|
||||||
|
|
||||||
def columnCount(self):
|
def columnCount(self, parent=QtCore.QModelIndex()):
|
||||||
return len(self.headers)
|
return len(self.headers)
|
||||||
|
|
||||||
def data(self, index, role=QtCore.Qt.DisplayRole):
|
def data(self, index, role=QtCore.Qt.DisplayRole):
|
||||||
if index.isValid():
|
if index.isValid():
|
||||||
return self.backing_struct[index.row()][index.col()]
|
return self.backing_struct[index.row()][index.column()]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def extend(self, data):
|
def extend(self, data):
|
||||||
@ -799,6 +800,7 @@ class WaveformDock(QtWidgets.QDockWidget):
|
|||||||
lambda: asyncio.ensure_future(self.rpc_client.trigger_proxy_task()))
|
lambda: asyncio.ensure_future(self.rpc_client.trigger_proxy_task()))
|
||||||
|
|
||||||
self._waveform_view = _WaveformView(self)
|
self._waveform_view = _WaveformView(self)
|
||||||
|
self._waveform_view.setModel(self._waveform_model)
|
||||||
grid.addWidget(self._waveform_view, 2, 0, colspan=12)
|
grid.addWidget(self._waveform_view, 2, 0, colspan=12)
|
||||||
|
|
||||||
self._add_btn = QtWidgets.QToolButton()
|
self._add_btn = QtWidgets.QToolButton()
|
||||||
@ -815,8 +817,6 @@ class WaveformDock(QtWidgets.QDockWidget):
|
|||||||
# self._waveform_area.on_cursor_move)
|
# self._waveform_area.on_cursor_move)
|
||||||
#self._waveform_area.cursorMoved.connect(self._cursor_control.display_value)
|
#self._waveform_area.cursorMoved.connect(self._cursor_control.display_value)
|
||||||
|
|
||||||
self.traceDataChanged.connect(self._update_log_channels)
|
|
||||||
|
|
||||||
self._file_menu = QtWidgets.QMenu()
|
self._file_menu = QtWidgets.QMenu()
|
||||||
self._add_async_action("Open trace...", self.load_trace)
|
self._add_async_action("Open trace...", self.load_trace)
|
||||||
self._add_async_action("Save trace...", self.save_trace)
|
self._add_async_action("Save trace...", self.save_trace)
|
||||||
@ -831,16 +831,14 @@ class WaveformDock(QtWidgets.QDockWidget):
|
|||||||
lambda: asyncio.ensure_future(exc_to_warning(coro())))
|
lambda: asyncio.ensure_future(exc_to_warning(coro())))
|
||||||
self._file_menu.addAction(action)
|
self._file_menu.addAction(action)
|
||||||
|
|
||||||
def _update_log_channels(self):
|
|
||||||
self._channel_model.update(self._state['logs'])
|
|
||||||
|
|
||||||
def on_dump_receive(self, data):
|
def on_dump_receive(self, data):
|
||||||
decoded_dump = comm_analyzer.decode_dump(data)
|
decoded_dump = comm_analyzer.decode_dump(data)
|
||||||
ddb = self._ddb
|
ddb = self._ddb
|
||||||
trace = comm_analyzer.decoded_dump_to_waveform_data(ddb, decoded_dump)
|
trace = comm_analyzer.decoded_dump_to_waveform_data(ddb, decoded_dump)
|
||||||
self._state.update(trace)
|
self._waveform_data.update(trace)
|
||||||
|
self._channel_model.update(trace['logs'])
|
||||||
|
self._waveform_model.update_data(self._waveform_data)
|
||||||
self._dump = data
|
self._dump = data
|
||||||
self.traceDataChanged.emit()
|
|
||||||
|
|
||||||
def on_add_channel_click(self):
|
def on_add_channel_click(self):
|
||||||
asyncio.ensure_future(self._add_waveform_task())
|
asyncio.ensure_future(self._add_waveform_task())
|
||||||
|
Loading…
Reference in New Issue
Block a user