|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
using DNSD_DB;
|
|
|
|
|
using NDSD_Screwdriver.Entity;
|
|
|
|
|
using NDSD_Screwdriver.Tool;
|
|
|
|
|
|
|
|
|
|
using NDSD_TouchSocket;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
@ -9,6 +11,7 @@ using System.Drawing;
|
|
|
|
|
using System.Drawing.Text;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
@ -55,6 +58,11 @@ namespace NDSD_Screwdriver
|
|
|
|
|
"5555222233334444"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SerialPortFactory serialPort;
|
|
|
|
|
|
|
|
|
|
private CancellationTokenSource cancellationTokenSource;
|
|
|
|
|
|
|
|
|
|
public MainForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
@ -64,7 +72,24 @@ namespace NDSD_Screwdriver
|
|
|
|
|
MessageBox.Show("服务端打开失败!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serialPort=new SerialPortFactory();
|
|
|
|
|
|
|
|
|
|
StartLongRunningTask();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StartLongRunningTask()
|
|
|
|
|
{
|
|
|
|
|
cancellationTokenSource = new CancellationTokenSource();
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
while (!cancellationTokenSource.Token.IsCancellationRequested)
|
|
|
|
|
{
|
|
|
|
|
// 这里是你的长期运行逻辑
|
|
|
|
|
Thread.Sleep(1000); // 模拟一些长时间的工作
|
|
|
|
|
}
|
|
|
|
|
}, cancellationTokenSource.Token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 打开DO测试
|
|
|
|
@ -73,6 +98,9 @@ namespace NDSD_Screwdriver
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void DOTest_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string str= serialPort.Read();
|
|
|
|
|
|
|
|
|
|
ScrewdriverTest screwdriverTest = new ScrewdriverTest(server, DOperate);
|
|
|
|
|
screwdriverTest.Show();
|
|
|
|
|
}
|
|
|
|
|