本文档详细描述了数字化工厂中央控制室驾驶舱系统的API接口规范,包括中端服务提供的数据接口和算法接口。
http://localhost:8000
http://localhost:8001
http://localhost:8002
所有API返回标准JSON格式,包含以下字段:
成功响应:
{
"status": "success",
"data": { ... } // 响应数据,根据接口不同而不同
}
错误响应:
{
"status": "error",
"message": "错误信息描述"
}
API使用Bearer Token认证:
Authorization: Bearer {token}
获取特定类型数据的最新记录。
/api/collector/data/{data_type}
GET
data_type
: 数据类型 (machine_data, agv_data, stamping_data等)limit
: 返回记录数量,默认10请求示例:
GET /api/collector/data/machine_data?limit=5
成功响应:
[
{
"_id": "634f2a1b3e01a5c33e8b4567",
"device_id": "CNC-001",
"device_type": "cnc",
"status": "running",
"temperature": 65.2,
"timestamp": "2025-05-07T14:30:25.123Z"
},
...
]
获取指定时间范围内的历史数据。
/api/collector/data/{data_type}/history
GET
data_type
: 数据类型start_time
: 开始时间 (ISO格式)end_time
: 结束时间 (ISO格式)limit
: 返回记录数量,默认100请求示例:
GET /api/collector/data/agv_data/history?start_time=2025-05-01T00:00:00&end_time=2025-05-07T23:59:59
成功响应:
[
{
"_id": "634f2a1b3e01a5c33e8b4568",
"device_id": "AGV-001",
"device_type": "agv",
"status": "busy",
"position": {
"x": 120.5,
"y": 85.3
},
"battery_level": 78.5,
"timestamp": "2025-05-07T10:15:33.456Z"
},
...
]
获取特定设备的数据。
/api/collector/device/{device_type}/{device_id}
GET
device_type
: 设备类型device_id
: 设备IDlimit
: 返回记录数量,默认10请求示例:
GET /api/collector/device/agv/AGV-001
成功响应:
[
{
"_id": "634f2a1b3e01a5c33e8b4568",
"device_id": "AGV-001",
"device_type": "agv",
"status": "busy",
"position": {
"x": 120.5,
"y": 85.3
},
"battery_level": 78.5,
"timestamp": "2025-05-07T10:15:33.456Z"
},
...
]
获取所有AGV的最新位置数据。
/api/collector/agv/positions
GET
请求示例:
GET /api/collector/agv/positions
成功响应:
[
{
"_id": "634f2a1b3e01a5c33e8b4568",
"device_id": "AGV-001",
"device_type": "agv",
"position": {
"x": 120.5,
"y": 85.3
},
"timestamp": "2025-05-07T15:30:10.123Z"
},
...
]
为AGV规划从起点到终点的路径。
/api/algorithm/path/plan
POST
{
"agv_id": "AGV-001",
"start_point": {
"x": 100,
"y": 100
},
"end_point": {
"x": 500,
"y": 400
},
"obstacles": [
{
"x": 300,
"y": 300
},
{
"x": 350,
"y": 300
}
],
"priority": 2
}
成功响应:
{
"agv_id": "AGV-001",
"path": [
{
"x": 100,
"y": 100
},
{
"x": 150,
"y": 150
},
...
{
"x": 500,
"y": 400
}
],
"distance": 565.68,
"estimated_time": 565.68
}
为多个AGV分配多个任务。
/api/algorithm/task/schedule
POST
{
"tasks": [
{
"id": "TASK-001",
"start": {
"x": 100,
"y": 100
},
"end": {
"x": 500,
"y": 400
},
"priority": 3
},
{
"id": "TASK-002",
"start": {
"x": 200,
"y": 200
},
"end": {
"x": 600,
"y": 500
},
"priority": 1
}
],
"available_agvs": ["AGV-001", "AGV-002", "AGV-003"]
}
成功响应:
{
"status": "success",
"assignments": [
{
"agv_id": "AGV-001",
"task_id": "TASK-001",
"path": [
{
"x": 100,
"y": 100
},
...
{
"x": 500,
"y": 400
}
],
"estimated_time": 565.68,
"start_time": "2025-05-07T16:45:20.123Z"
},
{
"agv_id": "AGV-002",
"task_id": "TASK-002",
"path": [
{
"x": 200,
"y": 200
},
...
{
"x": 600,
"y": 500
}
],
"estimated_time": 509.9,
"start_time": "2025-05-07T16:45:20.123Z"
}
],
"total_assigned": 2,
"total_pending": 0
}
获取特定AGV的当前位置。
/api/algorithm/agv/{agv_id}/position
GET
agv_id
: AGV ID请求示例:
GET /api/algorithm/agv/AGV-001/position
成功响应:
{
"x": 120.5,
"y": 85.3
}
更新特定AGV的位置。
/api/algorithm/agv/{agv_id}/position
PUT
agv_id
: AGV ID{
"x": 150.0,
"y": 90.5
}
成功响应:
{
"status": "success",
"message": "AGV AGV-001 位置已更新"
}
系统使用WebSocket提供实时数据更新。
ws://localhost:8000/ws
{
"event": "device_status",
"data": {
"device_id": "CNC-001",
"device_type": "cnc",
"status": "running",
"temperature": 67.8,
"timestamp": "2025-05-07T17:05:12.345Z"
}
}
{
"event": "agv_status",
"data": {
"device_id": "AGV-001",
"device_type": "agv",
"status": "busy",
"position": {
"x": 125.8,
"y": 87.2
},
"battery_level": 77.8,
"timestamp": "2025-05-07T17:05:15.678Z"
}
}
{
"event": "agv_path",
"data": {
"agv_id": "AGV-001",
"path": [
{
"x": 125.8,
"y": 87.2
},
...
{
"x": 500,
"y": 400
}
],
"timestamp": "2025-05-07T17:05:20.123Z"
}
}
状态码 | 错误类型 | 描述 |
---|---|---|
400 | Bad Request | 请求参数错误 |
401 | Unauthorized | 未授权访问 |
403 | Forbidden | 权限不足 |
404 | Not Found | 资源不存在 |
500 | Internal Server Error | 服务器内部错误 |
{
"device_id": "设备ID",
"device_type": "设备类型",
"status": "设备状态",
"timestamp": "时间戳",
// 其他属性根据设备类型不同而不同
}
{
"device_id": "AGV ID",
"device_type": "agv",
"status": "AGV状态",
"position": {
"x": "X坐标",
"y": "Y坐标"
},
"orientation": "方向角度",
"battery_level": "电量百分比",
"current_task": "当前任务ID",
"timestamp": "时间戳"
}
{
"agv_id": "AGV ID",
"start_point": {
"x": "起点X坐标",
"y": "起点Y坐标"
},
"end_point": {
"x": "终点X坐标",
"y": "终点Y坐标"
},
"path": [
{
"x": "点X坐标",
"y": "点Y坐标"
},
// 更多路径点
],
"distance": "路径长度",
"estimated_time": "预计时间",
"timestamp": "时间戳"
}
{
"id": "任务ID",
"start_point": {
"x": "起点X坐标",
"y": "起点Y坐标"
},
"end_point": {
"x": "终点X坐标",
"y": "终点Y坐标"
},
"priority": "优先级",
"assigned_agv": "分配的AGV ID",
"status": "任务状态",
"created_at": "创建时间",
"assigned_at": "分配时间",
"completed_at": "完成时间"
}
本项目是一个数字化工厂中央控制室驾驶舱系统,提供实时、全面的工厂运行状态可视化监控。系统集成了生产线数据采集、设备状态监控、生产效率分析、质量控制、能耗监测和预测性维护功能,为工厂管理者提供决策支持。
DigitalFactoryDashboard/
├── backend/ # 后端服务
│ ├── api/ # API接口
│ ├── data_acquisition/ # 数据采集模块
│ ├── data_processing/ # 数据处理与分析
│ └── database/ # 数据存储管理
├── middleware/ # 中端服务
│ ├── collector/ # 数据采集中间件
│ ├── database/ # 数据分类存储
│ ├── algorithm/ # 算法模块
│ │ ├── path_planning/ # 路径规划算法
│ │ └── scheduling/ # 调度算法
│ └── api/ # 中端API接口
├── frontend/ # 前端大屏显示
│ ├── src/ # 源代码
│ │ ├── components/ # 组件
│ │ ├── pages/ # 页面
│ │ └── utils/ # 工具函数
│ └── public/ # 静态资源
└── config/ # 配置文件
数据采集中间件提供以下接口:
GET /api/collector/data/{data_type}
返回指定类型的最新采集数据
GET /api/collector/data/{data_type}/history
返回指定类型的历史数据
参数:
- data_type: 数据类型 (production, device, energy, agv等)
- start_time: 开始时间
- end_time: 结束时间
路径规划算法提供以下接口:
POST /api/algorithm/path/plan
输入参数:
{
"agv_id": "AGV-001",
"start_point": {"x": 10, "y": 20},
"end_point": {"x": 90, "y": 80},
"obstacles": [{...}],
"priority": 1
}
返回:
{
"path": [
{"x": 10, "y": 20},
{"x": 30, "y": 20},
...
],
"distance": 120,
"estimated_time": 60
}
任务调度算法接口:
POST /api/algorithm/task/schedule
输入参数:
{
"tasks": [
{"id": "TASK-001", "start": {"x":10, "y":20}, "end": {"x":90, "y":80}, "priority": 1},
...
],
"available_agvs": ["AGV-001", "AGV-002"]
}
返回:
{
"assignments": [
{"agv_id": "AGV-001", "task_id": "TASK-001", "path": [...], "start_time": "..."},
...
]
}
详细的安装和使用说明将在项目开发完成后提供。
会话目的:为数字化工厂中央控制室驾驶舱系统添加中端数据采集系统和智能AGV路径规划算法模块
完成任务:
关键决策和解决方案:
使用的技术栈:
修改的文件:
会话目的:在系统中添加一个实时数据采集监控终端,用于可视化展示数据采集过程
完成任务:
关键决策和解决方案:
使用的技术栈:
修改的文件:
目的:数字化工厂中央控制室驾驶舱系统的整体架构和功能
完成:
发现:
使用的技术栈: