send_command: Alias data as new_value

Readablility: Once the change is known to bea value change, call the
"data" new_value.
This commit is contained in:
atse 2024-08-14 12:58:29 +08:00
parent 92004b2a47
commit c77f131afd

View File

@ -266,18 +266,19 @@ class MainWindow(QtWidgets.QMainWindow):
for inner_param, change, data in changes: for inner_param, change, data in changes:
if change == "value": if change == "value":
new_value = data
if "param" in inner_param.opts: if "param" in inner_param.opts:
if inner_param.opts.get("suffix", None) == "mA": if inner_param.opts.get("suffix", None) == "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() == "Postfilter Rate" and data is None: if inner_param.name() == "Postfilter 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)
@ -286,7 +287,7 @@ class MainWindow(QtWidgets.QMainWindow):
auto_tuner_param = inner_param.opts["pid_autotune"][0] auto_tuner_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(auto_tuner_param, ch, data) self.autotuners.set_params(auto_tuner_param, ch, new_value)
if "activaters" in inner_param.opts: if "activaters" in inner_param.opts:
activater = inner_param.opts["activaters"][ activater = inner_param.opts["activaters"][