pipe cutter new devs tbt in production

This commit is contained in:
edo-neo 2025-02-17 11:29:31 +01:00
parent ee302b1e91
commit f0b4bcfd9e
5 changed files with 38 additions and 8 deletions

View File

@ -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

View File

@ -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):

View File

@ -68,7 +68,7 @@
<addaction name="table_selection_a"/>
<addaction name="barcode_selection_a"/>
<addaction name="tag_a"/>
<addaction name="actionCalibra_Taglio"/>
<addaction name="cut_a"/>
<addaction name="ristampa_etichetta_a"/>
<addaction name="separator"/>
<addaction name="separator"/>
@ -153,7 +153,7 @@
<string>Scrivi Tag nfc</string>
</property>
</action>
<action name="actionCalibra_Taglio">
<action name="cut_a">
<property name="text">
<string>Calibra Taglio</string>
</property>

View File

@ -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"))

View File

@ -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()
QApplication.processEvents()
def to_calibrate(self):
self.to_calibrate=True