Sic.Framework-Nanjing-Baishi/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/DataProvider/BoolDataPollProvider.cs

25 lines
688 B
C#

using System;
using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.IOCore.Interlock.DataProvider.Base;
namespace Aitex.Core.RT.IOCore.Interlock.DataProvider;
public class BoolDataPollProvider : DataPollProvider<bool>
{
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.");
}
}