plc_control/docs/api-ops.md

72 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 运转系统 API
> 参考来源:`docs/superpowers/specs/2026-05-18-operation-system-engine-design.md`
## 健康检查
- `GET /api/health` — 返回应用名称和状态
## 日志
- `GET /api/logs` — 拉取日志内容
- `GET /api/logs/stream` — SSE 增量推送
## 文档
- `GET /api/docs/api-md` — 获取本 API 文档
- `GET /api/docs/readme-md` — 获取 README
## 平台基础接口
复用 `plc_platform_core::handler::platform_routes`:源 / 设备 / 点位 / 标签 / 页面。
## 工位配置§9.1.1
- `GET /api/station` — 列出工位(可选 `?line_code=`
- `POST /api/station` — 新建工位
- `GET /api/station/{id}` — 工位详情含信号绑定
- `PUT /api/station/{id}` — 更新工位
- `DELETE /api/station/{id}`
- `POST /api/station/{id}/signal` — Upsert 工位信号绑定
- `DELETE /api/station/{id}/signal/{role}`
## 流程段配置§9.1.1
- `GET /api/segment`(可选 `?line_code=`
- `POST /api/segment`
- `GET /api/segment/{id}`
- `GET /api/segment/{id}/detail` — 包含 step / interlock / resource
- `PUT /api/segment/{id}`
- `DELETE /api/segment/{id}`
- `GET /api/segment/{id}/step`
- `POST /api/segment/{id}/step`
- `PUT /api/segment/{id}/step/{step_no}`
- `DELETE /api/segment/{id}/step/{step_no}`
- `GET /api/segment/{id}/interlock`
- `POST /api/segment/{id}/interlock`
- `DELETE /api/segment/{id}/interlock/{interlock_id}`
- `GET /api/segment/{id}/resource`
- `PUT /api/segment/{id}/resource` — 用新的 `resource_keys` 数组整体替换
## 段运行控制§9.2
- `POST /api/control/segment/{id}/start-auto`
- `POST /api/control/segment/{id}/stop-auto`
- `POST /api/control/segment/{id}/ack-fault`
- `POST /api/control/segment/{id}/reset` — 仅在 Blocked / Faulted / ManualAckRequired 状态允许
- `POST /api/control/segment/batch-start-auto`
- `POST /api/control/segment/batch-stop-auto`
## 运行态查询§9.3
- `GET /api/runtime/overview` — 所有段 + 资源占用快照
- `GET /api/runtime/segment/{id}` — 单段配置 + runtime
- `GET /api/runtime/station/{id}` — 工位信号 + 最新点位监控值
## WebSocket§8.2
- `GET /ws/public` — 推送
- `point_new_value`(核心)
- `event_created`(核心)
- `app_event``{ app: "operation-system", event_type: "segment_runtime_changed", data: SegmentRuntime }`