diff --git a/UserClass/AsyncSerialPortClient.cs b/UserClass/AsyncSerialPortClient.cs index 3f165ec..4f87822 100644 --- a/UserClass/AsyncSerialPortClient.cs +++ b/UserClass/AsyncSerialPortClient.cs @@ -47,7 +47,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass int contentLength = endIndex - startIndex - 1; return contentLength > 0 ? source.Substring(contentStart, contentLength) : string.Empty; } - } + }//获取字符串指定字符的范围的值 public static string PortCOM1 { get; set; } public static string PortCOM2 { get; set; } @@ -68,7 +68,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass @"\n", RegexOptions.IgnoreCase); for (int i = 0; i < sArray.Length; i++) - { + { if (sArray[i].Length>5) { string SYSAPI = sArray[i].Substring(0, 5); @@ -231,17 +231,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass drEmployee["ERR"] = _new.GetValue("ERR"); drEmployee["LOCK"] = _new.GetValue("LOCK"); drEmployee["Message"] = _new.GetValue("Status"); - drEmployee["WorkOrder"] = _new.GetValue("WorkNumder"); + drEmployee["WorkOrder"] = _new.GetValue("Work"); drEmployee["Temperature"] = _new.GetValue("MTT"); drEmployee["WaterLevel"] = _new.GetValue("MTL"); drEmployee["Process"] = _new.GetValue("Process"); drEmployee["Step"] = _new.GetValue("Step"); - drEmployee["UserButton"] = _new.GetValue("UserButton"); - if (_new.GetValue("UserInfoStart").ToString() != "900") - { drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); } - drEmployee["UserInfo"] = _new.GetValue("UserInfo"); - drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN"); - drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID"); + drEmployee["UserButton"] = _new.GetValue("User"); + if (_new.GetValue("InfoS").ToString() != "900") + { drEmployee["UserInfoStart"] = _new.GetValue("InfoS"); } + drEmployee["UserInfo"] = _new.GetValue("Info"); + drEmployee["WORK_RUN"] = _new.GetValue("RUN"); + drEmployee["RUN_STEPID"] = _new.GetValue("STEPID"); drEmployee["CALL"] = _new.GetValue("CALL"); drEmployee.EndEdit(); drEmployee.AcceptChanges(); @@ -250,9 +250,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass if (_new.GetValue("Status").ToString() != "----------") { Dictionary Chart_new = new Dictionary();//缓存函数 - Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder")); + Chart_new.Add("WorkOrder", _new.GetValue("Work")); Chart_new.Add("Machine", mac); - Chart_new.Add("Time", _new.GetValue("Time")); + Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); Chart_new.Add("MST", _new.GetValue("MST")); Chart_new.Add("MTT", _new.GetValue("MTT")); Chart_new.Add("MTL", _new.GetValue("MTL")); @@ -602,38 +602,40 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass { try { - var t = CRCcheck16.ToCRC16(command); + // var t = CRCcheck16.ToCRC16(command); _responseEvent.Reset(); serialPortClients.Send(command); // 发送指令 // 等待500毫秒或直到收到响应 _responseEvent.Wait(TimeSpan.FromMilliseconds(1000)); - // 重置事件状态 - _responseEvent.Set(); - //清楚了解状态 - string Station = ClipBetween(command, '[', ']'); - lock (MainWindowViewModel.Machines.Rows.SyncRoot) - { - DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + - Station + "' AND Serial = 'PORT1'").First(); - if (drEmployee.Field("State") != 800) + if (!_responseEvent.IsSet) + { + //清机台状态 + string Station = ClipBetween(command, '[', ']'); + lock (MainWindowViewModel.Machines.Rows.SyncRoot) { - drEmployee.BeginEdit(); - drEmployee["State"] = "800"; - drEmployee["WorkOrder"] = "------"; - drEmployee["Dyelot"] = ""; - drEmployee["Temperature"] = 0.0; - drEmployee["WaterLevel"] = 0.0; - drEmployee["Process"] = ""; - drEmployee["Step"] = ""; - drEmployee["Message"] = ""; - drEmployee["SYSKEY"] = ""; - drEmployee["WORK_RUN"] = "-1"; - drEmployee["ERR"] = false; - drEmployee.EndEdit(); - drEmployee.AcceptChanges(); + DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + + Station + "' AND Serial = 'PORT1'").First(); + if (drEmployee.Field("State") != 800) + { + drEmployee.BeginEdit(); + drEmployee["State"] = "800"; + drEmployee["WorkOrder"] = "------"; + drEmployee["Dyelot"] = ""; + drEmployee["Temperature"] = 0.0; + drEmployee["WaterLevel"] = 0.0; + drEmployee["Process"] = ""; + drEmployee["Step"] = ""; + drEmployee["Message"] = ""; + drEmployee["SYSKEY"] = ""; + drEmployee["WORK_RUN"] = "-1"; + drEmployee["ERR"] = false; + drEmployee.EndEdit(); + drEmployee.AcceptChanges(); + } } } - + // 重置事件状态 + _responseEvent.Set(); } catch (Exception) { } } diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index 55512e0..e5201d9 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -771,7 +771,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel } } } - if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息 + if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309")|| (mac_s == "802"))//获取信息 { if (MachinesRow["Serial"].ToString() == "PORT1") {