2023-08-10 16:44:46 +08:00
|
|
|
using System;
|
|
|
|
using Aitex.Core.RT.DataCenter;
|
|
|
|
|
|
|
|
namespace Aitex.Core.RT.IOCore.Interlock.DataProvider;
|
|
|
|
|
2023-08-17 09:43:24 +08:00
|
|
|
public class BoolDataPollProvider : DataPollProviderBase<bool>, IInterlockLimitDataProvider
|
2023-08-10 16:44:46 +08:00
|
|
|
{
|
|
|
|
public BoolDataPollProvider(string dataPath) : base(dataPath)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override object HandleGetValue()
|
|
|
|
{
|
|
|
|
var value = DATA.Poll(DataPath);
|
|
|
|
if (value == null)
|
|
|
|
throw new NullReferenceException("unable to poll data, null is returned.");
|
|
|
|
|
|
|
|
if (bool.TryParse(value.ToString(), out var bValue))
|
|
|
|
return bValue;
|
|
|
|
|
|
|
|
throw new InvalidCastException($"the return value {value} is not bool.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|