From 15c7cb934b41bd0d976536aa06e35d1ed2015ea7 Mon Sep 17 00:00:00 2001 From: neo Date: Mon, 11 May 2026 09:08:52 +0200 Subject: [PATCH] added keep_true mode for test instructions to hold True state for ST-TEN-11 TBT --- README.md | 2 +- config/machine_settings/defaults.ini | 1 + config/machine_settings/st-ten-11.ini | 2 +- src/ui/test_instructions/test_instructions.py | 27 +++++++++++++------ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 58feb93..be9e63a 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ In addition to leak testing, the software supports many other functions, dependi - On Windows: ./init_win.bat - On Linux: ./init.sh -## fIX Chrome +## FIX Chrome If chrome doesn't start run this command rm ~/.config/google-chrome/SingletonLock ## FIX FOR TERMINAL NOT WORKINK FOR WINDOWS 10 diff --git a/config/machine_settings/defaults.ini b/config/machine_settings/defaults.ini index 380bbeb..0faa147 100644 --- a/config/machine_settings/defaults.ini +++ b/config/machine_settings/defaults.ini @@ -102,6 +102,7 @@ baudrate: 9600 [digital_io] id: USB-5862,BID#0 +keep_true = no [vision] neural_network: none diff --git a/config/machine_settings/st-ten-11.ini b/config/machine_settings/st-ten-11.ini index 58b2434..574197c 100644 --- a/config/machine_settings/st-ten-11.ini +++ b/config/machine_settings/st-ten-11.ini @@ -48,7 +48,7 @@ risoluzione:300 # OUTPUT MAP FOR FIXTURE CONNECTOR id: USB-5862,BID#0 first_output: 0 - +keep_true = yes [fixture_rfid] port: COM5 diff --git a/src/ui/test_instructions/test_instructions.py b/src/ui/test_instructions/test_instructions.py index a0f91f1..a705a53 100644 --- a/src/ui/test_instructions/test_instructions.py +++ b/src/ui/test_instructions/test_instructions.py @@ -38,6 +38,8 @@ class Test_Instructions(Test_Test): self.print_b.setVisible(True) self.print_b.setEnabled(True) self.print_b.clicked.connect(self.print_button) + # Read the keep_true configuration flag (defaults to disabled) + self.keep_true = str(self.config.get("digital_io", {}).get("keep_true", "no")).lower() in ["yes", "true", "1"] def start(self, recipe=None, step=None, pieces=None): show = super().start(recipe=recipe, step=step) @@ -192,10 +194,11 @@ class Test_Instructions(Test_Test): super().get(None, override=override) return - #check if all sensor are ok + # check if all sensor are ok ok = True - if len(data[0]["digital_io"])==0: + if len(data[0]["digital_io"]) == 0: return + for sensor in self.monitored_ids: sensor_name = sensor.attrib['id'] sensor_index_part = sensor.attrib['id'].split("_")[1] @@ -206,17 +209,26 @@ class Test_Instructions(Test_Test): sensor_index = sensor_index_part inverse = 'inv' in sensor_name - byte_idx=int(sensor_index/8) if isinstance(sensor_index, int) else None - bit_idx=sensor_index%8 if isinstance(sensor_index, int) else None + byte_idx = int(sensor_index / 8) if isinstance(sensor_index, int) else None + bit_idx = sensor_index % 8 if isinstance(sensor_index, int) else None current_bitstate = data[0]["digital_io"][byte_idx][bit_idx] if isinstance(sensor_index, int) else None if 'stat' in sensor_name: continue if isinstance(sensor_index, int): - if (inverse and current_bitstate != self.expected_input_state) or (not inverse and current_bitstate == self.expected_input_state): - self.inputs[sensor_index] = True - + is_expected = (inverse and current_bitstate != self.expected_input_state) or (not inverse and current_bitstate == self.expected_input_state) + + if self.keep_true: + # Memorize the True state if the condition is met + if is_expected: + self.inputs[sensor_index] = True + elif sensor_index not in self.inputs: + self.inputs[sensor_index] = False + else: + # Live tracking (Original behavior expectation when keep_true is not enabled) + self.inputs[sensor_index] = is_expected + if not self.inputs.get(sensor_index, False): ok = False else: @@ -234,7 +246,6 @@ class Test_Instructions(Test_Test): self.toggle_icons() - def set_done(self): self.done=True self.done_ok=True