2023-04-24 11:53:56 +08:00
|
|
|
using System;
|
|
|
|
|
2023-04-23 16:43:08 +08:00
|
|
|
namespace Aitex.Core.RT.IOCore;
|
|
|
|
|
|
|
|
public class InterlockLimitRangeInt: IAnalogInterlockLimitRange<int>
|
|
|
|
{
|
|
|
|
#region Constructors
|
|
|
|
|
2023-04-24 11:53:56 +08:00
|
|
|
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.");
|
|
|
|
}
|
|
|
|
|
2023-04-23 16:43:08 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|