From d87dc6460d8708b25d3603f823ee54bc03fd7422 Mon Sep 17 00:00:00 2001 From: hanqiangqiang <1364346467@qq.com> Date: Tue, 8 Aug 2023 11:24:51 +0800 Subject: [PATCH] =?UTF-8?q?[Common]=20ErrorDetectableBaseDevice=E7=B1=BB?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=90=8E=E6=B7=BB=E5=8A=A0=E5=9B=9E=E8=B0=83=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RT/Device/ErrorDetectableBaseDevice.cs | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/MECF.Framework.Common/Aitex/Core/RT/Device/ErrorDetectableBaseDevice.cs b/MECF.Framework.Common/Aitex/Core/RT/Device/ErrorDetectableBaseDevice.cs index fe91804..987389d 100644 --- a/MECF.Framework.Common/Aitex/Core/RT/Device/ErrorDetectableBaseDevice.cs +++ b/MECF.Framework.Common/Aitex/Core/RT/Device/ErrorDetectableBaseDevice.cs @@ -18,47 +18,47 @@ namespace MECF.Framework.Common.Aitex.Core.RT.Device { #region Variable - + private readonly R_TRIG _alarmTrigger; /// /// 是否启用误差检测 /// - private readonly bool _isEnableErrDetection; + private bool _isEnableErrDetection; /// /// 误差报警超限阈值 /// - private readonly double _alarmRange; + private double _alarmRange; /// /// 误差报警超限持续时间 /// - private readonly double _alarmTime; + private double _alarmTime; /// /// 误差警告超限阈值 /// - private readonly double _warningRange; + private double _warningRange; /// /// 误差警告超限持续时间 /// - private readonly double _warningTime; + private double _warningTime; protected readonly DIAccessor DiAlarm; protected readonly string AlarmText; - + /// /// 误差超限警告检查器 /// protected readonly ToleranceChecker ErrWarningChecker; - + /// /// 误差超限报警检查器 /// protected readonly ToleranceChecker ErrAlarmChecker; - + private readonly AlarmEventItem _alarmEvent; private readonly AlarmEventItem _warningEvent; @@ -70,7 +70,7 @@ namespace MECF.Framework.Common.Aitex.Core.RT.Device { // 获取diAlarm DiAlarm = ParseDiNode("diAlarm", node, ioModule); - + // 获取Alarm Text AlarmText = node.GetAttribute("AlarmText"); @@ -93,6 +93,12 @@ namespace MECF.Framework.Common.Aitex.Core.RT.Device EventLevel.Warning); _alarmEvent = SubscribeAlarm($"{Module}.{Display}.ToleranceAlarm", "", ResetAlarmChecker); + + SC.RegisterValueChangedCallback($"{ScBasePath}.{Display}.EnableAlarm", (o) => { _isEnableErrDetection = SC.GetConfigItem($"{ScBasePath}.{Display}.EnableAlarm")?.BoolValue ?? false; }); + SC.RegisterValueChangedCallback($"{ScBasePath}.AlarmRange", (o) => { _alarmRange = SC.GetConfigItem($"{ScBasePath}.AlarmRange")?.DoubleValue ?? double.NaN; }); + SC.RegisterValueChangedCallback($"{ScBasePath}.AlarmTime", (o) => { _alarmTime = SC.GetConfigItem($"{ScBasePath}.AlarmTime")?.DoubleValue ?? double.NaN; }); + SC.RegisterValueChangedCallback($"{ScBasePath}.WarningRange", (o) => { _warningRange = SC.GetConfigItem($"{ScBasePath}.WarningRange")?.DoubleValue ?? double.NaN; }); + SC.RegisterValueChangedCallback($"{ScBasePath}.WarningTime", (o) => { _warningTime = SC.GetConfigItem($"{ScBasePath}.WarningTime")?.IntValue ?? int.MinValue; }); } #endregion @@ -143,7 +149,7 @@ namespace MECF.Framework.Common.Aitex.Core.RT.Device _alarmEvent.Description = $"{Display} feedback ({feedback:F1}{Unit}) out of range {alarmLow} - {alarmHigh} {Unit} in {_alarmTime:F0} seconds"; _alarmEvent.Set(); } - + // 如果报Alarm,不再检查Warning。 if (_alarmEvent.IsTriggered) return; @@ -168,12 +174,12 @@ namespace MECF.Framework.Common.Aitex.Core.RT.Device public virtual void Monitor() { - + } public virtual void Terminate() { - + } public virtual void Reset()