EasyEdge.Client
1.0.0
dotnet add package EasyEdge.Client --version 1.0.0
NuGet\Install-Package EasyEdge.Client -Version 1.0.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="EasyEdge.Client" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyEdge.Client" Version="1.0.0" />
<PackageReference Include="EasyEdge.Client" />
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 EasyEdge.Client --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EasyEdge.Client, 1.0.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 EasyEdge.Client@1.0.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=EasyEdge.Client&version=1.0.0
#tool nuget:?package=EasyEdge.Client&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EasyEdge.Client
EasyEdge 工业数据采集网关客户端 SDK,支持 MQTT 数据订阅和 RPC 远程读写 PLC 数据。
安装
dotnet add package EasyEdge.Client
快速开始
基本使用
using EasyEdge.Client;
// 创建客户端
var client = new EasyEdgeClient(new EasyEdgeClientOptions
{
Host = "192.168.1.100",
Port = 1883,
Username = "admin",
Password = "123456"
});
// 连接
await client.ConnectAsync();
// 订阅设备数据
client.OnDeviceData += (sender, e) =>
{
Console.WriteLine($"设备: {e.DeviceName}");
foreach (var (tag, value) in e.Data)
{
Console.WriteLine($" {tag}: {value}");
}
};
await client.SubscribeAsync("PLC-001");
// RPC 读取
var readResult = await client.ReadAsync("PLC-001", "温度", "压力");
if (readResult.Success)
{
Console.WriteLine($"温度: {readResult.Data["温度"]}");
}
// RPC 写入
var writeResult = await client.WriteAsync("PLC-001", "温度设定值", 30.0);
// 断开连接
await client.DisconnectAsync();
依赖注入 (ASP.NET Core)
// Program.cs
using EasyEdge.Client.Extensions;
builder.Services.AddEasyEdgeClient(options =>
{
options.Host = "192.168.1.100";
options.Port = 1883;
options.Username = "admin";
options.Password = "123456";
});
// 或使用快捷方式
builder.Services.AddEasyEdgeClient("192.168.1.100");
// 在控制器或服务中使用
public class MyService
{
private readonly IEasyEdgeClient _client;
public MyService(IEasyEdgeClient client)
{
_client = client;
}
public async Task<double> GetTemperatureAsync()
{
var result = await _client.ReadAsync("PLC-001", "温度");
return result.Success ? Convert.ToDouble(result.Data["温度"]) : 0;
}
}
API 参考
连接管理
ConnectAsync()- 连接到网关DisconnectAsync()- 断开连接IsConnected- 连接状态ConnectionStateChanged- 连接状态变更事件
数据订阅
SubscribeAsync(deviceName)- 订阅设备数据SubscribeAllAsync()- 订阅所有设备UnsubscribeAsync(deviceName)- 取消订阅OnDeviceData- 数据接收事件
RPC 读取
ReadAsync(deviceName, tagNames)- 读取指定点位ReadAllAsync(deviceName)- 读取所有点位
RPC 写入
WriteAsync(deviceName, tagName, value)- 写入单个点位WriteAsync(deviceName, values)- 批量写入
配置选项
| 选项 | 默认值 | 说明 |
|---|---|---|
| Host | 127.0.0.1 | 网关地址 |
| Port | 1883 | MQTT端口 |
| Username | admin | 用户名 |
| Password | 123456 | 密码 |
| AutoReconnect | true | 自动重连 |
| RpcTimeoutSeconds | 30 | RPC超时 |
许可证
MIT License
| Product | Versions 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 is compatible. 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 was computed. 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.
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- MQTTnet (>= 5.0.1.1416)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- MQTTnet (>= 5.0.1.1416)
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 |
|---|---|---|
| 1.0.0 | 114 | 1/19/2026 |