77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
namespace Common.Hardware.SIRT.Parameters
|
|
{
|
|
using System;
|
|
|
|
public class RFModuleOperating
|
|
{
|
|
private readonly byte[] bits;
|
|
|
|
public RFModuleOperating() => this.bits = new byte[8];
|
|
|
|
private RFModuleOperating(byte[] bits) => this.bits = bits;
|
|
|
|
/// <summary>
|
|
/// 0 -> Transparent Mode at 115k2 Baud 8,n,1
|
|
/// </summary>
|
|
public OperatingModes OpMode
|
|
{
|
|
get
|
|
{
|
|
var bits = new byte[8];
|
|
|
|
Array.Copy(this.bits, 0, bits, 0, 4);
|
|
|
|
return (OperatingModes)bits.GetByte();
|
|
}
|
|
set
|
|
{
|
|
var bits = ((byte)value).GetBits();
|
|
|
|
Array.Copy(bits, 0, this.bits, 0, 4);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>external antenna</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>internal antenna</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool Antenna
|
|
{
|
|
get => this.bits[4] == 1;
|
|
set => this.bits[4] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <list>
|
|
/// <item>
|
|
/// <term>true</term>
|
|
/// <description>Module not powered</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>false</term>
|
|
/// <description>Module powered</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
public bool RfOff
|
|
{
|
|
get => this.bits[7] == 1;
|
|
set => this.bits[7] = (byte)(value ? 1 : 0);
|
|
}
|
|
|
|
public static implicit operator byte(RFModuleOperating param)
|
|
=> param.bits.GetByte();
|
|
|
|
public static implicit operator RFModuleOperating(byte _byte)
|
|
=> new RFModuleOperating(_byte.GetBits());
|
|
}
|
|
}
|