forked from M-Labs/thermostat
Fix loading all channel settings would bring up 2 info boxes
This commit is contained in:
parent
0133d2e41b
commit
22fc7cbf22
@ -130,18 +130,12 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
return await self._client.ipv4()
|
return await self._client.ipv4()
|
||||||
|
|
||||||
@asyncSlot()
|
@asyncSlot()
|
||||||
async def save_cfg(self, ch):
|
async def save_cfg(self, ch=""):
|
||||||
await self._client.save_config(ch)
|
await self._client.save_config(ch)
|
||||||
self.info_box_trigger.emit(
|
|
||||||
"Config saved", f"Channel {ch} Config has been saved from flash."
|
|
||||||
)
|
|
||||||
|
|
||||||
@asyncSlot()
|
@asyncSlot()
|
||||||
async def load_cfg(self, ch):
|
async def load_cfg(self, ch=""):
|
||||||
await self._client.load_config(ch)
|
await self._client.load_config(ch)
|
||||||
self.info_box_trigger.emit(
|
|
||||||
"Config loaded", f"Channel {ch} Config has been loaded from flash."
|
|
||||||
)
|
|
||||||
|
|
||||||
async def dfu(self):
|
async def dfu(self):
|
||||||
await self._client.dfu()
|
await self._client.dfu()
|
||||||
|
@ -51,6 +51,7 @@ class CtrlPanel(QObject):
|
|||||||
self,
|
self,
|
||||||
thermostat,
|
thermostat,
|
||||||
autotuner,
|
autotuner,
|
||||||
|
info_box,
|
||||||
trees_ui,
|
trees_ui,
|
||||||
param_tree,
|
param_tree,
|
||||||
sigActivated_handles,
|
sigActivated_handles,
|
||||||
@ -60,6 +61,7 @@ class CtrlPanel(QObject):
|
|||||||
|
|
||||||
self.thermostat = thermostat
|
self.thermostat = thermostat
|
||||||
self.autotuner = autotuner
|
self.autotuner = autotuner
|
||||||
|
self.info_box = info_box
|
||||||
self.trees_ui = trees_ui
|
self.trees_ui = trees_ui
|
||||||
self.NUM_CHANNELS = len(trees_ui)
|
self.NUM_CHANNELS = len(trees_ui)
|
||||||
|
|
||||||
@ -85,10 +87,10 @@ class CtrlPanel(QObject):
|
|||||||
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(
|
self.params[i].child("Save to flash").sigActivated.connect(
|
||||||
partial(self.thermostat.save_cfg, i)
|
partial(self.save_settings, i)
|
||||||
)
|
)
|
||||||
self.params[i].child("Load from flash").sigActivated.connect(
|
self.params[i].child("Load from flash").sigActivated.connect(
|
||||||
partial(self.thermostat.load_cfg, i)
|
partial(self.load_settings, 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])
|
||||||
@ -255,3 +257,19 @@ class CtrlPanel(QObject):
|
|||||||
self.params[channel].child(
|
self.params[channel].child(
|
||||||
"Thermistor Config", "Postfilter Rate"
|
"Thermistor Config", "Postfilter Rate"
|
||||||
).setValue(postfilter_params["rate"])
|
).setValue(postfilter_params["rate"])
|
||||||
|
|
||||||
|
@asyncSlot(int)
|
||||||
|
async def load_settings(self, ch):
|
||||||
|
await self.thermostat.load_cfg(ch)
|
||||||
|
|
||||||
|
self.info_box.display_info_box(
|
||||||
|
"Config loaded", f"Channel {ch} Config has been loaded from flash."
|
||||||
|
)
|
||||||
|
|
||||||
|
@asyncSlot(int)
|
||||||
|
async def save_settings(self, ch):
|
||||||
|
await self.thermostat.save_cfg(ch)
|
||||||
|
|
||||||
|
self.info_box.display_info_box(
|
||||||
|
"Config saved", f"Channel {ch} Config has been saved from flash."
|
||||||
|
)
|
||||||
|
@ -71,8 +71,8 @@ class ThermostatCtrlMenu(QtWidgets.QMenu):
|
|||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def load(_):
|
def load(_):
|
||||||
self.load_cfg_act.emit(0)
|
self._thermostat.load_cfg()
|
||||||
self.load_cfg_act.emit(1)
|
|
||||||
loaded = QtWidgets.QMessageBox(self)
|
loaded = QtWidgets.QMessageBox(self)
|
||||||
loaded.setWindowTitle("Config loaded")
|
loaded.setWindowTitle("Config loaded")
|
||||||
loaded.setText("All channel configs have been loaded from flash.")
|
loaded.setText("All channel configs have been loaded from flash.")
|
||||||
@ -85,8 +85,8 @@ class ThermostatCtrlMenu(QtWidgets.QMenu):
|
|||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def save(_):
|
def save(_):
|
||||||
self.save_cfg_act.emit(0)
|
self._thermostat.save_cfg()
|
||||||
self.save_cfg_act.emit(1)
|
|
||||||
saved = QtWidgets.QMessageBox(self)
|
saved = QtWidgets.QMessageBox(self)
|
||||||
saved.setWindowTitle("Config saved")
|
saved.setWindowTitle("Config saved")
|
||||||
saved.setText("All channel configs have been saved to flash.")
|
saved.setText("All channel configs have been saved to flash.")
|
||||||
|
@ -92,11 +92,11 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
]
|
]
|
||||||
for ch in range(self.NUM_CHANNELS)
|
for ch in range(self.NUM_CHANNELS)
|
||||||
]
|
]
|
||||||
self.thermostat.info_box_trigger.connect(self.info_box.display_info_box)
|
|
||||||
|
|
||||||
self.ctrl_panel_view = CtrlPanel(
|
self.ctrl_panel_view = CtrlPanel(
|
||||||
self.thermostat,
|
self.thermostat,
|
||||||
self.autotuners,
|
self.autotuners,
|
||||||
|
self.info_box,
|
||||||
[self.ch0_tree, self.ch1_tree],
|
[self.ch0_tree, self.ch1_tree],
|
||||||
get_ctrl_panel_config(args),
|
get_ctrl_panel_config(args),
|
||||||
param_tree_sigActivated_handles,
|
param_tree_sigActivated_handles,
|
||||||
|
Loading…
Reference in New Issue
Block a user