Snet.WeCon
                             
                            
                                25.288.1
                            
                        
                    
        
        
                                There is a newer version of this package available.
                                
See the version list below for details.
                    See the version list below for details.
dotnet add package Snet.WeCon --version 25.288.1
NuGet\Install-Package Snet.WeCon -Version 25.288.1
        
        
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="Snet.WeCon" Version="25.288.1" />
        
        
For projects that support PackageReference, copy this XML node into the project file to reference the package.
                    
    
    <PackageVersion Include="Snet.WeCon" Version="25.288.1" />
<PackageReference Include="Snet.WeCon" />
        
        
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 Snet.WeCon --version 25.288.1
        
        
 The NuGet Team does not provide support for this client. Please contact its maintainers for support.
                    
    
    #r "nuget: Snet.WeCon, 25.288.1"
        
        
#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 Snet.WeCon@25.288.1
        
        
#: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=Snet.WeCon&version=25.288.1
#tool nuget:?package=Snet.WeCon&version=25.288.1
        
        
 The NuGet Team does not provide support for this client. Please contact its maintainers for support.
                    
    
    <img src="https://api.shunnet.top/pic/nuget.png" height="32"> Snet - 工业协议与数据采集框架
🚀 统一 · 高效 · 灵活 · 可扩展
面向工业数据采集、传输、转发、消息中间件的全栈式解决方案
✨ 框架特色
- ✅ 所有协议公共函数 支持同步 / 异步
- ✅ 协议 读写参数统一,入参出参统一
- ✅ 支持多点转发 / 多点解析
- ✅ 快速对接与配置,可即插即用
- ✅ 支持虚拟点位(模拟测试更便捷)
- ✅ 采集协议全面支持 订阅模式
- ✅ 采集与转发协议接口统一
- ✅ 事件结果统一,并支持 异步事件
- ✅ 所有采集协议均支持 WebAPI 控制与数据获取
- ✅ 快捷二次开发,仅需继承接口与抽象类即可
- ✅ 拥有详细的日志记录,高度自定义日志输出路径与记录到数据库
- ✅ 全局支持中英文实时切换
- ✅ 支持反射,脚本解析,进程缓存,共享缓存,抽象扩展
- ✅ 支持JSON/XML/Protobuf...,一系列序列化与反序列化
🧩 核心组件
- [ Snet.Log ] 日志系统 - Verbose详细信息
- Debug调试
- Info信息
- Warning警告
- Error错误
- Fatal致命错误
 
- [ Snet.Unility ] 公共方法集合 - 字节、枚举、文件、字符串、验证、比对、转换、反射、Json、Xml、Ftp、System ...
 
- [ Snet.Model ] - 特性、数据结构、枚举、接口
 
- [ Snet.Core ] - 抽象、扩展、处理、反射、队列、中间件、脚本、订阅、虚拟地址、TCP、UDP、HTTP、WS、串口、WebApi
 
- [ Snet.Driver ] - 底层驱动通信库
 
