change - 接入报警灯

master
wangsr 1 year ago
parent 969946be45
commit 1faaf589c4

@ -1,4 +1,5 @@
using DevExpress.Xpo.DB;
using FastReport.Export.Dbf;
using HslCommunication;
using Mesnac.Codd.Session;
using Mesnac.DoUtils;
@ -8,6 +9,7 @@ using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
{
@ -126,7 +128,8 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
{
sai.AlarmData = Convert.ToInt16(result.Content); //对起始字偏移,为当前字的报警值
//打开报警灯
//打开报警灯:FIRST 关闭绿灯 SECOND 打开红灯
doControl.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.Off);
doControl.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.On);
//更新报警状态
@ -159,8 +162,18 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
}
}
}
else
{
// 关闭报警灯:FIRST 打开红灯 SECOND 关闭绿灯
doControl.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off);
doControl.DOControl(DoUtils.enumInfo.DOName.Green, DoUtils.enumInfo.DOOnOff.On);
}
}
else
{
doControl.DOControl(DoUtils.enumInfo.DOName.Red, DoUtils.enumInfo.DOOnOff.Off);
}
}
#region 触发事件

@ -110,9 +110,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\A3Lib\FastReport\FastReport.VSDesign.dll</HintPath>
</Reference>
<Reference Include="HslCommunication, Version=11.0.6.0, Culture=neutral, PublicKeyToken=3d72ad3b6b5ec0e3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Z:\Desktop\日常代码\榄菊项目\程序设计\lj_plc\PlugInPlatform\HslCommunication.dll</HintPath>
<Reference Include="HslCommunication">
<HintPath>..\..\..\PlugInPlatform\HslCommunication.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.Core, Version=4.3.0.9338, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

@ -251,6 +251,10 @@
<Project>{d0c0324f-434e-47eb-8f7c-ba6cd7f233b4}</Project>
<Name>Mesnac.Controls.Feeding</Name>
</ProjectReference>
<ProjectReference Include="..\..\Mesnac.DoUtils\Mesnac.DoUtils.csproj">
<Project>{ad132cad-5288-44dc-a38f-4b0658fc228c}</Project>
<Name>Mesnac.DoUtils</Name>
</ProjectReference>
<ProjectReference Include="..\..\Mesnac.PlcUtils\Mesnac.PlcUtils.csproj">
<Project>{88eac8d1-8783-478c-ad9d-f916673b7004}</Project>
<Name>Mesnac.PlcUtils</Name>

@ -10,6 +10,7 @@ using Mesnac.Gui.Run.Global;
namespace MCRun
{
using Mesnac.Core.Service;
using Mesnac.DoUtils;
using Mesnac.Gui.Workbench;
using Mesnac.PlcUtils;
using Mesnac.PlcUtils.common;
@ -120,6 +121,7 @@ namespace MCRun
WorkbenchSingleton.InitializeWorkbench();
PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc, "127.0.0.1", 12);
DoControl.Instance.ComOn();
ICSharpCode.Core.LoggingService<Program>.Debug("starting workbench...");
Form frmMain = WorkbenchSingleton.Workbench as Form;

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
@ -12,10 +13,9 @@ namespace Mesnac.DoUtils
/// <summary>
/// 报警灯控制类
/// </summary>
public sealed class DoControl
public class DoControl
{
public SerialPort serialPort;
public SerialPort serialPort = new SerialPort("COM5");
private static readonly Lazy<DoControl> lazy = new Lazy<DoControl>(() => new DoControl());
public static DoControl Instance
{
@ -31,7 +31,6 @@ namespace Mesnac.DoUtils
serialPort.DataBits = 8;
serialPort.StopBits = StopBits.One;
serialPort.Parity = Parity.None;
serialPort = new SerialPort("COM5");
}
/// <summary>
@ -131,6 +130,10 @@ namespace Mesnac.DoUtils
public void DOControl(DOName dOName, DOOnOff dOOnOff)
{
//ComOn();
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);
}

@ -30,6 +30,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

Loading…
Cancel
Save