This commit is contained in:
sc committed 2024-11-27 22:41:16 +08:00
commit fd59222165
3 files changed
+61 -12

No files matched your search

+32 -3
View File
@@ -25,6 +25,8 @@ using SunlightCentralizedControlManagement_SCCM_.View;
using TcpClient = TouchSocket.Sockets.TcpClient;
using Newtonsoft.Json.Linq;
using System.Xml.Linq;
using ScottPlot;
using System.Collections;
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{/// <summary>
@@ -47,7 +49,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee.ClearErrors();
return EasyTask.CompletedTask;
};//成功连接到服务器
};//成功连接到服务器
tcpClient.Closing = (client, e) =>
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
@@ -76,7 +78,34 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
string SYSAPI = e.ByteBlock.Span.ToString(Encoding.ASCII).Substring(0, 5);
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8);
if (SYSAPI == "SC800")
{ }
{
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
drEmployee.BeginEdit();
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString();
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString();
drEmployee["State"] = "802";
drEmployee.EndEdit();
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
}
else if (SYSAPI == "SC830")
{
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
drEmployee.BeginEdit();
drEmployee["Message"] = Chart_new.GetValue("Status").ToString();
drEmployee["WorkOrder"] = Chart_new.GetValue("WorkNumder").ToString();
drEmployee["Temperature"] = Chart_new.GetValue("MTT").ToString();
drEmployee.EndEdit();
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
}
else if (SYSAPI == "SC851")
{
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
@@ -106,7 +135,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
a.UseCheckClear()
.SetCheckClearType(CheckClearType.All)
.SetTick(TimeSpan.FromSeconds(30))
.SetTick(TimeSpan.FromSeconds(10))
.SetOnClose((c, t) =>
{
c.TryShutdown();