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

52 lines
1.3 KiB
C#
Raw Normal View History

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;
/// <summary>
/// 基于AO判断的互锁限制条件。
/// </summary>
internal class AoLimit : InterlockLimitBase<AoValueProvider, double>
{
#region Constructors
public AoLimit(AoValueProvider dataProvider, string value, string tip, Dictionary<string, string> cultureTip)
: base(dataProvider, value, tip, cultureTip)
{
LimitRange = new InterlockLimitRangeDouble(value);
}
#endregion
#region Properties
private InterlockLimitRangeDouble LimitRange { get; }
public override double CurrentValue => (double)DataProvider.GetValue();
public override string LimitReason =>
$"{DataProvider.Name} = {CurrentValue:F1}, out of 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
}