master
wangsr 1 year ago
commit bbdba86dd4

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

@ -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<bool> result = plcBusiness.readBoolValue(address);
ICSharpCode.Core.LoggingService<AlarmSaveHelper>.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<bool> result = plcBusiness.readBoolValue(address);
// ICSharpCode.Core.LoggingService<AlarmSaveHelper>.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 触发事件

@ -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();
}
}
}

@ -29,7 +29,6 @@
<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="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="FormPlan" Text="榄菊计划管理" ToolTipText="FormPlan" Tag="FormPlan" 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 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)
{

@ -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<PlcBusiness> lazy = new Lazy<PlcBusiness>(() => 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<OmronNJPlc>.Error("PLC初始化失败");
return;
}
else
{
if (!plcInstance.IsConnected)
{
bool connectResult = plcInstance.Connect(plcAddress, plcPort);
if (connectResult)
{
ICSharpCode.Core.LoggingService<OmronNJPlc>.Debug("PLC连接成功");
}
else
{
ICSharpCode.Core.LoggingService<OmronNJPlc>.Error("PLC连接失败");
}
}
}
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService<OmronNJPlc>.Error($"PLC初始化异常{ex.Message}");
}
}
public void Dispose()
{
plcInstance.DisConnect();
}
public OperateResult<bool> readBoolValue(string address)
{
if(plcInstance != null)
{
return plcInstance.readBoolByAddress(address);
}
else
{
return new OperateResult<bool>() {
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<PlcBusiness> lazy = new Lazy<PlcBusiness>(() => 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<OmronNJPlc>.Error("PLC初始化失败");
// return;
// }
// else
// {
// if (!plcInstance.IsConnected)
// {
// bool connectResult = plcInstance.Connect(plcAddress, plcPort);
// if (connectResult)
// {
// ICSharpCode.Core.LoggingService<OmronNJPlc>.Debug("PLC连接成功");
// }
// else
// {
// ICSharpCode.Core.LoggingService<OmronNJPlc>.Error("PLC连接失败");
// }
// }
// }
// }
// catch (Exception ex)
// {
// ICSharpCode.Core.LoggingService<OmronNJPlc>.Error($"PLC初始化异常{ex.Message}");
// }
// }
//
// public void Dispose()
// {
// plcInstance.DisConnect();
// }
//
//
// public OperateResult<bool> readBoolValue(string address)
// {
// if(plcInstance != null)
// {
// return plcInstance.readBoolByAddress(address);
// }
// else
// {
// return new OperateResult<bool>() {
// IsSuccess = false,
// Content = false
// };
// }
// }
//
// }
// }

Loading…
Cancel
Save