From f75348c69d54759d4d7d7088da6ffed9c5b6ba14 Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 28 Aug 2024 10:50:38 +0800 Subject: [PATCH] Clear Graph UI changes --- pytec/pytec/gui/view/live_plot_view.py | 9 +++++++++ pytec/tec_qt.py | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pytec/pytec/gui/view/live_plot_view.py b/pytec/pytec/gui/view/live_plot_view.py index 2243263..f651f43 100644 --- a/pytec/pytec/gui/view/live_plot_view.py +++ b/pytec/pytec/gui/view/live_plot_view.py @@ -5,6 +5,7 @@ from pglive.sources.live_plot import LiveLinePlot from pglive.sources.live_axis import LiveAxis from collections import deque import pyqtgraph as pg +from pytec.gui.model.thermostat import ThermostatConnectionState pg.setConfigOptions(antialias=True) @@ -16,6 +17,9 @@ class LiveDataPlotter(QObject): self._thermostat.report_update.connect(self.update_report) self._thermostat.pid_update.connect(self.update_pid) + self._thermostat.connection_state_changed.connect( + self.thermostat_state_change_handler + ) self.NUM_CHANNELS = len(live_plots) self.graphs = [] @@ -25,6 +29,11 @@ class LiveDataPlotter(QObject): live_plot[1].setTitle(f"Channel {i} Current") self.graphs.append(_TecGraphs(live_plot[0], live_plot[1])) + @pyqtSlot(ThermostatConnectionState) + def thermostat_state_change_handler(self, state): + if state == ThermostatConnectionState.DISCONNECTED: + self.clear_graphs() + def _config_connector_max_pts(self, connector, samples): connector.max_points = samples connector.x = deque(maxlen=int(connector.max_points)) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 44a3421..1cd90c9 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -156,7 +156,6 @@ class MainWindow(QtWidgets.QMainWindow): self.background_task_lbl.setText("Ready.") self.loading_spinner.hide() self.loading_spinner.stop() - self.channel_graphs.clear_graphs() self.report_box.setChecked(False) for ch in range(self.NUM_CHANNELS): if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF: