From 6be3816265c8af4dd791e55b96d68903cad03dda Mon Sep 17 00:00:00 2001 From: neo-nb3 Date: Sat, 23 Sep 2023 00:13:31 +0200 Subject: [PATCH 1/2] debug reprint --- src/ui/test/test.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/test/test.py b/src/ui/test/test.py index 7bda880..95435fe 100755 --- a/src/ui/test/test.py +++ b/src/ui/test/test.py @@ -219,9 +219,9 @@ class Test(Widget): def next(self, action=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.debug(f"cycle step: {model_to_dict(self.step)!r} action: {action!r} current index:{self.cycle_index}") else: - self.log.debug(f"cycle next: cycle step: {self.step!r} action: {action!r}") + self.log.debug(f"cycle step: {self.step!r} action: {action!r} current index:{self.cycle_index}") current_w = self.centralWidget if hasattr(current_w, "stop"): current_w.stop() @@ -250,8 +250,10 @@ class Test(Widget): if self.recipe is None or self.cycle_steps is None: # if recipe not set: select_recipe if self.recipe_selection_mode == "barcode": + self.log.info(f"returning to barcode recipe selection") self.step = Steps(type="barcode_recipe_selection") else: + self.log.info(f"returning to recipe selection table") self.step = Steps(type="select_recipe") 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)): @@ -300,7 +302,7 @@ class Test(Widget): "select_recipe", "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 if self.cycle_index == 0: self.data = {"ok": True, "overridden": False} @@ -452,13 +454,13 @@ class Test(Widget): w.reset() # UPDATE RECIPE DISPLAY if self.recipe is not None: - self.log.info(f"cycle recipe: 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.setStyleSheet("") self.cycle_index = -1 self.next() else: - self.log.info(f"cycle recipe: cycle recipe: {self.recipe!r} cycle steps: {self.cycle_steps}") + self.log.info(f"set recipe: none") self.recipe_l.setText("NON SELEZIONATA") self.recipe_l.setStyleSheet("QLabel { color: red; }") @@ -520,7 +522,7 @@ class Test(Widget): def done(self, ok=True): 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("available_steps",None) for leak in ["leak_1","leak_2"]: From 5a46797cd59fefd96f704dbd78af88ca40e742f7 Mon Sep 17 00:00:00 2001 From: STTEN8 Date: Sat, 23 Sep 2023 12:58:55 +0200 Subject: [PATCH 2/2] stten8 fix & reprint label --- src/main.py | 5 +++-- src/ui/main_window/main_window.ui | 6 ++++++ src/ui/test/test.py | 10 +++++++--- src/ui/test_instructions/test_instructions.py | 10 ++++++++-- src/ui/test_leak/test_leak.py | 4 ++-- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main.py b/src/main.py index fc7f700..a95ce6b 100644 --- a/src/main.py +++ b/src/main.py @@ -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.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.ristampa_etichetta_a.triggered.connect(self.reprint_label) if "--users-management" in sys.argv: self.main_window.users_management_a.trigger() @@ -252,7 +252,8 @@ try: def set_recipe_mode_barcode(self): self.main_window.centralWidget().set_recipe_mode_barcode() - + def reprint_label(self): + self.main_window.centralWidget().reprint_label() if __name__ == "__main__": app = QApplication(sys.argv) diff --git a/src/ui/main_window/main_window.ui b/src/ui/main_window/main_window.ui index 0ec3684..f03ca45 100644 --- a/src/ui/main_window/main_window.ui +++ b/src/ui/main_window/main_window.ui @@ -65,6 +65,7 @@ + @@ -120,6 +121,11 @@ Selezione ricetta da barcode + + + Ristampa etichetta + + diff --git a/src/ui/test/test.py b/src/ui/test/test.py index 95435fe..66b2a45 100755 --- a/src/ui/test/test.py +++ b/src/ui/test/test.py @@ -191,6 +191,8 @@ class Test(Widget): def set_recipe_mode_barcode(self): self.recipe_selection_mode = "barcode" self.change_recipe() + def reprint_label(self): + self.print(self.archived, self.print_step.spec.get("template", "EtichettaR5")) def fail_cycle(self): self.next(action="fail") @@ -219,9 +221,9 @@ class Test(Widget): def next(self, action=None): if self.step is not None: - self.log.debug(f"cycle step: {model_to_dict(self.step)!r} action: {action!r} current index:{self.cycle_index}") + self.log.info(f"cycle step: {model_to_dict(self.step)!r} action: {action!r} current index:{self.cycle_index}") else: - self.log.debug(f"cycle step: {self.step!r} action: {action!r} current index:{self.cycle_index}") + self.log.info(f"cycle step: {self.step!r} action: {action!r} current index:{self.cycle_index}") current_w = self.centralWidget if hasattr(current_w, "stop"): current_w.stop() @@ -232,6 +234,8 @@ class Test(Widget): self.cycle_available_steps["leak_2"].widget.recipe_written = False self.step = Steps(type="select_recipe") self.cycle_index = -1 + self.recipe=None + self.cycle_steps=None # COUNT RESET self.pieces["ok"] = 0 self.pieces["ko"] = 0 @@ -599,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) 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"] - printer_fields = self.step.spec + printer_fields = self.print_step.spec context = { # RECIPE DATA "RECIPE": self.labellify(recipe.get("name", "-")), diff --git a/src/ui/test_instructions/test_instructions.py b/src/ui/test_instructions/test_instructions.py index 67cecd6..dc96d3a 100644 --- a/src/ui/test_instructions/test_instructions.py +++ b/src/ui/test_instructions/test_instructions.py @@ -101,7 +101,9 @@ class Test_Instructions(Test_Test): QApplication.processEvents() 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 return if data is None: @@ -122,15 +124,18 @@ class Test_Instructions(Test_Test): self.inputs[sensor_index] = False ok = False if ok: + self.stop() super().get([{ "time": timing(), "results": { "ok": ok, }, }], override=override, fail=ok is False, skip_delay=False) - self.timer.stop() + self.set_done() + self.toggle_icons() + def set_done(self): self.done=True self.done_ok=True @@ -140,6 +145,7 @@ class Test_Instructions(Test_Test): #self.done=True #self.done_ok = True self.timer.stop() + self.disconnect(self.get_connection) super().stop() def reset(self): diff --git a/src/ui/test_leak/test_leak.py b/src/ui/test_leak/test_leak.py index 4e2862a..c216f2c 100644 --- a/src/ui/test_leak/test_leak.py +++ b/src/ui/test_leak/test_leak.py @@ -275,11 +275,11 @@ class Test_Leak(Test_Test): def set_digital_out(self,name=None,state=1): 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) if not ret: QMessageBox.critical(None, "ERRORE", f"ERRORE I/O DIGITALE - VERIFICARE CONNESSIONE USB") - self.io_ok=False + self.io_ok = False def save_last(self): if self.last is None: