Move sigActivatedHandle to CtrlPanel

This commit is contained in:
atse 2024-08-26 15:22:41 +08:00
parent bd6adf9526
commit d3df467017
2 changed files with 13 additions and 11 deletions

View File

@ -6,6 +6,7 @@ from pyqtgraph.parametertree import (
registerParameterType, registerParameterType,
) )
from qasync import asyncSlot from qasync import asyncSlot
from functools import partial
class MutexParameter(pTypes.ListParameter): class MutexParameter(pTypes.ListParameter):
@ -84,9 +85,21 @@ class CtrlPanel(QObject):
self.params[i].setValue = self._setValue self.params[i].setValue = self._setValue
self.params[i].sigTreeStateChanged.connect(self.send_command) self.params[i].sigTreeStateChanged.connect(self.send_command)
self.params[i].child("Save to flash").sigActivated.connect(
partial(self.thermostat.save_cfg, i)
)
self.params[i].child("Load from flash").sigActivated.connect(
partial(self.thermostat.load_cfg, i)
)
for handle in sigActivated_handles[i]: for handle in sigActivated_handles[i]:
self.params[i].child(*handle[0]).sigActivated.connect(handle[1]) self.params[i].child(*handle[0]).sigActivated.connect(handle[1])
self.thermostat.pid_update.connect(self.update_pid)
self.thermostat.report_update.connect(self.update_report)
self.thermostat.thermistor_update.connect(self.update_thermistor)
self.thermostat.pwm_update.connect(self.update_pwm)
self.thermostat.postfilter_update.connect(self.update_postfilter)
def _setValue(self, value, blockSignal=None): def _setValue(self, value, blockSignal=None):
""" """
Implement 'lock' mechanism for Parameter Type Implement 'lock' mechanism for Parameter Type

View File

@ -83,8 +83,6 @@ class MainWindow(QtWidgets.QMainWindow):
param_tree_sigActivated_handles = [ param_tree_sigActivated_handles = [
[ [
[["Save to flash"], partial(self.thermostat.save_cfg, ch)],
[["Load from flash"], partial(self.thermostat.load_cfg, ch)],
[ [
["PID Config", "PID Auto Tune", "Run"], ["PID Config", "PID Auto Tune", "Run"],
partial(self.pid_auto_tune_request, ch), partial(self.pid_auto_tune_request, ch),
@ -110,17 +108,8 @@ class MainWindow(QtWidgets.QMainWindow):
) )
self.thermostat.fan_update.connect(self.fan_update) self.thermostat.fan_update.connect(self.fan_update)
self.thermostat.report_update.connect(self.ctrl_panel_view.update_report)
self.thermostat.report_update.connect(self.autotuners.tick) self.thermostat.report_update.connect(self.autotuners.tick)
self.thermostat.report_update.connect(self.pid_autotune_handler) self.thermostat.report_update.connect(self.pid_autotune_handler)
self.thermostat.pid_update.connect(self.ctrl_panel_view.update_pid)
self.thermostat.pwm_update.connect(self.ctrl_panel_view.update_pwm)
self.thermostat.thermistor_update.connect(
self.ctrl_panel_view.update_thermistor
)
self.thermostat.postfilter_update.connect(
self.ctrl_panel_view.update_postfilter
)
self.thermostat.interval_update.connect( self.thermostat.interval_update.connect(
self.autotuners.update_sampling_interval self.autotuners.update_sampling_interval
) )