diff --git a/pytec/pytec/gui/model/pid_autotuner.py b/pytec/pytec/gui/model/pid_autotuner.py index a1a5598..3973dbf 100644 --- a/pytec/pytec/gui/model/pid_autotuner.py +++ b/pytec/pytec/gui/model/pid_autotuner.py @@ -30,19 +30,6 @@ class PIDAutoTuner(QObject): def get_state(self, ch): return self.autotuners[ch].state() - @asyncSlot() - async def pid_auto_tune_request(self, ch): - match self.get_state(ch): - case PIDAutotuneState.STATE_OFF | PIDAutotuneState.STATE_FAILED: - self.load_params_and_set_ready(ch) - - case ( - PIDAutotuneState.STATE_READY - | PIDAutotuneState.STATE_RELAY_STEP_UP - | PIDAutotuneState.STATE_RELAY_STEP_DOWN - ): - await self.stop_pid_from_running(ch) - def load_params_and_set_ready(self, ch): self.autotuners[ch].setParam( self.target_temp[ch], diff --git a/pytec/pytec/gui/view/ctrl_panel.py b/pytec/pytec/gui/view/ctrl_panel.py index d815def..2fcb6ec 100644 --- a/pytec/pytec/gui/view/ctrl_panel.py +++ b/pytec/pytec/gui/view/ctrl_panel.py @@ -94,7 +94,7 @@ class CtrlPanel(QObject): ) self.params[i].child( "PID Config", "PID Auto Tune", "Run" - ).sigActivated.connect(partial(self.autotuners.pid_auto_tune_request, i)) + ).sigActivated.connect(partial(self.pid_auto_tune_request, i)) self.thermostat.pid_update.connect(self.update_pid) self.thermostat.report_update.connect(self.update_report) @@ -285,6 +285,19 @@ class CtrlPanel(QObject): f"Channel {ch} PID Autotune has failed.", ) + @asyncSlot() + async def pid_auto_tune_request(self, ch): + match self.autotuners.get_state(ch): + case PIDAutotuneState.STATE_OFF | PIDAutotuneState.STATE_FAILED: + self.autotuners.load_params_and_set_ready(ch) + + case ( + PIDAutotuneState.STATE_READY + | PIDAutotuneState.STATE_RELAY_STEP_UP + | PIDAutotuneState.STATE_RELAY_STEP_DOWN + ): + await self.autotuners.stop_pid_from_running(ch) + @asyncSlot(int) async def load_settings(self, ch): await self.thermostat.load_cfg(ch)