|
|
|
@ -13,7 +13,7 @@ namespace Mesnac.DoUtils
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警灯控制类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DoControl
|
|
|
|
|
public sealed class DoControl
|
|
|
|
|
{
|
|
|
|
|
public SerialPort serialPort = new SerialPort("COM5");
|
|
|
|
|
private static readonly Lazy<DoControl> lazy = new Lazy<DoControl>(() => new DoControl());
|
|
|
|
@ -136,12 +136,14 @@ namespace Mesnac.DoUtils
|
|
|
|
|
/// <param name="dOOnOff">启停状态</param>
|
|
|
|
|
public void DOControl(DOName dOName, DOOnOff dOOnOff)
|
|
|
|
|
{
|
|
|
|
|
//ComOn();
|
|
|
|
|
if (!serialPort.IsOpen)
|
|
|
|
|
if (serialPort.IsOpen)
|
|
|
|
|
{
|
|
|
|
|
serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
serialPort.Open();
|
|
|
|
|
ComOn();
|
|
|
|
|
}
|
|
|
|
|
serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|