Tuan Nguyen 11 месяцев назад
Родитель
Сommit
80ac42f325

+ 1 - 1
dune_weaver_flask/app.py

@@ -40,7 +40,7 @@ def list_ports():
 def connect():
     port = request.json.get('port')
     if not port:
-        state.conn = WebSocketConnection('ws://fluidnc.local:81')
+        state.conn = connection_manager.WebSocketConnection('ws://fluidnc.local:81')
         logger.info(f'Successfully connected to websocket ws://fluidnc.local:81')
         return jsonify({'success': True})
 

+ 4 - 3
dune_weaver_flask/modules/connection/connection_manager.py

@@ -270,7 +270,7 @@ def get_machine_steps(timeout=10):
     logger.error("Timeout reached waiting for machine steps")
     return False
 
-
+# TODO: set custom homing speed based on the device
 def home():
     """
     Perform homing by checking device configuration and sending the appropriate commands.
@@ -288,8 +288,8 @@ def home():
         state.conn.send("G1 Y0 F100\n")
     else:
         logger.info("Sensorless homing not supported. Using crash homing")
-        logger.info(f"Homing with speed 300")
-        send_grbl_coordinates(0, -22, 300, home=True)
+        logger.info(f"Homing with speed {state.speed}")
+        send_grbl_coordinates(0, -22, state.speed, home=True)
     state.current_theta = state.current_rho = 0
     update_machine_position()
     state.save()
@@ -326,6 +326,7 @@ def get_machine_position(timeout=5):
                     return machine_x, machine_y
         except Exception as e:
             logger.error(f"Error getting machine position: {e}")
+            return
         time.sleep(0.1)
     logger.warning("Timeout reached waiting for machine position")
     return None, None

+ 8 - 8
dune_weaver_flask/modules/core/pattern_manager.py

@@ -190,14 +190,14 @@ def run_theta_rho_file(file_path, schedule_hours=None):
     """Run a theta-rho file by sending data in optimized batches with tqdm ETA tracking."""
     
     # Check if connection is still valid, if not, restart
-    if not connection_manager.get_status_response():
-        logger.info('Cannot get status response, restarting connection')
-        connection_manager.restart_connection(home=False)
-    if not state.conn and not state.conn.is_connected():
-        logger.error('Connection not established')
-        return
-    if not file_path:
-        return
+    # if not connection_manager.get_status_response() and isinstance(state.conn, connection_manager.WebSocketConnection):
+    #     logger.info('Cannot get status response, restarting connection')
+    #     connection_manager.restart_connection(home=False)
+    # if not state.conn and not state.conn.is_connected():
+    #     logger.error('Connection not established')
+    #     return
+    # if not file_path:
+    #     return
     
     coordinates = parse_theta_rho_file(file_path)
     total_coordinates = len(coordinates)