diff --git a/artiq/dashboard/waveform.py b/artiq/dashboard/waveform.py index e76bb1c3c..26931d974 100644 --- a/artiq/dashboard/waveform.py +++ b/artiq/dashboard/waveform.py @@ -114,7 +114,7 @@ class _AddChannelDialog(QtWidgets.QDialog): key = self._channel_model.index_to_key(select) if key is not None: width, ty = self._channel_model[key].ref - channels.append((key, ty, width, [])) + channels.append([key, ty, width, []]) self.accepted.emit(channels) self.close() @@ -153,10 +153,6 @@ class Waveform(pg.PlotWidget): self.name = name self.width = width - #self.state = state - #self.x_data = [] - #self.y_data = [] - self.plot_item = self.getPlotItem() self.plot_item.hideButtons() self.plot_item.getAxis("bottom").setStyle(showValues=False, tickLength=0) @@ -275,7 +271,7 @@ class LogWaveform(Waveform): self.addItem(lbl) lbl.setPos(old_x, DISPLAY_HIGH) 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=[]) def format_cursor_label(self): @@ -289,8 +285,6 @@ class BitWaveform(Waveform): #self.plot_data_item.setDownsampling(ds=1000, method="peak", auto=False) def onDataChange(self, data): - logger.info("bit waveform ondatachanged triggered") - logger.info(str(len(data))) try: display_y = [] display_x = [] @@ -312,7 +306,7 @@ class BitWaveform(Waveform): previous_y = y self.plot_data_item.setData(x=display_x, y=display_y) 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: self.removeItem(arw) self.plot_data_item.setData(x=[], y=[]) @@ -364,7 +358,7 @@ class BitVectorWaveform(Waveform): self._labels.append(lbl) self.plot_data_item.setData(x=display_x, y=display_y) 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: self.plot_item.removeItem(lbl) self.plot_data_item.setData(x=[], y=[]) @@ -393,7 +387,7 @@ class AnalogWaveform(Waveform): min_y = min(y_data) self.plot_item.setRange(yRange=(min_y, max_y), padding=0.1) 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=[]) # 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.rowsRemoved.connect(self.onRemove) self._model.rowsMoved.connect(self.onMove) + self._splitter.dropped.connect(self._model.move) def onDataChange(self, top, bottom, roles): first = top.row() - logger.info(str(first)) last = bottom.row() - logger.info(str(last)) for i in range(first, last + 1): data = self._model.data(self._model.index(i, 3)) self._splitter.widget(i).onDataChange(data) @@ -523,19 +516,24 @@ class _WaveformModel(QtCore.QAbstractTableModel): self.endRemoveRows() 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.backing_struct.insert(dest, self.backing_struct.pop(src)) self.endMoveRows() + def get_channels(self): + return [row[0] for row in self.backing_struct] + def update_data(self, waveform_data): for i in range(self.rowCount()): - logger.info(str(i)) name = self.data(self.index(i, 0)) if name in waveform_data: - logger.info(name) - self.backing_struct[i] = waveform_data[name] - self.dataChanged.emit(self.index(0, 0), - self.index(self.rowCount()-1, self.columnCount()-1)) + self.backing_struct[i][3] = waveform_data[name] + self.dataChanged.emit(self.index(0, 0), + self.index(self.rowCount()-1, self.columnCount()-1)) class WaveformArea(QtWidgets.QWidget): @@ -913,10 +911,8 @@ class WaveformDock(QtWidgets.QDockWidget): with open(filename, 'w') as f: decoded_dump = comm_analyzer.decode_dump(dump) comm_analyzer.decoded_dump_to_vcd(f, ddb, decoded_dump) - except Exception as e: - logger.error("Failed to save as VCD: %s", e) - finally: - logger.info("Finished writing to VCD.") + except: + logger.error("Failed to save as VCD.", exc_info=True) async def load_channels(self): try: @@ -958,19 +954,16 @@ class WaveformDock(QtWidgets.QDockWidget): self._channel_model.update(channel_list) desc = self._ddb.get("core_analyzer") if desc is not None: - logger.info("desc found") addr = desc["host"] - port = desc.get("port_proxy", 1385) - port_control = desc.get("port_proxy_control", 1386) - self.rpc_client.update_address(addr, port_control) - self.receiver_client.update_address(addr, port) + port = desc.get("port", 1386) + port_proxy = desc.get("port_proxy", 1385) + self.rpc_client.update_address(addr, port) + self.receiver_client.update_address(addr, port_proxy) def init_ddb(self, ddb): - logger.info("init ddb") self._ddb = ddb self._process_ddb() return ddb def update_ddb(self, mod): - logger.info("update ddb") self._process_ddb() diff --git a/artiq/gui/dndwidgets.py b/artiq/gui/dndwidgets.py index 372a6b595..0ba0d2cee 100644 --- a/artiq/gui/dndwidgets.py +++ b/artiq/gui/dndwidgets.py @@ -2,6 +2,8 @@ from PyQt5 import QtCore, QtWidgets class VDragDropSplitter(QtWidgets.QSplitter): + dropped = QtCore.pyqtSignal(int, int) + def __init__(self, parent): QtWidgets.QSplitter.__init__(self, parent=parent) self.setAcceptDrops(True) @@ -50,7 +52,7 @@ class VDragDropSplitter(QtWidgets.QSplitter): for n in range(self.count()): w = self.widget(n) if pos.y() < w.y() + w.size().height(): - self.insertWidget(n, src) + self.dropped.emit(src_i, n) break e.accept()