Răsfoiți Sursa

add stop check

tuanchris 2 săptămâni în urmă
părinte
comite
e992f3a39a
1 a modificat fișierele cu 11 adăugiri și 10 ștergeri
  1. 11 10
      modules/core/pattern_manager.py

+ 11 - 10
modules/core/pattern_manager.py

@@ -387,16 +387,17 @@ class MotionControlThread:
 
 
         while True:
         while True:
             try:
             try:
-                gcode = f"$J=G91 G21 Y{y} F{speed}" if home else f"G1 G53 X{x} Y{y} F{speed}"
-                state.conn.send(gcode + "\n")
-                logger.debug(f"Motion thread sent command: {gcode}")
-
-                while True:
-                    response = state.conn.readline()
-                    logger.debug(f"Motion thread response: {response}")
-                    if response.lower() == "ok":
-                        logger.debug("Motion thread: Command execution confirmed.")
-                        return
+                if not state.stop_requested:
+                    gcode = f"$J=G91 G21 Y{y} F{speed}" if home else f"G1 G53 X{x} Y{y} F{speed}"
+                    state.conn.send(gcode + "\n")
+                    logger.debug(f"Motion thread sent command: {gcode}")
+
+                    while True:
+                        response = state.conn.readline()
+                        logger.debug(f"Motion thread response: {response}")
+                        if response.lower() == "ok":
+                            logger.debug("Motion thread: Command execution confirmed.")
+                            return
 
 
             except Exception as e:
             except Exception as e:
                 error_str = str(e)
                 error_str = str(e)