diff --git a/MECF.Framework.RT.EquipmentLibrary/Devices/IoPressureBalanceChecker.cs b/MECF.Framework.RT.EquipmentLibrary/Devices/IoPressureBalanceChecker.cs new file mode 100644 index 0000000..be69fd5 --- /dev/null +++ b/MECF.Framework.RT.EquipmentLibrary/Devices/IoPressureBalanceChecker.cs @@ -0,0 +1,87 @@ +using Aitex.Core.RT.Device; +using Aitex.Core.RT.Device.Unit; +using Aitex.Core.RT.Event; +using Aitex.Core.RT.IOCore; +using Aitex.Core.RT.SCCore; +using Aitex.Core.RT.Tolerance; +using MECF.Framework.Common.Event; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; +using System.Xml; + +namespace Aitex.Core.RT.Device.Devices +{ + public class IoPressureBalanceChecker : BaseDevice, IDevice + { + private readonly AIAccessor _aiValue1 = null; + private readonly AIAccessor _aiValue2 = null; + private readonly string _formatString = "0.0"; + + private double _threshold = 8; + private double _value = 0; + + /// + /// 误差超限警告检查器 + /// + private readonly ToleranceChecker _balanceChecker; + + public string Value => _value.ToString(_formatString); + public IoPressureBalanceChecker(string module, XmlElement node, string ioModule = "") : base(module, node, ioModule) + { + _aiValue1 = ParseAiNode("aiValue1", node, ioModule); + _aiValue2 = ParseAiNode("aiValue2", node, ioModule); + + _balanceChecker = new ToleranceChecker(5); + + if (node.HasAttribute("formatString")) + _formatString = string.IsNullOrEmpty(node.GetAttribute("formatString")) ? "F5" : node.GetAttribute("formatString"); + } + + public bool Initialize() + { + _threshold = SC.GetValue($"PM.{Module}.Heater.PressureBalanceDifference"); + return true; + } + + private bool ResetChecker() + { + _balanceChecker.Reset(5); + return true; + } + + public void Reset() + { + _balanceChecker.Reset(5); + } + + public void Terminate() + { + _balanceChecker.Reset(5); + } + + protected override void HandleMonitor() + { + _value = _aiValue1.Value - _aiValue2.Value; + _balanceChecker.Monitor(_value, -_threshold, _threshold, 5); + if (_balanceChecker.Trig) + { + var alarmLevel = SC.SafeGetStringValue($"PM.{Module}.Heater.PressureImbalanceAlarmLevel", "Warning"); + if (alarmLevel == "Warning") + { + EV.PostWarningLog(Module, $"PT1:{_aiValue1}({_aiValue1.Value})/PT2:{_aiValue2}({_aiValue2.Value}) Pressure out of balance(threshold:{_threshold})"); + } + else + { + EV.PostAlarmLog(Module, $"PT1:{_aiValue1}({_aiValue1.Value})/PT2:{_aiValue2}({_aiValue2.Value}) Pressure out of balance(threshold:{_threshold})"); + } + + } + + } + } +} diff --git a/MECF.Framework.RT.EquipmentLibrary/MECF.Framework.RT.EquipmentLibrary.csproj b/MECF.Framework.RT.EquipmentLibrary/MECF.Framework.RT.EquipmentLibrary.csproj index 6d820bb..83e6a7a 100644 --- a/MECF.Framework.RT.EquipmentLibrary/MECF.Framework.RT.EquipmentLibrary.csproj +++ b/MECF.Framework.RT.EquipmentLibrary/MECF.Framework.RT.EquipmentLibrary.csproj @@ -78,6 +78,7 @@ +