change - 接入报警灯

master
wangsr 1 year ago
parent 969946be45
commit 1faaf589c4

@ -1,4 +1,5 @@
using DevExpress.Xpo.DB; using DevExpress.Xpo.DB;
using FastReport.Export.Dbf;
using HslCommunication; using HslCommunication;
using Mesnac.Codd.Session; using Mesnac.Codd.Session;
using Mesnac.DoUtils; using Mesnac.DoUtils;
@ -8,6 +9,7 @@ using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
{ {
@ -126,7 +128,8 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
{ {
sai.AlarmData = Convert.ToInt16(result.Content); //对起始字偏移,为当前字的报警值 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); 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 触发事件 #region 触发事件

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

@ -251,6 +251,10 @@
<Project>{d0c0324f-434e-47eb-8f7c-ba6cd7f233b4}</Project> <Project>{d0c0324f-434e-47eb-8f7c-ba6cd7f233b4}</Project>
<Name>Mesnac.Controls.Feeding</Name> <Name>Mesnac.Controls.Feeding</Name>
</ProjectReference> </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"> <ProjectReference Include="..\..\Mesnac.PlcUtils\Mesnac.PlcUtils.csproj">
<Project>{88eac8d1-8783-478c-ad9d-f916673b7004}</Project> <Project>{88eac8d1-8783-478c-ad9d-f916673b7004}</Project>
<Name>Mesnac.PlcUtils</Name> <Name>Mesnac.PlcUtils</Name>

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

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

Loading…
Cancel
Save