掌握 OPC UA 客户端开发:从基础架构到高级监控的完整指南

news2026/4/15 20:03:11
掌握 OPC UA 客户端开发从基础架构到高级监控的完整指南【免费下载链接】opc-ua-clientVisualize and control your enterprise using OPC Unified Architecture (OPC UA) and Visual Studio.项目地址: https://gitcode.com/gh_mirrors/op/opc-ua-client在工业自动化与物联网领域OPC UAOPC Unified Architecture已成为设备间数据交换的黄金标准协议。Workstation.UaClient 作为一个功能完整的 .NET 客户端库为开发者提供了与工业设备通信的强大工具。本文将深入探讨如何高效利用这个库构建可靠的工业数据采集系统涵盖从环境搭建到生产部署的全流程。OPC UA 协议基础与架构设计OPC UA 协议的核心优势在于其平台无关性、安全性和信息建模能力。与传统的 OPC Classic 相比OPC UA 基于服务导向架构SOA支持跨平台通信并通过完善的安全机制保障数据传输的机密性和完整性。Workstation.UaClient 库采用分层架构设计主要包含以下几个关键组件通信通道层Channels处理底层的 TCP 连接、安全会话建立和消息编码解码服务模型层ServiceModel实现 OPC UA 规范定义的各种服务如浏览、读取、写入、订阅等数据类型系统提供丰富的内置数据类型支持包括扩展节点标识、本地化文本、变体类型等安全认证模块支持匿名、用户名密码和 X.509 证书等多种身份验证方式开发环境配置与项目初始化系统要求与依赖管理在开始开发前确保您的开发环境满足以下要求.NET 6.0 SDK或更高版本Visual Studio 2022或Visual Studio Code搭配 C# 扩展Git版本控制系统项目获取与解决方案构建通过 Git 克隆项目仓库并构建解决方案# 克隆项目代码库 git clone https://gitcode.com/gh_mirrors/op/opc-ua-client.git # 进入项目目录 cd opc-ua-client # 恢复 NuGet 包依赖 dotnet restore # 构建整个解决方案 dotnet build opc-ua-client.sln项目解决方案包含三个主要部分UaClient- 核心客户端库提供所有 OPC UA 通信功能UaClient.UnitTests- 单元测试项目确保代码质量CustomTypeLibrary- 自定义类型库示例展示如何扩展数据类型包引用与依赖注入配置在您的应用程序项目中通过 NuGet 包管理器或 dotnet CLI 添加依赖!-- 项目文件中的包引用 -- ItemGroup PackageReference IncludeWorkstation.UaClient Version1.0.0 / /ItemGroup对于依赖注入配置可以在 Startup 类中进行初始化public class Startup { public void ConfigureServices(IServiceCollection services) { // 注册 OPC UA 应用服务 services.AddSingletonIUaApplication(provider { var builder new UaApplicationBuilder() .SetApplicationUri($urn:{Dns.GetHostName()}:MyIndustrialApp) .SetDirectoryStore(./pki) .SetIdentity(new AnonymousIdentity()); return builder.Build(); }); // 注册其他服务 services.AddControllers(); services.AddEndpointsApiExplorer(); services.AddSwaggerGen(); } }核心连接管理与会话建立基础连接配置建立 OPC UA 连接的第一步是正确配置客户端应用程序描述和安全策略using Workstation.ServiceModel.Ua; using Workstation.ServiceModel.Ua.Channels; public class OpcUaConnectionManager { private readonly ILoggerOpcUaConnectionManager _logger; public OpcUaConnectionManager(ILoggerOpcUaConnectionManager logger) { _logger logger; } public async TaskClientSessionChannel CreateSecureSessionAsync( string endpointUrl, IUserIdentity userIdentity null) { var appDescription new ApplicationDescription { ApplicationName IndustrialMonitoringSystem, ApplicationUri $urn:{Environment.MachineName}:IndustrialMonitoringSystem, ApplicationType ApplicationType.Client, ProductUri urn:mycompany:industrial-monitor }; // 配置传输选项 var transportOptions new ClientTransportChannelOptions { LocalReceiveBufferSize 65536, LocalSendBufferSize 65536, LocalMaxMessageSize 16777216, LocalMaxChunkCount 1024 }; // 创建会话通道 var channel new ClientSessionChannel( appDescription, certificateStore: null, // 使用默认证书存储 userIdentity ?? new AnonymousIdentity(), endpointUrl, SecurityPolicyUris.Basic256Sha256, transportOptions); try { await channel.OpenAsync(); _logger.LogInformation( OPC UA 会话已建立 - 端点: {EndpointUrl}, 会话ID: {SessionId}, channel.RemoteEndpoint.EndpointUrl, channel.SessionId); return channel; } catch (Exception ex) { _logger.LogError(ex, OPC UA 会话建立失败); await channel.AbortAsync(); throw; } } }安全策略与身份验证OPC UA 提供多层次的安全机制Workstation.UaClient 支持所有标准安全策略public enum SecurityConfiguration { // 无安全策略仅用于测试环境 None, // 基本安全策略 Basic128Rsa15, Basic256, Basic256Sha256, // 增强安全策略 Aes128Sha256RsaOaep, Aes256Sha256RsaPss } public class SecurityManager { public IUserIdentity GetUserIdentity(SecurityLevel level) { return level switch { SecurityLevel.Anonymous new AnonymousIdentity(), SecurityLevel.UsernamePassword new UserNameIdentity(operator, securePassword123), SecurityLevel.Certificate LoadX509Identity(), _ new AnonymousIdentity() }; } private X509Identity LoadX509Identity() { // 加载 X.509 证书用于身份验证 var certificate new X509Certificate2(client.pfx, certPassword); return new X509Identity(certificate); } }数据访问模式与监控实现节点浏览与发现服务在 OPC UA 中所有数据都通过节点Nodes组织成层次结构。浏览服务允许客户端发现服务器提供的数据结构public class NodeBrowser { private readonly ClientSessionChannel _channel; public async TaskListNodeDescription BrowseNodesAsync(NodeId startingNode, uint maxResults 100) { var browseRequest new BrowseRequest { NodesToBrowse new[] { new BrowseDescription { NodeId startingNode, BrowseDirection BrowseDirection.Forward, ReferenceTypeId ReferenceTypeIds.HierarchicalReferences, IncludeSubtypes true, NodeClassMask (uint)(NodeClass.Object | NodeClass.Variable), ResultMask (uint)BrowseResultMask.All } }, RequestedMaxReferencesPerNode maxResults }; var response await _channel.BrowseAsync(browseRequest); if (response.Results?[0].References ! null) { return response.Results[0].References .Select(r new NodeDescription { NodeId r.NodeId, BrowseName r.BrowseName, DisplayName r.DisplayName, NodeClass r.NodeClass }) .ToList(); } return new ListNodeDescription(); } } public class NodeDescription { public NodeId NodeId { get; set; } public QualifiedName BrowseName { get; set; } public LocalizedText DisplayName { get; set; } public NodeClass NodeClass { get; set; } }数据读取与写入操作读取和写入是 OPC UA 中最基本的操作。以下示例展示如何高效地进行批量数据操作public class DataAccessService { private readonly ClientSessionChannel _channel; public async TaskDictionaryNodeId, DataValue ReadMultipleVariablesAsync( IEnumerableNodeId nodeIds, DateTime? sourceTimestamp null) { var readValueIds nodeIds.Select(nodeId new ReadValueId { NodeId nodeId, AttributeId AttributeIds.Value, IndexRange null, DataEncoding null }).ToArray(); var readRequest new ReadRequest { NodesToRead readValueIds, TimestampsToReturn TimestampsToReturn.Both, MaxAge 0 }; var response await _channel.ReadAsync(readRequest); var results new DictionaryNodeId, DataValue(); for (int i 0; i nodeIds.Count(); i) { results[nodeIds.ElementAt(i)] response.Results[i]; } return results; } public async TaskListStatusCode WriteVariablesAsync( DictionaryNodeId, object valuesToWrite) { var writeValues valuesToWrite.Select(kvp new WriteValue { NodeId kvp.Key, AttributeId AttributeIds.Value, Value new DataValue { Value kvp.Value, SourceTimestamp DateTime.UtcNow, ServerTimestamp DateTime.UtcNow, StatusCode StatusCodes.Good } }).ToArray(); var writeRequest new WriteRequest { NodesToWrite writeValues }; var response await _channel.WriteAsync(writeRequest); return response.Results.ToList(); } }图现代工业自动化生产线中的 OPC UA 应用场景 - 展示机器人协同工作与数据采集订阅模式与实时数据监控订阅Subscription是 OPC UA 的核心特性之一允许客户端实时接收数据变化通知[Subscription( endpointUrl: opc.tcp://plc1.plant.local:4840, publishingInterval: 250, keepAliveCount: 10, lifetimeCount: 30, maxNotificationsPerPublish: 1000)] public class ProductionLineMonitor : SubscriptionBase { private readonly ILoggerProductionLineMonitor _logger; public ProductionLineMonitor(ILoggerProductionLineMonitor logger) { _logger logger; } // 监控温度传感器 [MonitoredItem(nodeId: ns2;sLine1.Machine1.Temperature)] public double MachineTemperature { get _machineTemperature; set { if (SetProperty(ref _machineTemperature, value)) { _logger.LogInformation(机器温度更新: {Temperature}°C, value); // 温度阈值检查 if (value 85.0) { OnTemperatureAlert?.Invoke(this, new TemperatureAlertEventArgs { MachineId Machine1, Temperature value, Timestamp DateTime.UtcNow }); } } } } private double _machineTemperature; // 监控生产计数器 [MonitoredItem(nodeId: ns2;sLine1.ProductionCounter)] public uint ProductionCount { get _productionCount; set { if (SetProperty(ref _productionCount, value)) { _logger.LogDebug(生产计数更新: {Count}, value); } } } private uint _productionCount; // 监控设备状态 [MonitoredItem(nodeId: ns2;sLine1.Machine1.Status)] public DeviceStatus MachineStatus { get _machineStatus; set { if (SetProperty(ref _machineStatus, value)) { _logger.LogInformation(设备状态变更: {Status}, value); } } } private DeviceStatus _machineStatus; // 事件定义 public event EventHandlerTemperatureAlertEventArgs OnTemperatureAlert; } public class TemperatureAlertEventArgs : EventArgs { public string MachineId { get; set; } public double Temperature { get; set; } public DateTime Timestamp { get; set; } } public enum DeviceStatus { Unknown 0, Running 1, Stopped 2, Error 3, Maintenance 4 }高级配置与性能优化连接池管理与故障恢复在生产环境中连接管理和故障恢复至关重要public class ConnectionPool : IDisposable { private readonly ConcurrentDictionarystring, ClientSessionChannel _channels; private readonly ILoggerConnectionPool _logger; private readonly Timer _healthCheckTimer; public ConnectionPool(ILoggerConnectionPool logger) { _channels new ConcurrentDictionarystring, ClientSessionChannel(); _logger logger; _healthCheckTimer new Timer(HealthCheckCallback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); } public async TaskClientSessionChannel GetOrCreateChannelAsync( string endpointUrl, IUserIdentity identity) { if (_channels.TryGetValue(endpointUrl, out var channel) channel.State CommunicationState.Opened) { return channel; } // 创建新连接 var newChannel await CreateChannelInternalAsync(endpointUrl, identity); _channels[endpointUrl] newChannel; return newChannel; } private async TaskClientSessionChannel CreateChannelInternalAsync( string endpointUrl, IUserIdentity identity) { var retryPolicy Policy .HandleServiceResultException() .OrTimeoutException() .WaitAndRetryAsync(3, retryAttempt TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); return await retryPolicy.ExecuteAsync(async () { var channel new ClientSessionChannel( CreateApplicationDescription(), null, identity, endpointUrl, SecurityPolicyUris.Basic256Sha256); await channel.OpenAsync(); _logger.LogInformation(成功连接到 {EndpointUrl}, endpointUrl); return channel; }); } private void HealthCheckCallback(object state) { foreach (var kvp in _channels) { if (kvp.Value.State ! CommunicationState.Opened) { _logger.LogWarning(连接 {EndpointUrl} 状态异常: {State}, kvp.Key, kvp.Value.State); // 尝试重新连接 Task.Run(() RepairConnectionAsync(kvp.Key)); } } } public void Dispose() { _healthCheckTimer?.Dispose(); foreach (var channel in _channels.Values) { channel?.CloseAsync().Wait(5000); } } }性能调优参数配置根据具体应用场景调整性能参数{ OpcUaSettings: { ConnectionPool: { MaxConnections: 10, ConnectionTimeout: 30000, KeepAliveInterval: 10000, RetryAttempts: 3 }, SubscriptionSettings: { DefaultPublishingInterval: 100, DefaultSamplingInterval: 100, DefaultQueueSize: 10, MaxNotificationsPerPublish: 1000, Priority: 1 }, SessionSettings: { SessionTimeout: 120000, MaxRequestMessageSize: 16777216, MaxResponseMessageSize: 16777216, MaxBrowseContinuationPoints: 10 }, SecuritySettings: { SecurityPolicy: Basic256Sha256, MessageSecurityMode: SignAndEncrypt, CertificateValidation: { ValidateCertificateChain: true, ValidateCertificateRevocation: false, RejectUnknownCertificate: false } } } }错误处理与诊断策略异常处理框架建立健壮的异常处理机制对于工业应用至关重要public class OpcUaExceptionHandler { private readonly ILoggerOpcUaExceptionHandler _logger; public async TaskT ExecuteWithRetryAsyncT( FuncTaskT operation, string operationName, int maxRetries 3) { var policy PolicyT .HandleServiceResultException(ex IsTransientError(ex.StatusCode)) .OrCommunicationException() .OrTimeoutException() .WaitAndRetryAsync( maxRetries, retryAttempt TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), onRetry: (exception, timeSpan, retryCount, context) { _logger.LogWarning( 操作 {OperationName} 第 {RetryCount} 次重试等待 {Delay}ms 后执行。错误: {Error}, operationName, retryCount, timeSpan.TotalMilliseconds, exception.Message); }); return await policy.ExecuteAsync(async () { try { return await operation(); } catch (ServiceResultException sre) { _logger.LogError(sre, OPC UA 服务错误 - 操作: {Operation}, 状态码: {StatusCode}, operationName, sre.StatusCode); throw; } catch (Exception ex) { _logger.LogError(ex, 执行操作 {Operation} 时发生未知错误, operationName); throw; } }); } private bool IsTransientError(StatusCode statusCode) { // 判断是否为暂时性错误可重试 return statusCode.CodeBits switch { StatusCodes.BadTimeout true, StatusCodes.BadNoCommunication true, StatusCodes.BadWaitingForInitialData true, StatusCodes.BadServerNotConnected true, StatusCodes.BadServerHalted true, _ false }; } }诊断信息收集与分析OPC UA 提供丰富的诊断信息可用于系统监控和故障排查public class DiagnosticMonitor { private readonly ClientSessionChannel _channel; private readonly ILoggerDiagnosticMonitor _logger; public async TaskDiagnosticInfo CollectDiagnosticsAsync() { var diagnostics new DiagnosticInfo(); try { // 读取服务器状态 var serverStatus await ReadServerStatusAsync(); diagnostics.ServerStatus serverStatus; // 收集会话诊断信息 diagnostics.SessionDiagnostics await GetSessionDiagnosticsAsync(); // 收集订阅诊断信息 diagnostics.SubscriptionDiagnostics await GetSubscriptionDiagnosticsAsync(); // 检查网络延迟 diagnostics.NetworkLatency await MeasureNetworkLatencyAsync(); _logger.LogInformation(诊断信息收集完成: {Diagnostics}, diagnostics); } catch (Exception ex) { _logger.LogError(ex, 收集诊断信息时发生错误); diagnostics.LastError ex.Message; } return diagnostics; } private async TaskServerStatusDataType ReadServerStatusAsync() { var readRequest new ReadRequest { NodesToRead new[] { new ReadValueId { NodeId NodeId.Parse(VariableIds.Server_ServerStatus), AttributeId AttributeIds.Value } } }; var response await _channel.ReadAsync(readRequest); return response.Results[0].GetValueOrDefaultServerStatusDataType(); } }部署策略与生产环境考虑容器化部署配置使用 Docker 容器化部署 OPC UA 客户端应用# Dockerfile FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY [IndustrialMonitor/IndustrialMonitor.csproj, IndustrialMonitor/] RUN dotnet restore IndustrialMonitor/IndustrialMonitor.csproj COPY . . WORKDIR /src/IndustrialMonitor RUN dotnet build IndustrialMonitor.csproj -c Release -o /app/build FROM build AS publish RUN dotnet publish IndustrialMonitor.csproj -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --frompublish /app/publish . ENTRYPOINT [dotnet, IndustrialMonitor.dll]配置管理与环境变量# docker-compose.yml version: 3.8 services: opcua-client: build: . environment: - ASPNETCORE_ENVIRONMENTProduction - OPCUA_ENDPOINT_URL${OPCUA_ENDPOINT_URL} - OPCUA_SECURITY_POLICY${OPCUA_SECURITY_POLICY} - OPCUA_IDENTITY_TYPE${OPCUA_IDENTITY_TYPE} - OPCUA_USERNAME${OPCUA_USERNAME} - OPCUA_PASSWORD${OPCUA_PASSWORD} volumes: - ./pki:/app/pki - ./logs:/app/logs restart: unless-stopped healthcheck: test: [CMD, curl, -f, http://localhost:80/health] interval: 30s timeout: 10s retries: 3监控与运维最佳实践健康检查端点实现[ApiController] [Route(api/[controller])] public class HealthController : ControllerBase { private readonly ConnectionPool _connectionPool; private readonly DiagnosticMonitor _diagnosticMonitor; public HealthController( ConnectionPool connectionPool, DiagnosticMonitor diagnosticMonitor) { _connectionPool connectionPool; _diagnosticMonitor diagnosticMonitor; } [HttpGet] public async TaskIActionResult GetHealthStatus() { var healthStatus new { Timestamp DateTime.UtcNow, Application Industrial OPC UA Monitor, Version 1.0.0, Connections _connectionPool.GetConnectionStatus(), Diagnostics await _diagnosticMonitor.CollectDiagnosticsAsync(), System new { MemoryUsage GC.GetTotalMemory(false) / 1024 / 1024, CpuUsage GetCpuUsage(), ActiveThreads Process.GetCurrentProcess().Threads.Count } }; return Ok(healthStatus); } }日志记录与审计跟踪public class OpcUaAuditLogger { private readonly ILoggerOpcUaAuditLogger _logger; public void LogDataAccess( string operation, NodeId nodeId, object value null, string userId null) { _logger.LogInformation( OPC UA 数据访问审计 - 操作: {Operation}, 节点: {NodeId}, 值: {Value}, 用户: {UserId}, 时间: {Timestamp}, operation, nodeId, value, userId ?? anonymous, DateTime.UtcNow); } public void LogSecurityEvent( SecurityEventType eventType, string endpointUrl, bool success, string details null) { var logLevel success ? LogLevel.Information : LogLevel.Warning; _logger.Log(logLevel, OPC UA 安全事件 - 类型: {EventType}, 端点: {Endpoint}, 成功: {Success}, 详情: {Details}, eventType, endpointUrl, success, details); } } public enum SecurityEventType { ConnectionEstablished, ConnectionTerminated, AuthenticationSuccess, AuthenticationFailed, CertificateValidation, SessionCreated, SessionClosed }总结与后续发展Workstation.UaClient 库为 .NET 开发者提供了强大而灵活的 OPC UA 客户端实现支持从简单的数据采集到复杂的工业监控系统的各种应用场景。通过本文介绍的最佳实践您可以构建出稳定、高效且易于维护的工业数据采集应用。关键要点总结架构设计采用分层架构分离通信、业务逻辑和展示层连接管理实现连接池和自动重连机制提高系统可靠性错误处理建立完善的异常处理和重试策略性能优化合理配置订阅参数和缓冲区大小安全考虑根据安全需求选择适当的安全策略和身份验证方式监控运维实现健康检查、日志记录和诊断信息收集随着工业 4.0 和物联网技术的不断发展OPC UA 协议将继续演进。建议定期关注 OPC Foundation 的规范更新并保持客户端库的版本同步以确保兼容最新的安全特性和性能改进。通过遵循本文提供的指南和实践您将能够构建出符合工业标准、稳定可靠的数据采集系统为智能制造和工业自动化提供坚实的数据基础。【免费下载链接】opc-ua-clientVisualize and control your enterprise using OPC Unified Architecture (OPC UA) and Visual Studio.项目地址: https://gitcode.com/gh_mirrors/op/opc-ua-client创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2520944.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SpringBoot-17-MyBatis动态SQL标签之常用标签

