mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-14 13:14:39 +00:00
signal when host node is ready
This commit is contained in:
@@ -1314,3 +1314,19 @@ class WebSocketClient(BaseCommunicationClient):
|
||||
logger.info(f"[WebSocketClient] Job {job_log} cancelled successfully")
|
||||
else:
|
||||
logger.warning(f"[WebSocketClient] Failed to cancel job {job_log}")
|
||||
|
||||
def publish_host_ready(self) -> None:
|
||||
"""发布host_node ready信号"""
|
||||
if self.is_disabled or not self.is_connected():
|
||||
logger.debug("[WebSocketClient] Not connected, cannot publish host ready signal")
|
||||
return
|
||||
|
||||
message = {
|
||||
"action": "host_node_ready",
|
||||
"data": {
|
||||
"status": "ready",
|
||||
"timestamp": time.time(),
|
||||
},
|
||||
}
|
||||
self.message_processor.send_message(message)
|
||||
logger.info("[WebSocketClient] Host node ready signal published")
|
||||
|
||||
@@ -289,6 +289,12 @@ class HostNode(BaseROS2DeviceNode):
|
||||
self.lab_logger().info("[Host Node] Host node initialized.")
|
||||
HostNode._ready_event.set()
|
||||
|
||||
# 发送host_node ready信号到所有桥接器
|
||||
for bridge in self.bridges:
|
||||
if hasattr(bridge, "publish_host_ready"):
|
||||
bridge.publish_host_ready()
|
||||
self.lab_logger().debug(f"Host ready signal sent via {bridge.__class__.__name__}")
|
||||
|
||||
def _send_re_register(self, sclient):
|
||||
sclient.wait_for_service()
|
||||
request = SerialCommand.Request()
|
||||
@@ -794,6 +800,7 @@ class HostNode(BaseROS2DeviceNode):
|
||||
# 存储结果供 HTTP API 查询
|
||||
try:
|
||||
from unilabos.app.web.controller import store_job_result
|
||||
|
||||
if goal_status == GoalStatus.STATUS_CANCELED:
|
||||
store_job_result(job_id, status, return_info, {})
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user