dev free_fall

This commit is contained in:
edo-neo 2025-10-16 09:52:34 +02:00
parent 65d931b92d
commit 9b0f39b882
3 changed files with 76 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 KiB

View File

@ -436,7 +436,7 @@ Fasi di Test</string>
</widget>
<widget class="QWidget" name="free_fall_t">
<attribute name="title">
<string>Free Fall</string>
<string>Test Pervietà</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_free_fall">
<item row="0" column="0">

View File

@ -158,28 +158,65 @@ class Test_Leak(Test_Test):
super().visualize(None, img=self.status_imgs_full["calibrated-leak"])
else:
if step.step_type == "test_freefall_leak":
# Flag Free Fall mode for special UI handling
self._free_fall_mode = True
self._free_fall_img_scale = 0.95 # scale image to almost full available space
# Hide parameters not relevant during free-fall
for name in [
"label_18", # Tempo di riempimento
"fill_time_l",
"label_19", # Tempo di assestamento
"settle_time_l",
"label_22", # Tempo di prova
"meas_time_l",
"template_label", # Etichetta selezionata (caption)
"template_print_l", # Etichetta selezionata (value)
"valore_PID", # Valore PID (caption)
"valore_PID_l", # Valore PID (value)
"label_17", # unit 's' for fill time
"label_20", # unit 's' for settling/measuring time
"label_21", # possibly another unit/aux label to hide in free fall
]:
if hasattr(self, name):
getattr(self, name).setVisible(False)
self.display_text(text="COLLAUDARE USANDO IL SISTEMA DI FLUSSAGGIO ALLA FINE DELLA PROVA POSIZIONRE IL PEZZO PER LA PROVATENUTA")
# Try to load custom Free Fall image from instruction images
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", "")
img_path = None
for ext in ("png", "jpg", "jpeg"):
candidate = f"config/instruction_images/{instr_folder}/free_fall.{ext}"
if os.path.exists(candidate):
img_path = candidate
break
# 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:
# Fallback to default image
super().visualize(None, img=self.status_imgs_full[None])
# 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])
else:
# Ensure Free Fall mode is disabled for other steps
self._free_fall_mode = False
self._free_fall_img_scale = None
self.display_text(text="COLLEGARE GLI ATTACCHI PNEUMATICI E PREMERE START PER INIZIARE LA PROVA TENUTA")
super().visualize(None, img=self.status_imgs_full[None])
self.template_print_l.setVisible(True)
self.template_label.setVisible(True)
if step.step_type != "test_freefall_leak":
self.template_print_l.setVisible(True)
self.template_label.setVisible(True)
if self.simulate:
QApplication.processEvents()
time.sleep(2)
@ -445,3 +482,26 @@ class Test_Leak(Test_Test):
# Always disable start button and enable stop button during connection issues
self.start_b.setEnabled(False)
self.stop_b.setEnabled(True)
def resizeEvent(self, event=None):
# First, let the base class handle default behavior
try:
super().resizeEvent(event)
except Exception:
# Fallback: ignore if base cannot handle the event
pass
# Apply Free Fall specific image scaling (half space)
if getattr(self, "_free_fall_mode", False):
if hasattr(self, "img_l") and hasattr(self, "img") and self.img_l is not None and self.img is not None:
try:
scale = float(getattr(self, "_free_fall_img_scale", 0.5) or 0.5)
except Exception:
scale = 0.5
w = max(1, int(self.img_l.width() * scale))
h = max(1, int(self.img_l.height() * scale))
try:
self.img_l.setPixmap(self.img.scaled(w, h, Qt.KeepAspectRatio, Qt.SmoothTransformation))
except Exception:
# If scaling fails, leave as base-class result
pass