e-register check Püfungvorbereitung und -abschluss

This commit is contained in:
Stoyan Zlatev
2024-12-03 17:03:33 +01:00
parent 6bb2ba0b68
commit a385f35efd
88 changed files with 5088 additions and 1213 deletions
@@ -1,7 +1,8 @@
namespace Common.Hardware.SIRT.Parameters
{
using Common.Hardware.Ports;
using System;
using System.Text;
/// <summary>
/// Parameter P11 is given at third position of "Telegram from Air" telegram and give more detailed information about the
@@ -172,15 +173,22 @@
set => this.bits[7] = (byte)(value ? 1 : 0);
}
public override string ToString()
=> $"{nameof(P11)}: {string.Join(string.Empty, this.bits)}"
+ $"{Environment.NewLine}{(this.SrcChannel ? "RF modul 2" : "RF modul 1")}"
+ (this.BothValid ? Environment.NewLine + nameof(this.BothValid) : default(string))
+ (this.InvalidMod1 ? Environment.NewLine + "RF modul 1 data invalid" : default(string))
+ (this.InvalidMod2 ? Environment.NewLine + "RF modul 2 data invalid" : default(string))
+ (this.LenOverflow ? Environment.NewLine + nameof(this.LenOverflow) : default(string))
+ (this.Attention ? Environment.NewLine + "Will look in PAM pool" : default(string))
+ $"{Environment.NewLine}{(this.ModeRF ? "Sensus RF" : "MBus")}";
public override string ToString()
{
var infoBuilder = new StringBuilder();
infoBuilder.AppendLine(string.Join(string.Empty, this.bits));
infoBuilder.AppendLine(this.SrcChannel ? "Source RF modul 2" : "Source RF modul 1");
infoBuilder.AppendLine(this.BothValid ? "Both RF modules data are valid" : "One RF module data is valid");
infoBuilder.AppendLine(this.InvalidMod1 ? "RF modul 1 data is invalid" : "RF modul 1 data is valid");
infoBuilder.AppendLine(this.InvalidMod2 ? "RF modul 2 data is invalid" : "RF modul 2 data is valid");
infoBuilder.AppendLine(this.LenOverflow ? "Length overflow (> 128)" : "Data length is valid");
infoBuilder.AppendLine(this.Attention ? "Will look in PAM/RAC pool" : "No attention of PAM/RAC pool");
infoBuilder.AppendLine(this.ModeSensus ? "Mode Sensus RF" : "Mode MBus");
infoBuilder.AppendLine(this.ModeRF ? (!this.ModeSensus ? "T1 mode" : "Receive at F2")
: (!this.ModeSensus ? "S1 mode" : "Receive at F1"));
return infoBuilder.ToString().Trim();
}
public static implicit operator byte(P11 p11)
=> p11.bits.GetByteLE();
@@ -0,0 +1,30 @@
namespace Common.Hardware.SIRT.Parameters
{
using Common.Hardware.Ports;
public class P821
{
private readonly byte[] bits;
public P821() => this.bits = new byte[8];
public P821(byte p12) => this.bits = p12.GetBitsLE();
public P821(byte[] bits) => this.bits = bits;
public bool PamStruct
{
get => this.bits[0] == 1;
set => this.bits[0] = (byte)(value ? 1 : 0);
}
public static implicit operator byte(P821 p11)
=> p11.bits.GetByteLE();
public static implicit operator string(P821 p11)
=> p11.ToString();
public static implicit operator P821(byte _byte)
=> new P821(_byte.GetBitsLE());
}
}
@@ -1,6 +1,8 @@
namespace Common.Hardware.SIRT.Parameters
{
using Common.Hardware.Ports;
using System;
using System.Text;
public class PAMStatus
{
@@ -21,31 +23,39 @@
public override string ToString()
{
var status = nameof(OK);
var value = this.bits.GetByteLE();
var statusBuilder = new StringBuilder();
if ((value & 1) == 1)
if (this.CMD_UNKNOWN)
{
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);
statusBuilder.AppendLine(nameof(this.CMD_UNKNOWN));
}
return status;
if (this.WRONG_AUTH)
{
statusBuilder.AppendLine(nameof(this.WRONG_AUTH));
}
if (this.EXPIRED_AUTH)
{
statusBuilder.AppendLine(nameof(this.EXPIRED_AUTH));
}
if (this.MIXED_TYPES)
{
statusBuilder.AppendLine(nameof(this.MIXED_TYPES));
}
if (this.OUT_OF_RANGE)
{
statusBuilder.AppendLine(nameof(this.OUT_OF_RANGE));
}
if (statusBuilder.Length == 0)
{
statusBuilder.AppendLine(nameof(OK));
}
return statusBuilder.ToString().Trim('\n', '\r');
}
public static byte OK = 0;
@@ -0,0 +1,32 @@
namespace Common.Hardware.SIRT.Parameters
{
public class RSSI
{
public RSSI(byte value, int mhz)
{
if (mhz == 433)
{
this.Dbm = value * 0.5 - 140;
this.Percent = value * 0.7333 - 57.6667;
}
else if (mhz == 868)
{
this.Dbm = value * 0.5 - 131.3;
this.Percent = value * 0.66 - 40.316;
}
if (this.Percent > 100)
{
this.Percent = 100;
}
else if (this.Percent < 0)
{
this.Percent = 0;
}
}
public double Dbm { get; }
public double Percent { get; }
}
}