From 3b9cefc0094dd1cc91efbf5cc258e4346d1139b7 Mon Sep 17 00:00:00 2001 From: neonb Date: Thu, 23 Jan 2025 15:35:10 +0100 Subject: [PATCH] dev pipe --- src/components/pipe_cutter_component.py | 2 -- src/ui/test/test.py | 4 +-- src/ui/test_pipe_cutter/test_pipe_cutter.py | 33 +++++++++++++-------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/components/pipe_cutter_component.py b/src/components/pipe_cutter_component.py index 4268e67..5429437 100644 --- a/src/components/pipe_cutter_component.py +++ b/src/components/pipe_cutter_component.py @@ -48,8 +48,6 @@ class PipeCutterComponent(ModbusComponent): # Read holding register at 4x767 (register 767) for a single register (count=1) response = self.read(register=766, count=1, ) status = response - # super()._get([status]) - print(f"response is {response}") # DEBUG return status except KeyError as ke: diff --git a/src/ui/test/test.py b/src/ui/test/test.py index 0eb5143..57a0261 100755 --- a/src/ui/test/test.py +++ b/src/ui/test/test.py @@ -20,7 +20,7 @@ from ui.test_count import Test_Count from ui.test_count_end import Test_Count_End from ui.test_fail import Test_Fail from ui.test_instructions import Test_Instructions -from ui.test_pipe_cutter import Test_Pipe_Cutter +from src.ui.test_pipe_cutter import Test_Pipe_Cutter from ui.test_leak import Test_Leak from ui.test_resistance import Test_Resistance from ui.test_screws import Test_Screws @@ -123,7 +123,7 @@ class Test(Widget): "flush": Test_Assembly(img_path=None, text=u"SCARICO ARIA IN CORSO - ATTENDERE...", widget=Test_Warning_Img(components=self.components, recipe=self.recipe, step=self.step)), "instruction": Test_Assembly(img_path=None, text=u"ESEGUIRE LE OPERAZIONI DI MONTAGGIO INDICATE IN FIGURA", widget=Test_Instructions(config=self.config,components=self.components, recipe=self.recipe, bench_name=self.config.machine_id, step=self.step)), - "pipe_cutter": Test_Assembly(img_path=None, text=u"ATTENZIONE TAGLIO CORRUGATOIN CORSO",widget=Test_Pipe_Cutter(config=self.config, components=self.components,recipe=self.recipe, bench_name=self.config.machine_id,step=self.step)), + "pipe_cutter": Test_Assembly(img_path=None, text=u"ATTENZIONE TAGLIO CORRUGATO IN CORSO",widget=Test_Pipe_Cutter(config=self.config, components=self.components,recipe=self.recipe, bench_name=self.config.machine_id,step=self.step)), "instruction_extra": Test_Assembly(img_path=None, text=u"ESEGUIRE LE OPERAZIONI DI MONTAGGIO EXTRA INDICATE IN FIGURA", widget=Test_Instructions(config=self.config, components=self.components,recipe=self.recipe, bench_name=self.config.machine_id,step=self.step)), "piece_removal": Test_Assembly(img_path=None, text=u"RIMUOVERE IL PEZZO APRENDO TUTTE LE CHIUSURE", diff --git a/src/ui/test_pipe_cutter/test_pipe_cutter.py b/src/ui/test_pipe_cutter/test_pipe_cutter.py index ec298c0..4c02279 100644 --- a/src/ui/test_pipe_cutter/test_pipe_cutter.py +++ b/src/ui/test_pipe_cutter/test_pipe_cutter.py @@ -1,21 +1,11 @@ from PyQt5.QtGui import QMovie import logging -from ui.test_test import Test_Test +from src.ui.test_test import Test_Test import time from PyQt5.QtCore import QByteArray logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) -def get(self, *args, **kwargs): - """ - Retrieve the current cutting length and update the interface. - """ - try: - self.current_cut_length = self.components["pipe_cutter"]._get_length() - logger.info(f"Current cut length: {self.current_cut_length}") - self.visualize() - except Exception as e: - logger.error(f"Failed to get current cut length: {e}") class Test_Pipe_Cutter(Test_Test): """ @@ -24,6 +14,7 @@ class Test_Pipe_Cutter(Test_Test): def __init__(self, config, components, recipe=None, run_once=False,reset_on_start=False, enable_override=False, bench_name="generic", step=None,): super().__init__(components=components, recipe=recipe, step=step, run_once=run_once,reset_on_start=reset_on_start, enable_override=enable_override,) + self.end_cut = None self.config = config self.bench_name = bench_name self.step=step @@ -83,14 +74,13 @@ class Test_Pipe_Cutter(Test_Test): """ try: self.components["pipe_cutter"].write_bit_with_delay(600, 2, 100) - #self.reset_machine() + self.end_cut = True except Exception as e: logger.error(f"Failed to stop the pipe cutting process: {e}") def stop(self): self.components["pipe_cutter"].pause() self.disconnect(self.get_connection) - super().emit_ok() @@ -103,3 +93,20 @@ class Test_Pipe_Cutter(Test_Test): except Exception as e: logger.error(f"Failed to reset the pipe cutter machine: {e}") + def get(self, data=None, override=False): + if self.done: # avoid processing if completed + return + if data is None or data[-1] is None: + super().get(None, override=override) + return + data = data[-1] + if self.end_cut is True: + ok = "Done" + else: + ok = None + + results = {"ok": ok} + super().get([{ + "time": data.get("time", None), + "results": results + }], override=override, fail=ok is False) \ No newline at end of file