214 lines
6.1 KiB
C#
214 lines
6.1 KiB
C#
namespace Common.Hardware.SIRT.Parameters
|
|
{
|
|
using System;
|
|
using System.Text;
|
|
|
|
/// <summary>
|
|
/// P12 is the parameter of "Acknowledge or Answer" message and is placed at third position,
|
|
/// if telegram from SIRT-> PC begins with {0xFF, 0x12}.
|
|
/// This parameter gives more detailed information about the last command or request which
|
|
/// was send to SIRT.
|
|
/// Parameter 12 is given at third position of acknowledge- or answer telegram from SIRT.
|
|
/// </summary>
|
|
public class P12
|
|
{
|
|
private readonly byte[] bits;
|
|
|
|
public P12() => this.bits = new byte[8];
|
|
|
|
public P12(byte p12) => this.bits = p12.GetBits();
|
|
|
|
public P12(byte[] bits) => this.bits = bits;
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>requested buffer is full or not available</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>Ok</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool BufFull
|
|
{
|
|
get => this.bits[0] == 1;
|
|
set => this.bits[0] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>operating system is busy</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>Ok</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool OsBusy
|
|
{
|
|
get => this.bits[1] == 1;
|
|
set => this.bits[1] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>wrong CRC recognized</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>Ok</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool WrongCRC
|
|
{
|
|
get => this.bits[2] == 1;
|
|
set => this.bits[2] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>command cannot be executed</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>Ok</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool CmdNotExecuted
|
|
{
|
|
get => this.bits[3] == 1;
|
|
set => this.bits[3] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>telegram or command byte unknown</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>Ok</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool CmdUnknown
|
|
{
|
|
get => this.bits[4] == 1;
|
|
set => this.bits[4] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>no such entry found</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>Ok</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool NoEntry
|
|
{
|
|
get => this.bits[5] == 1;
|
|
set => this.bits[5] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>unknown fixed byte</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>Ok</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool ByteUnknown
|
|
{
|
|
get => this.bits[6] == 1;
|
|
set => this.bits[6] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>address was 0xFFFFFFFF</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>normal address</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool WildCardAddr
|
|
{
|
|
get => this.bits[7] == 1;
|
|
set => this.bits[7] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
if (this.BufFull)
|
|
{
|
|
return nameof(this.BufFull);
|
|
}
|
|
else if (this.OsBusy)
|
|
{
|
|
return nameof(this.OsBusy);
|
|
}
|
|
else if (this.WrongCRC)
|
|
{
|
|
return nameof(this.WrongCRC);
|
|
}
|
|
else if (this.CmdNotExecuted)
|
|
{
|
|
return nameof(this.CmdNotExecuted);
|
|
}
|
|
else if (this.CmdUnknown)
|
|
{
|
|
return nameof(this.CmdUnknown);
|
|
}
|
|
else if (this.NoEntry)
|
|
{
|
|
return nameof(this.NoEntry);
|
|
}
|
|
else if (this.ByteUnknown)
|
|
{
|
|
return nameof(this.ByteUnknown);
|
|
}
|
|
else if (this.WildCardAddr)
|
|
{
|
|
return nameof(this.WildCardAddr);
|
|
}
|
|
|
|
return "AKN";
|
|
}
|
|
|
|
public static implicit operator byte(P12 p11)
|
|
=> p11.bits.GetByte();
|
|
|
|
public static implicit operator string(P12 p11)
|
|
=> p11.ToString();
|
|
|
|
public static implicit operator P12(byte _byte)
|
|
=> new P12(_byte.GetBits());
|
|
}
|
|
} |