DoNetDrive.Core 2.10.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DoNetDrive.Core --version 2.10.0                
NuGet\Install-Package DoNetDrive.Core -Version 2.10.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="DoNetDrive.Core" Version="2.10.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DoNetDrive.Core --version 2.10.0                
#r "nuget: DoNetDrive.Core, 2.10.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.
// Install DoNetDrive.Core as a Cake Addin
#addin nuget:?package=DoNetDrive.Core&version=2.10.0

// Install DoNetDrive.Core as a Cake Tool
#tool nuget:?package=DoNetDrive.Core&version=2.10.0                

DoNetDrive.Core

介绍

用于运行设备命令的基础库,依赖于 Nettty.Buffer ,包含TCP Client 、TCP Server 、UDP 的通讯实现,抽象设备命令和执行步骤。

封装命令收发的核心逻辑

软件架构

基于 netstandard2.0 ;

依赖于此动态库的项目

  1. DoNetDrive.Protocol 设备协议的抽象
  2. DoNetDrive.Connector.SerialPort 串口通讯的实现,可用于RS232/485通讯
  3. DoNetDrive.Protocol.Door 门禁控制板命令库
  4. DoNetDrive.Protocol.Fingerprint 指纹机/人脸机命令库
  5. DoNetDrive.Protocol.Fingerprint.Elevator 指纹机/人脸机附加电梯功能命令库
  6. DoNetDrive.Protocol.Elevator 电梯控制板命令库
  7. DoNetDrive.Protocol.POS 消费机命令库
  8. DoNetDrive.Protocol.USB.OfflinePatrol USB巡更棒命令库
  9. DoNetDrive.Protocol.USB.CardReader USB发卡器命令库

使用说明

var mAllocator = ConnectorAllocator.GetAllocator();



var cmdDtl = CommandDetailFactory.CreateDetail(CommandDetailFactory.ConnectType.TCPClient, "192.168.1.56", 8000,
                CommandDetailFactory.ControllerType.Door88, "0000000000000000", "FFFFFFFF");
ReadSN cmd = new ReadSN(cmdDtl);
try
{
    await mAllocator.AddCommandAsync(cmd);
    var snResult = cmd.getResult() as SN_Result;
    Console.WriteLine(snResult.SNBuf);

}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}

//释放
mAllocator.Dispose();

UDP Server 绑定端口使用示例

        private async void btnBindPort_Click(object sender, EventArgs e)
        {
            UDPServerDetail serverDetail;
            string sLocalIP = cmbLocalIP.Text;
            int iLocalPort = (int)txtLocalPort.Value;

            if (string.IsNullOrWhiteSpace(sLocalIP))
            {
                serverDetail = new UDPServerDetail(iLocalPort);
            }
            else
            {
                if (sLocalIP.Equals("*"))
                    serverDetail = new UDPServerDetail(iLocalPort);
                else
                    serverDetail = new UDPServerDetail(sLocalIP, iLocalPort);
            }



            //绑定处理事件
            serverDetail.ClientOfflineCallBlack = UDPServer_ClientOfflineCallBlack;
            serverDetail.ClientOnlineCallBlack = UDPServer_ClientOnlineCallBlack;
            serverDetail.ClosedCallBlack = UDPServer_ClosedCallBlack;
            //serverDetail.ConnectedCallBlack= UDPServer_ConnectedCallBlack;
            try
            {
                var connector = await Allocator.OpenConnectorAsync(serverDetail);

                AddLog("绑定成功:" + serverDetail.GetKey());
            }
            catch (Exception ex)
            {

                AddLog("绑定错误:" + ex.Message);
                ShowErr("绑定错误:" + ex.Message);
            }

        }


        private void UDPServer_ClientOnlineCallBlack(INConnector client)
        {
            AddLog("客户端上线:" + client.GetConnectorDetail().ToString());
            client.AddRequestHandle(new ConnectorObserverTextHandler(
                new ObserverTextDebug(
                    read: UDPClient_ReadCallBlack,
                    send: null
                    ),
                System.Text.Encoding.UTF8));
        }

        /// <summary>
        /// udp客户端接收到数据的回调
        /// </summary>
        /// <param name="client"></param>
        private void UDPClient_ReadCallBlack(INConnector client,string msg)
        {
            AddLog("收到数据:" + client.GetConnectorDetail().ToString() + "\r\n" + msg);
        }



        private void UDPServer_ClientOfflineCallBlack(INConnector client)
        {
            AddLog("客户端离线:" + client.GetConnectorDetail().ToString());
        }

        private void UDPServer_ConnectedCallBlack(INConnectorDetail connectorDetail)
        {
            AddLog("连接建立:" + connectorDetail.ToString());
        }

        /// <summary>
        /// 通道关闭时的回调
        /// </summary>
        /// <param name="obj"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void UDPServer_ClosedCallBlack(INConnectorDetail connDtl)
        {
            AddLog("连接关闭:" + connDtl.ToString());
        }

