报警灯完善

master
wangsr 1 year ago
parent c29239fef0
commit 00ebb2f69d

@ -13,7 +13,7 @@ namespace Mesnac.DoUtils
/// <summary>
/// 报警灯控制类
/// </summary>
public class DoControl
public sealed class DoControl
{
public SerialPort serialPort = new SerialPort("COM5");
private static readonly Lazy<DoControl> lazy = new Lazy<DoControl>(() => new DoControl());
@ -136,13 +136,15 @@ namespace Mesnac.DoUtils
/// <param name="dOOnOff">启停状态</param>
public void DOControl(DOName dOName, DOOnOff dOOnOff)
{
//ComOn();
if (!serialPort.IsOpen)
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);
}
else
{
ComOn();
}
}
/// <summary>
/// 文本框传输数据控制COM5串口

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

Loading…
Cancel
Save