From 96b0ddc26cfd6d35b4e7d5310f6e8c3ada22c19c Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 28 Aug 2024 13:37:49 +0800 Subject: [PATCH] Simply test for connectivity for turning PID off --- pytec/pytec/gui/model/pid_autotuner.py | 3 ++- pytec/tec_qt.py | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pytec/pytec/gui/model/pid_autotuner.py b/pytec/pytec/gui/model/pid_autotuner.py index 999e89e..a1a5598 100644 --- a/pytec/pytec/gui/model/pid_autotuner.py +++ b/pytec/pytec/gui/model/pid_autotuner.py @@ -57,7 +57,8 @@ class PIDAutoTuner(QObject): async def stop_pid_from_running(self, ch): self.autotuners[ch].setOff() self.autotune_state_changed.emit(ch, self.autotuners[ch].state()) - await self._thermostat.set_param("pwm", ch, "i_set", 0) + if self._thermostat.connected(): + await self._thermostat.set_param("pwm", ch, "i_set", 0) @asyncSlot(list) async def tick(self, report): diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 1de0af2..8447d12 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -159,11 +159,7 @@ class MainWindow(QtWidgets.QMainWindow): self.report_box.setChecked(False) for ch in range(self.NUM_CHANNELS): if self.autotuners.get_state(ch) != PIDAutotuneState.STATE_OFF: - if self.thermostat.connection_errored: - # Don't send any commands, just reset local state - self.autotuners.autotuners[ch].setOff() - else: - await self.autotuners.stop_pid_from_running(ch) + await self.autotuners.stop_pid_from_running(ch) @asyncSlot(int) async def on_report_box_stateChanged(self, enabled):