using System; using System.Collections.Generic; using Aitex.Core.RT.IOCore.Interlock.DataProvider; namespace Aitex.Core.RT.IOCore.Interlock; public class BoolDataPollLimit : InterlockLimit { #region Constructors public BoolDataPollLimit(IInterlockLimitDataProvider dataProvider, string value, string tip, Dictionary cultureTip) : base(dataProvider, value, tip, cultureTip) { if (bool.TryParse(value, out var limitValue)) LimitValue = limitValue; else throw new InvalidCastException($"unable to convert {value} to boolean."); } #endregion #region Properties public override bool CurrentValue => (bool)DataProvider.GetValue(); public override string LimitReason => $"{DataProvider.Name} = [{(CurrentValue ? "ON" : "OFF")}]{(string.IsNullOrEmpty(Tip) ? "" : $",{Tip}")}"; public override string DaemonReason => $"{DataProvider.Name} = [{(LimitValue ? "ON" : "OFF")}]{(string.IsNullOrEmpty(Tip) ? "" : $",{Tip}")}"; #endregion protected override bool CheckInRange() { return CurrentValue == LimitValue; } }