From f2d5e6a5d89ab526df2ff4706038d24f8475a1b6 Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Fri, 26 Jan 2024 15:08:49 +0800 Subject: [PATCH] waveform: add AnalogWaveform --- artiq/dashboard/waveform.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/artiq/dashboard/waveform.py b/artiq/dashboard/waveform.py index 53e250f34..366be19b7 100644 --- a/artiq/dashboard/waveform.py +++ b/artiq/dashboard/waveform.py @@ -186,6 +186,23 @@ class _BaseWaveform(pg.PlotWidget): super().wheelEvent(e) +class AnalogWaveform(_BaseWaveform): + def __init__(self, name, width, parent=None): + _BaseWaveform.__init__(self, name, width, parent) + + def onDataChange(self, data): + try: + x_data, y_data = zip(*data) + self.plot_data_item.setData(x=x_data, y=y_data) + max_y = max(y_data) + min_y = min(y_data) + self.plot_item.setRange(yRange=(min_y, max_y), padding=0.1) + except: + logger.error( + 'Error when displaying waveform: {}'.format(self.name), exc_info=True) + self.plot_data_item.setData(x=[], y=[]) + + class _WaveformView(QtWidgets.QWidget): def __init__(self, parent): QtWidgets.QWidget.__init__(self, parent=parent)