Repository navigation
✨ 新增 OPC UA Client 通信协议 - #2
Merged
Merged
Conversation
新增 OPC UA 客户端,复用统一的 IProtocol 生命周期与 IProtocolManager 实例管理, 但保持自己的“节点、会话、订阅、安全”模型,不抽象成地址读写接口,公共 API 也不泄漏 官方 SDK 类型。 主要内容: - 新增 IOpcUaProtocol / IOpcUaCommunicationConfig / IOpcUaSubscription / IOpcUaCredentialProvider 接口,以及 OpcUaProtocolClient 实现 - 轻量模型:OpcUaNodeId、OpcUaValue、OpcUaWriteResult、OpcUaBrowseNode、 OpcUaMethodResult、OpcUaMonitoredItem、OpcUaSubscriptionOptions 及相关枚举 - 单/批量读写(批量返回逐项状态)、浏览、方法调用、数据变化订阅、KeepAlive 与自动重连 - 安全:三种身份(匿名/用户名密码/客户端证书)与 None/Sign/SignAndEncrypt, 严格证书校验;密码不进入实例键/日志/异常,经 CredentialKey + CredentialProvider 解析 - 配置在创建时克隆为快照;订阅通知经内部队列派发,不阻塞 SDK Publish 流程 - 接入 ProtocolManager 与 GetInstanceKey;依赖 OPC Foundation 官方客户端并锁定统一版本 - 为 net481 补充 IsExternalInit 占位类型以支持 record/init - 补充根目录与 docs 文档,以及单元测试与集成测试 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request 描述
首版将
MAS.Communication扩展为支持 OPC UA Client。OPC UA 复用统一的IProtocol生命周期与IProtocolManager实例管理,但保持自己的“节点、会话、订阅、安全”模型,不抽象成 Modbus/MC 那样的地址读写接口,公共 API 也不泄漏官方 SDK 类型。提交前检查
net481/net8.0/net9.0/net10.0均 0 警告 0 错误)变更类型
目的
问题描述:
IOpcUaProtocol暴露业务能力,IOpcUaCommunicationConfig提供配置预期影响:
CommProtocol增加OpcUa、ProtocolManager.CreateProtocol与CommunicationConfigExtensions.GetInstanceKey各增加一个分支主要内容
IOpcUaProtocol、IOpcUaCommunicationConfig、IOpcUaSubscription、IOpcUaCredentialProviderOpcUaProtocolClient(生命周期映射 + KeepAlive +SessionReconnectHandler自动重连)、OpcUaSubscription(内部队列派发,不阻塞 SDK Publish 流程)、OpcUaEndpointSelector/OpcUaCertificateManager/OpcUaValueConverterOpcUaNodeId、OpcUaValue、OpcUaReadItem、OpcUaWriteItem、OpcUaWriteResult、OpcUaBrowseNode、OpcUaMethodResult、OpcUaMonitoredItem、OpcUaSubscriptionOptions、OpcUaUserCredential及枚举OpcUaServiceException(含StatusCode/诊断信息)、OpcUaCertificateExceptionNone/Sign/SignAndEncrypt,严格证书校验(默认不自动接受不受信任证书)OpcUa|规范化EndpointUrl|SecurityMode|SecurityPolicyUri|IdentityType|IdentityId,不包含密码/凭据引用Core/Client/Configuration,通过$(OpcUaVersion)锁定统一版本(1.5.378.156);Microsoft.Extensions.DependencyInjection.Abstractions升级到 10.0.8 以满足传递依赖IsExternalInit占位类型(src/Polyfills/CompilerPolyfills.cs)以支持record/initREADME.md、src/README.md、docs/index.md、docs/content/toc.yml,新增docs/content/MAS.Communication.OpcUaProtocol.md评估
性能影响:
兼容性问题:
CommProtocol.OpcUa枚举项(追加在末尾,保持既有序号不变)测试
tests/OpcUaProtocol/OpcUaConnectionTest.cs,共 5 项):通过环境变量MAS_OPCUA_ENDPOINT指定端点,无法连接时标记Inconclusive;已在本地StandardServer上验证 连接、单/泛型/批量读取(含部分失败逐项状态)、浏览、数据变化订阅 全部通过额外信息
ITelemetryContext新 API),OPC UA 实现文件在文件作用域内针对性抑制了CS0618,遥测 API 迁移暂不在首版范围src/Helpers/StructBinaryHelper.cs将#if !NETFRAMEWORK条件简化为s[..attr.Length](在net481上同样可编译)Copyright (c) MAS(厦门威光) Corporation. All rights reserved.