Sic.Framework-Nanjing-Baishi/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/Limits/DoubleDataPollLimit.cs

74 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<DoubleDataPollProvider, double>
{
#region Constructors
public DoubleDataPollLimit(IInterlockLimitDataProvider dataProvider, string value, string tip,
Dictionary<string, string> cultureTip,bool ignoreReverse) : base(dataProvider, value, tip, cultureTip, ignoreReverse)
{
LimitRange = new InterlockLimitRangeDouble(value);
}
#endregion
#region Properties
private InterlockLimitRangeDouble LimitRange { get; }
/// <summary>
/// <inheritdoc cref="InterlockLimitBase{TAccessor,TValue}.CurrentValue"/>
/// </summary>
public override double CurrentValue
{
get
{
if (DataProvider.GetValue() is double value)
return value;
// 如果Poll不到值始终返回LimitValue相反的值避免当前Limit被命中
return double.NaN;
}
}
/// <summary>
/// <inheritdoc cref="InterlockLimitBase{TAccessor,TValue}.LimitReason"/>
/// </summary>
public override string LimitReason =>
$"{DataProvider.Name} = {CurrentValue:F1}, in the range [{LimitRange}]{(string.IsNullOrEmpty(Tip) ? "" : $",{Tip}")}";
/// <summary>
/// <inheritdoc cref="InterlockLimitBase{TAccessor,TValue}.DaemonReason"/>
/// </summary>
public override string DaemonReason =>
$"{DataProvider.Name} = {CurrentValue:F1}, in the range [{LimitRange}]{(string.IsNullOrEmpty(Tip) ? "" : $",{Tip}")}";
#endregion
#region Methods
/// <summary>
/// <inheritdoc cref="InterlockLimitBase{TAccessor,TValue}.CheckInRange"/>
/// </summary>
/// <returns></returns>
protected override bool CheckInRange()
{
return LimitRange.CheckIsInRange(CurrentValue);
}
/// <summary>
/// <inheritdoc cref="InterlockLimitBase{TAccessor,TValue}.ToString"/>
/// </summary>
/// <returns></returns>
public override string ToString()
{
return $"{Name}, Limit={LimitRange}";
}
#endregion
}