From 35a179f7fa60c798f7f3609c9e46a2e72fe7b229 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 | 7 +++++++ pytec/tec_qt.py | 1 - 2 files changed, 7 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..e7ec852 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,7 @@ 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.NUM_CHANNELS = len(live_plots) self.graphs = [] @@ -25,6 +27,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 conn(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 a24fed1..8322ffc 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -164,7 +164,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: