From 7c1293e3d2f0f97094837879e8829c6c3fb2d065 Mon Sep 17 00:00:00 2001 From: atse Date: Fri, 20 Oct 2023 11:03:30 +0800 Subject: [PATCH] Number of channels generalisation --- pytec/tec_qt.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 9c27950..d28d97a 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -20,6 +20,8 @@ from autotune import PIDAutotune, PIDAutotuneState # pyuic6 -x tec_qt.ui -o ui_tec_qt.py from ui_tec_qt import Ui_MainWindow +"""Number of channels provided by the Thermostat""" +NUM_CHANNELS: int = 2 def get_argparser(): parser = argparse.ArgumentParser(description="ARTIQ master") @@ -254,7 +256,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): ]}, {'name': 'Save to flash', 'type': 'action', 'tip': 'Save config to thermostat, applies on reset'}, {'name': 'Load from flash', 'type': 'action', 'tip': 'Load config from flash'} - ] for ch in range(2)] + ] for ch in range(NUM_CHANNELS)] def __init__(self, args): super().__init__() @@ -287,18 +289,18 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.params = [ Parameter.create(name=f"Thermostat Channel {ch} Parameters", type='group', value=ch, children=self.THERMOSTAT_PARAMETERS[ch]) - for ch in range(2) + for ch in range(NUM_CHANNELS) ] self._set_param_tree() self.channel_graphs = [ ChannelGraphs(getattr(self, f'ch{ch}_t_graph'), getattr(self, f'ch{ch}_i_graph')) - for ch in range(2) + for ch in range(NUM_CHANNELS) ] self.autotuners = [ PIDAutotune(25) - for _ in range(2) + for _ in range(NUM_CHANNELS) ] self.loading_spinner.hide() @@ -813,7 +815,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): @pyqtSlot(list) def update_pwm(self, pwm_data): - channels_zeroed_limits = [set() for i in range(2)] + channels_zeroed_limits = [set() for i in range(NUM_CHANNELS)] for pwm_params in pwm_data: channel = pwm_params["channel"]