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.

130 lines
3.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using NDSD_TouchSocket;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
namespace NDSD_Screwdriver
{
public partial class ScrewdriverTest : Form
{
DOperate DOperate;
TcpServer server = TcpServer.Instance;
public ScrewdriverTest()
{
InitializeComponent();
DOperate = new DOperate();
if(!server.ServerOpen("192.168.0.101", "6001"))
{
MessageBox.Show("服务端打开失败!");
}
}
private void DOpenButton_Click(object sender, EventArgs e)
{
int no;
int.TryParse(DNoTextBox.Text, out no);
if(no >= 1 && no <= 16)
{
DOperate.DOpen(no);
}
else
{
MessageBox.Show("请输入1-16的数字");
return;
}
}
private void DCloseButton_Click(object sender, EventArgs e)
{
int no;
int.TryParse(DNoTextBox.Text, out no);
if (no >= 1 && no <= 16)
{
DOperate.DClose(no);
}
else
{
MessageBox.Show("请输入1-16的数字");
return;
}
}
private void DCloseAll_Click(object sender, EventArgs e)
{
int span;
int.TryParse(DelaySpanTextBox.Text, out span);
if(span <= 0)
{
MessageBox.Show("属性值无效!");
return;
}
for (int i = 0; i <= 16; i++)
{
DOperate.DClose(i);
Thread.Sleep(span);
}
}
private void DOpenAll_Click(object sender, EventArgs e)
{
int span;
int.TryParse(DelaySpanTextBox.Text, out span);
if (span <= 0)
{
MessageBox.Show("属性值无效!");
return;
}
for (int i = 0; i <= 16; i++)
{
DOperate.DOpen(i);
Thread.Sleep(span);
}
}
private void ScrewdriverTest_FormClosed(object sender, FormClosedEventArgs e)
{
server.ServerStop();
server.ServerDispose();
}
private void DelayButton_Click(object sender, EventArgs e)
{
int no;
int time;
int.TryParse(DNoTextBox.Text, out no);
int.TryParse(DelayTimeTextBox.Text, out time);
DOperate.DTimeOpen(no, time);
}
private void AllTimeButton_Click(object sender, EventArgs e)
{
int span;
int.TryParse(DelaySpanTextBox.Text, out span);
int time;
int.TryParse(DelayTimeTextBox.Text, out time);
if (span <= 0 || time <= 0)
{
MessageBox.Show("属性值无效!");
return;
}
for (int i = 0; i <= 16; i++)
{
DOperate.DTimeOpen(i, time);
Thread.Sleep(span);
}
}
}
}