|
|
@ -18,6 +18,7 @@ using System.Timers;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
using NewLife.Caching;
|
|
|
|
using NewLife.Caching;
|
|
|
|
|
|
|
|
using NewLife.Collections;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NDSD_Screwdriver
|
|
|
|
namespace NDSD_Screwdriver
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -68,25 +69,30 @@ namespace NDSD_Screwdriver
|
|
|
|
|
|
|
|
|
|
|
|
private CancellationTokenSource cancellationTokenSource;
|
|
|
|
private CancellationTokenSource cancellationTokenSource;
|
|
|
|
|
|
|
|
|
|
|
|
private CancellationTokenSource sendCancellationTokenSource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int textRFID = 0;
|
|
|
|
public int textRFID = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Queue<DOperateEntity> _methodQueue;
|
|
|
|
|
|
|
|
private ICache cache = Cache.Default;
|
|
|
|
private ICache cache = Cache.Default;
|
|
|
|
int FlashIndex = 0;
|
|
|
|
int FlashIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
bool _flashflag = true;
|
|
|
|
bool _flashflag = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private DengTool tool;
|
|
|
|
|
|
|
|
|
|
|
|
public MainForm()
|
|
|
|
public MainForm()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
InitializeComponent();
|
|
|
|
_methodQueue = new Queue<DOperateEntity>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tool = new DengTool();
|
|
|
|
|
|
|
|
tool.Start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FlashThreadTime();
|
|
|
|
FlashThreadTime();
|
|
|
@ -109,7 +115,7 @@ namespace NDSD_Screwdriver
|
|
|
|
{
|
|
|
|
{
|
|
|
|
serialPort = new SerialPortFactory(memorySetting.Com);
|
|
|
|
serialPort = new SerialPortFactory(memorySetting.Com);
|
|
|
|
StartLongRunningTask();
|
|
|
|
StartLongRunningTask();
|
|
|
|
SendRunningTask();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -139,10 +145,8 @@ namespace NDSD_Screwdriver
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sendCancellationTokenSource != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
tool.Stop();
|
|
|
|
sendCancellationTokenSource.Cancel();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cancellationTokenSource != null)
|
|
|
|
if (cancellationTokenSource != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -456,7 +460,7 @@ namespace NDSD_Screwdriver
|
|
|
|
if (RFIDStatesEntities[i].RFIDState == 1)
|
|
|
|
if (RFIDStatesEntities[i].RFIDState == 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// DOperateInfo.DOpen(lightsEntities[i].Yellow);
|
|
|
|
// DOperateInfo.DOpen(lightsEntities[i].Yellow);
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[i].Yellow,
|
|
|
|
port = lightsEntities[i].Yellow,
|
|
|
|
delay = 0
|
|
|
|
delay = 0
|
|
|
@ -465,13 +469,13 @@ namespace NDSD_Screwdriver
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (RFIDStatesEntities[i].RFIDState == 3)
|
|
|
|
else if (RFIDStatesEntities[i].RFIDState == 3)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[i].Green,
|
|
|
|
port = lightsEntities[i].Green,
|
|
|
|
delay = 0
|
|
|
|
delay = 0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[i].Yellow,
|
|
|
|
port = lightsEntities[i].Yellow,
|
|
|
|
delay = -1
|
|
|
|
delay = -1
|
|
|
@ -481,13 +485,13 @@ namespace NDSD_Screwdriver
|
|
|
|
else if (RFIDStatesEntities[i].RFIDState == 4)
|
|
|
|
else if (RFIDStatesEntities[i].RFIDState == 4)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[i].Red,
|
|
|
|
port = lightsEntities[i].Red,
|
|
|
|
delay = 0
|
|
|
|
delay = 0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[i].Yellow,
|
|
|
|
port = lightsEntities[i].Yellow,
|
|
|
|
delay = -1
|
|
|
|
delay = -1
|
|
|
@ -605,52 +609,7 @@ namespace NDSD_Screwdriver
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// RFID刷新任务
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private void SendRunningTask()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sendCancellationTokenSource = new CancellationTokenSource();
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
while (!sendCancellationTokenSource.Token.IsCancellationRequested)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!cache.ContainsKey("Test"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (_methodQueue.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var q = _methodQueue.Dequeue();
|
|
|
|
|
|
|
|
// -1 DClose > 0 DTimeOpen =0 Dopen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (q.delay == -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DOperateInfo.DClose(q.port);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (q.delay == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DOperateInfo.DOpen(q.port);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (q.delay > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DOperateInfo.DTimeOpen(q.port, q.delay);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(210); // 模拟一些长时间的工作
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_methodQueue.Clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(100); // 模拟一些长时间的工作
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, cancellationTokenSource.Token);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
///// <summary>
|
|
|
|
///// 等待工作指示灯闪烁进程
|
|
|
|
///// 等待工作指示灯闪烁进程
|
|
|
@ -687,7 +646,7 @@ namespace NDSD_Screwdriver
|
|
|
|
if (step == 0)
|
|
|
|
if (step == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
step = 1;
|
|
|
|
step = 1;
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[FlashIndex].Yellow,
|
|
|
|
port = lightsEntities[FlashIndex].Yellow,
|
|
|
|
delay = 1
|
|
|
|
delay = 1
|
|
|
@ -775,20 +734,20 @@ namespace NDSD_Screwdriver
|
|
|
|
for (int i = 0; i < RFIDStatesEntities.Count; i++)
|
|
|
|
for (int i = 0; i < RFIDStatesEntities.Count; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[i].Yellow,
|
|
|
|
port = lightsEntities[i].Yellow,
|
|
|
|
delay = -1
|
|
|
|
delay = -1
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[i].Red,
|
|
|
|
port = lightsEntities[i].Red,
|
|
|
|
delay = -1
|
|
|
|
delay = -1
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_methodQueue.Enqueue(new DOperateEntity()
|
|
|
|
tool.AddMq(new DOperateEntity()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
port = lightsEntities[i].Green,
|
|
|
|
port = lightsEntities[i].Green,
|
|
|
|
delay = -1
|
|
|
|
delay = -1
|
|
|
|