From da794080c6e018d515b38f9369601eb63920706b Mon Sep 17 00:00:00 2001 From: atse Date: Fri, 20 Oct 2023 10:47:08 +0800 Subject: [PATCH] More general activater --- pytec/tec_qt.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index f824a4a..d8aaf82 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -212,8 +212,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): {'name': 'Temperature', 'type': 'float', 'suffix': '°C', 'decimals': 6, 'readonly': True}, {'name': 'Current through TEC', 'type': 'float', 'suffix': 'mA', 'decimals': 6, 'readonly': True}, {'name': 'Output Config', 'expanded': True, 'type': 'group', 'children': [ - {'name': 'Control Method', 'type': 'mutex', 'limits': {'Constant Current': False, 'Temperature PID': True}, - 'activater': ('pwm', ch, 'pid'), 'children': [ + {'name': 'Control Method', 'type': 'mutex', 'limits': ['Constant Current', 'Temperature PID'], + 'activaters': [None, ('pwm', ch, 'pid')], 'children': [ {'name': 'Set Current', 'type': 'float', 'value': 0, 'step': 100, 'limits': (-3000, 3000), 'triggerOnShow': True, 'decimals': 6, 'suffix': 'mA', 'param': ('pwm', ch, 'i_set')}, {'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), @@ -671,9 +671,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): else: set_param_args = (*thermostat_param, data) await self.client.set_param(*set_param_args) - if inner_param.opts.get('activater', None) is not None: - if data: - await self.client.set_param(*inner_param.opts['activater']) + if inner_param.opts.get('activaters', None) is not None: + activater = inner_param.opts['activaters'][inner_param.opts['limits'].index(data)] + if activater is not None: + await self.client.set_param(*activater) def _set_param_tree(self): @@ -792,7 +793,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): channel = settings["channel"] self.channel_graphs[channel].plot_append(settings) with QSignalBlocker(self.params[channel]): - self.params[channel].child("Output Config", "Control Method").setValue(settings["pid_engaged"]) + self.params[channel].child("Output Config", "Control Method").setValue("Temperature PID" if settings["pid_engaged"] else "Constant Current") self.channel_graphs[channel].t_line.setVisible(settings["pid_engaged"]) self.params[channel].child("Output Config", "Control Method", "Set Current").setValue(settings["i_set"] * 1000) if settings['temperature'] is not None and settings['tec_i'] is not None: