PROFINET 驱动
概述
PROFINET IO — 基于工业以太网的 fieldbus。2026-07 原生重写 — 已移除旧的 Apache PLC4j profinet 委托方式(PLC4X profinet 使用 raw Ethernet(EtherType 0x8892,以 libpcap 为前提)+ canRead()=false,因此在 Edge 上 connect 本身就会异常中断)。目前使用 plantpulse-plc-protocol 自研的 acyclic Read-Implicit(DCE/RPC over UDP 34964) 实现(ProfinetPLC)—— 该服务无需 AR(Connect),以 ARUUID=0 读取 record(I&M 数据等工程工具路径),与轮询式采集器高度契合。
| 项目 | 值 |
|---|---|
opc_type | PROFINET |
| 实现类 | plantpulse.driver.protocol.profinet.ProfinetDriver |
| 库 | 自研原生 (plantpulse-plc-protocol 的 profinet — DCE/RPC Read-Implicit) |
| 继承 | BaseProtocolDriver (非 PLC4j) |
| 默认端口 | 34964 (PROFINET CM DCE/RPC, UDP) |
| 状态 | 稳定 (acyclic record 轮询) |
| read | OK (Read-Implicit, acyclic record) |
| write | ❌ (只读 — 未实现 Write record) |
| 安全 | 无 |
仅支持 acyclic record — 不支持周期性 RT
本驱动仅用于 acyclic record 轮询。不支持周期性 IO 交换(RT/IRT,L2 raw Ethernet)—— 如需 RT,则需要单独的 raw-ethernet(pcap, CAP_NET_RAW)方案。也不使用 GSDML 文件(直接指定 record 坐标)。
类结构
BaseProtocolDriver
└── ProfinetDriver — connect() 에서 ProfinetPLC(host, port) 생성 (UDP connectionless)
UDP 是无连接的,因此没有握手过程 —— 活性检测采用 read 失败时置为无效的方式(AB-ETH/BACnet 模式)。请求→响应的往返在 ProfinetPLC 内串行化(one outstanding request),响应通过 activityUuid + sequenceNumber 回显校验来拒绝过期报文。
OPC 注册选项
| 字段 | 含义 | 默认值 |
|---|---|---|
opc_agent_ip | PROFINET 设备 IP | 192.168.1.30 |
opc_agent_port | UDP 端口 | 34964 (为 0 则自动) |
options.read-timeout | 响应超时 (ms) | 3000 |
options.api | PROFINET API 编号 | 0 |
已移除旧的 PLC4X 选项
旧表单中的 gsd-directory / dap-id / ip-address 选项原生实现不再接受(已移除)。record 坐标通过标签地址直接指定。
标签 plc_address 格式 (新约定)
<slot>:<subslot>:<index>[:<TYPE>]
index: 十进制或0x十六进制 (例:I&M0 =0xAFF0)TYPE(默认WORD):WORD(u16) /INT(i16) /DINT(i32) /DWORD(u32) /REAL(float32) /BOOL/STRING[n](默认 n=32)。record data 为 big-endian。
| 写法 | 含义 |
|---|---|
0:1:0x0001:REAL | 将 slot0 / subslot1 的 record 0x0001 按 float32 解析 |
0:1:2 | 将 record 2 按 WORD(u16) 解析 — 省略 TYPE |
0:1:0xAFF0:STRING[32] | I&M0 区域字符串 |
support / 不支持
- read: DCE/RPC Read-Implicit (acyclic record) — OK。
- write: 不支持 —
isWriteSupported() = false、write()始终为false。(Write record 后续支持。) - 周期性 IO (RT/IRT): 不支持 — 仅支持 record 轮询。
- DCP discovery / 自动 IP 配置: 不支持 — 需直接指定 IP。
- PROFIsafe / PROFIenergy profile: 不支持。
curl 注册示例
curl -X POST http://<edge-host>/api/v1/opc \
-H "Content-Type: application/json" \
-d '{
"opc_id": "OPC_PROFINET_IO1",
"opc_type": "PROFINET",
"opc_name": "PN Device 1",
"opc_agent_ip": "192.168.1.30",
"opc_agent_port": "34964",
"site_id": "SITE_00001",
"auto_collect": true,
"timecycle": 1000,
"options": { "read-timeout": "3000" },
"tag_list": [
{"tag_id":"OPC_PROFINET_IO1_T01","tag_name":"Rec1","plc_address":"0:1:0x0001:REAL","data_type":"Float"},
{"tag_id":"OPC_PROFINET_IO1_T02","tag_name":"Rec2","plc_address":"0:1:2:WORD","data_type":"Integer"}
]
}'
参考
- Profinet IO — IEC 61158-6-10 / IEC 61784。Read-Implicit = CM opnum 5。
- 代码:
plantpulse-edge-driver/src/plantpulse/driver/protocol/profinet/ProfinetDriver.java+plantpulse-plc-protocol的profinet包。 - 运维: 若目的是采集 S7 PLC 内存值,S7 (ISO-on-TCP) 驱动更为通用 —— 本驱动用于 PROFINET 设备的 record(I&M 等)轮询。