|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|
|
|
using System.IO.Ports;
|
|
|
|
using System.IO.Ports;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
|
@ -12,10 +13,9 @@ namespace Mesnac.DoUtils
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 报警灯控制类
|
|
|
|
/// 报警灯控制类
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public sealed class DoControl
|
|
|
|
public class DoControl
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public SerialPort serialPort;
|
|
|
|
public SerialPort serialPort = new SerialPort("COM5");
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly Lazy<DoControl> lazy = new Lazy<DoControl>(() => new DoControl());
|
|
|
|
private static readonly Lazy<DoControl> lazy = new Lazy<DoControl>(() => new DoControl());
|
|
|
|
public static DoControl Instance
|
|
|
|
public static DoControl Instance
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -31,7 +31,6 @@ namespace Mesnac.DoUtils
|
|
|
|
serialPort.DataBits = 8;
|
|
|
|
serialPort.DataBits = 8;
|
|
|
|
serialPort.StopBits = StopBits.One;
|
|
|
|
serialPort.StopBits = StopBits.One;
|
|
|
|
serialPort.Parity = Parity.None;
|
|
|
|
serialPort.Parity = Parity.None;
|
|
|
|
serialPort = new SerialPort("COM5");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -131,6 +130,10 @@ namespace Mesnac.DoUtils
|
|
|
|
public void DOControl(DOName dOName, DOOnOff dOOnOff)
|
|
|
|
public void DOControl(DOName dOName, DOOnOff dOOnOff)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//ComOn();
|
|
|
|
//ComOn();
|
|
|
|
|
|
|
|
if (!serialPort.IsOpen)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
serialPort.Open();
|
|
|
|
|
|
|
|
}
|
|
|
|
serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12);
|
|
|
|
serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|