From 00ebb2f69d673628aa58748b978dd1663d56fed0 Mon Sep 17 00:00:00 2001 From: wangsr Date: Tue, 8 Aug 2023 13:49:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E7=81=AF=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mesnac.DoUtils/DoControl.cs | 12 +++++++----- Mesnac.DoUtils/Mesnac.DoUtils.csproj | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) 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