using System; using System.Collections.Generic; using Aitex.Core.RT.IOCore.Interlock.DataProvider; namespace Aitex.Core.RT.IOCore { /// /// 基于AO判断的互锁限制条件。 /// internal class DoLimit : InterlockLimit { 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}")}"; public DoLimit(DoValueProvider 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."); } protected override bool CheckInRange() { return CurrentValue == LimitValue; } } }