Test
杨威 2 months ago
parent d649cbbd8a
commit 954bac5bc8

@ -111,14 +111,12 @@ 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++)
{
DOperateInfo.DClose(i);
Thread.Sleep(300);
}
}
}
catch (Exception e)
@ -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)
{
timer.Stop();
DOperateInfo.DClose(monitorEntities[id].Red);
quClient2.Close();
Thread.Sleep(300);
DOperateInfo.DClose(monitorEntities[id].Yellow);
Thread.Sleep(300);
DOperateInfo.DOpen(monitorEntities[id].Green);
FormUtils.LogInsert(LogContext, "RFID {0} 发送绿灯", monitorEntities[id].RFIDValue);
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();

@ -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");
}

@ -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
/// <param name="delay">延迟1代表0.1s/100ms</param>
public void DTimeOpen(int port, int delay)
{
XTrace.WriteLine("发送延迟开灯指令:"+(int)port);
DTimeOpen((Port)(port + 4), delay);
}
@ -55,6 +57,7 @@ namespace NDSD_TouchSocket
/// <param name="port">int1-16</param>
public void DOpen(int port)
{
XTrace.WriteLine("发送开灯指令:"+(int)port);
DOpen((Port)(port + 4));
}
@ -75,6 +78,7 @@ namespace NDSD_TouchSocket
/// <param name="port">int1-16</param>
public void DClose(int port)
{
XTrace.WriteLine("发送关灯指令:"+(int)port);
DClose((Port)(port + 4));
}
}

@ -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;
};

Loading…
Cancel
Save