CSoft.Protocol 11.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package CSoft.Protocol --version 11.0.2
                    
NuGet\Install-Package CSoft.Protocol -Version 11.0.2
                    
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="CSoft.Protocol" Version="11.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSoft.Protocol" Version="11.0.2" />
                    
Directory.Packages.props
<PackageReference Include="CSoft.Protocol" />
                    
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 CSoft.Protocol --version 11.0.2
                    
#r "nuget: CSoft.Protocol, 11.0.2"
                    
#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 CSoft.Protocol@11.0.2
                    
#: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=CSoft.Protocol&version=11.0.2
                    
Install as a Cake Addin
#tool nuget:?package=CSoft.Protocol&version=11.0.2
                    
Install as a Cake Tool

CSoft.Protocol

设备协议和业务调用方之间的接口约定。包提供连接生命周期、服务端和多对多客户端管理、设备输入输出,以及采样数据模型。具体设备协议由应用或插件实现,并可组合 CSoft.TopPortLib 通讯口。

安装

dotnet add package CSoft.Protocol --version 11.0.2

包提供 netstandard2.0、net8.0、net9.0、net10.0 和 net11.0 资产。.NET Framework 4.8 可使用 netstandard2.0 资产。

接口与模型

类型 使用场景
IProtocol 点对点协议。通过 OpenAsync、CloseAsync、IsConnect 和连接事件管理会话。
IProtocol_Server 监听型协议。通过 StartAsync、StopAsync 和 IsListened 管理监听,并按 Guid 跟踪连接与收发事件。
IProtocol_M2M 多对多协议。提供监听和收发事件,并可用 AddClientAsync、RemoveClientAsync 管理远端地址。
IDeviceProtocol 继承点对点生命周期,公开 Parser、OnDevicePushData 和 SendData,便于应用统一处理设备输入输出。
IProtocolConfig 描述协议 ID、名称、输入输出方向和界面类型,供应用选择配置。

Protocol.Model.Sample 表示收到的采样,包含时间、名称、数值、状态和 PersistenceStrategy。持久化策略随样品传给应用,由应用负责入库。Protocol.Model.SendSample 表示发送的通道值,Value 可为空,并可附带单位和 Other 扩展信息。

调用已实现的设备协议

下面的方法接收应用提供的 IDeviceProtocol 实现,管理本次会话并发送一个设定值。Setpoint、状态字符串和 dataType 的含义由设备协议约定。

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Protocol;
using Protocol.Model;

public static class DeviceSession
{
    public static async Task WriteSetpointAsync(IDeviceProtocol device, decimal setpoint)
    {
        await device.OpenAsync();
        try
        {
            var samples = new List<SendSample>
            {
                new SendSample(DateTime.UtcNow, "Setpoint", setpoint, "OK") { Unit = "°C" }
            };
            await device.SendData(samples, dataType: null);
        }
        finally
        {
            await device.CloseAsync();
        }
    }
}

实现设备协议时,可用 CSoft.Communication.Builder 或 CSoft.TopPortLib 组装传输与分包,再在协议实现中处理命令编码、响应解析和采样映射。需要协议自动 Builder 时,使用 CSoft.TopPortLib 包内置的源码生成器。

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 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.  net11.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on CSoft.Protocol:

Package Downloads
CSoft.Protocol.Adam4017

Adam4017通讯协议

CSoft.Protocol.Modbus

Modbus通讯协议

CSoft.Protocol.HJ212

HJ212 协议库(HJ/T 212-2005、HJ 212-2017、HJ 212-2025),支持现场机和上位机。基于 CSoft.TopPortLib 和 CSoft.Protocol,三个版本共用命令注册表和编解码。

CSoft.Protocol.HygrometerYC

盈创湿度仪通讯协议

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.3 62 11/13/2026
11.0.2 50 11/13/2026
11.0.1 54 11/12/2026
11.0.0 49 11/12/2026
10.6.2 522 5/28/2026
10.6.1 126 5/28/2026
10.6.0 138 5/27/2026
10.5.1 127 5/25/2026
10.5.0 124 5/25/2026
10.4.10 154 5/19/2026
10.4.9 210 5/19/2026
10.4.8 127 5/18/2026
10.4.7 132 5/18/2026
10.4.6 175 5/15/2026
10.4.5 161 5/14/2026
10.4.3 125 5/14/2026
10.4.1 214 5/11/2026
10.4.0 140 5/11/2026 10.4.0 is deprecated because it has critical bugs.
10.3.1 119 5/7/2026
10.3.0 156 5/7/2026
Loading failed

依赖 CSoft.Communication.Builder 11.0.2,让协议项目通过原有引用自动升级通信层。