📡 采集协议
支持 20+ 种工业通信协议,覆盖 PLC / 工控 / 电力 / DB / 标准通信 等:
三菱 / 西门子 / Modbus / 汇川 / 欧姆龙 / LSis / 基恩士 / 松下 / 罗克韦尔 / 倍福  
通用电器 / 安川 / 山武 / 永宏 / 丰炜 / 富士 / 信捷 / 麦格米特 / 横河 / 丰田 / 台达 / 维控  
电力通讯规约 / OPC (UA、DA、DAHttp) / DB (SqlServer、MySql、Oracle、SQLite)  
TEP (Tcp扩展插件) / Sim (模拟库) / 英威腾 / 西蒙
接口定义:
/// <summary>
/// 数采接口
/// </summary>
public interface IDaq : IOn, IOff, IRead, IWrite, ISubscribe, IGetStatus, IEvent, IGetParam, ICreateInstance, ILog, IWA, IGetObject, ILanguage, IDisposable { }
📬 消息中间件协议
支持常见的高性能消息中间件:
- Kafka [AdminClient、Producer、Consumer]
- Mqtt [Client (Publish/Subscribe)、Service、WSService]
- RabbitMQ [Publish、Subscribe]
- Netty [Client (Publish/Subscribe)、Service]
- NetMQ [Publish、Subscribe]
接口定义:
/// <summary>
/// 消息中间件接口
/// </summary>
public interface IMq : IOn, IOff, IProducer, IConsumer, IGetStatus, IEvent, IGetParam, ICreateInstance, ILog, ILanguage, IDisposable { }
🖥️ 协议服务端 (数据模拟)
- Mqtt 服务端
- Mqtt WebSocket 服务端
- OpcUa 服务端
- Socket 服务端
- WebSocket 服务端
⚡ 实例创建方式
支持 无参、有参、单例、接口化实例 等多种方式,快速上手:
//实例创建的几种方式
//以OPCUA 采集协议为例
using Snet.Model.@interface;
using Snet.Opc.ua.client;
OpcUaClientOperate? operate = null;
IDaq? daq = null;
//无参实例
operate = new OpcUaClientOperate();
//无参实例调函数创建实例,与无参实例配合使用
operate = new OpcUaClientOperate().CreateInstance(new OpcUaClientData.Basics()).GetRData<OpcUaClientOperate>();
//有参实例
operate = new OpcUaClientOperate(new OpcUaClientData.Basics());
//有参单例
operate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics());
//接口 - 无参实例
daq = new OpcUaClientOperate();
//接口 - 无参实例调函数创建实例,与无参实例配合使用
daq = new OpcUaClientOperate().CreateInstance(new OpcUaClientData.Basics()).GetRData<OpcUaClientOperate>();
//接口 - 有参实例
daq = new OpcUaClientOperate(new OpcUaClientData.Basics());
//接口 - 有参单例
daq = OpcUaClientOperate.Instance(new OpcUaClientData.Basics());
using (operate)
{
    //使用完直接释放
}
using (daq)
{
    //使用完直接释放
}
📥 采集应用示例
通过 NuGet 安装协议包,快速实现采集:
//采集协议
//以OPCUA 采集协议为例
using System.Collections.Concurrent;
using Snet.Core.script;
using Snet.Log;
using Snet.Model.data;
using Snet.Model.@enum;
using Snet.Opc.ua.client;
using Snet.Utility;
using (OpcUaClientOperate operate = new OpcUaClientOperate(new OpcUaClientData.Basics
{
    ServerUrl = "opc.tcp://127.0.0.1:6688",
    UserName = "user",
    Password = "password",
}))
{
    //点位地址
    Address address = new Address();
    address.SN = Guid.NewGuid().ToString();
    address.CreationTime = DateTime.Now.ToLocalTime();
    address.AddressArray = new List<AddressDetails>
    {
         new AddressDetails()                                        //地址详情参数介绍
        {
            SN=$"",                                                  //可以理解成唯一标识符(可以存机台号、组名、车间、厂)
            AddressAnotherName="",                                   //地址别名
            AddressDataType=DataType.String,                         //数据类型
            AddressDescribe="",                                      //地址描述
            AddressExtendParam=new object(),                         //扩展数据
            AddressName="",                                          //实际地址[ 不能为空 ]
            AddressPropertyName="",                                  //属性名称
            AddressType=AddressType.Reality,                         //地址类型
            IsEnable=true,                                           //是否启用
            AddressMqParam=new AddressMq                      		 //消息队列生产
            {
                ISns = new List<string> { "ISN1", "ISN2" },          //实例SN
                Topic = $"topic",                                    //主题
                ContentFormat="Value:{0}"                            //内容格式
            },
            AddressParseParam=new AddressParse                       //脚本解析实例
            {
                ScriptParam=new ScriptData.Basics                    //脚本解析基础数据
                {
                    ScriptCode = @"function Convert(addressname,value) { return '【这是调用脚本解析】传入的地址是:'+ addressname + '----传入的参数是:' + value; }",  //脚本代码
                    ScriptFunction = "Convert",                                                                                                                        //脚本入口
                    ScriptType = ScriptData.ScriptType.JavaScript                                                                                                      //脚本类型
                }
            },
            //AddressParseParam = new AddressParse                  //反射解析
            //{
            //    ReflectionParam = new object[]                    //反射解析的参数
            //    {
            //        new ReflectionData.Basics                     //反射解析基础数据
            //        {
            //                                                      //反射解析的基础数据
            //        },
            //        "SN"                                          //反射解析的SN
            //    }
            // },
         }
    };
    #region 打开
    OperateResult result = operate.On();
    LogHelper.Info(result.ToJson(true));  //转成JSON.JSON格式化
    #endregion 打开
    #region 读取
    //读取
    result = operate.Read(address);
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 读取
    #region 订阅
	//事件信息结果
	operate.OnInfoEvent += delegate (object? sender, EventInfoResult e)
	{
		LogHelper.Info(e.ToJson(true));    //转成JSON.JSON格式化
	};
	//事件数据结果
    operate.OnDataEvent += delegate (object? sender, EventDataResult e)
	{
		LogHelper.Info(e.ToJson(true));    //转成JSON.JSON格式化
		//得到精简版数据 速度很快 <=2ms
		IEnumerable<AddressValueSimplify>? simplifies = e.GetSource<ConcurrentDictionary<string, AddressValue>>()?.GetSimplifyArray();
	};
    result = operate.Subscribe(address);
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 订阅
    #region 写入
    ConcurrentDictionary<string, object> value = new ConcurrentDictionary<string, object>
    {
        ["地址"] = "string 值",
        ["地址"] = (float)1.1f,
        ["地址"] = (double)2.2d,
        ["地址"] = (int)3,
        ["地址"] = true
    };
    result = operate.Write(value);
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 写入
    #region 关闭
    result = operate.Off();
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 关闭
    #region 获取状态
    result = operate.GetStatus();
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 获取状态
    #region 获取参数
    result = operate.GetParam();
    LogHelper.Info(result.GetRData<ParamStructure>().ToJson(true));   //转成JSON.JSON格式化
    #endregion 获取参数
}
🔄 MQ应用示例
//MQ协议
//以MQTT为例
using Snet.Log;
using Snet.Model.data;
using Snet.Mqtt.client;
using Snet.Utility;
using (MqttClientOperate operate = new MqttClientOperate(new MqttClientData.Basics
{
    Ip = "127.0.0.1",
    Port = 11819,
    UserName = "user",
    Password = "password"
}))
{
    #region 打开
    OperateResult result = operate.On();
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 打开
    #region 生产
    result = operate.Produce("主题", "内容");
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 生产
    #region 消费
    //事件信息结果
	operate.OnInfoEvent += delegate (object? sender, EventInfoResult e)
	{
		LogHelper.Info(e.ToJson(true));    //转成JSON.JSON格式化
	};
	//事件数据结果
    operate.OnDataEvent += delegate (object? sender, EventDataResult e)
	{
		LogHelper.Info(e.ToJson(true));    //转成JSON.JSON格式化
		//根据传进的RRT 转发响应类型来判断
		 switch (basics.RT)
		 {
			 case ResponseType.Bytes:  //字节数据
				 byte[] bytes = e.GetRData<byte[]>();
				 break;
			 case ResponseType.Content:  //字符串数据
				 string str = e.GetRData<string>();
				 break;
			 case ResponseType.ContentWithTopic: //带主题与内容的包体数据
			     ResponseModel rm = e.RData.ToJsonEntity<ResponseModel>();
				 break;
		 }
	};
    result = operate.Consume("主题");
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 消费
    #region 关闭
    result = operate.Off();
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 关闭
    #region 获取状态
    result = operate.GetStatus();
    LogHelper.Info(result.ToJson(true));   //转成JSON.JSON格式化
    #endregion 获取状态
    #region 获取参数
    result = operate.GetParam();
    LogHelper.Info(result.GetRData<ParamStructure>().ToJson(true));   //转成JSON.JSON格式化
    #endregion 获取参数
}
⚙️ 常用操作类名
SerialOperate       // 串口通信
HttpClientOperate   // HTTP 客户端
HttpServiceOperate  // HTTP 服务端
TcpClientOperate    // TCP 客户端
TcpServiceOperate   // TCP 服务端
UdpOperate          // UDP 通信
WsClientOperate     // WebSocket 客户端
WsServiceOperate    // WebSocket 服务端
ProcessCacheOperate // 内存缓存
ShareCacheOperate   // 共享缓存
MqOperate           // 消息队列
ReflectionOperate   // 反射操作
📦 快速开始
- 打开 NuGet 搜索并安装对应协议包
- 引入命名空间 using Snet.XXX
- 按照上方示例编写采集/转发代码
🏗️ 架构总结
Snet 框架通过 统一接口设计 与 模块化协议支持,实现了:
- 数据采集
- 协议转发
- 消息中间件交互
- 模拟服务端测试
- 高效日志与缓存
从 设备 → 协议 → 中间件 → 应用层 全链路打通,支持快速构建工业物联网系统。
📜 许可证
本项目基于 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- Snet.Core (>= 25.288.1)
- Snet.Driver (>= 25.288.1)
 
