diff --git a/NDSD-Screwdriver/MainForm.cs b/NDSD-Screwdriver/MainForm.cs index 95352da..75a5e5a 100644 --- a/NDSD-Screwdriver/MainForm.cs +++ b/NDSD-Screwdriver/MainForm.cs @@ -111,13 +111,11 @@ namespace NDSD_Screwdriver { serialPort = new SerialPortFactory(memorySetting.Com); - for (int w = 0; w < 2; w++) + Thread.Sleep(5000); + for (int i = 0; i < 16; i++) { - for (int i = 0; i < 16; i++) - { - DOperateInfo.DClose(i); - Thread.Sleep(300); - } + DOperateInfo.DClose(i); + Thread.Sleep(300); } } @@ -533,7 +531,7 @@ namespace NDSD_Screwdriver { var read = serialPort?.Read(); - // var read = ""; + XTrace.WriteLine("读取条码:"+read); if (read.Length == 16) { @@ -547,34 +545,30 @@ namespace NDSD_Screwdriver var monitorEntitiesCount = monitorEntities.Count; - var last = monitorEntities[FlashIndex].RFIDState; + if (FlashIndex < monitorEntitiesCount) { - if (last != 100 && last==1) + var rfidState = monitorEntities[FlashIndex].RFIDState; + var last = rfidState; + string no = monitorEntities[FlashIndex].RFIDValue; + if (last != 100 && no==read) { quClient2.Enable(); dateTime = DateTime.Now; if (FlashIndex < monitorEntitiesCount) { - XTrace.WriteLine("a"); - //状态修改 monitorEntities[FlashIndex].RFIDState = 1; - DOperateInfo.DOpen(monitorEntities[FlashIndex].Yellow); - - timer.Start(); + } } } - - - - + } else { - XTrace.WriteLine("aa"); + var total = DateTime.Now - dateTime; if (total.TotalSeconds > 2) { @@ -633,11 +627,10 @@ namespace NDSD_Screwdriver if (RFIDState == 2) { - DOperateInfo.DClose(monitorEntities[id].Red); - Thread.Sleep(300); - DOperateInfo.DClose(monitorEntities[id].Green); - Thread.Sleep(300); - + + // DOperateInfo.DClose(monitorEntities[id].Green); + // Thread.Sleep(300); + XTrace.WriteLine("亮黄灯延迟"); DOperateInfo.DTimeOpen(monitorEntities[id].Yellow, 1); monitorEntities[id].RowEntitys[2].Color = Brushes.Yellow; } @@ -668,6 +661,13 @@ namespace NDSD_Screwdriver { dictionary[monitorEntities[id].RFIDValue] = 1; } + + XTrace.WriteLine("读取Rfid 亮黄灯"); + //状态修改 + + DOperateInfo.DOpen(monitorEntities[FlashIndex].Yellow); + timer.Start(); + monitorEntities[id].RowEntitys[2].Color = Brushes.Yellow; } @@ -675,23 +675,19 @@ namespace NDSD_Screwdriver RFIDState = monitorEntities[id].RFIDState; if (RFIDState == 3) { - - DOperateInfo.DClose(monitorEntities[id].Red); - Thread.Sleep(300); - DOperateInfo.DClose(monitorEntities[id].Yellow); + timer.Stop(); + + quClient2.Close(); Thread.Sleep(300); - - FormUtils.LogInsert(LogContext, "RFID {0} 发送绿灯", monitorEntities[id].RFIDValue); + DOperateInfo.DClose(monitorEntities[id].Yellow); + Thread.Sleep(300); + DOperateInfo.DOpen(monitorEntities[id].Green); - XTrace.WriteLine("========================================================================"); - DOperateInfo.DOpen(monitorEntities[id].Green); - Thread.Sleep(300); - DOperateInfo.DOpen(monitorEntities[id].Green); - quClient2.Close(); + monitorEntities[id].RowEntitys[2].Color = Brushes.Green; monitorEntities[id].RFIDState=100; - timer.Stop(); + FlashIndex += 1; timer.Start(); diff --git a/NDSD-Screwdriver/Tool/QingTcpClient2.cs b/NDSD-Screwdriver/Tool/QingTcpClient2.cs index a180659..671e5d8 100644 --- a/NDSD-Screwdriver/Tool/QingTcpClient2.cs +++ b/NDSD-Screwdriver/Tool/QingTcpClient2.cs @@ -117,12 +117,14 @@ namespace NDSD_Screwdriver.Tool public void Enable() { + // XTrace.WriteLine("枪发送使能"); tcpClient.Send("00200043 \0"); } public void Close() { + // XTrace.WriteLine("枪发送关闭"); tcpClient.Send("00200042 \0"); } diff --git a/NDSD-TouchSocket/DOperate.cs b/NDSD-TouchSocket/DOperate.cs index 8ae6679..3e1f8d1 100644 --- a/NDSD-TouchSocket/DOperate.cs +++ b/NDSD-TouchSocket/DOperate.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using NewLife; +using NewLife.Log; namespace NDSD_TouchSocket { @@ -37,6 +38,7 @@ namespace NDSD_TouchSocket /// 延迟,1代表0.1s/100ms public void DTimeOpen(int port, int delay) { + XTrace.WriteLine("发送延迟开灯指令:"+(int)port); DTimeOpen((Port)(port + 4), delay); } @@ -55,6 +57,7 @@ namespace NDSD_TouchSocket /// int1-16 public void DOpen(int port) { + XTrace.WriteLine("发送开灯指令:"+(int)port); DOpen((Port)(port + 4)); } @@ -75,6 +78,7 @@ namespace NDSD_TouchSocket /// int1-16 public void DClose(int port) { + XTrace.WriteLine("发送关灯指令:"+(int)port); DClose((Port)(port + 4)); } } diff --git a/NDSD-TouchSocket/TcpServer.cs b/NDSD-TouchSocket/TcpServer.cs index 34ae1a7..7aa68e7 100644 --- a/NDSD-TouchSocket/TcpServer.cs +++ b/NDSD-TouchSocket/TcpServer.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using NewLife; +using NewLife.Log; using TouchSocket.Core; using TouchSocket.Sockets; @@ -28,12 +30,12 @@ namespace NDSD_TouchSocket { service.Connecting = (client, e) => { - Console.WriteLine(client.IP + " 正在连接"); + XTrace.WriteLine(client.IP + " 正在连接"); return EasyTask.CompletedTask; };//有客户端正在连接 service.Connected = (client, e) => { - Console.WriteLine(client.IP + " 成功连接"); + XTrace.WriteLine(client.IP + " 成功连接"); service.ResetIdAsync(client.Id, client.IP); this.ClientIP = client.IP; this.ClientPort = client.Port.ToString(); @@ -41,12 +43,12 @@ namespace NDSD_TouchSocket };//有客户端成功连接 service.Closing = (client, e) => { - Console.WriteLine(client.IP + " 正在断开连接"); + XTrace.WriteLine(client.IP + " 正在断开连接"); return EasyTask.CompletedTask; };//有客户端正在断开连接,只有当主动断开时才有效。 service.Closed = (client, e) => { - Console.WriteLine(client.IP + " 断开连接"); + XTrace.WriteLine(client.IP + " 断开连接"); return EasyTask.CompletedTask; };//有客户端断开连接 service.Received = (client, e) => @@ -56,7 +58,8 @@ namespace NDSD_TouchSocket //logHelper.Info($"已从{client.IP}:{client.Port}接收到信息:{mes}"); //BufferMemory(BufferAnalysis.SplitByteArray(e.ByteBlock.Span.ToArray(), 0, e.ByteBlock.Length)); - + var byte2 = BufferAnalysis.SplitByteArray(e.ByteBlock.Span.ToArray(), 0, e.ByteBlock.Length); + XTrace.WriteLine(byte2.ToHex(" ")); return EasyTask.CompletedTask; };