Remove "activater" option

Interpret commands directly in send_command
This commit is contained in:
atse 2024-07-18 11:27:26 +08:00
parent 0b0bf26244
commit c754dcfb18
2 changed files with 16 additions and 22 deletions

View File

@ -33,14 +33,10 @@
"Constant Current": "constant_current", "Constant Current": "constant_current",
"Temperature PID": "temperature_pid" "Temperature PID": "temperature_pid"
}, },
"activaters": [ "thermostat:set_param": {
null, "topic": "pwm",
[ "field": "pid"
"pwm", },
"ch",
"pid"
]
],
"tip": "Select control method of output", "tip": "Select control method of output",
"children": [ "children": [
{ {

View File

@ -270,13 +270,20 @@ class MainWindow(QtWidgets.QMainWindow):
if "thermostat:set_param" in inner_param.opts: if "thermostat:set_param" in inner_param.opts:
thermostat_param = inner_param.opts["thermostat:set_param"] thermostat_param = inner_param.opts["thermostat:set_param"]
if inner_param.opts.get("title", None).endswith(" (mA)"): # Handle thermostat command irregularities
new_value /= 1000 # Given in mA match inner_param.name(), new_value:
case "rate", "":
if inner_param.name() == "rate" and new_value == "":
thermostat_param = thermostat_param.copy() thermostat_param = thermostat_param.copy()
thermostat_param["field"] = "off" thermostat_param["field"] = "off"
case "control_method", "constant_current":
inner_param = inner_param.child("i_set")
thermostat_param = inner_param.opts["thermostat:set_param"]
new_value = inner_param.value()
case "control_method", "temperature_pid":
new_value = ""
if inner_param.opts.get("title", None).endswith(" (mA)"):
new_value /= 1000 # Given in mA
inner_param.setOpts(lock=True) inner_param.setOpts(lock=True)
await self.client.set_param( await self.client.set_param(
channel=ch, value=new_value, **thermostat_param channel=ch, value=new_value, **thermostat_param
@ -287,15 +294,6 @@ class MainWindow(QtWidgets.QMainWindow):
autotuner_param = inner_param.opts["pid_autotune"] autotuner_param = inner_param.opts["pid_autotune"]
self.autotuners.set_params(ch=ch, val=new_value, **autotuner_param) self.autotuners.set_params(ch=ch, val=new_value, **autotuner_param)
if "activaters" in inner_param.opts:
activater = inner_param.opts["activaters"][
inner_param.reverse[0].index(data) # ListParameter.reverse = list of codename values
]
if activater is not None:
if activater[1] == "ch":
activater[1] = ch
await self.client.set_param(*activater)
@asyncSlot() @asyncSlot()
async def pid_autotune_request(self, ch=0): async def pid_autotune_request(self, ch=0):
match self.autotuners.get_state(ch): match self.autotuners.get_state(ch):