You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.7 KiB
C#

using NDSD_TouchSocket;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace NDSD_Screwdriver.Tool
{
public class DengTool
{
private Queue<DOperateEntity> _methodQueue;
private CancellationTokenSource sendCancellationTokenSource;
/// <summary>
/// 输出端口操作
/// </summary>
private DOperate DOperateInfo;
public DengTool()
{
DOperateInfo = new DOperate();
_methodQueue =new Queue<DOperateEntity>();
}
/// <summary>
/// RFID刷新任务
/// </summary>
// private void SendRunningTask()
// {
// sendCancellationTokenSource = new CancellationTokenSource();
// Task.Run(() =>
// {
// while (!sendCancellationTokenSource.Token.IsCancellationRequested)
// {
// while (_methodQueue.Count > 0)
// {
// var q = _methodQueue.Dequeue();
// // -1 DClose > 0 DTimeOpen =0 Dopen
// //-1 DClose > 0 DTimeOpen =0 Dopen
// if (q.delay == -1)
// {
// DOperateInfo.DClose(q.port);
// }
//
// if (q.delay == 0)
// {
// DOperateInfo.DClose(q.port);
// Thread.Sleep(100); // 模拟一些长时间的工作
// DOperateInfo.DOpen(q.port);
// }
//
// if (q.delay ==1)
// {
//
// DOperateInfo.DTimeOpen(q.port, q.delay);
// }
//
// Thread.Sleep(100); // 模拟一些长时间的工作
// }
//
// Thread.Sleep(10); // 模拟一些长时间的工作
// }
// }, sendCancellationTokenSource.Token);
// }
public void AddMq(DOperateEntity entity)
{
_methodQueue.Enqueue(entity);
}
public void Stop()
{
_methodQueue.Clear();
sendCancellationTokenSource.Cancel();
}
public void Start()
{
// SendRunningTask();
}
public void Restart()
{
Stop();
Thread.Sleep(200);
Start();
}
}
}