From f0b4bcfd9e0eb1f16d165142dbf06ec7451ec4e5 Mon Sep 17 00:00:00 2001 From: edo-neo Date: Mon, 17 Feb 2025 11:29:31 +0100 Subject: [PATCH] pipe cutter new devs tbt in production --- src/components/pipe_cutter_component.py | 8 +++++++ src/main.py | 7 +++++++ src/ui/main_window/main_window.ui | 4 ++-- src/ui/test/test.py | 4 ++++ src/ui/test_pipe_cutter/test_pipe_cutter.py | 23 +++++++++++++++------ 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/components/pipe_cutter_component.py b/src/components/pipe_cutter_component.py index 8413468..1698820 100644 --- a/src/components/pipe_cutter_component.py +++ b/src/components/pipe_cutter_component.py @@ -209,3 +209,11 @@ class PipeCutterComponent(ModbusComponent): except Exception as e: self.log.error(f"Failed to write value {value} to register 30: {e}") raise + + def set_machine_mode(self): + try: + self.write(register=20, data=1, data_type="16bit_uint") + self.log.info(f"Successfully set machine mode to single cycle).") + except Exception as e: + self.log.error(f"Failed to set machine mode to single cycle: {e}") + raise \ No newline at end of file diff --git a/src/main.py b/src/main.py index b400965..0daeb6e 100644 --- a/src/main.py +++ b/src/main.py @@ -210,6 +210,11 @@ try: self.main_window.barcode_selection_a.triggered.connect(self.set_recipe_mode_barcode) self.main_window.ristampa_etichetta_a.triggered.connect(self.reprint_label) self.main_window.tag_a.triggered.connect(self.tag_write) + if "pipe_cutter" in self.components.keys(): + self.main_window.cut_a.setVisible(True) + self.main_window.cut_a.triggered.connect(self.cut_tube) + else: + self.main_window.cut_a.setVisible(False) self.main_window.diagnostics_a.triggered.connect( lambda checked, selfie=weakref.ref(self): selfie().main_window.open_dialog(Diagnostics(selfie()))) if "--users-management" in sys.argv: @@ -289,6 +294,8 @@ try: if isinstance(self.main_window.centralWidget().centralWidget.widget, Barcode_Recipe_Selection): barcode_data = self.main_window.centralWidget().centralWidget.widget.barcode_input_l.toPlainText().strip() self.main_window.centralWidget().centralWidget.widget.tag_write(barcode_data) + def cut_tube(self): + self.main_window.centralWidget().cut_tube() @pyqtSlot(str) def load_recipe_from_rfid(self, data): diff --git a/src/ui/main_window/main_window.ui b/src/ui/main_window/main_window.ui index 6ffe546..e570c97 100644 --- a/src/ui/main_window/main_window.ui +++ b/src/ui/main_window/main_window.ui @@ -68,7 +68,7 @@ - + @@ -153,7 +153,7 @@ Scrivi Tag nfc - + Calibra Taglio diff --git a/src/ui/test/test.py b/src/ui/test/test.py index c2a55ba..6cd140d 100755 --- a/src/ui/test/test.py +++ b/src/ui/test/test.py @@ -249,6 +249,10 @@ class Test(Widget): self.recipe_selection_mode = "barcode" self.change_recipe() + def cut_tube(self): + self.components["pipe_cutter"].to_calibrate() + self.components["pipe_cutter"].start_cutting() + def reprint_label(self): self.print(self.last_label, self.print_step.spec.get("template", "EtichettaR5")) diff --git a/src/ui/test_pipe_cutter/test_pipe_cutter.py b/src/ui/test_pipe_cutter/test_pipe_cutter.py index 2e123d1..a04e52b 100644 --- a/src/ui/test_pipe_cutter/test_pipe_cutter.py +++ b/src/ui/test_pipe_cutter/test_pipe_cutter.py @@ -23,6 +23,7 @@ class Test_Pipe_Cutter(Test_Test): self.step=step self.current_cut_length = 0 self.get_connection = None + self.to_calibrate=False gif_path = "config/instruction_images/st-ten-10/pipe.gif" self.movie = QMovie(gif_path,QByteArray(), self) @@ -52,14 +53,20 @@ class Test_Pipe_Cutter(Test_Test): """ Perform the pipe cutting process when in the 'ready for operation' state (102). """ - self.length = self.step.spec["length"] - self.diameter = self.step.spec["diameter"] + self.components["pipe_cutter"].set_machine_mode() + + if self.to_calibrate: + self.length = 100 + self.diameter = 21 + self.to_calibrate=False # resetting flag + else: + self.length = self.step.spec["length"] + self.diameter = self.step.spec["diameter"] if self.current_status == 102: try: self.length = int(self.length)*100 self.diameter = int(self.diameter)*100 - print(self.length) self.components["pipe_cutter"].write_od_of_pipe(self.diameter) time.sleep(1) self.components["pipe_cutter"].write_od_of_pipe(self.diameter) @@ -107,8 +114,7 @@ class Test_Pipe_Cutter(Test_Test): self.previus_status = None self.current_status = self.components["pipe_cutter"].read(register=766) - print(self.current_status) - + #print(self.current_status) # Status: 102 (ready for operation) if self.current_status == 102: if self.previous_status == 103: @@ -116,6 +122,7 @@ class Test_Pipe_Cutter(Test_Test): self.stop_cutting() # Start cutting if machine is ready + self.start_cutting() # Status: 103 (running) @@ -166,4 +173,8 @@ class Test_Pipe_Cutter(Test_Test): self.parent_assembly_widget().set_text(text=text, bg_color=bg_color,text_color=text_color) QApplication.processEvents() time.sleep(0.3) - QApplication.processEvents() \ No newline at end of file + QApplication.processEvents() + + + def to_calibrate(self): + self.to_calibrate=True \ No newline at end of file