diff --git a/Main/MCRun/Program.cs b/Main/MCRun/Program.cs index 7a9ee0c..b432696 100644 --- a/Main/MCRun/Program.cs +++ b/Main/MCRun/Program.cs @@ -102,6 +102,11 @@ namespace MCRun if (Mesnac.Gui.Common.RunEngine.Instance.Init(projectPath, true, true, true)) //初始化运行引擎 { AppConfigHandler.Instance.InitCustomerMenuAndToolStrip(WorkbenchSingleton.Workbench.TopMenu, WorkbenchSingleton.Workbench.ToolStrip); //初始化自定义系统菜单和工具栏 + + //初始化HslCommunication 11.0.6.0 + PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc, "127.0.0.1", 12); + //初始化连接报警器 + DoControl.Instance.ComOn(); } //if (!Mesnac.Basic.InfluxDbHelper.Instance.IsStartDbServer) @@ -120,9 +125,6 @@ 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 fdefe6a..4e90369 100644 --- a/Mesnac.DoUtils/DoControl.cs +++ b/Mesnac.DoUtils/DoControl.cs @@ -38,9 +38,16 @@ namespace Mesnac.DoUtils /// public void ComOn() { - if (!serialPort.IsOpen) + try { - serialPort.Open(); + if (!serialPort.IsOpen) + { + serialPort.Open(); + ICSharpCode.Core.LoggingService.Debug($"打开报警器串口成功,串口:{serialPort.PortName};波特率:{serialPort.BaudRate}"); + } + }catch (Exception ex) + { + ICSharpCode.Core.LoggingService.Error($"报警器串口打开异常,串口:{serialPort.PortName};波特率:{serialPort.BaudRate};异常信息:{ex.Message}"); } } /// diff --git a/Mesnac.DoUtils/Mesnac.DoUtils.csproj b/Mesnac.DoUtils/Mesnac.DoUtils.csproj index d8ad2d4..fae43aa 100644 --- a/Mesnac.DoUtils/Mesnac.DoUtils.csproj +++ b/Mesnac.DoUtils/Mesnac.DoUtils.csproj @@ -34,6 +34,12 @@ false + + Z:\Desktop\日常代码\榄菊项目\程序设计\lj_plc\PlugInPlatform\ICSharpCode.Core.dll + + + Z:\Desktop\日常代码\榄菊项目\程序设计\lj_plc\PlugInPlatform\ICSharpCode.Data.Core.dll + diff --git a/Mesnac.PlcUtils/Impl/OmronNJPlc.cs b/Mesnac.PlcUtils/Impl/OmronNJPlc.cs index de87a40..5ce008a 100644 --- a/Mesnac.PlcUtils/Impl/OmronNJPlc.cs +++ b/Mesnac.PlcUtils/Impl/OmronNJPlc.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace Mesnac.PlcUtils.Impl { - public class OmronNJPlc + public class OmronNJPlc:IPlc { private StringChange stringChange = StringChange.Instance;