From c754dcfb18e07845501ea67f35629cf8d3f99e9a Mon Sep 17 00:00:00 2001 From: atse Date: Thu, 18 Jul 2024 11:27:26 +0800 Subject: [PATCH] Remove "activater" option Interpret commands directly in send_command --- pytec/pytec/gui/view/param_tree.json | 12 ++++-------- pytec/tec_qt.py | 26 ++++++++++++-------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/pytec/pytec/gui/view/param_tree.json b/pytec/pytec/gui/view/param_tree.json index 2829687..798dfd1 100644 --- a/pytec/pytec/gui/view/param_tree.json +++ b/pytec/pytec/gui/view/param_tree.json @@ -33,14 +33,10 @@ "Constant Current": "constant_current", "Temperature PID": "temperature_pid" }, - "activaters": [ - null, - [ - "pwm", - "ch", - "pid" - ] - ], + "thermostat:set_param": { + "topic": "pwm", + "field": "pid" + }, "tip": "Select control method of output", "children": [ { diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 89c0dc3..cab3161 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -270,13 +270,20 @@ class MainWindow(QtWidgets.QMainWindow): if "thermostat:set_param" in inner_param.opts: thermostat_param = inner_param.opts["thermostat:set_param"] + # Handle thermostat command irregularities + match inner_param.name(), new_value: + case "rate", "": + thermostat_param = thermostat_param.copy() + 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 - - if inner_param.name() == "rate" and new_value == "": - thermostat_param = thermostat_param.copy() - thermostat_param["field"] = "off" - inner_param.setOpts(lock=True) await self.client.set_param( channel=ch, value=new_value, **thermostat_param @@ -287,15 +294,6 @@ class MainWindow(QtWidgets.QMainWindow): autotuner_param = inner_param.opts["pid_autotune"] 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() async def pid_autotune_request(self, ch=0): match self.autotuners.get_state(ch):