initial commit

This commit is contained in:
sladro 2026-01-21 16:20:16 +08:00
commit 096f3398c5
5 changed files with 985 additions and 0 deletions

Binary file not shown.

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
aiohttp==3.10.11

393
server.py Normal file
View File

@ -0,0 +1,393 @@
import asyncio
import os
import random
import time
from aiohttp import web
def now_ms() -> float:
return time.time() * 1000
def now_s() -> float:
return time.time()
def build_vehicle_status(vehicle_id: str) -> dict:
timestamp = now_ms()
return {
"code": 200,
"message": "success",
"data": {
"vehicleInfo": {"vehicleId": vehicle_id},
"operationalStatus": {
"powerStatus": "ON",
"systemHealth": "HEALTHY",
"operationalMode": "AUTONOMOUS",
"emergencyStatus": "NORMAL",
"lastHeartbeat": timestamp,
},
"controlStatus": {
"controlMode": "MANUAL",
"controlAuthority": "SYSTEM",
"remoteControlActive": True,
},
"motionStatus": {
"position": {
"latitude": 142.2157,
"longitude": 148.92,
},
"velocity": {
"speed": 0,
"direction": -1.0080692e-10,
},
},
"safetyStatus": {
"collisionAvoidanceActive": True,
"emergencyBrakingReady": True,
"pathPlanningStatus": "ACTIVE",
"obstacleDetectionStatus": "ACTIVE",
"minimumRiskManeuverTriggered": True,
},
"sensorStatus": {
"gps": {
"status": "ACTIVE",
"accuracy": 0.5,
"lastUpdate": timestamp,
}
},
"batteryStatus": {
"mainBattery": {
"chargeLevel": "0.0",
"voltage": 0,
"current": 0,
"temperature": 0,
"chargingStatus": "DISCHARGING",
}
},
"communicationStatus": {
"v2xStatus": "CONNECTED",
"cellularSignalStrength": 0,
"wifiStatus": "CONNECTED",
"cloudConnectivity": "ONLINE",
},
"missionContext": {
"currentMission": {
"missionId": None,
"missionType": "",
"startTime": 0,
"estimatedEndTime": 0,
"progress": 0,
"totalMileage": 0,
},
"waypoints": [],
},
},
"timestamp": timestamp,
}
def build_vehicle_order_info(vehicle_id: str) -> dict:
return {
"data": {
"messageName": "VehicleOrderInfo",
"businessKey": str(int(now_ms())),
"tenantId": "UpHang",
"processDefKey": "UpHang",
"vehicleId": vehicle_id,
"jobStatus": 1,
"abortBy": None,
"orderStatus": "",
"cancelReason": None,
"jobStage": "HANG_UP",
"jobStageTag": "WORKING",
"jobStageVehicle": 0,
"origin": "FMS",
"jobType": "UpHang",
"qctpCranId": "",
"craneID": None,
"passingLocation": "",
"isNeedToTs": -1,
"isNeedReshuffGate": 0,
"movementType": "ProcessTask",
"vesselVisitID": None,
"loadable": False,
"executeTogether": False,
"doubleYardSpecialStack": None,
"uniqueOrderIDOrigin": "",
"firstJobId": "",
"destination": {
"logicalLocation": {
"area": "YARD",
"block": "BU01",
"lane": "01",
"stack": "001",
"tier": "",
},
"portLocation": {
"fmsX": None,
"fmsY": None,
"fmsZ": None,
"orientation": None,
},
},
"points": {},
"jobContent": {
"logicalLocation": {
"area": "YARD",
"block": "BU01",
"lane": "01",
"stack": "001",
}
},
"workflowNodes": [
{
"node": "START",
"time": now_s(),
"origin": "AUTO",
"state": True,
},
{
"node": "END",
"time": now_s(),
"origin": "AUTO",
"state": False,
},
],
"isSecondBox": False,
"boxBelongsJob": None,
"trainId": "",
"mainId": 1134,
"createOn": "2026-01-06T02:32:56.685437+00:00",
"updateOn": "2026-01-06T02:32:56.685437+00:00",
"plannedContainerDestinationList": [],
"jobExtra": {"hangType": "large", "hangNum": "4", "uploadNum": "0"},
"jobAdd": [
{
"destPointType": "gateDestination",
"destination": {"area": "GateCheck", "block": "GC01", "lane": "01", "stack": "001"},
},
{
"destPointType": "upHangDestination",
"destination": {"area": "UpHang", "block": "UH01", "lane": "01", "stack": "001"},
},
{
"destPointType": "recvConDestination",
"destination": {"area": "RecvCon", "block": "RC01", "lane": "01", "stack": "001"},
},
{
"destPointType": "conveyorDestination",
"destination": {"area": "Conveyor", "block": "CV01", "lane": "01", "stack": "001"},
},
{
"destPointType": "downHangDestination",
"destination": {"area": "DownHang", "block": "DH01", "lane": "01", "stack": "001"},
},
],
}
}
def build_vehicle_details(vehicle_id: str) -> dict:
return {
"messageName": "VehicleDetails",
"vehicleId": vehicle_id,
"vin": None,
"manufacturer": None,
"vehicleType": "QTRUCK",
"createAt": "2025-08-05T07:54:09.721537+00:00",
"updateAt": "2025-11-06T07:40:30.789366+00:00",
"color": None,
"engineType": None,
}
def build_vehicle_login_status(vehicle_id: str, login: bool) -> dict:
return {
"messageName": "VehicleLoginStatus",
"vehicleId": vehicle_id,
"loginStatus": "login" if login else "logout",
}
def build_vehicle_chassis_info(vehicle_id: str) -> dict:
return {
"messageName": "VehicleChassisInfo",
"vehicleId": vehicle_id,
"reportAt": now_s(),
"sys_info": {
"i_at_id": vehicle_id,
"i_driving_mode": "1",
"overweight_speed_limit": 0,
"state_info": {
"d_speed_kmph": random.choice([0, 5, 10]),
"i_vehicle_miles_traveled": "0",
"d_battery_available": f"{random.uniform(10, 100):.1f}",
"i_gear_position": 1,
"d_battery_soh": "0.0",
},
},
}
def build_vehicle_suspend_report(vehicle_id: str) -> dict:
return {
"messageName": "VehicleSuspendReport",
"vehicleId": vehicle_id,
"suspendStatus": 0,
"origin": "device",
}
def build_vehicle_tailer_num(vehicle_id: str) -> dict:
return {
"messageName": "VehicleTailerNum",
"vehicleId": vehicle_id,
"tailerNum": "0",
}
def build_vehicle_position_info(vehicle_id: str) -> dict:
return {
"messageName": "VehiclePositionInfo",
"vehicleId": vehicle_id,
"updateAt": "20260106T024227963Z",
"update_at": "20260106T024227963Z",
"reportAt": now_s(),
"report_at": now_s(),
"action": 0,
"z": 0,
"x": 6.12613 + random.uniform(-0.5, 0.5),
"y": 101.70456 + random.uniform(-0.5, 0.5),
"direction": 1,
"v": 0,
"theta": -1.5224342,
"trailer": {
"x": 3.555143,
"y": 111.36841,
"theta": 100000,
},
}
def build_navi_short_path_report(vehicle_id: str) -> dict:
return {
"vehicleId": vehicle_id,
"vehicleMissionId": "04078d1e-eaa8-11f0-8723-fa30eca52200",
"destinationType": 0,
"shortNavi": False,
"path": [
{"x": 6.126130111981183, "y": 101.70455933734775, "theta": -1.5224548170138026},
{"x": 6.138059945020359, "y": 101.45796921849251, "theta": -1.5224956618374788},
{"x": 6.149855710682459, "y": 101.2139437738806, "theta": -1.5240533769087043},
{"x": 6.161292306904215, "y": 100.96945202164352, "theta": -1.5256081246300013},
{"x": 6.172369011037517, "y": 100.72449508309364, "theta": -1.5239545312967973},
],
"messageName": "NaviShortPathReport",
}
def build_fms_message(vehicle_id: str) -> dict:
return {
"vehicleID": vehicle_id,
"code": "4119010",
"type": 1,
"level": 4,
"isActive": 1,
"longTermDisplayMessage": False,
"description": "里程计信息超时",
"ts": "2026-01-06T03:36:09.637195+00:00",
"messageName": "GetFmsMessage",
}
async def handle_vehicle_status(request: web.Request) -> web.Response:
vehicle_id = request.match_info.get("vehicleId") or request.query.get("vehicleId") or "AET01"
return web.json_response(build_vehicle_status(vehicle_id))
async def ws_at_manager(request: web.Request) -> web.WebSocketResponse:
vehicle_id = request.query.get("vehicleId") or "AET01"
ws = web.WebSocketResponse()
await ws.prepare(request)
messages = [
build_vehicle_order_info(vehicle_id),
build_vehicle_details(vehicle_id),
build_vehicle_login_status(vehicle_id, True),
build_vehicle_chassis_info(vehicle_id),
build_vehicle_suspend_report(vehicle_id),
build_vehicle_tailer_num(vehicle_id),
build_fms_message(vehicle_id),
]
async def send_loop() -> None:
index = 0
while not ws.closed:
await ws.send_json(messages[index % len(messages)])
index += 1
await asyncio.sleep(1)
task = asyncio.create_task(send_loop())
async for msg in ws:
if msg.type == web.WSMsgType.ERROR:
break
task.cancel()
return ws
async def ws_at_manager_bsm(request: web.Request) -> web.WebSocketResponse:
vehicle_id = request.query.get("vehicleId") or "AET01"
ws = web.WebSocketResponse()
await ws.prepare(request)
async def send_loop() -> None:
while not ws.closed:
await ws.send_json(build_vehicle_position_info(vehicle_id))
await asyncio.sleep(1)
task = asyncio.create_task(send_loop())
async for msg in ws:
if msg.type == web.WSMsgType.ERROR:
break
task.cancel()
return ws
async def ws_at_manager_path(request: web.Request) -> web.WebSocketResponse:
vehicle_id = request.query.get("vehicleId") or "AET01"
ws = web.WebSocketResponse()
await ws.prepare(request)
async def send_loop() -> None:
while not ws.closed:
await ws.send_json(build_navi_short_path_report(vehicle_id))
await asyncio.sleep(2)
task = asyncio.create_task(send_loop())
async for msg in ws:
if msg.type == web.WSMsgType.ERROR:
break
task.cancel()
return ws
def create_app() -> web.Application:
app = web.Application()
app.router.add_post("/api/vehicle_manager/v1/vehicles/{vehicleId}/status", handle_vehicle_status)
app.router.add_get("/ws/at_manager", ws_at_manager)
app.router.add_get("/ws/at_manager_bsm", ws_at_manager_bsm)
app.router.add_get("/ws/at_manager_path", ws_at_manager_path)
return app
if __name__ == "__main__":
host = os.getenv("HOST", "0.0.0.0")
port = int(os.getenv("PORT", "8020"))
web.run_app(create_app(), host=host, port=port)

