forked from M-Labs/thermostat
Split PID handler UI up
This commit is contained in:
parent
b2f6a61a71
commit
c25c49d8c1
@ -100,6 +100,7 @@ class CtrlPanel(QObject):
|
|||||||
self.thermostat.thermistor_update.connect(self.update_thermistor)
|
self.thermostat.thermistor_update.connect(self.update_thermistor)
|
||||||
self.thermostat.pwm_update.connect(self.update_pwm)
|
self.thermostat.pwm_update.connect(self.update_pwm)
|
||||||
self.thermostat.postfilter_update.connect(self.update_postfilter)
|
self.thermostat.postfilter_update.connect(self.update_postfilter)
|
||||||
|
self.autotuners.autotune_state_changed.connect(self.update_pid_autotune)
|
||||||
|
|
||||||
def change_params_title(self, channel, path, title):
|
def change_params_title(self, channel, path, title):
|
||||||
self.params[channel].child(*path).setOpts(title=title)
|
self.params[channel].child(*path).setOpts(title=title)
|
||||||
@ -230,6 +231,31 @@ class CtrlPanel(QObject):
|
|||||||
postfilter_params["rate"]
|
postfilter_params["rate"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_pid_autotune(self, ch, state):
|
||||||
|
match state:
|
||||||
|
case PIDAutotuneState.STATE_OFF:
|
||||||
|
self.change_params_title(
|
||||||
|
ch, ("pid", "pid_autotune", "run_pid"), "Run"
|
||||||
|
)
|
||||||
|
case (
|
||||||
|
PIDAutotuneState.STATE_READY
|
||||||
|
| PIDAutotuneState.STATE_RELAY_STEP_UP
|
||||||
|
| PIDAutotuneState.STATE_RELAY_STEP_DOWN
|
||||||
|
):
|
||||||
|
self.change_params_title(
|
||||||
|
ch, ("pid", "pid_autotune", "run_pid"), "Stop"
|
||||||
|
)
|
||||||
|
case PIDAutotuneState.STATE_SUCCEEDED:
|
||||||
|
self.info_box.display_info_box(
|
||||||
|
"PID Autotune Success",
|
||||||
|
f"Channel {ch} PID Config has been loaded to Thermostat. Regulating temperature.",
|
||||||
|
)
|
||||||
|
case PIDAutotuneState.STATE_FAILED:
|
||||||
|
self.info_box.display_info_box(
|
||||||
|
"PID Autotune Failed",
|
||||||
|
f"Channel {ch} PID Autotune has failed.",
|
||||||
|
)
|
||||||
|
|
||||||
@asyncSlot(int)
|
@asyncSlot(int)
|
||||||
async def load_settings(self, ch):
|
async def load_settings(self, ch):
|
||||||
await self.thermostat.load_cfg(ch)
|
await self.thermostat.load_cfg(ch)
|
||||||
|
@ -209,35 +209,13 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
async def pid_autotune_handler(self, _ch, _state):
|
async def pid_autotune_handler(self, _ch, _state):
|
||||||
ch_tuning = []
|
ch_tuning = []
|
||||||
for ch in range(self.NUM_CHANNELS):
|
for ch in range(self.NUM_CHANNELS):
|
||||||
match self.autotuners.get_state(ch):
|
if self.autotuners.get_state(ch) in {
|
||||||
case PIDAutotuneState.STATE_OFF:
|
PIDAutotuneState.STATE_READY,
|
||||||
self.ctrl_panel_view.change_params_title(
|
PIDAutotuneState.STATE_RELAY_STEP_UP,
|
||||||
ch, ("pid", "pid_autotune", "run_pid"), "Run"
|
PIDAutotuneState.STATE_RELAY_STEP_DOWN,
|
||||||
)
|
}:
|
||||||
case (
|
|
||||||
PIDAutotuneState.STATE_READY
|
|
||||||
| PIDAutotuneState.STATE_RELAY_STEP_UP
|
|
||||||
| PIDAutotuneState.STATE_RELAY_STEP_DOWN
|
|
||||||
):
|
|
||||||
self.ctrl_panel_view.change_params_title(
|
|
||||||
ch, ("pid", "pid_autotune", "run_pid"), "Stop"
|
|
||||||
)
|
|
||||||
ch_tuning.append(ch)
|
ch_tuning.append(ch)
|
||||||
|
|
||||||
case PIDAutotuneState.STATE_SUCCEEDED:
|
|
||||||
self.info_box.display_info_box(
|
|
||||||
"PID Autotune Success",
|
|
||||||
f"Channel {ch} PID Settings has been loaded to Thermostat. Regulating temperature.",
|
|
||||||
)
|
|
||||||
self.info_box.show()
|
|
||||||
|
|
||||||
case PIDAutotuneState.STATE_FAILED:
|
|
||||||
self.info_box.display_info_box(
|
|
||||||
"PID Autotune Failed",
|
|
||||||
f"Channel {ch} PID Autotune has failed.",
|
|
||||||
)
|
|
||||||
self.info_box.show()
|
|
||||||
|
|
||||||
if len(ch_tuning) == 0:
|
if len(ch_tuning) == 0:
|
||||||
self.background_task_lbl.setText("Ready.")
|
self.background_task_lbl.setText("Ready.")
|
||||||
self.loading_spinner.hide()
|
self.loading_spinner.hide()
|
||||||
|
Loading…
Reference in New Issue
Block a user