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

43 lines
921 B
C#
Raw Normal View History

using System;
namespace Aitex.Core.RT.IOCore;
public class InterlockLimitRangeInt: IAnalogInterlockLimitRange<int>
{
#region Constructors
public InterlockLimitRangeInt(string value)
{
var strValues = value.Split(':');
if (strValues.Length == 2
&& int.TryParse(strValues[0], out var min)
&& int.TryParse(strValues[1], out var max))
{
Min = min;
Max = max;
}
else
throw new InvalidCastException($"unable to convert {value} to double range.");
}
public InterlockLimitRangeInt(short min, short max)
{
Min = min;
Max = max;
}
#endregion
#region Properties
public int Min { get; }
public int Max { get; }
#endregion
public virtual bool CheckIsInRange(int currentValue)
{
return currentValue >= Min && currentValue <= Max;
}
}