diff --git a/Mesnac.DoUtils.zip b/Mesnac.DoUtils.zip new file mode 100644 index 0000000..eb2344b Binary files /dev/null and b/Mesnac.DoUtils.zip differ diff --git a/Mesnac.DoUtils/DoControl.cs b/Mesnac.DoUtils/DoControl.cs index e03ff4e..d261e13 100644 --- a/Mesnac.DoUtils/DoControl.cs +++ b/Mesnac.DoUtils/DoControl.cs @@ -18,7 +18,7 @@ namespace Mesnac.DoUtils public SerialPort serialPort = new SerialPort("COM5"); private static readonly Lazy lazy = new Lazy(() => new DoControl()); public static DoControl Instance => lazy.Value; - + public bool AlarmState { get; private set; } = false; private DoControl() { serialPort.BaudRate = 115200; @@ -125,11 +125,20 @@ namespace Mesnac.DoUtils /// /// DO启停控制 + /// 如果收到红灯亮的信号,AlarmState会变为True; 收到红灯灭的信号,AlarmState设置为false /// /// DegitalOut接口名称 /// 启停状态 public void DOControl(DOName dOName, DOOnOff dOOnOff) { + if(dOName.Equals(DOName.Red) && dOOnOff.Equals(DOOnOff.On)) + { + AlarmState = true; + } + if(dOName.Equals(DOName.Red) && dOOnOff.Equals(DOOnOff.Off)) + { + AlarmState = false; + } if (serialPort.IsOpen) { serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12); @@ -137,6 +146,7 @@ namespace Mesnac.DoUtils else { ComOn(); + serialPort.Write(new byte[] { 0xE3, 0x01, 0x09, (byte)dOName, (byte)dOOnOff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 12); } } diff --git a/Mesnac.PlcUtils.zip b/Mesnac.PlcUtils.zip new file mode 100644 index 0000000..b4f5e66 Binary files /dev/null and b/Mesnac.PlcUtils.zip differ