39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Aitex.Core.RT.IOCore.Interlock.DataProvider;
|
|
|
|
namespace Aitex.Core.RT.IOCore.Interlock;
|
|
|
|
public class BoolDataPollLimit : InterlockLimit<BoolDataPollProvider, bool>
|
|
{
|
|
#region Constructors
|
|
|
|
public BoolDataPollLimit(IInterlockLimitDataProvider 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.");
|
|
}
|
|
|
|
#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;
|
|
}
|
|
} |