laatzen/Common/Hardware/Interfaces/Ports/Common.Hardware.Interfaces.Ports.SIRT/Parameters/RFModuleOperating.cs
2024-09-02 16:24:34 +02:00

77 lines
2.1 KiB
C#

namespace Common.Hardware.Interfaces.Ports.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 Boolean 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 Boolean 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());
}
}