文章目录 1 代码1.1 实体User.java1.2 接口UserMapper.java1.3 映射UserMapper.xml1.3.1 标签if1.3.2 标签if和where1.3.3 标签choose和when和otherwise1.4 UserController.java2 常用动态SQL标签2.1 标签set2.1.1 UserMapper.java2.1.2 UserMapper.xml2.1.3 UserController.ja…

wordpress后台更新后 前端没变化的解决方法

使用siteground主机的wordpress网站,会出现更新了网站内容和修改了php模板文件、js文件、css文件、图片文件后,网站没有变化的情况。 不熟悉siteground主机的新手,遇到这个问题,就很抓狂,明明是哪都没操作错误&#x…

网络编程(Modbus进阶)

思维导图 Modbus RTU(先学一点理论) 概念 Modbus RTU 是工业自动化领域 最广泛应用的串行通信协议,由 Modicon 公司(现施耐德电气)于 1979 年推出。它以 高效率、强健性、易实现的特点成为工业控制系统的通信标准。 包…

UE5 学习系列(二)用户操作界面及介绍

这篇博客是 UE5 学习系列博客的第二篇,在第一篇的基础上展开这篇内容。博客参考的 B 站视频资料和第一篇的链接如下: 【Note】:如果你已经完成安装等操作,可以只执行第一篇博客中 2. 新建一个空白游戏项目 章节操作,重…

