35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Aitex.Core.RT.IOCore.Interlock.DataProvider;
|
|
|
|
namespace Aitex.Core.RT.IOCore
|
|
{
|
|
/// <summary>
|
|
/// 基于AO判断的互锁限制条件。
|
|
/// </summary>
|
|
internal class DoLimit : InterlockLimit<DoValueProvider, bool>
|
|
{
|
|
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<string, string> 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;
|
|
}
|
|
}
|
|
}
|