From 046b9fd712e470c60600fb6ce2bb2d15f9c63355 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 8 Apr 2026 12:06:30 +0200 Subject: [PATCH] dual channel --- src/ui/test_leak/test_leak.py | 55 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/ui/test_leak/test_leak.py b/src/ui/test_leak/test_leak.py index 081f4c7..78e77cd 100644 --- a/src/ui/test_leak/test_leak.py +++ b/src/ui/test_leak/test_leak.py @@ -47,43 +47,54 @@ class Test_Leak(Test_Test): self.stop_b.setEnabled(False) def start_test(self): + # 1. HANDLE FREEFALL SPECIFIC OUTPUTS if self.step.step_type == "test_freefall_leak": - self.set_digital_out("first_output", 1) # Set high - # print extra labels + self.set_digital_out("first_output", 1) + + # 2. PRINT LABELS IF NECESSARY if self.step.step_type == "leak_1": self.parent.print_extra_labels() - # SELECT TEST CHANNEL + # 3. CHANNEL SELECTION (Moved outside of the flush/blow check) + # This ensures channels are switched even if external_flush_blow is absent + if self.parent.config["hardware_config"].get("dual_channel", None) == "present": + chan_sel = self.step.spec.get("chan_sel", 0) # Default to CH1 (0) if not specified + self.set_digital_out("out_channel_select", chan_sel) + self.set_digital_out("in_channel_select", chan_sel) + + # SET LED INDICATORS + if chan_sel == 0: + self.set_digital_out("ch1_led", True) + self.set_digital_out("ch2_led", False) # Ensure the other is off + else: + self.set_digital_out("ch2_led", True) + self.set_digital_out("ch1_led", False) + + time.sleep(VALVE_TIME) + + # 4. EXTERNAL FLUSH / BLOW LOGIC if self.parent.config["hardware_config"].get("external_flush_blow", None) == "present": - if self.parent.config["hardware_config"].get("dual_channel", None) == "present": - chan_sel = self.step.spec["chan_sel"] # 0=CH1, 1=CH2 - self.set_digital_out("out_channel_select", chan_sel) - self.set_digital_out("in_channel_select", chan_sel) - time.sleep(VALVE_TIME) - - # SET LED INDICATORS - if chan_sel == 0: - self.set_digital_out("ch1_led", True) - else: - self.set_digital_out("ch2_led", True) - - self.blow_on=True + self.blow_on = True self.display_text("SOFFIAGGIO IN CORSO...") - self.set_digital_out("blow_led",True) - self.set_digital_out("blow_on",True) + self.set_digital_out("blow_led", True) + self.set_digital_out("blow_on", True) time.sleep(VALVE_TIME) self.set_digital_out("flush_on", True) - blow_time=int(self.step.spec.get('ext_blow_time',3)) - self.set_digital_out("blow_led", True) + + blow_time = int(self.step.spec.get('ext_blow_time', 3)) time.sleep(blow_time) + self.set_digital_out("blow_led", False) self.set_digital_out("blow_on", False) time.sleep(VALVE_TIME) self.set_digital_out("flush_on", False) - if self.parent.config["hardware_config"].get("dual_channel", None) != "present": - self.set_digital_out("ch1_led", True) + # 5. FALLBACK LED FOR SINGLE CHANNEL MACHINES + elif self.parent.config["hardware_config"].get("dual_channel", None) != "present": + # Ensure CH1 LED is on for standard machines if no dual channel exists + self.set_digital_out("ch1_led", True) + # 6. TRIGGER PHYSICAL TESTER self.blow_on = False if not self.simulate: self.components[self.tester_component].start_test()