110,566
社区成员
发帖
与我相关
我的任务
分享
private void Device_Load(object sender, EventArgs e)
{
Creatlabel();
Iniform();
timersend.Enabled = false;
if (conf.Openport(serialPort, Comname, boudrate, parity, databit, stopbit))
{
MessageBox.Show("通讯成功");
timersend.Enabled = true;
}
else
{
MessageBox.Show("通讯失败,请检查串口是否被占用?");
}
timersend.Interval = 2000;
}
private void SendCommand()
{
int i;
string sendstr;
for (i = 0; i < Equiment.Length; i++)
{
// RRSTSB0000ZU
sendstr = "RRSTSB" + Equiment[i].PadLeft(4, '0') + "ZU";
serialPort.WriteLine(sendstr);
Delay(2000);
}
}
private void Delay(int mm)
{
DateTime current = DateTime.Now;
while (current.AddMilliseconds(mm) > DateTime.Now)
{
Application.DoEvents();
}
return;
}
private void Delay(int mm)
{
DateTime current = DateTime.Now;
while (current.AddMilliseconds(mm) > DateTime.Now)
{
Application.DoEvents();
}
return;
}