60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
namespace Common.Hardware.SIRT.Parameters
|
|
{
|
|
using Common.Hardware.Ports;
|
|
|
|
public class PAMStatus
|
|
{
|
|
private readonly byte[] bits;
|
|
|
|
public PAMStatus(byte _byte)
|
|
=> this.bits = _byte.GetBitsLE();
|
|
|
|
public bool CMD_UNKNOWN => this.bits[0] == 1;
|
|
|
|
public bool WRONG_AUTH => this.bits[1] == 1;
|
|
|
|
public bool EXPIRED_AUTH => this.bits[2] == 1;
|
|
|
|
public bool MIXED_TYPES => this.bits[3] == 1;
|
|
|
|
public bool OUT_OF_RANGE => this.bits[4] == 1;
|
|
|
|
public override string ToString()
|
|
{
|
|
var status = nameof(OK);
|
|
var value = this.bits.GetByteLE();
|
|
|
|
if ((value & 1) == 1)
|
|
{
|
|
status = nameof(CMD_UNKNOWN);
|
|
}
|
|
else if ((value & 2) == 2)
|
|
{
|
|
status = nameof(WRONG_AUTH);
|
|
}
|
|
else if ((value & 4) == 4)
|
|
{
|
|
status = nameof(EXPIRED_AUTH);
|
|
}
|
|
else if ((value & 8) == 8)
|
|
{
|
|
status = nameof(MIXED_TYPES);
|
|
}
|
|
else if ((value & 16) == 16)
|
|
{
|
|
status = nameof(OUT_OF_RANGE);
|
|
}
|
|
|
|
return status;
|
|
}
|
|
|
|
public static byte OK = 0;
|
|
|
|
public static implicit operator byte(PAMStatus status)
|
|
=> status?.bits?.GetByteLE() ?? 0xFF;
|
|
|
|
public static implicit operator string(PAMStatus status)
|
|
=> status?.ToString();
|
|
}
|
|
}
|