ZY.TCP.Core
1.0.4
dotnet add package ZY.TCP.Core --version 1.0.4
NuGet\Install-Package ZY.TCP.Core -Version 1.0.4
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="ZY.TCP.Core" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZY.TCP.Core" Version="1.0.4" />
<PackageReference Include="ZY.TCP.Core" />
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 ZY.TCP.Core --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZY.TCP.Core, 1.0.4"
#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 ZY.TCP.Core@1.0.4
#: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=ZY.TCP.Core&version=1.0.4
#tool nuget:?package=ZY.TCP.Core&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TCP链接
nuget引用组件 :ZY.TCP.Core
客户端实现
public class TCPConnetion
{
TcpClient client;
public TCPConnetion()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);//编码
}
/// <summary>
/// 启动tcp客户端
/// </summary>
public void Start()
{
client = new TcpClient("192.168.1.1", "8131");//服务端IP,端口
zenith.BindMessageHandler(RecMsg);//绑定消息接收事件
}
/// <summary>
/// 接收消息
/// </summary>
/// <param name="data">消息内容</param>
/// <returns></returns>
public async Task RecMsg(byte[] data)
{
try
{
var str = Encoding.GetEncoding("GB2312").GetString(data, 0, data.Length);
//接收消息的处理
}
catch (Exception ex){ }
}
/// <summary>
/// 发送消息
/// </summary>
/// <param name="data">消息内容</param>
/// <returns></returns>
public async Task SendText(string data)
{
try
{
client.SendText(data);
}
catch (Exception ex){ }
}
/// <summary>
/// 短链接发送返回消息
/// </summary>
/// <param name="data">消息内容</param>
/// <returns></returns>
public async Task SendResult(string data)
{
try
{
TcpClient client = new TcpClient("10.0.201.210", "8117", false);
byte[] by = client.SendResult(data);
}
catch (Exception ex){ }
}
}
摄像头TCP链接
public class TCPConnetion
{
VisionZenith _tcp;//榛识
//HuaXia _tcp;//华夏
//QianYi _tcp;//千熠
public TCPConnetion()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);//编码
}
/// <summary>
/// 启动tcp客户端
/// </summary>
/// <param name="ip">摄像头IP</param>
public void Start(string ip)
{
_tcp = new VisionZenith(ip, "8131");//实例化榛识tcp链接,摄像头IP,端口
_tcp.BindMessageHandler(RecMsg);//绑定消息接收事件
}
public Task RecMsg(string data)
{
if (_result)
{
ReceiveInfo = new ReceiveInfo
{
Content = data
};
}
else
{
if (data.Contains("PlateResult"))
{
var plateinfo = DataAnalysis.ToPlateInfo(_tcp.ServerIP, data);
//_callback.Notify("CaptureRec", plateinfo);
CaptureRec.Invoke(this, new ResultInfo { IP = _tcp.ServerIP, Type = "plate", Data = plateinfo });
}
if (data.Contains("IoResult"))
{
var ioinfo = DataAnalysis.ToBarrier(data);
CaptureRec.Invoke(this, new ResultInfo { IP = _tcp.ServerIP, Type = "io", Data = ioinfo });
}
}
return null;
}
public void Capture()
{
_tcp.Trigge();
}
public PlateInfo CaptureResult()
{
_result = true;
ReceiveInfo = null;
_tcp.Trigge();
DateTime now = DateTime.Now;
while (ReceiveInfo == null && DateTime.Now.AddMilliseconds(-5 * 1000) < now)
{
if (ReceiveInfo?.Content?.Contains("PlateResult") ?? false)
{
_result = false;
return DataAnalysis.ToPlateInfo(_tcp.ServerIP, ReceiveInfo.Content);
}
Thread.Sleep(50);
}
_result = false;
if (ReceiveInfo?.Content?.Contains("PlateResult") ?? false)
{
return DataAnalysis.ToPlateInfo(_tcp.ServerIP, ReceiveInfo?.Content ?? "");
}
else
{
return new PlateInfo();
}
}
public void Open()
{
_tcp.Open();
}
public void Close()
{
_tcp.Close();
}
public bool GPIO(int io)
{
return _tcp.GetGPIO_IN(io);
}
public void ShowLed(string voice, string[] content, bool landscape)
{
_tcp.ShowAndPlayTTR(content,voice,landscape);
}
public void Play(string voice)
{
_tcp.PlayTTR(voice);
}
public void InitTime(DateTime time)
{
_tcp.InitTime(time);
}
}
同时链接多个TCP服务
public static IApplicationBuilder UseApplication(this IApplicationBuilder app)
{
Task.Run(() =>
{
using (var scope = app.ApplicationServices.CreateScope())
{
scope.ServiceProvider.GetService<ITCPConnetion>().Start("10.0.201.246");
}
});
Task.Run(() =>
{
using (var scope = app.ApplicationServices.CreateScope())
{
scope.ServiceProvider.GetService<ITCPConnetion>().Start("10.0.201.249");
}
});
return app;
}
备注
科发LED驱动板
横屏,最后 5竖屏
本地局域网能顺利连接服务端但是无法接收消息?
可能系统设置有问题,windows防火墙》高级设置》入站规则》文件和打印机共享(回显请求 - ICMPv4-In)。。。。。。本地子网络》启用且设置任何IP可以
| Product | Versions 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. 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 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. |
| .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 is compatible. |
| .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.
-
.NETStandard 2.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Logging.Abstractions (>= 2.2.0)
- Newtonsoft.Json (>= 12.0.2)
-
.NETStandard 2.1
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Logging.Abstractions (>= 2.2.0)
- Newtonsoft.Json (>= 12.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ZY.TCP.Core:
| Package | Downloads |
|---|---|
|
ZY.PlateRecognition.TCP
车牌识别摄像头TCP协议 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.4 | 212 | 6/30/2026 |
| 1.0.3.2 | 156 | 6/29/2026 |
| 1.0.3.1 | 491 | 5/15/2025 |
| 1.0.2.6 | 414 | 10/31/2024 |
| 1.0.2.5 | 627 | 7/15/2024 |
| 1.0.2.4 | 188 | 7/14/2024 |
| 1.0.2.3 | 233 | 7/14/2024 |
| 1.0.2.2 | 556 | 6/14/2024 |
| 1.0.2.1 | 330 | 5/15/2024 |
| 1.0.1.5 | 754 | 3/6/2024 |
| 1.0.1.4 | 374 | 2/28/2024 |
| 1.0.1.3 | 394 | 1/23/2024 |
| 1.0.1.2 | 252 | 11/30/2023 |
| 1.0.1.1 | 228 | 10/12/2023 |
| 1.0.0.4 | 406 | 2/21/2023 |
| 1.0.0.3 | 391 | 2/3/2023 |
| 1.0.0.2 | 414 | 2/1/2023 |
| 1.0.0.1 | 428 | 1/29/2023 |