fix freefall

This commit is contained in:
eduar 2026-02-02 09:59:00 +01:00
parent ce63d006da
commit 815135bbc6

View File

@ -30,13 +30,6 @@ class Test_Leak(Test_Test):
# Connect to the tecna_error_signal to handle connection issues
self.components[self.tester_component].tecna_error_signal.connect(self.handle_modbus_error)
def _test_output_sequence(self, step):
"""Sets the first digital output of the usb_586x based on the step type."""
if step.step_type == "test_freefall_leak":
self.set_digital_out("first_output", 1) # Set high
else:
self.set_digital_out("first_output", 0) # Set low
def show_instruction(self):
dialog=Dialog()
dialog.setCentralWidget(Test_Instructions_Reminder(recipe=self.parent.recipe,bench_name=self.parent.config.machine_id))
@ -54,6 +47,8 @@ class Test_Leak(Test_Test):
self.stop_b.setEnabled(False)
def start_test(self):
if self.step.step_type == "test_freefall_leak":
self.set_digital_out("first_output", 1) # Set high
# print extra labels
if self.step.step_type == "leak_1":
self.parent.print_extra_labels()
@ -95,7 +90,6 @@ class Test_Leak(Test_Test):
def start(self, recipe=None, step=None, pieces=None):
self._test_output_sequence(step) # Call with the step object
# TESTING
if "--test-leak" in sys.argv:
self.simulate = True
@ -191,33 +185,10 @@ class Test_Leak(Test_Test):
self.display_text(text="USARE IL SISTEMA DI FLUSSAGGIO. AL TERMINE POSIZIONARE IL PEZZO PER LA PROVA TENUTA")
# Show placeholder image for free-fall: PERVIETÀ.png
pervieta_path_candidates = [
"config/warning_images/generic/PERVIETÀ.png",
"config/warning_images/generic/PERVIETA.png",
"config/warning_images/generic/pervieta.png",
]
img_path = next((p for p in pervieta_path_candidates if os.path.exists(p)), None)
if img_path is not None:
super().visualize(None, img=QPixmap(img_path))
else:
# Fallbacks: try the older instruction image or default
try:
instr_folder = (self.config.get("machine", {}) or {}).get("instruction_folder", getattr(self.config, "machine_id", "")).strip() or getattr(self.config, "machine_id", "")
except Exception:
instr_folder = getattr(self.config, "machine_id", "")
ff_img = None
for ext in ("png", "jpg", "jpeg"):
candidate = f"config/instruction_images/{instr_folder}/free_fall.{ext}"
if os.path.exists(candidate):
ff_img = candidate
break
if ff_img is not None:
super().visualize(None, img=QPixmap(ff_img))
else:
super().visualize(None, img=self.status_imgs_full[None])
# Show placeholder image for free-fall
super().visualize(None, img=self.status_imgs_full[None])
else:
# If the recipe contains a Free Fall test, show the PERVIETÀ image as default even on Leak steps
# If the recipe contains a Free Fall test, show a default image even on Leak steps
try:
has_free_fall = any(getattr(s, "step_type", None) == "test_freefall_leak" for s in (self.parent.cycle_steps or []))
except Exception:
@ -228,17 +199,8 @@ class Test_Leak(Test_Test):
self._free_fall_img_scale = 1.75
# Keep normal Leak instruction text
self.display_text(text="COLLEGARE GLI ATTACCHI PNEUMATICI E PREMERE START PER INIZIARE LA PROVA TENUTA")
# Load PERVIETÀ image with fallbacks
pervieta_path_candidates = [
"config/warning_images/generic/PERVIETÀ_2.png",
"config/warning_images/generic/PERVIETA_2.png",
"config/warning_images/generic/pervieta_2.png",
]
img_path = next((p for p in pervieta_path_candidates if os.path.exists(p)), None)
if img_path is not None:
super().visualize(None, img=QPixmap(img_path))
else:
super().visualize(None, img=self.status_imgs_full[None])
# Load default image
super().visualize(None, img=self.status_imgs_full[None])
else:
# Ensure Free Fall mode is disabled for other steps
self._free_fall_mode = False