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