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()