master
nodyang 1 year ago
parent 8a6fecc6cb
commit 18634444a4

@ -113,7 +113,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch
{ {
#region 0、实时刷新自动保存报警 #region 0、实时刷新自动保存报警
SaveHelper.AlarmSaveHelper.Instance.Save();
ReportWetMixerSaveHelper.Instance.SaveWetMixerReport(); ReportWetMixerSaveHelper.Instance.SaveWetMixerReport();
#endregion #endregion

@ -26,7 +26,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
public object senderExtend = null; public object senderExtend = null;
private int WordLength = 16; //定义字长 private int WordLength = 16; //定义字长
private PlcBusiness plcBusiness = PlcBusiness.Instance; // private PlcBusiness plcBusiness = PlcBusiness.Instance;
// private DoControl doControl = DoControl.Instance; // private DoControl doControl = DoControl.Instance;
@ -132,16 +132,16 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
foreach (Entity.AlarmInfo info in _alarmInfoList) foreach (Entity.AlarmInfo info in _alarmInfoList)
{ {
string address = $"DB{info.AlarmBlock}.DBX{info.AlarmWord}.{info.AlarmBit}"; string address = $"DB{info.AlarmBlock}.DBX{info.AlarmWord}.{info.AlarmBit}";
OperateResult<bool> result = plcBusiness.readBoolValue(address); // OperateResult<bool> result = plcBusiness.readBoolValue(address);
ICSharpCode.Core.LoggingService<AlarmSaveHelper>.Debug(string.Format("{0}读取{1}", address, result.IsSuccess == true ? $"成功;读取结果:{result.Content}" : "失败")); // ICSharpCode.Core.LoggingService<AlarmSaveHelper>.Debug(string.Format("{0}读取{1}", address, result.IsSuccess == true ? $"成功;读取结果:{result.Content}" : "失败"));
if (result.IsSuccess == true) // if (result.IsSuccess == true)
{ // {
if (result.Content) // if (result.Content)
{ // {
AlarmLogicalProcessing(_alarmBlockWordList, info); // AlarmLogicalProcessing(_alarmBlockWordList, info);
} // }
} // }
AlarmLight(result.Content); //控制报警灯 True红灯False绿灯 // AlarmLight(result.Content); //控制报警灯 True红灯False绿灯
} }
#region 触发事件 #region 触发事件

@ -14,7 +14,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test
public void Run(RuntimeParameter runtime) public void Run(RuntimeParameter runtime)
{ {
base.RunIni(runtime); base.RunIni(runtime);
FinishBatch.SaveHelper.AlarmSaveHelper.Instance.Save(); // FinishBatch.SaveHelper.AlarmSaveHelper.Instance.Save();
} }
} }
} }

@ -29,7 +29,6 @@
<Node Name="FormWeight" Text="称量配方管理" ToolTipText="FormWeight" Tag="FormWeight" ImageIndex="3" SelectedImageIndex="3" /> <Node Name="FormWeight" Text="称量配方管理" ToolTipText="FormWeight" Tag="FormWeight" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="FormMix" Text="混合配方管理" ToolTipText="FormMix" Tag="FormMix" ImageIndex="3" SelectedImageIndex="3" /> <Node Name="FormMix" Text="混合配方管理" ToolTipText="FormMix" Tag="FormMix" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="FormProductLine" Text="榄菊产线管理" ToolTipText="FormProductLine" Tag="FormProductLine" ImageIndex="3" SelectedImageIndex="3" /> <Node Name="FormProductLine" Text="榄菊产线管理" ToolTipText="FormProductLine" Tag="FormProductLine" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="FormDeviceMonitor" Text="榄菊设备监控" ToolTipText="FormDeviceMonitor" Tag="FormDeviceMonitor" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="FormDeviceDetail2" Text="设备细节2" ToolTipText="FormDeviceDetail2" Tag="FormDeviceDetail2" ImageIndex="3" SelectedImageIndex="3" /> <Node Name="FormDeviceDetail2" Text="设备细节2" ToolTipText="FormDeviceDetail2" Tag="FormDeviceDetail2" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="FormPlan" Text="榄菊计划管理" ToolTipText="FormPlan" Tag="FormPlan" ImageIndex="3" SelectedImageIndex="3" /> <Node Name="FormPlan" Text="榄菊计划管理" ToolTipText="FormPlan" Tag="FormPlan" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="FormSheBei" Text="榄菊设备配方" ToolTipText="FormSheBei" Tag="FormSheBei" ImageIndex="3" SelectedImageIndex="3" /> <Node Name="FormSheBei" Text="榄菊设备配方" ToolTipText="FormSheBei" Tag="FormSheBei" ImageIndex="3" SelectedImageIndex="3" />

