This commit is contained in:
sc committed 2024-11-25 23:31:55 +08:00
commit 13a2c4ca63
2 files changed
+52 -15

No files matched your search

+32 -4
View File
@@ -47,17 +47,45 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
return EasyTask.CompletedTask;
};//成功连接到服务器
tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
tcpClient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从服务器断开连接,当连接不成功时不会触发。
tcpClient.Closing = (client, e) =>
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
drEmployee.BeginEdit();
drEmployee["State"] = "899";
drEmployee.EndEdit();
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
tcpClient.Closed = (client, e) =>
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
drEmployee.BeginEdit();
drEmployee["State"] = "899";
drEmployee.EndEdit();
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
return EasyTask.CompletedTask; };//从服务器断开连接,当连接不成功时不会触发。
tcpClient.Received = (client, e) =>
{
//从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。
var mes = e.ByteBlock.Span.ToString(Encoding.UTF8);
string SYSAPI = e.ByteBlock.Span.ToString(Encoding.ASCII).Substring(0, 5);
string DAT = e.ByteBlock.Span.ToString(Encoding.ASCII);
if (SYSAPI == "SC851")
{
// client.SendAsync("SC851" + "[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_d.ToJsonString());//数字开关信息
}//数字开关表
// tcpClient.Logger.Info($"客户端接收到信息:{mes}");
// tcpClient.Logger.Info($"客户端接收到信息:{mes}");
return EasyTask.CompletedTask;
};