修改运行时显示

This commit is contained in:
ywb
2026-05-29 13:37:02 +08:00
parent a556a0858b
commit f64068475f
6 changed files with 229 additions and 37 deletions
+29 -1
View File
@@ -1376,6 +1376,23 @@ def api_mission_state():
if r < len(grid) and c < len(grid[r]) and grid[r][c]:
path.append((r, c))
# 网格级别任务数据
result["rows"] = rows
result["cols"] = cols
result["grid"] = grid
result["point_status"] = {f"{pr}_{c}": "pending" for pr in range(rows+1) for c in range(cols)}
result["machine_status"] = {}
for r in range(rows):
for c in range(cols):
if r < len(grid) and c < len(grid[r]) and grid[r][c]:
result["machine_status"][f"{r}_{c}"] = {
"has_machine": True,
"qr": "pending", "qr_val": None,
"front": "pending", "front_cnt": 0,
"back": "pending", "back_cnt": 0,
"status": "pending", "step": "等待",
}
# 保留旧的 tasks 列表(兼容)
tlist = []
for (r, c) in path:
tlist.append({
@@ -1390,15 +1407,26 @@ def api_mission_state():
})
result["tasks"] = tlist
except Exception:
result["rows"] = 1
result["cols"] = 1
result["grid"] = []
result["point_status"] = {}
result["machine_status"] = {}
result["tasks"] = []
# 错误弹窗状态
# 错误弹窗状态和实时网格状态
if hasattr(MissionExecutorV3, "_instance") and MissionExecutorV3._instance:
ex = MissionExecutorV3._instance
st = ex.get_status()
result["error_msg"] = st.get("error", "")
result["waiting_step"] = (st.get("status") == "waiting_step")
result["waiting_error"] = (st.get("status") == "waiting_error")
# 从 executor.report 读取实时点/机器状态
rpt = ex.report
if rpt.get("point_status"):
result["point_status"] = rpt["point_status"]
if rpt.get("machine_status"):
result["machine_status"] = rpt["machine_status"]
else:
result["error_msg"] = ""
result["waiting_step"] = False