GUI: Refactor send_command #4

Merged
linuswck merged 6 commits from gui_dev-refactor-send_command into gui_dev 2024-10-07 13:03:38 +08:00
2 changed files with 14 additions and 21 deletions
Showing only changes of commit 41abad7aa3 - Show all commits

View File

@ -25,14 +25,10 @@
"Constant Current", "Constant Current",
"Temperature PID" "Temperature PID"
], ],
"activaters":[ "thermostat:set_param":{
null, "topic":"pwm",
[ "field":"pid"
"pwm", },
"ch",
"pid"
]
],
"children":[ "children":[
{ {
"name":"Set Current", "name":"Set Current",

View File

@ -273,10 +273,16 @@ class MainWindow(QtWidgets.QMainWindow):
thermostat_param = inner_param.opts["thermostat:set_param"] thermostat_param = inner_param.opts["thermostat:set_param"]
if inner_param.name() == "Postfilter Rate" and new_value is None: # Handle thermostat command irregularities
match inner_param.name(), new_value:
case "Postfilter Rate", None:
thermostat_param = thermostat_param.copy() thermostat_param = thermostat_param.copy()
thermostat_param["field"] = "off" thermostat_param["field"] = "off"
new_value = "" new_value = ""
case "Control Method", "Constant Current":
return
case "Control Method", "Temperature PID":
new_value = ""
inner_param.setOpts(lock=True) inner_param.setOpts(lock=True)
await self.client.set_param( await self.client.set_param(
@ -288,15 +294,6 @@ class MainWindow(QtWidgets.QMainWindow):
auto_tuner_param = inner_param.opts["pid_autotune"] auto_tuner_param = inner_param.opts["pid_autotune"]
self.autotuners.set_params(auto_tuner_param, ch, new_value) self.autotuners.set_params(auto_tuner_param, ch, new_value)
if "activaters" in inner_param.opts:
activater = inner_param.opts["activaters"][
inner_param.opts["limits"].index(data)
]
if activater is not None:
if activater[1] == "ch":
activater[1] = ch
await self.client.set_param(*activater)
@asyncSlot() @asyncSlot()
async def pid_auto_tune_request(self, ch=0): async def pid_auto_tune_request(self, ch=0):
match self.autotuners.get_state(ch): match self.autotuners.get_state(ch):