forked from M-Labs/artiq
waveform: working new without cursor
This commit is contained in:
parent
ea0cbefa67
commit
53cbd62aa0
@ -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, ty, width, []))
|
channels.append([key, ty, width, []])
|
||||||
self.accepted.emit(channels)
|
self.accepted.emit(channels)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@ -153,10 +153,6 @@ class Waveform(pg.PlotWidget):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.width = width
|
self.width = width
|
||||||
|
|
||||||
#self.state = state
|
|
||||||
#self.x_data = []
|
|
||||||
#self.y_data = []
|
|
||||||
|
|
||||||
self.plot_item = self.getPlotItem()
|
self.plot_item = self.getPlotItem()
|
||||||
self.plot_item.hideButtons()
|
self.plot_item.hideButtons()
|
||||||
self.plot_item.getAxis("bottom").setStyle(showValues=False, tickLength=0)
|
self.plot_item.getAxis("bottom").setStyle(showValues=False, tickLength=0)
|
||||||
@ -275,7 +271,7 @@ class LogWaveform(Waveform):
|
|||||||
self.addItem(lbl)
|
self.addItem(lbl)
|
||||||
lbl.setPos(old_x, DISPLAY_HIGH)
|
lbl.setPos(old_x, DISPLAY_HIGH)
|
||||||
except:
|
except:
|
||||||
logger.debug('Error caught when displaying waveform: {}'.format(self.name), exc_info=True)
|
logger.error('Error caught when displaying waveform: {}'.format(self.name), exc_info=True)
|
||||||
self.plot_data_item.setData(x=[], y=[])
|
self.plot_data_item.setData(x=[], y=[])
|
||||||
|
|
||||||
def format_cursor_label(self):
|
def format_cursor_label(self):
|
||||||
@ -289,8 +285,6 @@ class BitWaveform(Waveform):
|
|||||||
#self.plot_data_item.setDownsampling(ds=1000, method="peak", auto=False)
|
#self.plot_data_item.setDownsampling(ds=1000, method="peak", auto=False)
|
||||||
|
|
||||||
def onDataChange(self, data):
|
def onDataChange(self, data):
|
||||||
logger.info("bit waveform ondatachanged triggered")
|
|
||||||
logger.info(str(len(data)))
|
|
||||||
try:
|
try:
|
||||||
display_y = []
|
display_y = []
|
||||||
display_x = []
|
display_x = []
|
||||||
@ -312,7 +306,7 @@ class BitWaveform(Waveform):
|
|||||||
previous_y = y
|
previous_y = y
|
||||||
self.plot_data_item.setData(x=display_x, y=display_y)
|
self.plot_data_item.setData(x=display_x, y=display_y)
|
||||||
except:
|
except:
|
||||||
logger.debug('Error caught when displaying waveform: {}'.format(self.name), exc_info=True)
|
logger.error('Error caught when displaying waveform: {}'.format(self.name), exc_info=True)
|
||||||
for arw in self._arrows:
|
for arw in self._arrows:
|
||||||
self.removeItem(arw)
|
self.removeItem(arw)
|
||||||
self.plot_data_item.setData(x=[], y=[])
|
self.plot_data_item.setData(x=[], y=[])
|
||||||
@ -364,7 +358,7 @@ class BitVectorWaveform(Waveform):
|
|||||||
self._labels.append(lbl)
|
self._labels.append(lbl)
|
||||||
self.plot_data_item.setData(x=display_x, y=display_y)
|
self.plot_data_item.setData(x=display_x, y=display_y)
|
||||||
except:
|
except:
|
||||||
logger.debug('Error caught when displaying waveform: {}'.format(self.name), exc_info=True)
|
logger.error('Error caught when displaying waveform: {}'.format(self.name), exc_info=True)
|
||||||
for lbl in self._labels:
|
for lbl in self._labels:
|
||||||
self.plot_item.removeItem(lbl)
|
self.plot_item.removeItem(lbl)
|
||||||
self.plot_data_item.setData(x=[], y=[])
|
self.plot_data_item.setData(x=[], y=[])
|
||||||
@ -393,7 +387,7 @@ class AnalogWaveform(Waveform):
|
|||||||
min_y = min(y_data)
|
min_y = min(y_data)
|
||||||
self.plot_item.setRange(yRange=(min_y, max_y), padding=0.1)
|
self.plot_item.setRange(yRange=(min_y, max_y), padding=0.1)
|
||||||
except:
|
except:
|
||||||
logger.debug('Error caught when displaying waveform: {}'.format(self.name), exc_info=True)
|
logger.error('Error caught when displaying waveform: {}'.format(self.name), exc_info=True)
|
||||||
self.plot_data_item.setData(x=[], y=[])
|
self.plot_data_item.setData(x=[], y=[])
|
||||||
|
|
||||||
# TODO: can also just leave it as None -> simpler
|
# TODO: can also just leave it as None -> simpler
|
||||||
@ -447,12 +441,11 @@ class _WaveformView(QtWidgets.QWidget):
|
|||||||
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)
|
||||||
|
self._splitter.dropped.connect(self._model.move)
|
||||||
|
|
||||||
def onDataChange(self, top, bottom, roles):
|
def onDataChange(self, top, bottom, roles):
|
||||||
first = top.row()
|
first = top.row()
|
||||||
logger.info(str(first))
|
|
||||||
last = bottom.row()
|
last = bottom.row()
|
||||||
logger.info(str(last))
|
|
||||||
for i in range(first, last + 1):
|
for i in range(first, last + 1):
|
||||||
data = self._model.data(self._model.index(i, 3))
|
data = self._model.data(self._model.index(i, 3))
|
||||||
self._splitter.widget(i).onDataChange(data)
|
self._splitter.widget(i).onDataChange(data)
|
||||||
@ -523,17 +516,22 @@ class _WaveformModel(QtCore.QAbstractTableModel):
|
|||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
|
|
||||||
def move(self, src, dest):
|
def move(self, src, dest):
|
||||||
|
if src == dest:
|
||||||
|
return
|
||||||
|
if dest == src + 1:
|
||||||
|
dest, src = src, dest
|
||||||
self.beginMoveRows(QtCore.QModelIndex(), src, src, QtCore.QModelIndex(), dest)
|
self.beginMoveRows(QtCore.QModelIndex(), src, src, QtCore.QModelIndex(), dest)
|
||||||
self.backing_struct.insert(dest, self.backing_struct.pop(src))
|
self.backing_struct.insert(dest, self.backing_struct.pop(src))
|
||||||
self.endMoveRows()
|
self.endMoveRows()
|
||||||
|
|
||||||
|
def get_channels(self):
|
||||||
|
return [row[0] for row in self.backing_struct]
|
||||||
|
|
||||||
def update_data(self, waveform_data):
|
def update_data(self, waveform_data):
|
||||||
for i in range(self.rowCount()):
|
for i in range(self.rowCount()):
|
||||||
logger.info(str(i))
|
|
||||||
name = self.data(self.index(i, 0))
|
name = self.data(self.index(i, 0))
|
||||||
if name in waveform_data:
|
if name in waveform_data:
|
||||||
logger.info(name)
|
self.backing_struct[i][3] = waveform_data[name]
|
||||||
self.backing_struct[i] = waveform_data[name]
|
|
||||||
self.dataChanged.emit(self.index(0, 0),
|
self.dataChanged.emit(self.index(0, 0),
|
||||||
self.index(self.rowCount()-1, self.columnCount()-1))
|
self.index(self.rowCount()-1, self.columnCount()-1))
|
||||||
|
|
||||||
@ -913,10 +911,8 @@ class WaveformDock(QtWidgets.QDockWidget):
|
|||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
decoded_dump = comm_analyzer.decode_dump(dump)
|
decoded_dump = comm_analyzer.decode_dump(dump)
|
||||||
comm_analyzer.decoded_dump_to_vcd(f, ddb, decoded_dump)
|
comm_analyzer.decoded_dump_to_vcd(f, ddb, decoded_dump)
|
||||||
except Exception as e:
|
except:
|
||||||
logger.error("Failed to save as VCD: %s", e)
|
logger.error("Failed to save as VCD.", exc_info=True)
|
||||||
finally:
|
|
||||||
logger.info("Finished writing to VCD.")
|
|
||||||
|
|
||||||
async def load_channels(self):
|
async def load_channels(self):
|
||||||
try:
|
try:
|
||||||
@ -958,19 +954,16 @@ class WaveformDock(QtWidgets.QDockWidget):
|
|||||||
self._channel_model.update(channel_list)
|
self._channel_model.update(channel_list)
|
||||||
desc = self._ddb.get("core_analyzer")
|
desc = self._ddb.get("core_analyzer")
|
||||||
if desc is not None:
|
if desc is not None:
|
||||||
logger.info("desc found")
|
|
||||||
addr = desc["host"]
|
addr = desc["host"]
|
||||||
port = desc.get("port_proxy", 1385)
|
port = desc.get("port", 1386)
|
||||||
port_control = desc.get("port_proxy_control", 1386)
|
port_proxy = desc.get("port_proxy", 1385)
|
||||||
self.rpc_client.update_address(addr, port_control)
|
self.rpc_client.update_address(addr, port)
|
||||||
self.receiver_client.update_address(addr, port)
|
self.receiver_client.update_address(addr, port_proxy)
|
||||||
|
|
||||||
def init_ddb(self, ddb):
|
def init_ddb(self, ddb):
|
||||||
logger.info("init ddb")
|
|
||||||
self._ddb = ddb
|
self._ddb = ddb
|
||||||
self._process_ddb()
|
self._process_ddb()
|
||||||
return ddb
|
return ddb
|
||||||
|
|
||||||
def update_ddb(self, mod):
|
def update_ddb(self, mod):
|
||||||
logger.info("update ddb")
|
|
||||||
self._process_ddb()
|
self._process_ddb()
|
||||||
|
@ -2,6 +2,8 @@ from PyQt5 import QtCore, QtWidgets
|
|||||||
|
|
||||||
|
|
||||||
class VDragDropSplitter(QtWidgets.QSplitter):
|
class VDragDropSplitter(QtWidgets.QSplitter):
|
||||||
|
dropped = QtCore.pyqtSignal(int, int)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QtWidgets.QSplitter.__init__(self, parent=parent)
|
QtWidgets.QSplitter.__init__(self, parent=parent)
|
||||||
self.setAcceptDrops(True)
|
self.setAcceptDrops(True)
|
||||||
@ -50,7 +52,7 @@ class VDragDropSplitter(QtWidgets.QSplitter):
|
|||||||
for n in range(self.count()):
|
for n in range(self.count()):
|
||||||
w = self.widget(n)
|
w = self.widget(n)
|
||||||
if pos.y() < w.y() + w.size().height():
|
if pos.y() < w.y() + w.size().height():
|
||||||
self.insertWidget(n, src)
|
self.dropped.emit(src_i, n)
|
||||||
break
|
break
|
||||||
e.accept()
|
e.accept()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user