Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement
This commit is contained in:
commit
fd59222165
3 files changed
+60
-11
No files matched your search
@@ -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>
|
||||
@@ -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();
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
inf[i].Process.Text = Selet_Machines(MainWindowViewModel.Machines, "Process", i).ToString();
|
||||
inf[i].Step.Text = Selet_Machines(MainWindowViewModel.Machines, "Step", i).ToString();
|
||||
inf[i].Message.Text = Selet_Machines(MainWindowViewModel.Machines, "Message", i).ToString();
|
||||
inf[i].Orders.Text = Selet_Machines(MainWindowViewModel.Machines, "Orders", i).ToString();
|
||||
inf[i].Orders.Text = Selet_Machines(MainWindowViewModel.Machines, "WorkOrder", i).ToString();
|
||||
inf[i].time.Text = Selet_Machines(MainWindowViewModel.Machines, "time", i).ToString();
|
||||
|
||||
WholeView.Children.Add(inf[i]);
|
||||
@@ -112,7 +112,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
inf[i].Process.Text = Selet_Machines(MainWindowViewModel.Machines, "Process", i).ToString();
|
||||
inf[i].Step.Text = Selet_Machines(MainWindowViewModel.Machines, "Step", i).ToString();
|
||||
inf[i].Message.Text = Selet_Machines(MainWindowViewModel.Machines, "Message", i).ToString();
|
||||
inf[i].Orders.Text = Selet_Machines(MainWindowViewModel.Machines, "Orders", i).ToString();
|
||||
inf[i].Orders.Text = Selet_Machines(MainWindowViewModel.Machines, "WorkOrder", i).ToString();
|
||||
inf[i].time.Text = Selet_Machines(MainWindowViewModel.Machines, "time", i).ToString();
|
||||
|
||||
}
|
||||
|
||||
@@ -76,22 +76,42 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
|
||||
|
||||
for (int i = 0; i < Machinesdata_Count; i++)
|
||||
{
|
||||
if (Selet_Machines(Machines, "State", i).ToString() == "802")
|
||||
{
|
||||
MachiensTcpClient[i].SendAsync("SC830"+ Selet_Machines(Machines, "SYSKEY", i).ToString());
|
||||
Updata_Machines(Machines, "State", i, "101");
|
||||
// DataRow dt = machinesdata[i];
|
||||
//Updata_Machines(Machines, Convert.ToInt16(dt["ID"]), "State", "800");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
||||
{
|
||||
for (int i = 0; i < Machinesdata_Count; i++)
|
||||
{
|
||||
if ( Selet_Machines(Machines,"State", i).ToString() =="801")
|
||||
MachiensTcpClient[i].SendAsync("SC800:SCCM["+ MachiensTcpClient[i].IP+";"+ MachiensTcpClient[i].Port+"]");
|
||||
|
||||
// MachiensTcpClient[1].SendAsync("SC851BED2E58B6EBB4BD4");
|
||||
if (Selet_Machines(Machines, "State", i).ToString() == "801")
|
||||
{
|
||||
MachiensTcpClient[i].SendAsync("SC800:SCCM[" + MachiensTcpClient[i].IP + ";" + MachiensTcpClient[i].Port + "]");
|
||||
}
|
||||
// MachiensTcpClient[1].SendAsync("SC851BED2E58B6EBB4BD4");
|
||||
|
||||
}
|
||||
}
|
||||
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
|
||||
{
|
||||
for (int i = 0; i < Machinesdata_Count; i++)
|
||||
{
|
||||
if (Selet_Machines(Machines, "State", i).ToString() == "101")
|
||||
{
|
||||
MachiensTcpClient[i].SendAsync("SC830" + Selet_Machines(Machines, "SYSKEY", i).ToString());
|
||||
|
||||
// DataRow dt = machinesdata[i];
|
||||
//Updata_Machines(Machines, Convert.ToInt16(dt["ID"]), "State", "800");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
@@ -121,7 +141,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
MachiensTcpClient[i] = new TcpClient();
|
||||
DataRow dt = machinesdata[i];
|
||||
Updata_Machines(Machines, Convert.ToInt16(dt["ID"]), "State", "800");
|
||||
Updata_Machines(Machines, "State", Convert.ToInt16(dt["ID"]), "800");
|
||||
_ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接
|
||||
, Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString()
|
||||
, Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString());
|
||||
@@ -155,7 +175,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public static void Updata_Machines(DataTable DB, int key, string name, string Value)//更新数据
|
||||
public static void Updata_Machines(DataTable DB, string name, int key, string Value)//更新数据
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user