AB-EtherNet (PLC-5 / SLC-500) 驱动
概述
AB-EtherNet — Allen-Bradley 传统 PLC-5 / SLC-500 PLC 所使用的 CSP(Client/Server Protocol) over EtherNet + PCCC 命令。它与 ControlLogix 的 EtherNet/IP(CIP)相互独立,采用基于文件/元素的 logical addressing(N7:0)。2026-07 原生重写 — 已移除对旧版 Apache PLC4j ab-eth 的委托(该驱动在 CSP 连接建立后不发送请求便断开套接字,导致无法采集)。现在使用 plantpulse-plc-protocol 的自研 CSP/PCCC 实现(AbEthPLC)— 与 FINS / MELSEC 相同的原生模式。
| 项目 | 值 |
|---|---|
opc_type | AB-ETH |
| 实现类 | plantpulse.driver.protocol.ab_eth.ABEthDriver |
| 库 | 自研原生 (plantpulse-plc-protocol 的 abeth — 直接操作 CSP/PCCC socket) |
| 继承 | BaseProtocolDriver (非 PLC4j) |
| 默认端口 | 2222 (CSP — 非 EtherNet/IP 44818) |
| 状态 | 稳定 (支持老旧设备) |
| read | OK (Protected Typed Logical Read) |
| write | ❌ (只读 — 未实现 Protected Typed Logical Write) |
| 安全 | 无 |
AB-ETH 使用 CSP over TCP/2222,而不是 EtherNet/IP(CIP)的 44818 — 旧文档/表单中的 44818 属于笔误。ControlLogix(L8x / L7x)请使用 EtherNet/IP 驱动(opc_type=EIP,44818)。
AB-ETH 驱动仅适用于 PLC-5 / SLC-500 — 它使用的是 N7:0 这类传统 logical address,而非符号标签(MyTag)。
类结构
BaseProtocolDriver
└── ABEthDriver — connect() 에서 AbEthPLC(host, port, station) 생성 후 CSP register handshake
connect() 打开 AbEthPLC 套接字并执行 CSP register。read 失败时会将套接字置为无效(connected=false),促使 Edge 重新连接。
wire 格式摘要(自研实现)
- 在 CSP encapsulation(register session)之上承载 PCCC 命令。
- PCCC: PLC-5 / SLC-500 Protected Typed Logical Read (word range)。
- Logical address:
N<file>:<element>[/<bit>]。
OPC 注册选项
| 字段 | 含义 | 默认 |
|---|---|---|
opc_agent_ip | PLC IP | 192.168.0.80 |
opc_agent_port | TCP 端口 | 2222 (CSP) |
options.station | DF1 目标站号 | 1 |
options.read-timeout | 响应超时 (ms) | 3000 |
标签 plc_address 格式
N<file>:<element>[/<bit>]:<TYPE>[[size]]
文件字符固定为 N(Integer)。TYPE 为必填:
| 表示 | 含义 |
|---|---|
N7:0:WORD | Integer file 7, element 0 — 16-bit |
N7:0:INTEGER | 同上 (WORD 的别名,signed 16-bit) |
N7:3:DWORD | element 3 — 32-bit |
N7:5:FLOAT | element 5 — 32-bit float |
N7:10/0:SINGLEBIT | element 10 的第 0 位 (Boolean) |
支持的 TYPE: WORD(16-bit) / INTEGER(=WORD) / DWORD(32-bit) / FLOAT(32-bit) / SINGLEBIT(单个位)。若省略 TYPE 或填写其他值,read 将返回空字符串。
.PRE / .ACC 等)定时器/计数器的 .PRE / .ACC 子字段以及 F8:(Float file)前缀表示法,原生解析器不予接受。Float 值请使用 N<file>:<elem>:FLOAT 读取。
支持 / 不支持
- read: Protected Typed Logical Read (word range) — OK。
- write: 不支持 —
isWriteSupported() = false、write()始终为false。(Protected Typed Logical Write 将后续实现。) - ControlLogix 符号标签(
MyController:Tag1): 不属于本驱动范围 — 请使用 EIP 驱动。 - DH+ / DH-485 网关路由: 不支持 — 需要直连 EtherNet 接口。
curl 注册示例
curl -X POST http://<edge-host>/api/v1/opc \
-H "Content-Type: application/json" \
-d '{
"opc_id": "OPC_ABETH_L1",
"opc_type": "AB-ETH",
"opc_name": "SLC-500 Line 1",
"opc_agent_ip": "192.168.0.80",
"opc_agent_port": "2222",
"site_id": "SITE_00001",
"auto_collect": true,
"timecycle": 1000,
"options": { "station": "1", "read-timeout": "3000" },
"tag_list": [
{"tag_id":"OPC_ABETH_L1_T01","tag_name":"Count","plc_address":"N7:0:WORD","data_type":"Integer"},
{"tag_id":"OPC_ABETH_L1_T02","tag_name":"Temp","plc_address":"N7:5:FLOAT","data_type":"Float"},
{"tag_id":"OPC_ABETH_L1_T03","tag_name":"Run","plc_address":"N7:10/0:SINGLEBIT","data_type":"Boolean"}
]
}'
参考
- Allen-Bradley DF1 / PCCC Programming Reference (1770-6.5.16)。
- 代码:
plantpulse-edge-driver/src/plantpulse/driver/protocol/ab_eth/ABEthDriver.java+plantpulse-plc-protocol的abeth包。 - 运维: PLC-5 / SLC-500 已停产(2017),备件可获得性下降 — 新设计建议采用 ControlLogix + EtherNet/IP。本驱动用于既有 PLC 的数据采集。