报警灯完善

master
wangsr 1 year ago
parent c29239fef0
commit 00ebb2f69d

@ -13,7 +13,7 @@ namespace Mesnac.DoUtils
/// <summary> /// <summary>
/// 报警灯控制类 /// 报警灯控制类
/// </summary> /// </summary>
public class DoControl public sealed class DoControl
{ {
public SerialPort serialPort = new SerialPort("COM5"); 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());
@ -136,12 +136,14 @@ namespace Mesnac.DoUtils
/// <param name="dOOnOff">启停状态</param> /// <param name="dOOnOff">启停状态</param>
public void DOControl(DOName dOName, DOOnOff dOOnOff) 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> /// <summary>

@ -35,10 +35,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ICSharpCode.Core"> <Reference Include="ICSharpCode.Core">
<HintPath>Z:\Desktop\日常代码\榄菊项目\程序设计\lj_plc\PlugInPlatform\ICSharpCode.Core.dll</HintPath> <HintPath>..\PlugInPlatform\ICSharpCode.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="ICSharpCode.Data.Core"> <Reference Include="ICSharpCode.Data.Core">
<HintPath>Z:\Desktop\日常代码\榄菊项目\程序设计\lj_plc\PlugInPlatform\ICSharpCode.Data.Core.dll</HintPath> <HintPath>..\PlugInPlatform\ICSharpCode.Data.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

Loading…
Cancel
Save