30 lines
899 B
C#
30 lines
899 B
C#
using System;
|
|
using Aitex.Core.RT.DataCenter;
|
|
|
|
namespace Aitex.Core.RT.IOCore.Interlock.DataProvider;
|
|
|
|
public class BoolDataPollProvider : DataPollProviderBase<bool>, IInterlockLimitDataProvider
|
|
{
|
|
public BoolDataPollProvider(string dataPath) : base(dataPath)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// <inheritdoc cref="DataPollProviderBase{T}.HandleGetValue"/>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NullReferenceException"></exception>
|
|
/// <exception cref="InvalidCastException"></exception>
|
|
protected override object HandleGetValue()
|
|
{
|
|
var value = DATA.Poll(DataPath);
|
|
if (value == null)
|
|
throw new NullReferenceException("null is returned.");
|
|
|
|
if (bool.TryParse(value.ToString(), out var bValue))
|
|
return bValue;
|
|
|
|
throw new InvalidCastException($"the return value {value} is not bool.");
|
|
|
|
}
|
|
} |