- 
                                                    net9.0- Snet.Core (>= 25.288.1)
- Snet.Driver (>= 25.288.1)
 
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 | 
|---|---|---|
| 25.304.1 | 0 | 10/31/2025 | 
| 25.300.1 | 112 | 10/27/2025 | 
| 25.294.1 | 273 | 10/21/2025 | 
| 25.293.1 | 263 | 10/20/2025 | 
| 25.288.1 | 273 | 10/15/2025 | 
| 25.284.1 | 187 | 10/11/2025 | 
| 25.271.1 | 199 | 9/27/2025 | 
| 25.267.1 | 350 | 9/24/2025 | 
| 25.262.1 | 391 | 9/19/2025 | 
| 25.259.1 | 461 | 9/16/2025 | 
| 25.253.2 | 278 | 9/10/2025 | 
| 25.253.1 | 269 | 9/10/2025 | 
| 25.252.1 | 252 | 9/9/2025 | 
| 25.247.1 | 278 | 9/4/2025 | 
| 25.246.1 | 290 | 9/3/2025 | 
| 25.245.1 | 265 | 9/2/2025 | 
| 25.244.1 | 259 | 9/1/2025 | 
| 25.240.1 | 304 | 8/28/2025 | 
| 25.239.1 | 316 | 8/27/2025 | 
| 25.238.1 | 307 | 8/26/2025 | 
| 25.234.1 | 223 | 8/22/2025 | 
| 25.224.1 | 265 | 8/12/2025 | 
| 25.219.1 | 346 | 8/7/2025 | 
| 25.213.1 | 221 | 8/1/2025 | 
| 25.212.1 | 254 | 7/31/2025 | 
| 25.211.1 | 197 | 7/30/2025 | 
| 25.204.4 | 703 | 7/23/2025 | 
| 25.204.3 | 695 | 7/23/2025 | 
| 25.204.2 | 696 | 7/23/2025 | 
| 25.204.1 | 718 | 7/23/2025 | 
| 25.190.1 | 317 | 7/9/2025 | 
| 25.187.1 | 270 | 7/5/2025 | 
| 25.177.2 | 303 | 6/26/2025 | 
| 25.177.1 | 311 | 6/25/2025 | 
| 25.175.1 | 306 | 6/24/2025 | 
| 25.168.1 | 340 | 6/17/2025 | 
| 25.162.1 | 467 | 6/11/2025 | 
| 25.161.1 | 465 | 6/10/2025 | 
| 25.157.2 | 300 | 6/6/2025 | 
| 25.157.1 | 314 | 6/6/2025 | 
| 25.156.1 | 336 | 6/5/2025 | 
| 25.155.1 | 344 | 6/4/2025 | 
| 25.136.1 | 383 | 5/16/2025 | 
| 25.132.1 | 388 | 5/12/2025 | 
| 25.129.1 | 305 | 5/9/2025 | 
| 25.128.1 | 328 | 5/8/2025 | 
| 25.127.1 | 311 | 5/7/2025 | 
| 25.118.1 | 329 | 4/28/2025 | 
| 25.112.1 | 376 | 4/22/2025 | 
| 25.107.1 | 393 | 4/17/2025 | 
| 25.106.1 | 386 | 4/16/2025 | 
| 25.105.1 | 407 | 4/15/2025 | 
| 25.104.1 | 418 | 4/14/2025 | 
| 25.100.1 | 370 | 4/10/2025 | 
| 25.99.1 | 368 | 4/9/2025 | 
| 25.88.2 | 311 | 3/29/2025 | 
| 25.88.1 | 307 | 3/29/2025 | 
| 25.87.1 | 340 | 3/28/2025 | 
| 25.86.3 | 341 | 3/27/2025 | 
| 25.86.2 | 342 | 3/27/2025 | 
| 25.86.1 | 336 | 3/27/2025 | 
| 25.79.1 | 360 | 3/20/2025 | 
| 25.77.1 | 342 | 3/18/2025 | 
| 25.76.1 | 330 | 3/17/2025 | 
| 25.71.1 | 343 | 3/12/2025 | 
| 25.69.2 | 324 | 3/10/2025 | 
| 25.69.1 | 360 | 3/10/2025 | 
| 25.68.1 | 324 | 3/9/2025 | 
| 25.65.1 | 244 | 3/6/2025 | 
| 25.63.3 | 254 | 3/4/2025 | 
| 25.63.2 | 258 | 3/4/2025 | 
| 25.63.1 | 247 | 3/4/2025 | 
| 25.62.1 | 197 | 3/3/2025 | 
| 25.59.1 | 151 | 2/28/2025 | 
| 25.44.1 | 151 | 2/13/2025 | 
| 25.43.1 | 142 | 2/12/2025 | 
| 25.35.1 | 167 | 2/4/2025 | 
| 25.2.3 | 182 | 1/1/2025 | 
| 25.2.2 | 170 | 1/1/2025 | 
| 25.2.1 | 157 | 1/1/2025 | 
| 24.365.6485 | 156 | 12/29/2024 | 
| 24.365.3593 | 125 | 12/29/2024 | 
| 24.363.11982 | 144 | 12/27/2024 |