IDEA运行Tomcat出现乱码问题解决汇总

最近正值期末周,有很多同学在写期末Java web作业时,运行tomcat出现乱码问题,经过多次解决与研究,我做了如下整理: 原因: IDEA本身编码与tomcat的编码与Windows编码不同导致,Windows 系统控制台…

利用最小二乘法找圆心和半径

#include <iostream> #include <vector> #include <cmath> #include <Eigen/Dense> // 需安装Eigen库用于矩阵运算 // 定义点结构 struct Point { double x, y; Point(double x_, double y_) : x(x_), y(y_) {} }; // 最小二乘法求圆心和半径 …

使用docker在3台服务器上搭建基于redis 6.x的一主两从三台均是哨兵模式

一、环境及版本说明 如果服务器已经安装了docker,则忽略此步骤,如果没有安装,则可以按照一下方式安装: 1. 在线安装(有互联网环境): 请看我这篇文章 传送阵>> 点我查看 2. 离线安装(内网环境):请看我这篇文章 传送阵>> 点我查看 说明&#xff1a;假设每台服务器已…

XML Group端口详解

在XML数据映射过程中&#xff0c;经常需要对数据进行分组聚合操作。例如&#xff0c;当处理包含多个物料明细的XML文件时&#xff0c;可能需要将相同物料号的明细归为一组&#xff0c;或对相同物料号的数量进行求和计算。传统实现方式通常需要编写脚本代码&#xff0c;增加了开…

LBE-LEX系列工业语音播放器|预警播报器|喇叭蜂鸣器的上位机配置操作说明

LBE-LEX系列工业语音播放器|预警播报器|喇叭蜂鸣器专为工业环境精心打造&#xff0c;完美适配AGV和无人叉车。同时&#xff0c;集成以太网与语音合成技术&#xff0c;为各类高级系统&#xff08;如MES、调度系统、库位管理、立库等&#xff09;提供高效便捷的语音交互体验。 L…

(LeetCode 每日一题) 3442. 奇偶频次间的最大差值 I (哈希、字符串)

题目&#xff1a;3442. 奇偶频次间的最大差值 I 思路 &#xff1a;哈希&#xff0c;时间复杂度0(n)。 用哈希表来记录每个字符串中字符的分布情况&#xff0c;哈希表这里用数组即可实现。 C版本&#xff1a; class Solution { public:int maxDifference(string s) {int a[26]…

【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型

摘要 拍照搜题系统采用“三层管道&#xff08;多模态 OCR → 语义检索 → 答案渲染&#xff09;、两级检索&#xff08;倒排 BM25 向量 HNSW&#xff09;并以大语言模型兜底”的整体框架&#xff1a; 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后&#xff0c;分别用…

【Axure高保真原型】引导弹窗

今天和大家中分享引导弹窗的原型模板&#xff0c;载入页面后&#xff0c;会显示引导弹窗&#xff0c;适用于引导用户使用页面&#xff0c;点击完成后&#xff0c;会显示下一个引导弹窗&#xff0c;直至最后一个引导弹窗完成后进入首页。具体效果可以点击下方视频观看或打开下方…

接口测试中缓存处理策略

在接口测试中&#xff0c;缓存处理策略是一个关键环节&#xff0c;直接影响测试结果的准确性和可靠性。合理的缓存处理策略能够确保测试环境的一致性&#xff0c;避免因缓存数据导致的测试偏差。以下是接口测试中常见的缓存处理策略及其详细说明&#xff1a; 一、缓存处理的核…

龙虎榜——20250610

上证指数放量收阴线&#xff0c;个股多数下跌&#xff0c;盘中受消息影响大幅波动。 深证指数放量收阴线形成顶分型&#xff0c;指数短线有调整的需求&#xff0c;大概需要一两天。 2025年6月10日龙虎榜行业方向分析 1. 金融科技 代表标的&#xff1a;御银股份、雄帝科技 驱动…

观成科技:隐蔽隧道工具Ligolo-ng加密流量分析

1.工具介绍 Ligolo-ng是一款由go编写的高效隧道工具&#xff0c;该工具基于TUN接口实现其功能&#xff0c;利用反向TCP/TLS连接建立一条隐蔽的通信信道&#xff0c;支持使用Let’s Encrypt自动生成证书。Ligolo-ng的通信隐蔽性体现在其支持多种连接方式&#xff0c;适应复杂网…

铭豹扩展坞 USB转网口 突然无法识别解决方法

当 USB 转网口扩展坞在一台笔记本上无法识别,但在其他电脑上正常工作时,问题通常出在笔记本自身或其与扩展坞的兼容性上。以下是系统化的定位思路和排查步骤,帮助你快速找到故障原因: 背景: 一个M-pard(铭豹)扩展坞的网卡突然无法识别了,扩展出来的三个USB接口正常。…

未来机器人的大脑:如何用神经网络模拟器实现更智能的决策?

编辑&#xff1a;陈萍萍的公主一点人工一点智能 未来机器人的大脑&#xff1a;如何用神经网络模拟器实现更智能的决策&#xff1f;RWM通过双自回归机制有效解决了复合误差、部分可观测性和随机动力学等关键挑战&#xff0c;在不依赖领域特定归纳偏见的条件下实现了卓越的预测准…

Linux应用开发之网络套接字编程(实例篇)

服务端与客户端单连接 服务端代码 #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> …

华为云AI开发平台ModelArts

华为云ModelArts&#xff1a;重塑AI开发流程的“智能引擎”与“创新加速器”&#xff01; 在人工智能浪潮席卷全球的2025年&#xff0c;企业拥抱AI的意愿空前高涨&#xff0c;但技术门槛高、流程复杂、资源投入巨大的现实&#xff0c;却让许多创新构想止步于实验室。数据科学家…

深度学习在微纳光子学中的应用

深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向&#xff1a; 逆向设计 通过神经网络快速预测微纳结构的光学响应&#xff0c;替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…