pipe cutter test ok recipe ok need calibration for first cut
This commit is contained in:
parent
4ff84cf342
commit
69eb9a9f5f
@ -362,9 +362,7 @@ class Test(Widget):
|
||||
self.data["recipe"] = model_to_dict(self.recipe)
|
||||
w = self.cycle_available_steps[self.step.step_type]
|
||||
show = None
|
||||
if self.step.step_type == "pipe_cutter":
|
||||
if current_w != w :
|
||||
self.setCentralWidget(w)
|
||||
|
||||
if self.step.step_type == "leak_2":
|
||||
self.setCentralWidget(w) # NEED TO PRESHOW UI
|
||||
if hasattr(w, "start"):
|
||||
|
||||
@ -15,6 +15,8 @@ class Test_Pipe_Cutter(Test_Test):
|
||||
|
||||
def __init__(self, config, components, recipe=None, run_once=False,reset_on_start=True, 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.current_status = None
|
||||
self.previous_status = None
|
||||
self.end_cut = None
|
||||
self.config = config
|
||||
self.bench_name = bench_name
|
||||
@ -39,77 +41,14 @@ class Test_Pipe_Cutter(Test_Test):
|
||||
if show is False:
|
||||
return show
|
||||
|
||||
# Define status messages
|
||||
status_actions = {
|
||||
102: "ready for operation",
|
||||
103: "running",
|
||||
105: "emergency",
|
||||
100: "need to reset"
|
||||
}
|
||||
|
||||
# Initialize variables to track current and previous status
|
||||
previous_status = None
|
||||
self.current_status = None
|
||||
|
||||
self.get_connection = self.components["pipe_cutter"].out.connect(self.get)
|
||||
self.components["pipe_cutter"].resume()
|
||||
|
||||
|
||||
# Continuously monitor and handle pipe cutter statuses
|
||||
while True:
|
||||
self.current_status = self.components["pipe_cutter"].read(register=766)
|
||||
print(self.current_status)
|
||||
|
||||
# Status: 102 (ready for operation)
|
||||
if self.current_status == 102:
|
||||
if previous_status == 103:
|
||||
#print("Transition detected: 103 -> 102. Stopping the cutting process.")
|
||||
self.stop_cutting()
|
||||
|
||||
# Start cutting if machine is ready
|
||||
self.start_cutting(recipe=recipe, step=step)
|
||||
|
||||
# Status: 103 (running)
|
||||
elif self.current_status == 103:
|
||||
#print(f"Status {self.current_status}: The pipe cutter is running. Monitoring the system.")
|
||||
self.display_text(text="TAGLIO CORRUGATO IN CORSO", bg_color="green")
|
||||
|
||||
# Status: 105 (emergency)
|
||||
elif self.current_status == 105:
|
||||
#print(f"Status {self.current_status}: Emergency detected! Resetting the system.")
|
||||
try:
|
||||
self.display_text(text="EMERGENZA INTERVENUTA RIPETERE IL TEST", bg_color="red")
|
||||
self.start_cutting()
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to handle the emergency state: {e}")
|
||||
|
||||
# Status: 100 (need to reset)
|
||||
elif self.current_status == 100:
|
||||
#print(f"Status {self.current_status}: The system requires resetting. Performing reset.")
|
||||
try:
|
||||
self.display_text(text="RESET IN CORSO", bg_color="yellow")
|
||||
self.reset_machine()
|
||||
self.display_text(text="TAGLIO CORRUGATO IN CORSO", bg_color="green")
|
||||
self.start_cutting(recipe=recipe, step=step)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to reset the system: {e}")
|
||||
|
||||
# Unknown status
|
||||
else:
|
||||
# print(f"Unknown status {self.current_status}. Skipping operation.")
|
||||
logger.warning(f"Unknown pipe cutter status {self.current_status} detected.")
|
||||
|
||||
previous_status = self.current_status
|
||||
if step is not None and self.end_cut:
|
||||
print("Cutting process complete. Exiting monitoring loop.")
|
||||
break
|
||||
|
||||
self.stop()
|
||||
return show
|
||||
|
||||
def start_cutting(self, recipe=None, step=None):
|
||||
def start_cutting(self):
|
||||
"""
|
||||
Perform the pipe cutting process when in the 'ready for operation' state (102).
|
||||
"""
|
||||
@ -165,6 +104,54 @@ class Test_Pipe_Cutter(Test_Test):
|
||||
super().get(None, override=override)
|
||||
return
|
||||
data = data[-1]
|
||||
|
||||
self.previus_status = None
|
||||
self.current_status = self.components["pipe_cutter"].read(register=766)
|
||||
print(self.current_status)
|
||||
|
||||
# Status: 102 (ready for operation)
|
||||
if self.current_status == 102:
|
||||
if self.previous_status == 103:
|
||||
#print("Transition detected: 103 -> 102. Stopping the cutting process.")
|
||||
self.stop_cutting()
|
||||
|
||||
# Start cutting if machine is ready
|
||||
self.start_cutting()
|
||||
|
||||
# Status: 103 (running)
|
||||
elif self.current_status == 103:
|
||||
#print(f"Status {self.current_status}: The pipe cutter is running. Monitoring the system.")
|
||||
self.display_text(text="TAGLIO CORRUGATO IN CORSO", bg_color="green")
|
||||
|
||||
# Status: 105 (emergency)
|
||||
elif self.current_status == 105:
|
||||
#print(f"Status {self.current_status}: Emergency detected! Resetting the system.")
|
||||
try:
|
||||
self.display_text(text="EMERGENZA INTERVENUTA RIPETERE IL TEST", bg_color="red")
|
||||
self.end_cut=False
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to handle the emergency state: {e}")
|
||||
|
||||
# Status: 100 (need to reset)
|
||||
elif self.current_status == 100:
|
||||
#print(f"Status {self.current_status}: The system requires resetting. Performing reset.")
|
||||
try:
|
||||
self.display_text(text="RESET IN CORSO", bg_color="yellow")
|
||||
self.reset_machine()
|
||||
self.display_text(text="TAGLIO CORRUGATO IN CORSO", bg_color="green")
|
||||
self.start_cutting()
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to reset the system: {e}")
|
||||
|
||||
# Unknown status
|
||||
else:
|
||||
# print(f"Unknown status {self.current_status}. Skipping operation.")
|
||||
logger.warning(f"Unknown pipe cutter status {self.current_status} detected.")
|
||||
|
||||
self.previous_status = self.current_status
|
||||
|
||||
if self.end_cut is True:
|
||||
ok = True
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user