416
接口文档1.md Normal file
View File

@ -0,0 +1,416 @@
# 车辆信息接口文档
## 1. 概述
* **连接方式**WebSocket
* **数据格式**JSON
* **交互逻辑**:客户端建立 WebSocket 连接成功后,服务端会自动推送数据。
---
## 2. 接口详情
### 2.1 VehicleOrderInfo - 任务信息
* **接口地址**`ws://ip:port/ws/at_manager`
* **用途**GUI 根据该消息刷新页面任务信息
* **推送频率**:数据变化推送
* **Message Name**`VehicleOrderInfo`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `VehicleOrderInfo` |
| businessKey | 任务id | 是 | str | 任务的唯一标识 |
| vehicleId | 车号 | 是 | str | 车号 |
| jobStatus | 任务状态 | 是 | int | 0:未开始, 1:执行中, 4:终止, 9:完成 |
| abortBy | 取消来源 | 否 | str | 描述任务是被谁终止的 |
| cancelReason | 取消原因 | 否 | str | 描述任务取消的原因 |
| jobStage | 任务进度 | 是 | str | |
| jobStageTag | 任务进度标签 | 是 | str | |
| origin | 任务来源 | 是 | str | GUI客户端发送的任务 |
| jobType | 收送类型 | 是 | str | 作业类型 |
| passingLocation | 任务必经点 | 否 | str | |
| isNeedToTs | 是否经过锁站 | 否 | int | |
| movementType | 作业类型 | 否 | str | |
| offset | 引导值 | 否 | str | |
| vesselVisitID | 船id | 否 | str | |
| uniqueOrderIDOrigin | 原始任务ID | 否 | str | 重派的任务该字段为原始任务ID |
| **destination** | **目的位置** | **是** | **dict** | |
| └ logicalLocation | 目的位置 | 是 | dict | |
|   ├ area | 目标区域类型 | 是 | str | 固定值 YARD |
|   ├ block | 目标区域 | 是 | str | |
|   ├ lane | 车道 | 是 | str | |
|   ├ stack | 贝位 | 是 | str | |
| **points** | **指定点位** | **否** | **dict** | 该值不为空时系统使用该坐标导航(如GUI选点) |
| └ x | x坐标 | 否 | float | |
| └ y | y坐标 | 否 | float | |
| └ heading | 航向角 | 否 | float | |
| jobContent | 任务内容 | 否 | dict | 结构同 destination |
| **workflowNodes** | **流程节点记录** | **是** | **list** | |
| └ node | 节点名字 | 是 | str | |
| └ time | 记录时间戳 | 是 | float | |
| └ origin | 来源 | 是 | str | AUTO:系统, GUI:人工 |
| └ state | 节点状态 | 是 | bool | open:当前节点打开, close:已完成 |
#### 代码示例
```json
{
"data": {
"messageName": "VehicleOrderInfo",
"businessKey": "1767666776611",
"tenantId": "UpHang",
"processDefKey": "UpHang",
"vehicleId": "AET01",
"jobStatus": 1,
"abortBy": null,
"orderStatus": "",
"cancelReason": null,
"jobStage": "HANG_UP",
"jobStageTag": "WORKING",
"jobStageVehicle": 0,
"origin": "FMS",
"jobType": "UpHang",
"qctpCranId": "",
"craneID": null,
"passingLocation": "",
"isNeedToTs": -1,
"isNeedReshuffGate": 0,
"movementType": "ProcessTask",
"vesselVisitID": null,
"loadable": false,
"executeTogether": false,
"doubleYardSpecialStack": null,
"uniqueOrderIDOrigin": "",
"firstJobId": "",
"destination": {
"logicalLocation": {
"area": "BackUp",
"block": "BU01",
"lane": "01",
"stack": "001",
"tier": ""
},
"portLocation": {
"fmsX": null,
"fmsY": null,
"fmsZ": null,
"orientation": null
}
},
"points": {},
"isSecondBox": false,
"boxBelongsJob": null,
"trainId": "",
"mainId": 1134,
"createOn": "2026-01-06T02:32:56.685437+00:00",
"updateOn": "2026-01-06T02:32:56.685437+00:00",
"plannedContainerDestinationList": [],
"jobExtra": {
"hangType": "large",
"hangNum": "4",
"uploadNum": "0"
},
"jobAdd": [
{
"destPointType": "gateDestination",
"destination": {
"area": "GateCheck",
"block": "GC01",
"lane": "01",
"stack": "001"
}
}
]
}
}
```
---
### 2.2 VehicleDetails - 车辆列表/类型
* **接口地址**`ws://ip:port/ws/at_manager`
* **用途**GUI 根据该数据展示车辆模型
* **推送频率**:数据发生变化推送
* **Message Name**`VehicleDetails`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `VehicleDetails` |
| vehicleId | 车号 | 是 | str | |
| vehicleType | 车辆类型 | 是 | str | 例如QTRUCK |
#### 代码示例
```json
{
"messageName": "VehicleDetails",
"vehicleId": "AET01",
"vin": null,
"manufacturer": null,
"vehicleType": "QTRUCK",
"createAt": "2025-08-05T07:54:09.721537+00:00",
"updateAt": "2025-11-06T07:40:30.789366+00:00",
"color": null,
"engineType": null
}
```
---
### 2.3 VehicleLoginStatus - 车辆上线/下线消息
* **接口地址**`ws://ip:port/ws/at_manager`
* **用途**GUI 根据该数据展示上线/下线的车
* **推送频率**:数据发生变化推送
* **Message Name**`VehicleLoginStatus`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `VehicleLoginStatus` |
| vehicleId | 车号 | 是 | str | |
| loginStatus | 上线下线状态 | 是 | str | `login`:在线, `logout`:离线 |
#### 代码示例
```json
{
"messageName": "VehicleLoginStatus",
"vehicleId": "AET01",
"loginStatus": "login"
}
```
---
### 2.4 VehicleChassisInfo - 单车底盘信息
* **接口地址**`ws://ip:port/ws/at_manager`
* **用途**GUI 显示速度、电量、里程、底盘模式、胎压等
* **推送频率**:数据发生变化推送
* **Message Name**`VehicleChassisInfo`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `VehicleChassisInfo` |
| vehicleId | 车号 | 是 | str | |
| **sys_info** | **系统信息** | **否** | **dict** | |
| └ i_driving_mode | 驾驶模式 | 否 | str | |
| └ **state_info** | **状态信息** | **否** | **dict** | |
|   ├ d_speed_kmph | 速度 | 是 | Float | 单位: KM/小时 |
|   ├ i_vehicle_miles_traveled | 里程表 | 否 | str | 底盘记录总路程,单位 m |
|   ├ d_battery_available | 电量 | 否 | str | 剩余电量百分比 |
|   ├ i_gear_position | 档位 | 否 | int | 1:N, 2:D, 3:P, 4:R, 5:未知 |
#### 代码示例
```json
{
"messageName": "VehicleChassisInfo",
"vehicleId": "AET01",
"reportAt": 1767667344.8743727,
"sys_info": {
"i_at_id": "AET01",
"i_driving_mode": "1",
"overweight_speed_limit": 0,
"state_info": {
"d_speed_kmph": 0,
"d_battery_available": "0.0",
"d_battery_soh": "0.0"
}
}
}
```
---
### 2.5 VehicleSuspendReport - 车辆紧停状态
* **接口地址**`ws://ip:port/ws/at_manager`
* **用途**GUI 操作紧停/恢复按钮状态,或展示当前车辆是否紧停
* **推送频率**:数据发生变化推送
* **Message Name**`VehicleSuspendReport`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `VehicleSuspendReport` |
| vehicleId | 车号 | 是 | str | |
| suspendStatus | 当前车辆状态 | 是 | int | 0:恢复行驶, 1:紧急急停, 2:缓停 |
#### 代码示例
```json
{
"messageName": "VehicleSuspendReport",
"vehicleId": "AET01",
"suspendStatus": 0,
"origin": "device"
}
```
---
### 2.6 VehicleTailerNum - 拖挂数量
* **接口地址**`ws://ip:port/ws/at_manager`
* **用途**:推送单车拖挂数量
* **推送频率**N/A (通常为变化推送)
* **Message Name**`VehicleTailerNum`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `VehicleTailerNum` |
| vehicleId | 车号 | 是 | str | |
| tailerNum | 拖挂数量 | 是 | str | 0或空表示无挂其他数字表示有挂 |
#### 代码示例
```json
{
"messageName": "VehicleTailerNum",
"vehicleId": "AET01",
"tailerNum": "0"
}
```
---
### 2.7 VehiclePositionInfo - 车辆位置信息
* **接口地址**`ws://ip:port/ws/at_manager_bsm`
* **用途**GUI 根据该数据展示车辆位置信息
* **推送频率**:数据发生变化推送
* **Message Name**`VehiclePositionInfo`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `VehiclePositionInfo` |
| vehicleId | 车号 | 是 | str | |
| x | 车辆X坐标 | 是 | float | |
| y | 车辆Y坐标 | 是 | float | |
| theta | 车辆航向角 | 是 | float | 弧度正东0, 正北1.57, 正西3.14, 正南-1.57 |
| direction | 行驶方向 | 是 | int | 1:正向行驶, 2:反向行驶 |
| **trailer** | **拖挂信息** | **是** | **dict** | |
| └ x | 拖挂x坐标 | 是 | float | 不准,是车头坐标 |
| └ y | 拖挂Y坐标 | 是 | float | 不准,是车头坐标 |
| └ theta | 拖挂角度 | 是 | float | 弧度定义同上 |
#### 代码示例
```json
{
"messageName": "VehiclePositionInfo",
"vehicleId": "AET01",
"updateAt": "20260106T024227963Z",
"update_at": "20260106T024227963Z",
"reportAt": 1767667348.1297243,
"report_at": 1767667348.1297243,
"action": 0,
"z": 0,
"x": 6.12613,
"y": 101.70456,
"direction": 0,
"v": 0,
"theta": -1.5224342,
"trailer": {
"x": 3.555143,
"y": 111.36841,
"theta": 100000
}
}
```
---
### 2.8 NaviShortPathReport - 车辆短路径信息
* **接口地址**`ws://ip:port/ws/at_manager_path`
* **用途**GUI 根据该数据展示车辆路径规划
* **推送频率**:数据发生变化推送
* **Message Name**`NaviShortPathReport`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `NaviShortPathReport` |
| vehicleId | 车号 | 是 | str | |
| vehicleMissionId | 任务ID | 是 | str | (注原文此处类型标注为float有误示例为str) |
| destinationType | 目的地类型 | 是 | int | |
| **path** | **路径信息** | **是** | **list** | |
| └ x | 路径点x坐标 | 是 | float | UTM坐标 |
| └ y | 路径点y坐标 | 是 | float | UTM坐标 |
| └ theta | 路径点角度 | 是 | float | 弧度定义同上 |
#### 代码示例
```json
{
"vehicleId": "AET01",
"vehicleMissionId": "04078d1e-eaa8-11f0-8723-fa30eca52200",
"destinationType": "",
"shortNavi": false,
"path": [
{
"x": 6.126130111981183,
"y": 101.70455933734775,
"theta": -1.5224548170138026
},
{
"x": 6.138059945020359,
"y": 101.45796921849251,
"theta": -1.5224956618374788
},
{
"x": 6.650000399346166,
"y": 50.25839266739786,
"theta": -1.570796333683315
}
],
"messageName": "NaviShortPathReport"
}
```
---
### 2.9 GetFmsMessage - 系统和单车告警信息
* **接口地址**`ws://ip:port/ws/at_manager`
* **用途**:推送系统和单车的告警信息
* **推送频率**:数据发生变化推送
* **Message Name**`GetFmsMessage`
#### 输出参数
| 参数名 | 参数说明 | 是否必填 | 字段类型 | 备注说明 |
| :--- | :--- | :--- | :--- | :--- |
| messageName | 消息名称 | 是 | str | 固定值 `GetFmsMessage` |
| vehicleID | 车号 | 是 | str | |
| description | 描述 | 否 | str | |
| code | 告警码 | 否 | str | |
| level | 告警等级 | 是 | int | |
| type | 来源 | 是 | int | 1:单车, 2:系统告警 |
| ts | 告警时间 | 是 | str | 时间戳 |
#### 代码示例
```json
{
"vehicleID": "AET01",
"code": "4119010",
"type": 1,
"level": 4,
"isActive": 1,
"longTermDisplayMessage": false,
"description": "里程计信息超时",
"ts": "2026-01-06T03:36:09.637195+00:00",
"messageName": "GetFmsMessage"
}
```

