using System.Collections.Generic; using Aitex.Core.RT.IOCore.Interlock.DataProvider; using Aitex.Core.RT.IOCore.Interlock.Utils; namespace Aitex.Core.RT.IOCore.Interlock.Limits; public class DoubleDataPollLimit : InterlockLimitBase { #region Constructors public DoubleDataPollLimit(IInterlockLimitDataProvider dataProvider, string value, string tip, Dictionary cultureTip,bool ignoreReverse) : base(dataProvider, value, tip, cultureTip, ignoreReverse) { LimitRange = new InterlockLimitRangeDouble(value); } #endregion #region Properties private InterlockLimitRangeDouble LimitRange { get; } /// /// /// public override double CurrentValue { get { if (DataProvider.GetValue() is double value) return value; // 如果Poll不到值,始终返回LimitValue相反的值,避免当前Limit被命中 return double.NaN; } } /// /// /// public override string LimitReason => $"{DataProvider.Name} = {CurrentValue:F1}, in the range [{LimitRange}]{(string.IsNullOrEmpty(Tip) ? "" : $",{Tip}")}"; /// /// /// public override string DaemonReason => $"{DataProvider.Name} = {CurrentValue:F1}, in the range [{LimitRange}]{(string.IsNullOrEmpty(Tip) ? "" : $",{Tip}")}"; #endregion #region Methods /// /// /// /// protected override bool CheckInRange() { return LimitRange.CheckIsInRange(CurrentValue); } /// /// /// /// public override string ToString() { return $"{Name}, Limit={LimitRange}"; } #endregion }