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.Diagnostics.CodeAnalysis;
using System.Text;
using InnovEnergy.Lib.Devices.Battery48TL.DataTypes; using InnovEnergy.Lib.Devices.Battery48TL.DataTypes;
using InnovEnergy.Lib.Units; using InnovEnergy.Lib.Units;
using InnovEnergy.Lib.Units.Power; using InnovEnergy.Lib.Units.Power;
@ -18,12 +19,13 @@ public partial class Battery48TlRecord
public StringActive_ BatteryStrings => new StringActive_(this); public StringActive_ BatteryStrings => new StringActive_(this);
public IoStatus_ IoStatus => new IoStatus_(this); public IoStatus_ IoStatus => new IoStatus_(this);
public Boolean Eoc => ParseEocReached();//Leds is { Green: On, Amber: Off, Blue : Off }; // ParseEocReached(); //
public Boolean Eoc => Leds is { Green: On, Amber: Off, Blue : Off };
public UInt16 IoStates => _IoStates; public UInt16 IoStates => _IoStates;
public UInt16 LimpBitMap => _LimpBitMap; public UInt16 LimpBitMap => _LimpBitMap;
public String BatteryState => ParseBatteryState();
public String SerialNumber => $"{_SerialNum1:X4}{_SerialNum2:X4}{_SerialNum3:X4}{_SerialNum4:X4}".TrimEnd('0'); public String SerialNumber => $"{_SerialNum1:X4}{_SerialNum2:X4}{_SerialNum3:X4}{_SerialNum4:X4}".TrimEnd('0');
public String FwVersion => _FwVersion.ToString("X4"); public String FwVersion => _FwVersion.ToString("X4");
@ -123,6 +125,20 @@ public partial class Battery48TlRecord
private Battery48TlRecord Self { get; } 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")] [SuppressMessage("ReSharper", "StringLiteralTypo")]
private IEnumerable<String> ParseAlarms() private IEnumerable<String> ParseAlarms()
{ {