Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/ui/test/test.py
This commit is contained in:
neo-dl 2023-09-23 16:08:40 +02:00
commit 43a2b38b38
5 changed files with 32 additions and 13 deletions

View File

@ -185,7 +185,7 @@ try:
self.main_window.users_management_a.triggered.connect(lambda checked, self=weakref.ref(self): self().main_window.open_dialog(Users_Management())) self.main_window.users_management_a.triggered.connect(lambda checked, self=weakref.ref(self): self().main_window.open_dialog(Users_Management()))
self.main_window.table_selection_a.triggered.connect(self.set_recipe_mode_table) self.main_window.table_selection_a.triggered.connect(self.set_recipe_mode_table)
self.main_window.barcode_selection_a.triggered.connect(self.set_recipe_mode_barcode) self.main_window.barcode_selection_a.triggered.connect(self.set_recipe_mode_barcode)
self.main_window.ristampa_etichetta_a.triggered.connect(self.reprint_label)
if "--users-management" in sys.argv: if "--users-management" in sys.argv:
self.main_window.users_management_a.trigger() self.main_window.users_management_a.trigger()
@ -252,7 +252,8 @@ try:
def set_recipe_mode_barcode(self): def set_recipe_mode_barcode(self):
self.main_window.centralWidget().set_recipe_mode_barcode() self.main_window.centralWidget().set_recipe_mode_barcode()
def reprint_label(self):
self.main_window.centralWidget().reprint_label()
if __name__ == "__main__": if __name__ == "__main__":
app = QApplication(sys.argv) app = QApplication(sys.argv)

View File

