From 18634444a4ce896c675c9e3ebe3645e7dd2ec90a Mon Sep 17 00:00:00 2001 From: nodyang Date: Tue, 29 Aug 2023 17:18:02 +0800 Subject: [PATCH] fix --- .../FinishBatch/FinishBatchService.cs | 2 +- .../FinishBatch/SaveHelper/AlarmSaveHelper.cs | 22 +-- .../Test/TestTrigerAlarmAction.cs | 2 +- Main/MCEdit/Data/MCProject/SCWSProject2.mprj | 1 - Main/MCRun/Program.cs | 2 +- Mesnac.PlcUtils/PlcBusiness.cs | 178 +++++++++--------- 6 files changed, 103 insertions(+), 104 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs index 072cbef..cd6c7fe 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs @@ -113,7 +113,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch { #region 0、实时刷新自动保存报警 - SaveHelper.AlarmSaveHelper.Instance.Save(); + ReportWetMixerSaveHelper.Instance.SaveWetMixerReport(); #endregion diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs index 68577a1..09f21a2 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/AlarmSaveHelper.cs @@ -26,7 +26,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper public object senderExtend = null; private int WordLength = 16; //定义字长 - private PlcBusiness plcBusiness = PlcBusiness.Instance; + // private PlcBusiness plcBusiness = PlcBusiness.Instance; // private DoControl doControl = DoControl.Instance; @@ -132,16 +132,16 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper foreach (Entity.AlarmInfo info in _alarmInfoList) { string address = $"DB{info.AlarmBlock}.DBX{info.AlarmWord}.{info.AlarmBit}"; - OperateResult result = plcBusiness.readBoolValue(address); - ICSharpCode.Core.LoggingService.Debug(string.Format("{0}读取{1}", address, result.IsSuccess == true ? $"成功;读取结果:{result.Content}" : "失败")); - if (result.IsSuccess == true) - { - if (result.Content) - { - AlarmLogicalProcessing(_alarmBlockWordList, info); - } - } - AlarmLight(result.Content); //控制报警灯 True红灯;False绿灯 + // OperateResult result = plcBusiness.readBoolValue(address); + // ICSharpCode.Core.LoggingService.Debug(string.Format("{0}读取{1}", address, result.IsSuccess == true ? $"成功;读取结果:{result.Content}" : "失败")); + // if (result.IsSuccess == true) + // { + // if (result.Content) + // { + // AlarmLogicalProcessing(_alarmBlockWordList, info); + // } + // } + // AlarmLight(result.Content); //控制报警灯 True红灯;False绿灯 } #region 触发事件 diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestTrigerAlarmAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestTrigerAlarmAction.cs index 4b84de9..3ef5cd7 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestTrigerAlarmAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestTrigerAlarmAction.cs @@ -14,7 +14,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test public void Run(RuntimeParameter runtime) { base.RunIni(runtime); - FinishBatch.SaveHelper.AlarmSaveHelper.Instance.Save(); + // FinishBatch.SaveHelper.AlarmSaveHelper.Instance.Save(); } } } diff --git a/Main/MCEdit/Data/MCProject/SCWSProject2.mprj b/Main/MCEdit/Data/MCProject/SCWSProject2.mprj index 745c146..d0ff891 100644 --- a/Main/MCEdit/Data/MCProject/SCWSProject2.mprj +++ b/Main/MCEdit/Data/MCProject/SCWSProject2.mprj @@ -29,7 +29,6 @@ - diff --git a/Main/MCRun/Program.cs b/Main/MCRun/Program.cs index bb62845..f914200 100644 --- a/Main/MCRun/Program.cs +++ b/Main/MCRun/Program.cs @@ -118,7 +118,7 @@ namespace MCRun var nodes = doc.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[4].ChildNodes[0]; var ip = nodes.Attributes["value"].Value; //初始化HslCommunication 11.0.6.0 - PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc,ip, 102); + // PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc,ip, 102); } catch (Exception exception) { diff --git a/Mesnac.PlcUtils/PlcBusiness.cs b/Mesnac.PlcUtils/PlcBusiness.cs index 1b3ac13..5228576 100644 --- a/Mesnac.PlcUtils/PlcBusiness.cs +++ b/Mesnac.PlcUtils/PlcBusiness.cs @@ -1,89 +1,89 @@ -using HslCommunication; -using Mesnac.PlcUtils.common; -using Mesnac.PlcUtils.enumInfo; -using Mesnac.PlcUtils.Impl; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace Mesnac.PlcUtils -{ - public sealed class PlcBusiness - { - - private static readonly Lazy lazy = new Lazy(() => new PlcBusiness()); - public static PlcBusiness Instance - { - get - { - return lazy.Value; - } - } - - private PlcBusiness() { } - - private static IPlc plcInstance = null; - - public void InitPlcConnect(PlcType plcType, string plcAddress, int plcPort) - { - try - { - string str = System.Environment.CurrentDirectory; - str = str + "\\Mesnac.PlcUtils.dll"; - Assembly assembly = Assembly.LoadFile(str); // 加载程序集(EXE 或 DLL) - string AssemName = "Mesnac.PlcUtils.Impl." + plcType.GetDescription(); - var obj = assembly.CreateInstance(AssemName, true); - plcInstance = obj as IPlc; - if (plcInstance == null) - { - ICSharpCode.Core.LoggingService.Error("PLC初始化失败!!!"); - return; - } - else - { - if (!plcInstance.IsConnected) - { - bool connectResult = plcInstance.Connect(plcAddress, plcPort); - if (connectResult) - { - ICSharpCode.Core.LoggingService.Debug("PLC连接成功!!!"); - } - else - { - ICSharpCode.Core.LoggingService.Error("PLC连接失败!!!"); - } - } - } - } - catch (Exception ex) - { - ICSharpCode.Core.LoggingService.Error($"PLC初始化异常:{ex.Message}"); - } - } - - public void Dispose() - { - plcInstance.DisConnect(); - } - - - public OperateResult readBoolValue(string address) - { - if(plcInstance != null) - { - return plcInstance.readBoolByAddress(address); - } - else - { - return new OperateResult() { - IsSuccess = false, - Content = false - }; - } - } - - } -} +// using HslCommunication; +// using Mesnac.PlcUtils.common; +// using Mesnac.PlcUtils.enumInfo; +// using Mesnac.PlcUtils.Impl; +// using System; +// using System.Collections.Generic; +// using System.Linq; +// using System.Reflection; +// using System.Text; +// using System.Threading.Tasks; +// +// namespace Mesnac.PlcUtils +// { +// public sealed class PlcBusiness +// { +// +// private static readonly Lazy lazy = new Lazy(() => new PlcBusiness()); +// public static PlcBusiness Instance +// { +// get +// { +// return lazy.Value; +// } +// } +// +// private PlcBusiness() { } +// +// private static IPlc plcInstance = null; +// +// public void InitPlcConnect(PlcType plcType, string plcAddress, int plcPort) +// { +// try +// { +// string str = System.Environment.CurrentDirectory; +// str = str + "\\Mesnac.PlcUtils.dll"; +// Assembly assembly = Assembly.LoadFile(str); // 加载程序集(EXE 或 DLL) +// string AssemName = "Mesnac.PlcUtils.Impl." + plcType.GetDescription(); +// var obj = assembly.CreateInstance(AssemName, true); +// plcInstance = obj as IPlc; +// if (plcInstance == null) +// { +// ICSharpCode.Core.LoggingService.Error("PLC初始化失败!!!"); +// return; +// } +// else +// { +// if (!plcInstance.IsConnected) +// { +// bool connectResult = plcInstance.Connect(plcAddress, plcPort); +// if (connectResult) +// { +// ICSharpCode.Core.LoggingService.Debug("PLC连接成功!!!"); +// } +// else +// { +// ICSharpCode.Core.LoggingService.Error("PLC连接失败!!!"); +// } +// } +// } +// } +// catch (Exception ex) +// { +// ICSharpCode.Core.LoggingService.Error($"PLC初始化异常:{ex.Message}"); +// } +// } +// +// public void Dispose() +// { +// plcInstance.DisConnect(); +// } +// +// +// public OperateResult readBoolValue(string address) +// { +// if(plcInstance != null) +// { +// return plcInstance.readBoolByAddress(address); +// } +// else +// { +// return new OperateResult() { +// IsSuccess = false, +// Content = false +// }; +// } +// } +// +// } +// }