Files
BR_YKC/Doc/桩和网关通讯协议文档.md
2026-05-21 13:24:05 +08:00

975 lines
28 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.
# 充电桩与网关 UDP JSON 通讯协议
## 概述
充电桩与网关之间通过 **以太网 UDP** 通信,使用 **JSON** 格式进行数据交换。
| 项目 | 说明 |
|------|------|
| 传输层 | UDP |
| 网关端口 | 6001 |
| 桩IP范围 | 10.12.19.101 ~ 106 |
| 数据格式 | JSON |
| 编码 | UTF-8 |
---
## 通讯流程
```
充电桩上电
发送 online上电 ──────→ 网关回复 charger_id
正常运行时,每 5~10 秒
发送 heartbeat心跳 ──→ 网关回复
┌─── 网关下发 start charging启动充电
充电桩周期上报实时数据 ←──── 网关可下发 end charging停止充电
(realtime data / charge process real / bms info real)
└─── 充电结束 → 上报 settlement bill结算账单
```
---
## 指令列表
| # | 标题 | cmd | 方向 | 触发方式 |
|---|------|-----|------|----------|
| 1 | 桩上电 | `online` | 桩 → 网关 → 桩 | 上电即发 |
| 2 | 心跳 | `heartbeat` | 桩 → 网关 → 桩 | 5~10秒周期 |
| 3 | 启动充电 | `start charging` | 网关 → 桩 → 网关 | 网关主动下发 |
| 4 | 停止充电 | `end charging` | 网关 → 桩 → 网关 | 网关主动下发 |
| 5 | 主动停止充电 | `proactive end charging` | 桩 → 网关 → 桩 | 桩主动上报 |
| 6 | 实时数据上报 | `realtime data` | 桩 → 网关 → 桩 | 周期上送 |
| 7 | BMS信息上报 | `bms info` | 桩 → 网关 → 桩 | 桩主动上报 |
| 8 | 充电参数配置 | `charge config` | 桩 → 网关 → 桩 | 桩主动上报 |
| 9 | 充电错误报文 | `charge error` | 桩 → 网关 → 桩 | 桩主动上报 |
| 10 | BMS中止充电 | `bms stop` | 桩 → 网关 → 桩 | 桩主动上报 |
| 11 | 充电机中止充电 | `charger stop` | 桩 → 网关 → 桩 | 桩主动上报 |
| 12 | 充电过程BMS需求与输出 | `charge process real` | 桩 → 网关 → 桩 | 15秒周期 |
| 13 | 充电过程BMS信息 | `bms info real` | 桩 → 网关 → 桩 | 15秒周期 |
| 14 | 结算账单上传 | `settlement bill` | 桩 → 网关 → 桩 | 桩主动上报 |
---
## 通用字段说明
所有 JSON 消息均包含以下固定字段:
| 字段 | 类型 | 说明 |
|------|------|------|
| `id` | Number | 桩编码 (1~6) |
| `cmd` | String | 指令标识,见指令列表 |
| `type` | String | `"request"` 请求帧 / `"response"` 回复帧 |
---
## 1. 桩上电
> **方向**:充电桩 → 网关 → 充电桩
充电桩上电后立即发送网关回复桩的唯一ID。
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "online",
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 |
| cmd | String | 是 | "online" |
| type | String | 是 | "request" |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "online",
"charger_id": "32010203040506",
"type": "response"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 |
| cmd | String | 是 | "online" |
| charger_id | String | 是 | 桩唯一ID |
| type | String | 是 | "response" |
---
## 2. 心跳
> **方向**:充电桩 → 网关 → 充电桩
> **周期**5~10 秒
桩定期上报各枪实时状态。
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "heartbeat",
"gun": [
{ "id": 1, "state": 0 },
{ "id": 2, "state": 0 }
],
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "heartbeat" |
| gun | Array | 是 | 枪口列表 |
| gun[].id | Number | 是 | 枪编号 (1~N) |
| gun[].state | Number | 是 | 枪状态0 离线1 故障2 空闲3 充电 |
| type | String | 是 | "request" |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "heartbeat",
"gun_id": 1,
"type": "response"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "heartbeat" |
| gun_id | Number | 是 | 枪编号 (1~N) |
| type | String | 是 | "response" |
---
## 3. 启动充电
> **方向**:网关 → 充电桩 → 网关
网关向充电桩下发启动充电指令,同步下发**计费模型**。
**Request (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "start charging",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"fee": [
[1, 0, 6, 0.3, 0.5],
[2, 6, 10, 0.8, 0.8],
[3, 10, 15, 1.2, 0.8],
[4, 15, 24, 0.6, 0.6]
],
"limit_amount": 0,
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "start charging" |
| transaction_id | String | 是 | 订单编码 32位 |
| gun_id | Number | 是 | 枪编码 (1~N) |
| fee | Array | 是 | 计费模型数组,每行:[计费段, 开始时间, 结束时间, 电费, 服务费] |
| limit_amount | Float | 是 | 停止金额。0 为不限制 |
| type | String | 是 | "request" |
**fee 数组格式:**
每行固定5个元素
```
[计费段, 开始时间(小时), 结束时间(小时), 电费单价, 服务费单价]
```
| 计费段 | 含义 |
|--------|------|
| 1 | 尖 |
| 2 | 峰 |
| 3 | 平 |
| 4 | 谷 |
**Response (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "start charging",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"result": 0,
"error_code": 0,
"type": "response"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "start charging" |
| transaction_id | String | 是 | 订单编码 32位 |
| gun_id | Number | 是 | 枪编码 (1~N) |
| result | Number | 是 | 启动结果0=失败1=成功 |
| error_code | Number | 是 | 错误码0=无1=设备编号不匹配2=枪已在充电3=设备故障4=设备离线5=未插枪 |
| type | String | 是 | "response" |
---
## 4. 停止充电
> **方向**:网关 → 充电桩 → 网关
**Request (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "end charging",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "end charging" |
| transaction_id | String | 是 | 订单编码 32位 |
| gun_id | Number | 是 | 枪编码 (1~N) |
| type | String | 是 | "request" |
**Response (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "end charging",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"result": 0,
"error_code": 0,
"type": "response"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "end charging" |
| transaction_id | String | 是 | 订单编码 32位 |
| gun_id | Number | 是 | 枪编码 (1~N) |
| result | Number | 是 | 停止结果0 失败1 成功 |
| error_code | Number | 是 | 错误码0 无1 枪未在充电2 其他故障 |
| type | String | 是 | "response" |
---
## 5. 主动停止充电
> **方向**:充电桩 → 网关 → 充电桩
充电桩主动上报停止充电如用户刷卡停止、车辆BMS中止等
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "proactive end charging",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "proactive end charging" |
| transaction_id | String | 是 | 订单编码 32位 |
| gun_id | Number | 是 | 枪编码 (1~N) |
| type | String | 是 | "request" |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "proactive end charging",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"type": "response"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "end charging" |
| transaction_id | String | 是 | 订单编码 32位 |
| gun_id | Number | 是 | 枪编码 (1~N) |
| type | String | 是 | "response" |
---
## 6. 充电桩实时数据上报
> **方向**:充电桩 → 网关 → 充电桩
> **周期**:待机 5 分钟、充电 15 秒
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "realtime data",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"state": 0,
"gun_back": 0,
"gun_insert": 1,
"voltage": 2222,
"current": 2222,
"cable_temp": 85,
"cable_code": "1234567890123456",
"soc": 85,
"battery_temp": 95,
"charge_time": 45,
"remain_time": 30,
"charge_kwh": 12.3456,
"loss_kwh": 12.4567,
"charge_amount": 18.6851,
"fault": 0,
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "realtime data" |
| transaction_id | String | 是 | 交易流水号 32位待机时填充0 |
| gun_id | Number | 是 | 枪编号 (1~N) |
| state | Number | 是 | 枪状态0 离线1 故障2 空闲3 充电 |
| gun_back | Number | 是 | 枪是否归位0 否1 是2 未知 |
| gun_insert | Number | 是 | 是否插枪0 否1 是 |
| voltage | Float | 是 | 输出电压单位0.1V。待机时为0 |
| current | Float | 是 | 输出电流单位0.1A。待机时为0 |
| cable_temp | Number | 是 | 枪线温度,单位℃,偏移量-50。待机时为0 |
| cable_code | String | 是 | 枪线编码 16位没有时填充0 |
| soc | Number | 是 | 电池SOC百分比 0~100待机/交流桩为0 |
| battery_temp | Number | 是 | 电池组最高温度,单位℃,偏移量-50。待机/交流桩为0 |
| charge_time | Number | 是 | 累计充电时间单位分钟。待机时为0 |
| remain_time | Number | 是 | 剩余时间,单位分钟。待机/交流桩为0 |
| charge_kwh | Float | 是 | 充电度数(kWh)精确到小数点后4位。待机时为0 |
| loss_kwh | Float | 是 | 计损充电度数(kWh)。未设置计损比例时等于charge_kwh |
| charge_amount | Float | 是 | 已充金额(元)精确到小数点后4位 |
| fault | Number | 是 | 硬件故障位图16bit见下方说明 |
| type | String | 是 | "request" |
**fault 故障位图:**
| Bit | 故障 |
|-----|------|
| 1 | 急停 |
| 2 | 无模块 |
| 3 | 温度高 |
| 4 | 防雷故障 |
| 5 | DC20中断 |
| 6 | FC08中断 |
| 7 | 电表中断 |
| 8 | 读卡器中断 |
| 9 | RC10中断 |
| 10 | 风扇故障 |
| 11 | 熔断器故障 |
| 12 | 接触器故障 |
| 13 | 门打开 |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "realtime data",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"type": "response"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "realtime data" |
| transaction_id | String | 是 | 交易流水号 32位 |
| gun_id | Number | 是 | 枪编号 (1~N) |
| type | String | 是 | "response" |
---
## 7. BMS信息上报
> **方向**:充电桩 → 网关 → 充电桩
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "bms info",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"protocol_version": "0001.01",
"battery_type": 3,
"rated_capacity": 600.0,
"rated_voltage": 3600.0,
"manufacturer": "CATL",
"battery_sn": "BT123456",
"production_year": 2023,
"production_month": 6,
"production_day": 15,
"charge_count": 1250,
"ownership": 1,
"reserved": 0,
"vin": "LSVAA4182E2123456",
"software_version": "FFFFFF.07DF.0B.0A.10",
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "bms info" |
| transaction_id | String | 是 | 交易流水号 32位 |
| gun_id | Number | 是 | 枪编号 (1~N) |
| protocol_version | String | 是 | BMS通信协议版本号。格式`byte3.byte2-byte1`,例:"0001.01"=V1.1 |
| battery_type | Number | 是 | 电池类型1铅酸2氢电池3磷酸铁锂4锰酸锂5钴酸锂6三元材料7聚合物锂离子8钛酸锂255其他 |
| rated_capacity | Float | 是 | 额定容量单位0.1Ah。例600.0=60.0Ah |
| rated_voltage | Float | 是 | 额定总电压单位0.1V。例3600.0=360.0V |
| manufacturer | String | 是 | 电池生产厂商名称最长4字节 |
| battery_sn | String | 是 | 电池组序号最长4字节 |
| production_year | Number | 是 | 生产年份1985偏移量。例2023=1985+38 |
| production_month | Number | 是 | 生产月份1~12 |
| production_day | Number | 是 | 生产日1~31 |
| charge_count | Number | 是 | 电池组充电次数0次偏移量 |
| ownership | Number | 是 | 电池产权标识0租赁1车自有 |
| reserved | Number | 是 | 预留位 |
| vin | String | 是 | 车辆识别码VIN17位字符 |
| software_version | String | 是 | BMS软件版本号。格式`byte8.byte7-byte5.byte4-byte3-byte2-byte1` |
| type | String | 是 | "request" |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "bms info",
"gun_id": 1,
"type": "response"
}
```
---
## 8. 充电参数配置
> **方向**:充电桩 → 网关 → 充电桩
> **依据**GBT-27930 充电桩与BMS参数配置阶段报文
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "charge config",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"bms_max_cell_voltage": 4.20,
"bms_max_current": 250.0,
"bms_rated_energy": 60.0,
"bms_max_voltage": 750.0,
"bms_max_temp": 95,
"bms_soc": 85.0,
"bms_current_voltage": 680.0,
"pile_max_voltage": 750.0,
"pile_min_voltage": 200.0,
"pile_max_current": 250.0,
"pile_min_current": 10.0,
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "charge config" |
| transaction_id | String | 是 | 交易流水号 32位 |
| gun_id | Number | 是 | 枪编号 (1~N) |
| bms_max_cell_voltage | Float | 是 | BMS单体最高允许充电电压单位0.01V范围0~24V |
| bms_max_current | Float | 是 | BMS最高允许充电电流单位0.1A-400A偏移量 |
| bms_rated_energy | Float | 是 | BMS标称总能量单位0.1kWh范围0~1000kWh |
| bms_max_voltage | Float | 是 | BMS最高允许充电总电压单位0.1V |
| bms_max_temp | Number | 是 | BMS最高允许温度单位℃-50℃偏移量范围-50~200℃ |
| bms_soc | Float | 是 | BMS荷电状态SOC单位0.1%范围0~100% |
| bms_current_voltage | Float | 是 | BMS当前电池电压单位0.1V |
| pile_max_voltage | Float | 是 | 电桩最高输出电压单位0.1V |
| pile_min_voltage | Float | 是 | 电桩最低输出电压单位0.1V |
| pile_max_current | Float | 是 | 电桩最大输出电流单位0.1A-400A偏移量 |
| pile_min_current | Float | 是 | 电桩最小输出电流单位0.1A-400A偏移量 |
| type | String | 是 | "request" |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "charge config",
"gun_id": 1,
"type": "response"
}
```
---
## 9. 充电错误报文
> **方向**:充电桩 → 网关 → 充电桩
> **依据**GBT-27930 充电桩与BMS充电错误报文
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "charge error",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"charger_spn2560_00_timeout": 0,
"charger_spn2560_aa_timeout": 0,
"charger_time_sync_timeout": 0,
"charger_ready_timeout": 0,
"charger_status_timeout": 0,
"charger_stop_timeout": 0,
"charger_statistics_timeout": 0,
"bms_identify_timeout": 0,
"battery_param_timeout": 0,
"bms_ready_timeout": 0,
"battery_status_timeout": 0,
"battery_demand_timeout": 0,
"bms_stop_timeout": 0,
"bms_statistics_timeout": 0,
"type": "request"
}
```
所有超时字段取值0=正常1=超时2=不可信状态
| 字段 | 说明 |
|------|------|
| charger_spn2560_00_timeout | 接收SPN2560=0x00的充电机辨识报文超时 |
| charger_spn2560_aa_timeout | 接收SPN2560=0xAA的充电机辨识报文超时 |
| charger_time_sync_timeout | 接收时间同步和充电机最大输出能力报文超时 |
| charger_ready_timeout | 接收充电机完成充电准备报文超时 |
| charger_status_timeout | 接收充电机充电状态报文超时 |
| charger_stop_timeout | 接收充电机中止充电报文超时 |
| charger_statistics_timeout | 接收充电机充电统计报文超时 |
| bms_identify_timeout | 接收BMS和车辆的辨识报文超时 |
| battery_param_timeout | 接收电池充电参数报文超时 |
| bms_ready_timeout | 接收BMS完成充电准备报文超时 |
| battery_status_timeout | 接收电池充电总状态报文超时 |
| battery_demand_timeout | 接收电池充电要求报文超时 |
| bms_stop_timeout | 接收BMS中止充电报文超时 |
| bms_statistics_timeout | 接收BMS充电统计报文超时 |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "charge error",
"gun_id": 1,
"type": "response"
}
```
---
## 10. BMS中止充电
> **方向**:充电桩 → 网关 → 充电桩
> **依据**GBT-27930 充电桩与BMS充电阶段BMS中止报文
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "bms stop",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"stop_reason_soc": 0,
"stop_reason_total_voltage": 0,
"stop_reason_cell_voltage": 0,
"stop_reason_charger": 0,
"fault_insulation": 0,
"fault_connector_temp": 0,
"fault_bms_temp": 0,
"fault_connector": 0,
"fault_battery_temp": 0,
"fault_relay": 0,
"fault_voltage_detect": 0,
"fault_other": 0,
"error_current": 0,
"error_voltage": 0,
"type": "request"
}
```
所有字段取值0=正常1=中止/异常
| 字段 | 说明 |
|------|------|
| stop_reason_soc | 达到SOC目标值中止 |
| stop_reason_total_voltage | 达到总电压设定值中止 |
| stop_reason_cell_voltage | 达到单体电压设定值中止 |
| stop_reason_charger | 充电机主动中止 |
| fault_insulation | 绝缘故障 |
| fault_connector_temp | 输出连接器过温 |
| fault_bms_temp | BMS元件过温 |
| fault_connector | 充电连接器故障 |
| fault_battery_temp | 电池组温度过高 |
| fault_relay | 高压继电器故障 |
| fault_voltage_detect | 检测点2电压检测故障 |
| fault_other | 其他故障 |
| error_current | 电流过大 |
| error_voltage | 电压异常 |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "bms stop",
"gun_id": 1,
"type": "response"
}
```
---
## 11. 充电机中止充电
> **方向**:充电桩 → 网关 → 充电桩
> **依据**GBT-27930 充电桩与BMS充电阶段充电机中止报文
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "charger stop",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"stop_reason_condition": 0,
"stop_reason_manual": 0,
"stop_reason_abnormal": 0,
"stop_reason_bms": 0,
"fault_charger_temp": 0,
"fault_connector": 0,
"fault_internal_temp": 0,
"fault_power_transfer": 0,
"fault_emergency": 0,
"fault_other": 0,
"error_current": 0,
"error_voltage": 0,
"type": "request"
}
```
所有字段取值0=正常1=中止/异常
| 字段 | 说明 |
|------|------|
| stop_reason_condition | 达到充电机设定的条件 |
| stop_reason_manual | 人工中止 |
| stop_reason_abnormal | 异常中止 |
| stop_reason_bms | BMS主动中止 |
| fault_charger_temp | 充电机过温 |
| fault_connector | 充电连接器故障 |
| fault_internal_temp | 充电机内部过温 |
| fault_power_transfer | 所需电量不能传送 |
| fault_emergency | 充电机急停 |
| fault_other | 其他故障 |
| error_current | 电流不匹配 |
| error_voltage | 电压异常 |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "charger stop",
"gun_id": 1,
"type": "response"
}
```
---
## 12. 充电过程BMS需求与充电机输出
> **方向**:充电桩 → 网关 → 充电桩
> **周期**15 秒
> **依据**GBT-27930 充电过程BMS需求、充电机输出报文
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "charge process real",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"bms_voltage_demand": 680.0,
"bms_current_demand": 250.0,
"bms_charge_mode": 2,
"bms_voltage_measure": 678.5,
"bms_current_measure": 248.0,
"bms_max_cell_voltage": 4.15,
"bms_max_cell_group": 3,
"bms_soc": 85,
"bms_remain_time": 30,
"pile_voltage_output": 680.0,
"pile_current_output": 250.0,
"charge_time": 45,
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "charge process real" |
| transaction_id | String | 是 | 交易流水号 32位 |
| gun_id | Number | 是 | 枪编号 (1~N) |
| bms_voltage_demand | Float | 是 | BMS电压需求单位0.1V |
| bms_current_demand | Float | 是 | BMS电流需求单位0.1A-400A偏移量 |
| bms_charge_mode | Number | 是 | 充电模式1恒压2恒流 |
| bms_voltage_measure | Float | 是 | BMS充电电压测量值单位0.1V |
| bms_current_measure | Float | 是 | BMS充电电流测量值单位0.1A-400A偏移量 |
| bms_max_cell_voltage | Float | 是 | 最高单体蓄电池电压单位0.01V范围0~24V |
| bms_max_cell_group | Number | 是 | 最高单体电压所在组号范围0~15 |
| bms_soc | Number | 是 | 当前SOC单位%范围0~100 |
| bms_remain_time | Number | 是 | 估算剩余充电时间单位分钟范围0~600 |
| pile_voltage_output | Float | 是 | 电桩电压输出值单位0.1V |
| pile_current_output | Float | 是 | 电桩电流输出值单位0.1A-400A偏移量 |
| charge_time | Number | 是 | 累计充电时间单位分钟范围0~600 |
| type | String | 是 | "request" |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "charge process real",
"gun_id": 1,
"type": "response"
}
```
---
## 13. 充电过程BMS信息
> **方向**:充电桩 → 网关 → 充电桩
> **周期**15 秒
> **依据**GBT-27930 充电过程BMS信息报文
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "bms info real",
"transaction_id": "32010200000000111511161555350260",
"gun_id": 1,
"max_cell_voltage_no": 128,
"max_battery_temp": 45,
"max_temp_point_no": 8,
"min_battery_temp": 25,
"min_temp_point_no": 3,
"cell_voltage_status": 0,
"soc_status": 0,
"charge_current_status": 0,
"battery_temp_status": 0,
"insulation_status": 0,
"connector_status": 0,
"charge_enable": 1,
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "bms info real" |
| transaction_id | String | 是 | 交易流水号 32位 |
| gun_id | Number | 是 | 枪编号 (1~N) |
| max_cell_voltage_no | Number | 是 | 最高单体电压所在编号1偏移量范围1~256 |
| max_battery_temp | Number | 是 | 最高电池温度,单位℃,-50℃偏移量范围-50~200℃ |
| max_temp_point_no | Number | 是 | 最高温度检测点编号1偏移量范围1~128 |
| min_battery_temp | Number | 是 | 最低电池温度,单位℃,-50℃偏移量 |
| min_temp_point_no | Number | 是 | 最低温度检测点编号1偏移量 |
| cell_voltage_status | Number | 是 | 单体电压过高/过低0正常1过高2过低 |
| soc_status | Number | 是 | SOC过高/过低0正常1过高2过低 |
| charge_current_status | Number | 是 | 充电过电流0正常1过流2不可信 |
| battery_temp_status | Number | 是 | 电池温度过高0正常1过高2不可信 |
| insulation_status | Number | 是 | 绝缘状态0正常1异常2不可信 |
| connector_status | Number | 是 | 输出连接器连接状态0正常1异常2不可信 |
| charge_enable | Number | 是 | 充电禁止0禁止1允许 |
| type | String | 是 | "request" |
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "bms info real",
"gun_id": 1,
"type": "response"
}
```
---
## 14. 结算账单上传
> **方向**:充电桩 → 网关 → 充电桩
充电结束生成结算账单上传。若未收到响应间隔30秒重试一次最多重试3次。收到成功响应后充电桩本地删除该账单。
**Request (充电桩 → 网关)**
```json
{
"id": 1,
"cmd": "settlement bill",
"transaction_id": "55031412782305012018061910262392",
"gun_id": 1,
"start_time": 1584349487,
"end_time": 1584349487,
"billing": [
[1.30000, 0.0000, 0.0000, 0.0000],
[1.30000, 0.0000, 0.0000, 0.0000],
[1.30000, 0.0000, 0.0000, 0.0000],
[1.30000, 0.0000, 0.0000, 0.0000]
],
"meter_start": 0.0000,
"meter_end": 0.0000,
"total_energy": 0.0000,
"total_energy_loss": 0.0000,
"total_amount": 0.0000,
"vin": "",
"trade_type": 2,
"trade_time": 1584349487,
"stop_reason": 0,
"card_physical_id": "D14B0A54",
"type": "request"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "settlement bill" |
| transaction_id | String | 是 | 交易流水号 32位 |
| gun_id | Number | 是 | 枪编号 (1~N) |
| start_time | Number | 是 | 充电开始时间Unix时间戳 |
| end_time | Number | 是 | 充电结束时间Unix时间戳 |
| billing | Array | 是 | 尖峰平谷计费数组4行顺序[尖,峰,平,谷],每行:[单价(.5f), 电量(.4f), 计损电量(.4f), 金额(.4f)] |
| meter_start | Float | 是 | 电表总起值(kWh),四位小数 |
| meter_end | Float | 是 | 电表总止值(kWh),四位小数 |
| total_energy | Float | 是 | 总电量(kWh),四位小数 |
| total_energy_loss | Float | 是 | 计损总电量(kWh),四位小数 |
| total_amount | Float | 是 | 消费金额(元),含电费和服务费,四位小数 |
| vin | String | 是 | 电动汽车VIN码17位ASCII |
| trade_type | Number | 是 | 交易标识1=app启动2=卡启动4=离线卡启动5=VIN码启动 |
| trade_time | Number | 是 | 交易时间Unix时间戳 |
| stop_reason | Number | 是 | 停止原因见云快充附录13.1 |
| card_physical_id | String | 是 | 物理卡号,默认为空 |
| type | String | 是 | "request" |
**billing 数组格式:**
```
[尖, 峰, 平, 谷] ← 4行固定顺序
└─ [单价(.5f), 电量(.4f), 计损电量(.4f), 金额(.4f)]
```
**Response (网关 → 充电桩)**
```json
{
"id": 1,
"cmd": "settlement bill",
"transaction_id": "55031412782305012018061910262392",
"gun_id": 1,
"result": 1,
"type": "response"
}
```
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Number | 是 | 桩编码 (1~6) |
| cmd | String | 是 | "settlement bill" |
| transaction_id | String | 是 | 交易流水号 32位 |
| gun_id | Number | 是 | 枪编号 (1~N) |
| result | Number | 是 | 账单上传结果1=成功0=失败 |
| type | String | 是 | "response" |
> **重试机制**若未收到响应间隔30秒重试一次最多重试3次。收到成功响应后本账单在充电桩本地删除。
---
## 附录:协议汇总表
| 编号 | cmd | 请求方 | 响应方 | 触发方式 |
|------|-----|--------|--------|----------|
| 1 | online | 充电桩 | 网关 | 上电 |
| 2 | heartbeat | 充电桩 | 网关 | 5~10s周期 |
| 3 | start charging | 网关 | 充电桩 | 网关下发 |
| 4 | end charging | 网关 | 充电桩 | 网关下发 |
| 5 | proactive end charging | 充电桩 | 网关 | 桩主动 |
| 6 | realtime data | 充电桩 | 网关 | 周期上送 |
| 7 | bms info | 充电桩 | 网关 | 桩主动 |
| 8 | charge config | 充电桩 | 网关 | 桩主动 |
| 9 | charge error | 充电桩 | 网关 | 桩主动 |
| 10 | bms stop | 充电桩 | 网关 | 桩主动 |
| 11 | charger stop | 充电桩 | 网关 | 桩主动 |
| 12 | charge process real | 充电桩 | 网关 | 15s周期 |
| 13 | bms info real | 充电桩 | 网关 | 15s周期 |
| 14 | settlement bill | 充电桩 | 网关 | 充电结束 |