24 lines
699 B
C#
24 lines
699 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 DoubleDataPollProvider : DataPollProvider<double>
|
||
|
{
|
||
|
public DoubleDataPollProvider(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 (double.TryParse(value.ToString(), out var dValue))
|
||
|
return dValue;
|
||
|
|
||
|
throw new InvalidCastException($"the return value {value} is not a number.");
|
||
|
}
|
||
|
}
|