forked from M-Labs/thermostat
Split PID handler UI up
This commit is contained in:
parent
3387ad67f7
commit
c4309c5ba0
@ -101,6 +101,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 _setValue(self, value, blockSignal=None):
|
def _setValue(self, value, blockSignal=None):
|
||||||
"""
|
"""
|
||||||
@ -259,6 +260,31 @@ class CtrlPanel(QObject):
|
|||||||
"Thermistor Config", "Postfilter Rate"
|
"Thermistor Config", "Postfilter Rate"
|
||||||
).setValue(postfilter_params["rate"])
|
).setValue(postfilter_params["rate"])
|
||||||
|
|
||||||
|
def update_pid_autotune(self, ch, state):
|
||||||
|
match state:
|
||||||
|
case PIDAutotuneState.STATE_OFF:
|
||||||
|
self.change_params_title(
|
||||||
|
ch, ("PID Config", "PID Auto Tune", "Run"), "Run"
|
||||||
|
)
|
||||||
|
case (
|
||||||
|
PIDAutotuneState.STATE_READY
|
||||||
|
| PIDAutotuneState.STATE_RELAY_STEP_UP
|
||||||
|
| PIDAutotuneState.STATE_RELAY_STEP_DOWN
|
||||||
|
):
|
||||||
|
self.change_params_title(
|
||||||
|
ch, ("PID Config", "PID Auto Tune", "Run"), "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,34 +209,12 @@ 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 Config", "PID Auto Tune", "Run"), "Run"
|
PIDAutotuneState.STATE_RELAY_STEP_DOWN,
|
||||||
)
|
}:
|
||||||
case (
|
ch_tuning.append(ch)
|
||||||
PIDAutotuneState.STATE_READY
|
|
||||||
| PIDAutotuneState.STATE_RELAY_STEP_UP
|
|
||||||
| PIDAutotuneState.STATE_RELAY_STEP_DOWN
|
|
||||||
):
|
|
||||||
self.ctrl_panel_view.change_params_title(
|
|
||||||
ch, ("PID Config", "PID Auto Tune", "Run"), "Stop"
|
|
||||||
)
|
|
||||||
ch_tuning.append(ch)
|
|
||||||
|
|
||||||
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.",
|
|
||||||
)
|
|
||||||
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.")
|
||||||
|
Loading…
Reference in New Issue
Block a user