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.

147 lines
3.7 KiB
C#

3 months ago
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;
3 months ago
using System.Threading.Tasks;
using System.Windows.Forms;
3 months ago
using DNSD_DB;
using NewLife.Caching;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
3 months ago
3 months ago
namespace NDSD_Screwdriver
{
public partial class ScrewdriverTest : Form
{
DOperate DOperate;
TcpServer server;
public ScrewdriverTest(TcpServer s, DOperate d) : this()
{
server = s;
DOperate = d;
}
private ICache cache = Cache.Default;
3 months ago
public ScrewdriverTest()
{
InitializeComponent();
cache.Set("Test", DateTime.Now);
3 months ago
}
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;
}
3 months ago
}
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;
}
3 months ago
}
private void DCloseAll_Click(object sender, EventArgs e)
{
int span;
int.TryParse(DelaySpanTextBox.Text, out span);
if(span <= 0)
{
MessageBox.Show("属性值无效!");
return;
}
Thread thread = new Thread(() =>
{
for (int i = 0; i <= 16; i++)
{
DOperate.DClose(i);
Thread.Sleep(span);
}
});
thread.Start();
3 months ago
}
private void DOpenAll_Click(object sender, EventArgs e)
{
int span;
int.TryParse(DelaySpanTextBox.Text, out span);
if (span <= 0)
{
MessageBox.Show("属性值无效!");
return;
}
Thread thread = new Thread(() =>
{
for (int i = 0; i <= 16; i++)
{
DOperate.DOpen(i);
Thread.Sleep(span);
}
});
thread.Start();
}
private void ScrewdriverTest_FormClosed(object sender, FormClosedEventArgs e)
{
cache.Remove("Test");
}
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);
}
3 months ago
private void AllTimeButton_Click(object sender, EventArgs e)
{
3 months ago
int.TryParse(DelaySpanTextBox.Text, out var span);
int.TryParse(DelayTimeTextBox.Text, out var time);
if (span <= 0 || time <= 0)
{
MessageBox.Show("属性值无效!");
return;
}
Thread thread = new Thread(() =>
{
for (int i = 0; i <= 16; i++)
{
DOperate.DTimeOpen(i, time);
Thread.Sleep(span);
}
});
thread.Start();
3 months ago
}
3 months ago
}
}