using System; using System.Collections.Generic; namespace Aitex.Core.RT.IOCore { /// /// 基于AO判断的互锁限制条件。 /// internal class DoLimit : InterlockLimit { public override bool CurrentValue => Io.Value; public override string LimitReason => $"DO-{Io.IoTableIndex}({Io.Name}) = [{(Io.Value ? "ON" : "OFF")}]{(string.IsNullOrEmpty(Tip) ? "" : $",{Tip}")}"; public DoLimit(DOAccessor doItem, string value, string tip, Dictionary cultureTip) : base(doItem, 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; } } }