2023-06-13 10:53:52 +00:00
|
|
|
using InnovEnergy.Lib.Units;
|
|
|
|
using InnovEnergy.Lib.Units.Composite;
|
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Devices.Battery48TL;
|
|
|
|
|
|
|
|
public class Battery48TlRecords
|
|
|
|
{
|
|
|
|
public Battery48TlRecords(IReadOnlyList<Battery48TlRecord> records)
|
|
|
|
{
|
|
|
|
var empty = records.Count == 0;
|
|
|
|
|
2023-06-22 07:50:24 +00:00
|
|
|
Devices = records;
|
|
|
|
Eoc = !empty && records.All(r => r.Eoc);
|
|
|
|
Warnings = records.SelectMany(r => r.Warnings).Distinct().ToList();
|
|
|
|
Alarms = records.SelectMany(r => r.Alarms).Distinct().ToList();
|
2023-06-13 10:53:52 +00:00
|
|
|
Soc = empty ? 0 : records.Min(r => r.Soc.Value);
|
2023-06-22 07:50:24 +00:00
|
|
|
Temperature = records.Any() ? records.Average(b => b.Temperatures.Cells.Average.Value) : 0;
|
|
|
|
|
2023-06-13 10:53:52 +00:00
|
|
|
Dc = empty
|
|
|
|
? DcBus.FromVoltageCurrent(0, 0)
|
|
|
|
: DcBus.FromVoltageCurrent
|
|
|
|
(
|
|
|
|
records.Average(r => r.Dc.Voltage),
|
|
|
|
records.Sum(r => r.Dc.Current)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public DcBus Dc { get; init; }
|
|
|
|
public Boolean Eoc { get; init; }
|
|
|
|
public IReadOnlyList<String> Warnings { get; init; }
|
|
|
|
public IReadOnlyList<String> Alarms { get; init; }
|
|
|
|
public Percent Soc { get; init; }
|
2023-06-22 07:50:24 +00:00
|
|
|
public Temperature Temperature { get; init; }
|
2023-06-13 10:53:52 +00:00
|
|
|
|
|
|
|
public IReadOnlyList<Battery48TlRecord> Devices { get; init; }
|
|
|
|
|
2023-06-22 08:13:21 +00:00
|
|
|
public static Battery48TlRecords Null => new Battery48TlRecords(Array.Empty<Battery48TlRecord>());
|
2023-06-13 10:53:52 +00:00
|
|
|
}
|