175
接口文档2.md Normal file
View File

@ -0,0 +1,175 @@
好的,我已经将您提供的“中机科文档接口文档”内容整理成了标准的 Markdown 格式。我已经去除了原文中的行号和干扰字符,并对 JSON 代码块进行了格式化。
---
# 中机科文档接口文档
## 车辆信息获取接口
### 1. 接口概述
* **接口描述**:该接口用于上层系统从 FMS 获取车辆信息,按照上层系统提供的测试接口文档返回数据。对于没有数据的字段会标记出来(返回默认值)。
* **协议名称**HTTP
* **接口地址**`/api/vehicle_manager/v1/vehicles/{vehicleId}/status`
* **请求方法**POST
### 2. 请求参数
**参数位置**:路径参数 (Path Parameter) / 查询参数 (Query Parameter)
| 参数名称 | 参数类型 | 是否必须 | 描述 |
| :--- | :--- | :--- | :--- |
| vehicleId | str | 是 | 查询车号 |
### 3. 响应数据
#### 顶层结构
| 参数名称 | 参数类型 | 描述 |
| :--- | :--- | :--- |
| code | int | 状态码 |
| message | str | 响应状态 |
| timestamp | float | 时间戳 |
| data | dict | 响应数据详情(见下表) |
#### data 结构详情
| 字段路径 | 参数名 | 类型 | 描述 | 备注/默认值 |
| :--- | :--- | :--- | :--- | :--- |
| **vehicleInfo** | **车辆信息** | **dict** | | |
| └ | vehicleId | str | 车号 | |
| **operationalStatus** | **运行状态** | **dict** | | |
| └ | powerStatus | str | 上电状态 | ON/OFF |
| └ | systemHealth | str | 系统监控状态 | 无数据时默认: `HEALTHY` |
| └ | operationalMode | str | 运作模式 | 无数据时默认: `AUTONOMOUS` |
| └ | emergencyStatus | str | 紧急状态 | 无数据时默认: `NORMAL` |
| └ | lastHeartbeat | float | 最后心跳 | |
| **controlStatus** | **控制状态** | **dict** | | |
| └ | controlMode | str | 控制模式 | 无数据时默认: `MANUAL` |
| └ | controlAuthority | str | 控制权限 | 无数据时默认: `SYSTEM` |
| └ | remoteControlActive | bool | 是否激活远控 | 无数据时默认: `true` |
| **motionStatus** | **运动状态** | **dict** | | |
| └ **position** | **位置信息** | **dict** | | |
|   ├ | latitude | float | 经度 | |
|   └ | longitude | float | 维度 | |
| └ **velocity** | **速度** | **dict** | | |
|   ├ | speed | float | 速度 | |
|   └ | direction | float | 角度 | |
| **safetyStatus** | **安全状态** | **dict** | | |
| └ | collisionAvoidanceActive | bool | 主动避障 | 无数据时默认: `true` |
| └ | emergencyBrakingReady | bool | 紧急制动 | |
| └ | pathPlanningStatus | str | 路径规划状态 | 无数据时默认: `ACTIVE` |
| └ | obstacleDetectionStatus | str | 障碍物检测状态 | 无数据时默认: `ACTIVE` |
| └ | minimumRiskManeuverTriggered | bool | 触发最小风险机动 | 无数据时默认: `true` |
| **sensorStatus** | **传感器状态** | **dict** | | |
| └ **gps** | **gps** | **dict** | | |
|   ├ | status | str | GPS状态 | 无数据时默认: `ACTIVE` |
|   ├ | accuracy | float | 精度 | 无数据时默认: `0.5` |
|   └ | lastUpdate | float | 最后心跳 | |
| **batteryStatus** | **电量信息** | **dict** | | |
| └ **mainBattery** | | **float** | *(原文此处类型标注可能为dict)* | |
|   ├ | chargeLevel | float | 电量 | |
|   ├ | voltage | float | 电压 | 无数据时默认: `0` |
|   ├ | current | float | 电流 | 无数据时默认: `0` |
|   ├ | temperature | float | 温度 | 无数据时默认: `0` |
|   └ | chargingStatus | str | 充电状态 | 无数据时默认: `DISCHARGING` |
| **communicationStatus** | **通信状态** | **dict** | | |
| └ | v2xStatus | string | v2x状态 | 无数据时默认: `CONNECTED` |
| └ | cellularSignalStrength | int | 信号强度 | 无数据时默认: `0` |
| └ | wifiStatus | string | 无线网络状态 | 无数据时默认: `CONNECTED` |
| └ | cloudConnectivity | string | 云连接 | 无数据时默认: `ONLINE` |
| **missionContext** | **任务上下文** | **dict** | | |
| └ **currentMission** | **当前任务** | **dict** | | |
|   ├ | missionId | str | 任务ID | |
|   ├ | missionType | str | 任务类型 | |
|   ├ | startTime | float | 开始时间 | |
|   ├ | estimatedEndTime | float | 预计结束时间 | 无数据时给默认数据 |
|   ├ | progress | float | 任务进度百分比 | 无数据时默认: `0` |
|   └ | totalMileage | float | 总里程 | 无数据时默认: `0` |
| └ **waypoints** | **路径点列表** | **list** | | |
|   └ | waypointId | str | 路径点唯一标识符 | 无数据时默认: 计数 |
|   └ | latitude | float | 路径点纬度 | |
|   └ | longitude | float | 路径点经度 | |
|   └ | status | str | 路径点状态 | 无数据时默认: `PENDING` |
### 4. 请求示例
```bash
curl -X 'POST' \
'http://10.3.8.22:8020/api/vehicle_manager/v1/vehicles/AET01/status' \
-H 'accept: application/json' \
-d ''
```
### 5. 响应示例
```json
{
"code": 200,
"message": "success",
"data": {
"vehicleInfo": {
"vehicleId": "AET01"
},
"operationalStatus": {
"powerStatus": "ON",
"systemHealth": "HEALTHY",
"operationalMode": "AUTONOMOUS",
"emergencyStatus": "NORMAL",
"lastHeartbeat": 1767838334301.7153
},
"controlStatus": {
"controlMode": "MANUAL",
"controlAuthority": "SYSTEM",
"remoteControlActive": true
},
"motionStatus": {
"position": {
"latitude": 142.2157,
"longitude": 148.92
},
"velocity": {
"speed": 0,
"direction": -1.0080692e-10
}
},
"safetyStatus": {
"collisionAvoidanceActive": true,
"emergencyBrakingReady": true,
"pathPlanningStatus": "ACTIVE",
"obstacleDetectionStatus": "ACTIVE",
"minimumRiskManeuverTriggered": true
},
"sensorStatus": {
"gps": {
"status": "ACTIVE",
"accuracy": 0.5,
"lastUpdate": 1767838334301.7153
}
},
"batteryStatus": {
"mainBattery": {
"chargeLevel": "0.0",
"voltage": 0,
"current": 0,
"temperature": 0,
"chargingStatus": "DISCHARGING"
}
},
"communicationStatus": {
"v2xStatus": "CONNECTED",
"cellularSignalStrength": 0,
"wifiStatus": "CONNECTED",
"cloudConnectivity": "ONLINE"
},
"missionContext": {
"currentMission": {
"missionId": null,
"missionType": "",
"startTime": 0,
"estimatedEndTime": 0,
"progress": 0,
"totalMileage": 0
},
"waypoints": []
}
},
"timestamp": 1767838334301.7153
}
```