Add battery status

This commit is contained in:
atef 2024-03-20 13:52:36 +01:00
parent 7b5b529080
commit c6a21232f1
1 changed files with 18 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Text;
using InnovEnergy.Lib.Devices.Battery48TL.DataTypes;
using InnovEnergy.Lib.Units;
using InnovEnergy.Lib.Units.Power;
@ -18,11 +19,12 @@ public partial class Battery48TlRecord
public StringActive_ BatteryStrings => new StringActive_(this);
public IoStatus_ IoStatus => new IoStatus_(this);
public Boolean Eoc => Leds is { Green: On, Amber: Off, Blue : Off };
public Boolean Eoc => ParseEocReached();//Leds is { Green: On, Amber: Off, Blue : Off }; // ParseEocReached(); //
public UInt16 IoStates => _IoStates;
public UInt16 LimpBitMap => _LimpBitMap;
public String BatteryState => ParseBatteryState();
public String SerialNumber => $"{_SerialNum1:X4}{_SerialNum2:X4}{_SerialNum3:X4}{_SerialNum4:X4}".TrimEnd('0');
@ -123,6 +125,20 @@ public partial class Battery48TlRecord
private Battery48TlRecord Self { get; }
}
private String ParseBatteryState()
{
var s1 = Encoding.ASCII.GetString(BitConverter.GetBytes(_BatteryState1).Reverse().ToArray()); // endian swap
var s2 = Encoding.ASCII.GetString(BitConverter.GetBytes(_BatteryState2).Reverse().ToArray()); // endian swap
return s1 + s2;
}
private Boolean ParseEocReached()
{
return "EOC_" == ParseBatteryState();
}
[SuppressMessage("ReSharper", "StringLiteralTypo")]
private IEnumerable<String> ParseAlarms()
{