Add temperature average to battery record

This commit is contained in:
atef 2023-06-22 09:50:24 +02:00
parent 8feee5db43
commit 98bdec1a36
3 changed files with 16 additions and 13 deletions

View File

@ -57,6 +57,7 @@ public partial class Battery48TlRecord
public Temperature Center => Self._TemperaturesCellsCenter;
public Temperature Left => Self._TemperaturesCellsLeft;
public Temperature Right => Self._TemperaturesCellsRight;
public Temperature Average => Self._TemperaturesCellsAverage;
internal Cells_(Battery48TlRecord self) => Self = self;
private Battery48TlRecord Self { get; }
@ -73,7 +74,7 @@ public partial class Battery48TlRecord
}
[SuppressMessage("ReSharper", "StringLiteralTypo")]
internal IEnumerable<String> ParseAlarms()
private IEnumerable<String> ParseAlarms()
{
Boolean HasBit(Int16 bit) => (_AlarmFlags & 1uL << bit) > 0;
@ -110,7 +111,7 @@ public partial class Battery48TlRecord
}
[SuppressMessage("ReSharper", "StringLiteralTypo")]
internal IEnumerable<String> ParseWarnings()
private IEnumerable<String> ParseWarnings()
{
Boolean HasBit(Int16 bit) => (_WarningFlags & 1uL << bit) > 0;

View File

@ -11,7 +11,6 @@ namespace InnovEnergy.Lib.Devices.Battery48TL;
[SuppressMessage("ReSharper", "UnusedMember.Global")]
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")]
[BigEndian]
[NestProperties("Battery48TlRecord")]
public partial class Battery48TlRecord
{
[InputRegister(1004)] private UInt16 _LedStates;
@ -28,6 +27,7 @@ public partial class Battery48TlRecord
[InputRegister(1015, Scale = 0.1, Offset = -400)] private Double _TemperaturesCellsCenter;
[InputRegister(1016, Scale = 0.1, Offset = -400)] private Double _TemperaturesCellsLeft;
[InputRegister(1017, Scale = 0.1, Offset = -400)] private Double _TemperaturesCellsRight;
[InputRegister(1003, Scale = 0.1, Offset = -400)] private Double _TemperaturesCellsAverage;
private LedState ParseLed(LedColor led) => (LedState)((_LedStates >> (Int32)led) & 3);

View File

@ -14,6 +14,7 @@ public class Battery48TlRecords
Warnings = records.SelectMany(r => r.Warnings).Distinct().ToList();
Alarms = records.SelectMany(r => r.Alarms).Distinct().ToList();
Soc = empty ? 0 : records.Min(r => r.Soc.Value);
Temperature = records.Any() ? records.Average(b => b.Temperatures.Cells.Average.Value) : 0;
Dc = empty
? DcBus.FromVoltageCurrent(0, 0)
@ -29,6 +30,7 @@ public class Battery48TlRecords
public IReadOnlyList<String> Warnings { get; init; }
public IReadOnlyList<String> Alarms { get; init; }
public Percent Soc { get; init; }
public Temperature Temperature { get; init; }
public IReadOnlyList<Battery48TlRecord> Devices { get; init; }