diff --git a/Mesnac.DoUtils/DoControl.cs b/Mesnac.DoUtils/DoControl.cs index 4e90369..e5b8f6c 100644 --- a/Mesnac.DoUtils/DoControl.cs +++ b/Mesnac.DoUtils/DoControl.cs @@ -13,7 +13,7 @@ namespace Mesnac.DoUtils /// /// 报警灯控制类 /// - public class DoControl + public sealed class DoControl { public SerialPort serialPort = new SerialPort("COM5"); private static readonly Lazy lazy = new Lazy(() => new DoControl()); @@ -136,12 +136,14 @@ namespace Mesnac.DoUtils /// 启停状态 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); } /// diff --git a/Mesnac.DoUtils/Mesnac.DoUtils.csproj b/Mesnac.DoUtils/Mesnac.DoUtils.csproj index fae43aa..4806769 100644 --- a/Mesnac.DoUtils/Mesnac.DoUtils.csproj +++ b/Mesnac.DoUtils/Mesnac.DoUtils.csproj @@ -35,10 +35,10 @@ - Z:\Desktop\日常代码\榄菊项目\程序设计\lj_plc\PlugInPlatform\ICSharpCode.Core.dll + ..\PlugInPlatform\ICSharpCode.Core.dll - Z:\Desktop\日常代码\榄菊项目\程序设计\lj_plc\PlugInPlatform\ICSharpCode.Data.Core.dll + ..\PlugInPlatform\ICSharpCode.Data.Core.dll