@ -118,7 +118,7 @@ namespace MCRun
var nodes = doc.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[4].ChildNodes[0]; var nodes = doc.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[4].ChildNodes[0];
var ip = nodes.Attributes["value"].Value; var ip = nodes.Attributes["value"].Value;
//初始化HslCommunication 11.0.6.0 //初始化HslCommunication 11.0.6.0
PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc,ip, 102); // PlcBusiness.Instance.InitPlcConnect(PlcType.SiemensPlc,ip, 102);
} }
catch (Exception exception) catch (Exception exception)
{ {

@ -1,89 +1,89 @@
using HslCommunication; // using HslCommunication;
using Mesnac.PlcUtils.common; // using Mesnac.PlcUtils.common;
using Mesnac.PlcUtils.enumInfo; // using Mesnac.PlcUtils.enumInfo;
using Mesnac.PlcUtils.Impl; // using Mesnac.PlcUtils.Impl;
using System; // using System;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Linq; // using System.Linq;
using System.Reflection; // using System.Reflection;
using System.Text; // using System.Text;
using System.Threading.Tasks; // using System.Threading.Tasks;
//
namespace Mesnac.PlcUtils // namespace Mesnac.PlcUtils
{ // {
public sealed class PlcBusiness // public sealed class PlcBusiness
{ // {
//
private static readonly Lazy<PlcBusiness> lazy = new Lazy<PlcBusiness>(() => new PlcBusiness()); // private static readonly Lazy<PlcBusiness> lazy = new Lazy<PlcBusiness>(() => new PlcBusiness());
public static PlcBusiness Instance // public static PlcBusiness Instance
{ // {
get // get
{ // {
return lazy.Value; // return lazy.Value;
} // }
} // }
//
private PlcBusiness() { } // private PlcBusiness() { }
//
private static IPlc plcInstance = null; // private static IPlc plcInstance = null;
//
public void InitPlcConnect(PlcType plcType, string plcAddress, int plcPort) // public void InitPlcConnect(PlcType plcType, string plcAddress, int plcPort)
{ // {
try // try
{ // {
string str = System.Environment.CurrentDirectory; // string str = System.Environment.CurrentDirectory;
str = str + "\\Mesnac.PlcUtils.dll"; // str = str + "\\Mesnac.PlcUtils.dll";
Assembly assembly = Assembly.LoadFile(str); // 加载程序集EXE 或 DLL // Assembly assembly = Assembly.LoadFile(str); // 加载程序集EXE 或 DLL
string AssemName = "Mesnac.PlcUtils.Impl." + plcType.GetDescription(); // string AssemName = "Mesnac.PlcUtils.Impl." + plcType.GetDescription();
var obj = assembly.CreateInstance(AssemName, true); // var obj = assembly.CreateInstance(AssemName, true);
plcInstance = obj as IPlc; // plcInstance = obj as IPlc;
if (plcInstance == null) // if (plcInstance == null)
{ // {
ICSharpCode.Core.LoggingService<OmronNJPlc>.Error("PLC初始化失败"); // ICSharpCode.Core.LoggingService<OmronNJPlc>.Error("PLC初始化失败");
return; // return;
} // }
else // else
{ // {
if (!plcInstance.IsConnected) // if (!plcInstance.IsConnected)
{ // {
bool connectResult = plcInstance.Connect(plcAddress, plcPort); // bool connectResult = plcInstance.Connect(plcAddress, plcPort);
if (connectResult) // if (connectResult)
{ // {
ICSharpCode.Core.LoggingService<OmronNJPlc>.Debug("PLC连接成功"); // ICSharpCode.Core.LoggingService<OmronNJPlc>.Debug("PLC连接成功");
} // }
else // else
{ // {
ICSharpCode.Core.LoggingService<OmronNJPlc>.Error("PLC连接失败"); // ICSharpCode.Core.LoggingService<OmronNJPlc>.Error("PLC连接失败");
} // }
} // }
} // }
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
ICSharpCode.Core.LoggingService<OmronNJPlc>.Error($"PLC初始化异常{ex.Message}"); // ICSharpCode.Core.LoggingService<OmronNJPlc>.Error($"PLC初始化异常{ex.Message}");
} // }
} // }
//
public void Dispose() // public void Dispose()
{ // {
plcInstance.DisConnect(); // plcInstance.DisConnect();
} // }
//
//
public OperateResult<bool> readBoolValue(string address) // public OperateResult<bool> readBoolValue(string address)
{ // {
if(plcInstance != null) // if(plcInstance != null)
{ // {
return plcInstance.readBoolByAddress(address); // return plcInstance.readBoolByAddress(address);
} // }
else // else
{ // {
return new OperateResult<bool>() { // return new OperateResult<bool>() {
IsSuccess = false, // IsSuccess = false,
Content = false // Content = false
}; // };
} // }
} // }
//
} // }
} // }

Loading…
Cancel
Save