diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs index e4b2696..2702761 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs @@ -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 触发事件 diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index bc6905a..3a8cb83 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -110,9 +110,8 @@ False ..\..\..\A3Lib\FastReport\FastReport.VSDesign.dll - - False - Z:\Desktop\日常代码\榄菊项目\程序设计\lj_plc\PlugInPlatform\HslCommunication.dll + + ..\..\..\PlugInPlatform\HslCommunication.dll False diff --git a/Main/MCRun/MCRun.csproj b/Main/MCRun/MCRun.csproj index 9dec82d..f9f7c87 100644 --- a/Main/MCRun/MCRun.csproj +++ b/Main/MCRun/MCRun.csproj @@ -251,6 +251,10 @@ {d0c0324f-434e-47eb-8f7c-ba6cd7f233b4} Mesnac.Controls.Feeding + + {ad132cad-5288-44dc-a38f-4b0658fc228c} + Mesnac.DoUtils + {88eac8d1-8783-478c-ad9d-f916673b7004} Mesnac.PlcUtils diff --git a/Main/MCRun/Program.cs b/Main/MCRun/Program.cs index baf2532..7a9ee0c 100644 --- a/Main/MCRun/Program.cs +++ b/Main/MCRun/Program.cs @@ -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.Debug("starting workbench..."); Form frmMain = WorkbenchSingleton.Workbench as Form; diff --git a/Mesnac.DoUtils/DoControl.cs b/Mesnac.DoUtils/DoControl.cs index b58862c..fdefe6a 100644 --- a/Mesnac.DoUtils/DoControl.cs +++ b/Mesnac.DoUtils/DoControl.cs @@ -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 /// /// 报警灯控制类 /// - public sealed class DoControl + public class DoControl { - public SerialPort serialPort; - + public SerialPort serialPort = new SerialPort("COM5"); private static readonly Lazy lazy = new Lazy(() => 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"); } /// @@ -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); } diff --git a/Mesnac.DoUtils/Mesnac.DoUtils.csproj b/Mesnac.DoUtils/Mesnac.DoUtils.csproj index f979560..d8ad2d4 100644 --- a/Mesnac.DoUtils/Mesnac.DoUtils.csproj +++ b/Mesnac.DoUtils/Mesnac.DoUtils.csproj @@ -30,6 +30,9 @@ prompt 4 + + false +