Add a Calibration Charge Flag based on the Time Since TOC.
This commit is contained in:
parent
20c3e95666
commit
9bbccfd34b
|
@ -195,16 +195,21 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean MustDoCalibrationCharge(this StatusRecord statusRecord)
|
private static Boolean MustDoCalibrationCharge(this StatusRecord statusRecord)
|
||||||
{
|
{
|
||||||
var config = statusRecord.Config;
|
// var config = statusRecord.Config;
|
||||||
|
//
|
||||||
|
// if (statusRecord.Battery.Eoc)
|
||||||
|
// {
|
||||||
|
// "Batteries have reached EOC".LogInfo();
|
||||||
|
// config.LastEoc = UnixTime.Now;
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return UnixTime.Now - statusRecord.Config.LastEoc > MaxTimeWithoutEoc;
|
||||||
|
|
||||||
if (statusRecord.Battery.Eoc)
|
// no need to return false in case of EOC reached
|
||||||
{
|
// because the BMS will set the Time Since TOC to 0 as soon a battery reach EOC
|
||||||
"Batteries have reached EOC".LogInfo();
|
// then Calibration Charge flag will be set false by the software
|
||||||
config.LastEoc = UnixTime.Now;
|
return statusRecord.Battery.CalibrationChargeFlag;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return UnixTime.Now - statusRecord.Config.LastEoc > MaxTimeWithoutEoc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -171,13 +171,21 @@ internal static class Program
|
||||||
{
|
{
|
||||||
Watchdog.NotifyAlive();
|
Watchdog.NotifyAlive();
|
||||||
|
|
||||||
var t = UnixTime.Now;
|
|
||||||
var record = ReadStatus();
|
var record = ReadStatus();
|
||||||
|
|
||||||
var batteryTimeToToc = (3600 - record.Battery.TimeToToc / 60 );
|
int i = 1;
|
||||||
|
|
||||||
|
// For Debug purpose, will be deleted after
|
||||||
|
foreach (var device in record.Battery.Devices)
|
||||||
|
{
|
||||||
|
Console.WriteLine(" Battery " + i);
|
||||||
|
device.TimeSinceTOC.WriteLine(" : Value of register 54");
|
||||||
|
device.Soc.WriteLine(" : SOC");
|
||||||
|
device.CalibrationChargeFlag.WriteLine(" : Calibration Charge Flag");
|
||||||
|
i++;
|
||||||
|
"====================".WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
record.Battery.TimeToToc.WriteLine(" : Value of register 54");
|
|
||||||
batteryTimeToToc .WriteLine(" : Remaining time before next top of charge");
|
|
||||||
|
|
||||||
record.ControlConstants();
|
record.ControlConstants();
|
||||||
record.ControlSystemState();
|
record.ControlSystemState();
|
||||||
|
|
|
@ -13,6 +13,7 @@ using Strings = IReadOnlyList<String>;
|
||||||
[SuppressMessage("ReSharper", "ConvertToAutoProperty")]
|
[SuppressMessage("ReSharper", "ConvertToAutoProperty")]
|
||||||
public partial class Battery48TlRecord
|
public partial class Battery48TlRecord
|
||||||
{
|
{
|
||||||
|
private UInt16 OneWeekInMinutes => 10080;
|
||||||
public Dc_ Dc => new Dc_(this);
|
public Dc_ Dc => new Dc_(this);
|
||||||
public Leds_ Leds => new Leds_(this);
|
public Leds_ Leds => new Leds_(this);
|
||||||
public Temperatures_ Temperatures => new Temperatures_(this);
|
public Temperatures_ Temperatures => new Temperatures_(this);
|
||||||
|
@ -25,7 +26,9 @@ public partial class Battery48TlRecord
|
||||||
|
|
||||||
public Percent Soc => _Soc;
|
public Percent Soc => _Soc;
|
||||||
|
|
||||||
public UInt16 TimeToTOC => (UInt16)_TimeToTOC;
|
// Time since TOC is a counter from the last moment when the battery reached EOC
|
||||||
|
// When The battery is full charged (reached EOC) the Time Since TOC is set to 0
|
||||||
|
public UInt16 TimeSinceTOC => _TimeSinceToc;
|
||||||
|
|
||||||
public Current BusCurrent => _BusCurrent;
|
public Current BusCurrent => _BusCurrent;
|
||||||
|
|
||||||
|
@ -33,6 +36,8 @@ public partial class Battery48TlRecord
|
||||||
|
|
||||||
public DcPower HeatingPower => HeatingCurrent * Dc.Voltage;
|
public DcPower HeatingPower => HeatingCurrent * Dc.Voltage;
|
||||||
|
|
||||||
|
public Boolean CalibrationChargeFlag => TimeSinceTOC > OneWeekInMinutes;
|
||||||
|
|
||||||
public readonly struct Leds_
|
public readonly struct Leds_
|
||||||
{
|
{
|
||||||
public LedState Blue => Self.ParseLed(LedColor.Blue);
|
public LedState Blue => Self.ParseLed(LedColor.Blue);
|
||||||
|
@ -42,6 +47,7 @@ public partial class Battery48TlRecord
|
||||||
|
|
||||||
private Battery48TlRecord Self { get; }
|
private Battery48TlRecord Self { get; }
|
||||||
internal Leds_(Battery48TlRecord self) => this.Self = self;
|
internal Leds_(Battery48TlRecord self) => this.Self = self;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly struct Temperatures_
|
public readonly struct Temperatures_
|
||||||
|
|
|
@ -23,7 +23,7 @@ public partial class Battery48TlRecord
|
||||||
[InputRegister(1062, Scale = 0.01, Offset = -10000)] private Double _BusCurrent;
|
[InputRegister(1062, Scale = 0.01, Offset = -10000)] private Double _BusCurrent;
|
||||||
|
|
||||||
[InputRegister(1053, Scale = 0.1)] private Double _Soc;
|
[InputRegister(1053, Scale = 0.1)] private Double _Soc;
|
||||||
[InputRegister(1052)] private Double _TimeToTOC;
|
[InputRegister(1052)] private UInt16 _TimeSinceToc;
|
||||||
|
|
||||||
[InputRegister(1014, Scale = 0.1, Offset = -400)] private Double _TemperaturesBoard;
|
[InputRegister(1014, Scale = 0.1, Offset = -400)] private Double _TemperaturesBoard;
|
||||||
[InputRegister(1015, Scale = 0.1, Offset = -400)] private Double _TemperaturesCellsCenter;
|
[InputRegister(1015, Scale = 0.1, Offset = -400)] private Double _TemperaturesCellsCenter;
|
||||||
|
|
|
@ -14,7 +14,8 @@ public class Battery48TlRecords
|
||||||
public required Percent CurrentMinSoc { get; init; }
|
public required Percent CurrentMinSoc { get; init; }
|
||||||
public required Temperature Temperature { get; init; }
|
public required Temperature Temperature { get; init; }
|
||||||
public required DcPower HeatingPower { get; init; }
|
public required DcPower HeatingPower { get; init; }
|
||||||
public required UInt16 TimeToToc { get; init; }
|
public required UInt16 TimeSinceToc { get; init; }
|
||||||
|
public required Boolean CalibrationChargeFlag { get; init; }
|
||||||
|
|
||||||
public required IReadOnlyList<Battery48TlRecord> Devices { get; init; }
|
public required IReadOnlyList<Battery48TlRecord> Devices { get; init; }
|
||||||
|
|
||||||
|
@ -33,7 +34,8 @@ public class Battery48TlRecords
|
||||||
CurrentMinSoc = records.Min(r => r.Soc.Value),
|
CurrentMinSoc = records.Min(r => r.Soc.Value),
|
||||||
Temperature = records.Average(b => b.Temperatures.Cells.Average.Value),
|
Temperature = records.Average(b => b.Temperatures.Cells.Average.Value),
|
||||||
HeatingPower = records.Sum(b => b.HeatingPower),
|
HeatingPower = records.Sum(b => b.HeatingPower),
|
||||||
TimeToToc = records.Min(r => r.TimeToTOC),
|
TimeSinceToc = records.Max(r => r.TimeSinceTOC),
|
||||||
|
CalibrationChargeFlag = records.Any(r => r.CalibrationChargeFlag),
|
||||||
|
|
||||||
Dc = new()
|
Dc = new()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue