ZL.IotHub.Server 2.3.0

dotnet add package ZL.IotHub.Server --version 2.3.0
                    
NuGet\Install-Package ZL.IotHub.Server -Version 2.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZL.IotHub.Server" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZL.IotHub.Server" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="ZL.IotHub.Server" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZL.IotHub.Server --version 2.3.0
                    
#r "nuget: ZL.IotHub.Server, 2.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZL.IotHub.Server@2.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZL.IotHub.Server&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=ZL.IotHub.Server&version=2.3.0
                    
Install as a Cake Tool

ZL.IotHub.Server

把采集运行时暴露为 HTTP REST + SignalR 服务(ASP.NET Core)。

目标框架:net8.0 / net10.0(不支持 netstandard2.0 / net48)


装什么

dotnet add package ZL.IotHub.Server

三步接入

using ZL.IotHub.Server;

var builder = WebApplication.CreateBuilder(args);

// ① 注册 SCADA 服务(可传 IConfiguration;不传则用宿主默认配置)
builder.Services.AddZlScada(builder.Configuration);

var app = builder.Build();

// ② 挂载全部默认端点(= 静态文件 + CORS + Health + SignalR Hub + REST)
app.MapZlScada();

app.Run();

也可以只挂你需要的部分(MapZlScada() 就是下面三者的组合):

app.MapZlScadaHealth();     // GET /health
app.MapZlScadaHub();        // SignalR:默认 /scadahub
app.MapZlScadaRestApi();    // REST:默认前缀 /api

默认端点(实测自 ScadaServerExtensions.cs)

方法 路径 用途
GET /health 健康检查
GET /api/devices 设备与连接状态
GET /api/tags/{deviceId} 该设备的点位快照
GET /api/tags/{deviceId}/{tagId} 单个点位当前值
POST /api/tags/{deviceId}/{tagId} 写单个点位
POST /api/devices/{deviceId}/batch-read 批量读
POST /api/devices/{deviceId}/batch-write 批量写
GET /api/metrics 运行时指标快照
SignalR /scadahub 增量推送(ScadaHub)

前缀可改:app.MapZlScadaRestApi("/v1");Hub 路径可改:app.MapZlScadaHub("/hubs/plc")。


鉴权(可选)

builder.Services.AddZlScadaAuth(builder.Configuration);
...
app.UseZlScadaAuth(builder.Configuration);

边界

  • 默认无鉴权:MapZlScada() 会在检测到"无鉴权暴露"时只告警不阻断 (把选择权和知情权留给部署者)⇒ 暴露公网前必须自行加认证(用 AddZlScadaAuth/UseZlScadaAuth 或网关)
  • 面向内网 / 边缘部署
  • 只依赖 ZL.IotEngine + ZL.IotDriver,不含业务逻辑
  • AddZlScada() 注册的是 SCADA 侧服务;采集运行时仍需宿主自行初始化(见 ZL.IotEngine README)

OPC UA 对外暴露(2026-11-16 新增)

作用:把采集到的任意协议数据自动包装为 OPC UA,供 SCADA / MES 读取。

用户只需要做三件事

  1. 配置设备(Scada:Devices)
  2. 配点表
  3. 启动

不需要知道任何细节

OPC UA 地址、NodeId 规则、命名空间索引、默认安全策略全部自动生成,并在启动日志打印:

[OPC UA] 已对外暴露:opc.tcp://<主机名>:4840 | 设备 2 个 / 点位 37 个 | 节点规则 ns=2;s=tag.<设备>.<点位>

在 UaExpert / Prosys 里连 opc.tcp://<主机名>:4840,即可看到: Objects → <设备名> → <点位名>

关闭它(不想要 OPC UA 时)

"OpcUa": { "Enabled": false }

默认值与安全

项 默认 说明
Enabled true 零配置即得 OPC UA 能力
Port 4840 OPC UA 标准端口

默认使用 None(明文) 安全策略,仅建议内网 / POC;生产请启用安全策略并配置证书(见 docs/704 §五)。 启动日志在端口为 4840 时会明确打印该警告,不静默。

失败不会拖垮主功能

若 OPC UA 起不来(例如 4840 被占用),只记 Error 日志并安全收尾; HTTP REST / SignalR / 采集全部照常工作,但绝不静默(避免"以为在暴露其实没有")。

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 72 11/19/2026
2.2.18 109 11/7/2026
2.2.17 124 10/27/2026
2.2.16-beta.3 69 10/15/2026
2.2.16-beta.2 72 10/15/2026
2.2.15 108 10/8/2026
2.2.14 114 10/6/2026