@ -65,6 +65,7 @@
<addaction name="logout_a"/> <addaction name="logout_a"/>
<addaction name="table_selection_a"/> <addaction name="table_selection_a"/>
<addaction name="barcode_selection_a"/> <addaction name="barcode_selection_a"/>
<addaction name="ristampa_etichetta_a"/>
</widget> </widget>
<addaction name="menuStrumenti"/> <addaction name="menuStrumenti"/>
<addaction name="admin_m"/> <addaction name="admin_m"/>
@ -120,6 +121,11 @@
<string>Selezione ricetta da barcode</string> <string>Selezione ricetta da barcode</string>
</property> </property>
</action> </action>
<action name="ristampa_etichetta_a">
<property name="text">
<string>Ristampa etichetta</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -191,6 +191,8 @@ class Test(Widget):
def set_recipe_mode_barcode(self): def set_recipe_mode_barcode(self):
self.recipe_selection_mode = "barcode" self.recipe_selection_mode = "barcode"
self.change_recipe() self.change_recipe()
def reprint_label(self):
self.print(self.archived, self.print_step.spec.get("template", "EtichettaR5"))
def fail_cycle(self): def fail_cycle(self):
self.next(action="fail") self.next(action="fail")
@ -219,9 +221,9 @@ class Test(Widget):
def next(self, action=None): def next(self, action=None):
if self.step is not None: if self.step is not None:
self.log.debug(f"cycle next: cycle step: {model_to_dict(self.step)!r} action: {action!r}") self.log.info(f"cycle step: {model_to_dict(self.step)!r} action: {action!r} current index:{self.cycle_index}")
else: else:
self.log.debug(f"cycle next: cycle step: {self.step!r} action: {action!r}") self.log.info(f"cycle step: {self.step!r} action: {action!r} current index:{self.cycle_index}")
current_w = self.centralWidget current_w = self.centralWidget
if hasattr(current_w, "stop"): if hasattr(current_w, "stop"):
current_w.stop() current_w.stop()
@ -232,6 +234,8 @@ class Test(Widget):
self.cycle_available_steps["leak_2"].widget.recipe_written = False self.cycle_available_steps["leak_2"].widget.recipe_written = False
self.step = Steps(type="select_recipe") self.step = Steps(type="select_recipe")
self.cycle_index = -1 self.cycle_index = -1
self.recipe=None
self.cycle_steps=None
# COUNT RESET # COUNT RESET
self.pieces["ok"] = 0 self.pieces["ok"] = 0
self.pieces["ko"] = 0 self.pieces["ko"] = 0
@ -250,8 +254,10 @@ class Test(Widget):
if self.recipe is None or self.cycle_steps is None: if self.recipe is None or self.cycle_steps is None:
# if recipe not set: select_recipe # if recipe not set: select_recipe
if self.recipe_selection_mode == "barcode": if self.recipe_selection_mode == "barcode":
self.log.info(f"returning to barcode recipe selection")
self.step = Steps(type="barcode_recipe_selection") self.step = Steps(type="barcode_recipe_selection")
else: else:
self.log.info(f"returning to recipe selection table")
self.step = Steps(type="select_recipe") self.step = Steps(type="select_recipe")
elif action is None: elif action is None:
if self.autotest_request is not False and self.autotest_cycle_steps is not None and not self.autotesting and (self.cycle_index == -1 or self.cycle_index + 1 >= len(self.cycle_steps)): if self.autotest_request is not False and self.autotest_cycle_steps is not None and not self.autotesting and (self.cycle_index == -1 or self.cycle_index + 1 >= len(self.cycle_steps)):
@ -300,7 +306,7 @@ class Test(Widget):
"select_recipe", "select_recipe",
"wait", "wait",
}) })
self.log.info(f"cycle next: next cycle step: {model_to_dict(self.step)!r}") self.log.info(f"next cycle step: {model_to_dict(self.step)!r}")
# INIT TEST DATA IF STARTING CYCLE LOOP OR IF RESET IS NEEDED # INIT TEST DATA IF STARTING CYCLE LOOP OR IF RESET IS NEEDED
if self.cycle_index == 0: if self.cycle_index == 0:
self.data = {"ok": True, "overridden": False} self.data = {"ok": True, "overridden": False}
@ -452,13 +458,13 @@ class Test(Widget):
w.reset() w.reset()
# UPDATE RECIPE DISPLAY # UPDATE RECIPE DISPLAY
if self.recipe is not None: if self.recipe is not None:
self.log.info(f"cycle recipe: {model_to_dict(self.recipe)!r} cycle steps: {[model_to_dict(s) for s in self.cycle_steps]}") self.log.info(f"set recipe: {model_to_dict(self.recipe)!r} cycle steps: {[model_to_dict(s) for s in self.cycle_steps]}")
self.recipe_l.setText(self.recipe.name) self.recipe_l.setText(self.recipe.name)
self.recipe_l.setStyleSheet("") self.recipe_l.setStyleSheet("")
self.cycle_index = -1 self.cycle_index = -1
self.next() self.next()
else: else:
self.log.info(f"cycle recipe: {self.recipe!r} cycle steps: {self.cycle_steps}") self.log.info(f"set recipe: {self.recipe!r} cycle steps: {self.cycle_steps}")
self.recipe_l.setText("NON SELEZIONATA") self.recipe_l.setText("NON SELEZIONATA")
self.recipe_l.setStyleSheet("QLabel { color: red; }") self.recipe_l.setStyleSheet("QLabel { color: red; }")
@ -520,7 +526,7 @@ class Test(Widget):
def done(self, ok=True): def done(self, ok=True):
self.log.info("cycle done, saving data...") self.log.info("cycle done, saving data...")
#remove useless info # remove useless info
self.data.get("recipe",{}).get("spec",{}).pop("steps",None) self.data.get("recipe",{}).get("spec",{}).pop("steps",None)
self.data.get("recipe",{}).get("spec",{}).pop("available_steps",None) self.data.get("recipe",{}).get("spec",{}).pop("available_steps",None)
for leak in ["leak_1","leak_2"]: for leak in ["leak_1","leak_2"]:
@ -597,7 +603,7 @@ class Test(Widget):
psetminp2_a = leak_test_2_step_spec.get("settling_pressure_min_percent", 0) * (100+leak_test_2_step_spec.get("test_pressure_qneg", 0)/100) psetminp2_a = leak_test_2_step_spec.get("settling_pressure_min_percent", 0) * (100+leak_test_2_step_spec.get("test_pressure_qneg", 0)/100)
psetmaxp2_a = leak_test_2_step_spec.get("settling_pressure_max_percent", 0) * (100+leak_test_2_step_spec.get("test_pressure_qpos", 0)/100) psetmaxp2_a = leak_test_2_step_spec.get("settling_pressure_max_percent", 0) * (100+leak_test_2_step_spec.get("test_pressure_qpos", 0)/100)
leak_test_1_results["Running test: pressure at the end of measure"] = leak_test_1_results["Running test: pressure at the end of settling"] - leak_test_1_results["Running test: measured leak"] leak_test_1_results["Running test: pressure at the end of measure"] = leak_test_1_results["Running test: pressure at the end of settling"] - leak_test_1_results["Running test: measured leak"]
printer_fields = self.step.spec printer_fields = self.print_step.spec
context = { context = {
# RECIPE DATA # RECIPE DATA
"RECIPE": self.labellify(recipe.get("name", "-")), "RECIPE": self.labellify(recipe.get("name", "-")),

View File

@ -101,7 +101,9 @@ class Test_Instructions(Test_Test):
QApplication.processEvents() QApplication.processEvents()
def get(self, data=None, override=False): def get(self, data=None, override=False):
if self.parent_assembly_widget().parent().step.type == "select_recipe":
self.stop()
return
if self.done: # avoid proccessing if completed if self.done: # avoid proccessing if completed
return return
if data is None: if data is None:
@ -122,15 +124,18 @@ class Test_Instructions(Test_Test):
self.inputs[sensor_index] = False self.inputs[sensor_index] = False
ok = False ok = False
if ok: if ok:
self.stop()
super().get([{ super().get([{
"time": timing(), "time": timing(),
"results": { "results": {
"ok": ok, "ok": ok,
}, },
}], override=override, fail=ok is False, skip_delay=False) }], override=override, fail=ok is False, skip_delay=False)
self.timer.stop() self.set_done()
self.toggle_icons() self.toggle_icons()
def set_done(self): def set_done(self):
self.done=True self.done=True
self.done_ok=True self.done_ok=True
@ -140,6 +145,7 @@ class Test_Instructions(Test_Test):
#self.done=True #self.done=True
#self.done_ok = True #self.done_ok = True
self.timer.stop() self.timer.stop()
self.disconnect(self.get_connection)
super().stop() super().stop()
def reset(self): def reset(self):

View File

@ -275,11 +275,11 @@ class Test_Leak(Test_Test):
def set_digital_out(self,name=None,state=1): def set_digital_out(self,name=None,state=1):
if self.io_ok: if self.io_ok:
bit=int(self.parent.config["digital_io"][name]) bit = int(self.parent.config["digital_io"][name])
ret = self.components["digital_io"].set_bit_verify(0,bit,state) ret = self.components["digital_io"].set_bit_verify(0,bit,state)
if not ret: if not ret:
QMessageBox.critical(None, "ERRORE", f"ERRORE I/O DIGITALE - VERIFICARE CONNESSIONE USB") QMessageBox.critical(None, "ERRORE", f"ERRORE I/O DIGITALE - VERIFICARE CONNESSIONE USB")
self.io_ok=False self.io_ok = False
def save_last(self): def save_last(self):
if self.last is None: if self.last is None: