|
|
|
@ -109,17 +109,28 @@ namespace SlnMesnac.Common
|
|
|
|
|
{
|
|
|
|
|
if (serialPort.IsOpen)
|
|
|
|
|
{
|
|
|
|
|
byte[] buffer = null;
|
|
|
|
|
|
|
|
|
|
if (data == "NG")
|
|
|
|
|
{
|
|
|
|
|
buffer = GetBytesByCommand("OpenRed");
|
|
|
|
|
byte[] buffer = GetBytesByCommand("CloseRed");
|
|
|
|
|
serialPort.Write(buffer, 0x0, 0x4);
|
|
|
|
|
byte[] buffer1 = GetBytesByCommand("OpenRed");
|
|
|
|
|
serialPort.Write(buffer1, 0x0, 0x4);
|
|
|
|
|
}
|
|
|
|
|
else if (data == "OK")
|
|
|
|
|
{
|
|
|
|
|
buffer = GetBytesByCommand("CloseRed");
|
|
|
|
|
byte[] buffer = GetBytesByCommand("CloseRed");
|
|
|
|
|
serialPort.Write(buffer, 0x0, 0x4);
|
|
|
|
|
byte[] buffer1 = GetBytesByCommand("OpenGreen");
|
|
|
|
|
serialPort.Write(buffer1, 0x0, 0x4);
|
|
|
|
|
}
|
|
|
|
|
else if(data == "Exit")
|
|
|
|
|
{
|
|
|
|
|
byte[] buffer = GetBytesByCommand("CloseRed");
|
|
|
|
|
serialPort.Write(buffer, 0x0, 0x4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("串口未打开,请先初始化串口并打开连接。");
|
|
|
|
@ -142,18 +153,16 @@ namespace SlnMesnac.Common
|
|
|
|
|
byte[] buffer = null;
|
|
|
|
|
switch (command)
|
|
|
|
|
{
|
|
|
|
|
// 打开红灯+蜂鸣
|
|
|
|
|
case "OpenRed": buffer = new byte[] { 0xA0, 0x00, 0x02, 0xA2 }; break;
|
|
|
|
|
// 关闭红灯+蜂鸣
|
|
|
|
|
// 打开红灯闪烁+蜂鸣
|
|
|
|
|
case "OpenRed": buffer = new byte[] { 0xA0, 0x07, 0x02, 0xA9 }; break;
|
|
|
|
|
// 打开红灯闪烁
|
|
|
|
|
//case "OpenRed": buffer = new byte[] { 0xA0, 0x03, 0x02, 0xA5 }; break;
|
|
|
|
|
// 全部关闭
|
|
|
|
|
case "CloseRed": buffer = new byte[] { 0xA0, 0x00, 0x00, 0xA0 }; break;
|
|
|
|
|
////闪烁红灯+蜂鸣
|
|
|
|
|
//case "FlashRed": buffer = new byte[] { 0xA0, 0x07, 0x02, 0xA9 }; break;
|
|
|
|
|
|
|
|
|
|
//// 打开绿灯
|
|
|
|
|
//case "OpenGreen": buffer = new byte[] { 0xA0, 0x00, 0x01, 0xA1 }; break;
|
|
|
|
|
//// 关闭绿灯
|
|
|
|
|
//case "CloseGreen": buffer = new byte[] { 0xA0, 0x00, 0x00, 0xA0 }; break;
|
|
|
|
|
//// 闪烁绿灯
|
|
|
|
|
//case "FlashGreen": buffer = new byte[] { 0xA0, 0x00, 0x02, 0xA2 }; break;
|
|
|
|
|
case "OpenGreen": buffer = new byte[] { 0xA0, 0x02, 0x01, 0xA3 }; break;
|
|
|
|
|
|
|
|
|
|
default:return null;
|
|
|
|
|
}
|
|
|
|
|
return buffer;
|
|
|
|
|