diff --git a/App.xaml.cs b/App.xaml.cs index ab7e58d..a442956 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,4 +1,5 @@ -using LiveChartsCore; +using DyeingComputer.UserClass; +using LiveChartsCore; using LiveChartsCore.SkiaSharpView; using SkiaSharp; using System; @@ -84,7 +85,7 @@ namespace SunlightCentralizedControlManagement_SCCM_ mutex = new System.Threading.Mutex(true, "SCCM", out ret);//程序只允许启动一次 if (!ret) { - // LogGing.LogGingDATA("800_The program has been launched"); + LogGing.LogGingDATA("800_The program has been launched"); MessageBox.Show("The program has been launched"); Environment.Exit(0); } @@ -127,8 +128,8 @@ namespace SunlightCentralizedControlManagement_SCCM_ string Log_time = DateTime.Now.ToString("yyyy-MM-dd"); string logpath = System.Environment.CurrentDirectory + "\\ERR";//日志文件目录 - //string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件 - // System.IO.DirectoryInfo log = new System.IO.DirectoryInfo();//生成日志文件目录 + // string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件 + // System.IO.DirectoryInfo log = new System.IO.DirectoryInfo();//生成日志文件目录 string log_path = logpath + "\\ERR" + Log_time + ".txt"; string Log_timehms = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (Directory.Exists(logpath))//检查日志路径 diff --git a/UserClass/AsyncTcpClient.cs b/UserClass/AsyncTcpClient.cs index 98472ed..607bcee 100644 --- a/UserClass/AsyncTcpClient.cs +++ b/UserClass/AsyncTcpClient.cs @@ -27,6 +27,7 @@ using Newtonsoft.Json.Linq; using System.Xml.Linq; using ScottPlot; using System.Collections; +using DyeingComputer.UserClass; namespace SunlightCentralizedControlManagement_SCCM_.UserClass {/// @@ -49,6 +50,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass drEmployee.AcceptChanges(); drEmployee.ClearErrors(); + LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK"); + return EasyTask.CompletedTask; };//成功连接到服务器 tcpClient.Closing = (client, e) => @@ -59,6 +62,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass drEmployee.EndEdit(); drEmployee.AcceptChanges(); drEmployee.ClearErrors(); + LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP"); return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。 @@ -70,6 +74,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass drEmployee.EndEdit(); drEmployee.AcceptChanges(); drEmployee.ClearErrors(); + LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT"); return EasyTask.CompletedTask; };//从服务器断开连接,当连接不成功时不会触发。 @@ -100,20 +105,19 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass _new = JsonConvert.DeserializeObject>(DAT);//反序列化 DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First(); drEmployee.BeginEdit(); - drEmployee["Message"] = _new.GetValue("Status").ToString(); - drEmployee["WorkOrder"] = _new.GetValue("WorkNumder").ToString(); - drEmployee["Temperature"] = _new.GetValue("MTT").ToString(); - drEmployee["WaterLevel"] = _new.GetValue("MTL").ToString(); - drEmployee["Process"] = _new.GetValue("Process").ToString(); - drEmployee["Step"] = _new.GetValue("Step").ToString(); + drEmployee["Message"] = _new.GetValue("Status"); + drEmployee["WorkOrder"] = _new.GetValue("WorkNumder"); + drEmployee["Temperature"] = _new.GetValue("MTT"); + drEmployee["WaterLevel"] = _new.GetValue("MTL"); + drEmployee["Process"] = _new.GetValue("Process"); + drEmployee["Step"] = _new.GetValue("Step"); drEmployee.EndEdit(); drEmployee.AcceptChanges(); drEmployee.ClearErrors(); if (_new.GetValue("Status").ToString() != "----------") { - Dictionary Chart_new = new Dictionary();//缓存函数 - // Chart_new.Add("DYELOT", _new.GetValue("Status")); + Dictionary Chart_new = new Dictionary();//缓存函数 Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder")); Chart_new.Add("Machine", _new.GetValue("Machine")); Chart_new.Add("Time", _new.GetValue("Time")); diff --git a/View/MonitorView.xaml b/View/MonitorView.xaml index a1d484d..b55595c 100644 --- a/View/MonitorView.xaml +++ b/View/MonitorView.xaml @@ -97,7 +97,7 @@ - dat_821 = new Dictionary(); dat_821.Clear(); dat_821.Add("INSTRUCTION", "EDIT"); @@ -184,7 +185,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View viewstop.data = ID; viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Insert_ButtonClicked); viewstop.ShowDialog(); - }//插入 + }//插入 private void Insert_ButtonClicked(object sender, AddressUpdateEventArgs e)//cr返回结果 { diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index 0ebdc60..3243501 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -163,12 +163,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel { for (int i = 0; i < Machinesdata_Count; i++) { - MachiensTcpClient[i] = new TcpClient(); - DataRow dt = machinesdata[i]; - 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()); + if (Selet_Machines(Machines, "State", i).ToString() == "800") + { + MachiensTcpClient[i] = new TcpClient(); + DataRow dt = machinesdata[i]; + _ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接 + , Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString() + , Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString()); + } } } @@ -447,6 +449,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel return lst; } //通讯队列 + public static UInt32 RX=0; + public static UInt32 TX=0; public class QueueString { public int ID { get; set; }