forked from M-Labs/thermostat
Make send_command more readable
This commit is contained in:
parent
405d40c543
commit
bbd6774c75
@ -266,29 +266,32 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
for inner_param, change, data in changes:
|
for inner_param, change, data in changes:
|
||||||
if change == "value":
|
if change == "value":
|
||||||
if inner_param.opts.get("param", None) is not None:
|
new_value = data
|
||||||
|
if "thermostat:set_param" in inner_param.opts:
|
||||||
|
thermostat_param = inner_param.opts["thermostat:set_param"]
|
||||||
|
|
||||||
if inner_param.opts.get("title", None).endswith(" (mA)"):
|
if inner_param.opts.get("title", None).endswith(" (mA)"):
|
||||||
data /= 1000 # Given in mA
|
new_value /= 1000 # Given in mA
|
||||||
|
|
||||||
thermostat_param = inner_param.opts["param"]
|
thermostat_param = inner_param.opts["param"]
|
||||||
if thermostat_param[1] == "ch":
|
if thermostat_param[1] == "ch":
|
||||||
thermostat_param[1] = ch
|
thermostat_param[1] = ch
|
||||||
|
|
||||||
if inner_param.name() == "rate" and data is None:
|
if inner_param.name() == "rate" and new_value is None:
|
||||||
set_param_args = (*thermostat_param[:2], "off")
|
set_param_args = (*thermostat_param[:2], "off")
|
||||||
else:
|
else:
|
||||||
set_param_args = (*thermostat_param, data)
|
set_param_args = (*thermostat_param, new_value)
|
||||||
param.child(*param.childPath(inner_param)).setOpts(lock=True)
|
param.child(*param.childPath(inner_param)).setOpts(lock=True)
|
||||||
await self.client.set_param(*set_param_args)
|
await self.client.set_param(*set_param_args)
|
||||||
param.child(*param.childPath(inner_param)).setOpts(lock=False)
|
param.child(*param.childPath(inner_param)).setOpts(lock=False)
|
||||||
|
|
||||||
if inner_param.opts.get("pid_autotune", None) is not None:
|
if "pid_autotune" in inner_param.opts:
|
||||||
autotuner_param = inner_param.opts["pid_autotune"][0]
|
autotuner_param = inner_param.opts["pid_autotune"][0]
|
||||||
if inner_param.opts["pid_autotune"][1] != "ch":
|
if inner_param.opts["pid_autotune"][1] != "ch":
|
||||||
ch = inner_param.opts["pid_autotune"][1]
|
ch = inner_param.opts["pid_autotune"][1]
|
||||||
self.autotuners.set_params(autotuner_param, ch, data)
|
self.autotuners.set_params(autotuner_param, ch, data)
|
||||||
|
|
||||||
if inner_param.opts.get("activaters", None) is not None:
|
if "activaters" in inner_param.opts:
|
||||||
activater = inner_param.opts["activaters"][
|
activater = inner_param.opts["activaters"][
|
||||||
inner_param.reverse[0].index(data) # ListParameter.reverse = list of codename values
|
inner_param.reverse[0].index(data) # ListParameter.reverse = list of codename values
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user