From 82c357660366c161f439caaff6d805158ecd5d67 Mon Sep 17 00:00:00 2001 From: atse Date: Fri, 4 Aug 2023 17:46:38 +0800 Subject: [PATCH] Don't use payload to get channel Use parent param instead --- pytec/tec_qt.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 8f88fd5..860636f 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -26,10 +26,10 @@ class CommandsParameter(Parameter): THERMOSTAT_PARAMETERS = [[ {'name': 'Constant Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (-3, 3), 'siPrefix': True, 'suffix': 'A', 'commands': [f'pwm {ch} i_set {{value}}']}, - {'name': 'Temperature PID', 'type': 'bool', 'value': False, 'commands': [f'pwm {ch} pid'], 'payload': ch, + {'name': 'Temperature PID', 'type': 'bool', 'value': False, 'commands': [f'pwm {ch} pid'], 'children': [ {'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), 'siPrefix': True, - 'suffix': '°C', 'commands': [f'pid {ch} target {{value}}'], 'payload': ch}, + 'suffix': '°C', 'commands': [f'pid {ch} target {{value}}']}, ]}, {'name': 'Output Config', 'expanded': False, 'type': 'group', 'children': [ {'name': 'Max Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (0, 3), 'siPrefix': True, 'prefix': '±', @@ -65,8 +65,8 @@ THERMOSTAT_PARAMETERS = [[ params = [ - CommandsParameter.create(name='Thermostat Params 0', type='group', children=THERMOSTAT_PARAMETERS[0]), - CommandsParameter.create(name='Thermostat Params 1', type='group', children=THERMOSTAT_PARAMETERS[1]), + CommandsParameter.create(name='Thermostat Params 0', type='group', value=0, children=THERMOSTAT_PARAMETERS[0]), + CommandsParameter.create(name='Thermostat Params 1', type='group', value=1, children=THERMOSTAT_PARAMETERS[1]), ] @@ -602,10 +602,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): async def send_command(self, param, changes): for inner_param, change, data in changes: if inner_param.opts.get("commands", None) is not None: + ch = param.value() match inner_param.name(): case 'Temperature PID': pid_enabled = data - ch = inner_param.opts['payload'] getattr(self, f'ch{ch}_t_line').setVisible(pid_enabled) if pid_enabled: getattr(self, f'ch{ch}_t_line').setValue(inner_param.child('Set Temperature').value()) @@ -613,7 +613,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): await self.client.set_param('pwm', ch, 'i_set', param.child('Constant Current').value()) return case 'Set Temperature': - ch = inner_param.opts['payload'] getattr(self, f'ch{ch}_t_line').setValue(data) await asyncio.gather(*[self.client._command(x.format(value=data)) for x in inner_param.opts["commands"]])