版本记录

ver 2.01.0

增加 async 和 await 的方式操作命令

ver 2.02.0

改进了上个版本使用async 和 await方式时,当连接建立成功,但是发送命令后没有响应,命令超时时,不能正确返回,导致await一直等待的bug

ver 2.03.0

  1. 删除了 SerialPort 减少了依赖库,如果要使用串口通讯,需要额外添加 DoNetDrive.Connector.SerialPort.dll ,并再分配器的连接器创建工厂中增加SerialPort

代码如下: VB.Net

Dim defFactory As DefaultConnectorFactory = TryCast(Allocator.ConnectorFactory, DefaultConnectorFactory)
defFactory.ConnectorFactoryDictionary.Add(ConnectorType.SerialPort, DoNetDrive.Connector.COM.SerialPortFactory.GetInstance())
  1. INConnectorDetail 类 增加了 ConnectingCallBlack 回调,再TCPClient 时,发起连接时会调用
  2. ConnectorAllocator 增加了ConnectorConnectingEvent 事件,再TCPClient 时,发起连接时会调用

ver 2.04.0

解决UDP通讯时由于对方决绝会导致udp的socket套接字意外关闭导致发送数据出错的问题 修复 CommandDetailFactory.vb 中没有移除 串口相关类型导致报错的问题 增加 CommandStatusExtension.vb ,增加判断命令是否成功完成的扩展函数

ver 2.05.0

修改命令发送后的等待发送缓冲区成功的逻辑

ver 2.06.0

修改设置最后发送命令时间的时机

ver 2.08.0

UDPServerClientConnector
1. 增加连接建立事件
2. ConnectAsync 改为可调用,但不执行任何操作
3. CloseAsync 调用时增加触发ClientOffline回调
UDPServerConnector
1. Bind端口时增加支持IPV6
2. 等待接收数据报时增加出错检测及自动重试,重试次数为100,重试失败后将关闭连接
3. 接收到数据报后将数据报发送到 本地IP:本地端口号:远程IP:远程端口号 4个组件组成的通道
4. 接收到数据报后尝试查询本地的广播通道,将数据报转发到广播通道。
5. 接收到数据报创建子通道时将ClosedCallBlack和ErrorCallBlack委托传递到子通道。

ver 2.09.0

  1. 修复在单独一个代码块中为每个命令都添加 using ,或者单独调用 cmd.Dispose() 会引发阻塞的bug,
  2. 如下面代码块在第二次 await Allocator.AddCommandAsync(cmd); 会引发阻塞。
  3. 现在已对这种情况进行了修复,不会再发生阻塞了

ver 2.10.0

  • 增加已释放的命令重复提交到命令队列造成死锁问题的防范机制
  • TCPserver 本地监听增加 * 允许监听所有网络接口

try
{
    using var par = new DoNetDrive.Protocol.Door.Door8800.SystemParameter.KeepAliveInterval
        .WriteKeepAliveInterval_Parameter(20);

    using var cmd = new DoNetDrive.Protocol.Door.Door8800.SystemParameter.KeepAliveInterval
    .WriteKeepAliveInterval(cmdDtl, par);
    await Allocator.AddCommandAsync(cmd);


}
catch (Exception ex)
{

    return;
}
try
{
    using var par = new DoNetDrive.Protocol.Door.Door8800.SystemParameter.KeepAliveInterval
        .WriteKeepAliveInterval_Parameter(20);

    using var cmd = new DoNetDrive.Protocol.Door.Door8800.SystemParameter.KeepAliveInterval
    .WriteKeepAliveInterval(cmdDtl, par);
    
    await Allocator.AddCommandAsync(cmd);

}
catch (Exception ex)
{

    return;
}

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 was computed.  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. 
.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 DoNetDrive.Core:

Package Downloads
DoNetDrive.Protocol

用于运行设备命令的协议解析抽象层,定义了各种产品的协议格式及编解码器

DoNetDrive.Connector.SerialPort

用于完成 串口 的通讯实现,需要依赖 。DoNetDrive.Core

DoNetDrive.Protocol.USB.CardReader

用于定义USB 发卡器的设备命令

DoNetDrive.Connector.WindowsBLE

用于基于Win10 1809 以上版本SDK开发的用于蓝牙BLE通讯基础库

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.11.0 75 8/5/2024
2.10.0 510 8/29/2023
2.9.0 3,563 7/26/2022
2.8.0 396 7/21/2022
2.7.0 3,161 6/28/2022
2.5.0 2,005 4/3/2022
2.4.0 1,776 4/2/2022
2.3.0 743 3/9/2022 2.3.0 is deprecated because it has critical bugs.
2.2.0 495 3/2/2022 2.2.0 is deprecated because it has critical bugs.
2.1.0 1,179 1/10/2022 2.1.0 is deprecated because it has critical bugs.