erikwang2013 / industrial-protocols-opc-ua
OPC UA Binary 协议包 — 完整 UA Binary 协议栈,支持 CreateSession/Read/Write/Browse
Package info
github.com/erikwang2013/industrial-protocols-opcua
Type:industrial-protocol
pkg:composer/erikwang2013/industrial-protocols-opc-ua
Requires
- php: >=8.1
- erikwang2013/industrial-protocols-kernel: *
README
OPC UA (Unified Architecture) Binary 协议栈,TCP 端口 4840。实现 Hello/Acknowledge 握手、SecureChannel 安全通道、SessionManager 会话管理、Read/Write/Browse 服务。
安装
composer require erikwang2013/industrial-protocols-opcua
架构
OpcUaDriver(TCP)→ UaTcpMessage(Hello/Ack)→ SecureChannel(安全通道)→ SessionManager(CreateSession/ActivateSession)→ Read/Write/Browse 服务。BinaryEncoder/Decoder 二进制编解码。NodeId/StatusCode/Variant 类型系统。
功能
TCP Hello/Acknowledge 握手、SecureChannel Open/Close、CreateSession/ActivateSession、Read/Write/Browse 服务、NodeId 多种格式(ns=0;i=2258 / ns=2;s=Temp / i=2258 / 原始数值)、Variant 类型(Int32/Double/String/Bool/NodeId)、StatusCode 状态码
使用说明
$conn = $kernel->getConnectionManager()->connect('opcua-server'); $result = $conn->read('ns=0;i=2258'); // CurrentTime $result = $conn->read('ns=2;s=Temperature'); // 字符串标识 $conn->write(['ns=2;s=SetPoint' => 100.0]); // 写入 $children = $conn->browse('i=85'); // 浏览 Objects
配置示例
'devices' => [ 'opcua-server' => [ 'protocol' => 'opc-ua', 'variant' => 'binary', 'host' => '192.168.1.100', 'port' => 4840, 'timeout' => 5000, 'application_uri' => 'urn:myapp:industrial-protocols', 'session_name' => 'PHP-OPCUA-Client', ], ],
兼容框架
Laravel / Webman / Hyperf / ThinkPHP / Yii2 / Plain PHP
系统要求
- PHP >= 8.1
- Composer
- erikwang2013/industrial-protocols-kernel
License
MIT — Copyright (c) 2026 erik erik@erik.xyz — https://erik.xyz