From d7b088ebe14540c2b5930c27e02c66c4d6c80bcb Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 14 Aug 2024 13:15:19 +0800 Subject: [PATCH] send_command: Remove "activater" Interpret commands anomalies directly in send_command instead --- pytec/pytec/gui/view/param_tree.json | 12 ++++-------- pytec/tec_qt.py | 23 ++++++++++------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/pytec/pytec/gui/view/param_tree.json b/pytec/pytec/gui/view/param_tree.json index fff0a0d..28ce704 100644 --- a/pytec/pytec/gui/view/param_tree.json +++ b/pytec/pytec/gui/view/param_tree.json @@ -25,14 +25,10 @@ "Constant Current", "Temperature PID" ], - "activaters":[ - null, - [ - "pwm", - "ch", - "pid" - ] - ], + "thermostat:set_param":{ + "topic":"pwm", + "field":"pid" + }, "children":[ { "name":"Set Current", diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 70103fa..c760d88 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -273,10 +273,16 @@ class MainWindow(QtWidgets.QMainWindow): thermostat_param = inner_param.opts["thermostat:set_param"] - if inner_param.name() == "Postfilter Rate" and new_value is None: - thermostat_param = thermostat_param.copy() - thermostat_param["field"] = "off" - new_value = "" + # Handle thermostat command irregularities + match inner_param.name(), new_value: + case "Postfilter Rate", None: + thermostat_param = thermostat_param.copy() + thermostat_param["field"] = "off" + new_value = "" + case "Control Method", "Constant Current": + return + case "Control Method", "Temperature PID": + new_value = "" inner_param.setOpts(lock=True) await self.client.set_param( @@ -288,15 +294,6 @@ class MainWindow(QtWidgets.QMainWindow): auto_tuner_param = inner_param.opts["pid_autotune"] 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() async def pid_auto_tune_request(self, ch=0): match self.autotuners.get_state(ch):