Add the new force calibration charge in the controller

This commit is contained in:
atef 2023-11-27 09:28:32 +01:00
parent 732274933b
commit 825a6c87bd
1 changed files with 11 additions and 4 deletions

View File

@ -1,3 +1,4 @@
using InnovEnergy.App.SaliMax.SystemConfig;
using InnovEnergy.Lib.Devices.Battery48TL; using InnovEnergy.Lib.Devices.Battery48TL;
using InnovEnergy.Lib.Devices.Battery48TL.DataTypes; using InnovEnergy.Lib.Devices.Battery48TL.DataTypes;
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes; using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes;
@ -187,18 +188,24 @@ public static class Controller
} }
private static Boolean MustDoCalibrationCharge(this StatusRecord statusRecord) private static Boolean MustDoCalibrationCharge(this StatusRecord statusRecord)
{ {
var calibrationChargeForced = statusRecord.Config.ForceCalibrationCharge; var calibrationChargeForced = statusRecord.Config.ForceCalibrationCharge;
var batteryCalibrationChargeRequested = statusRecord.Battery?.CalibrationChargeRequested?? false ; var batteryCalibrationChargeRequested = statusRecord.Battery?.CalibrationChargeRequested?? false ;
var mustDoCalibrationCharge = batteryCalibrationChargeRequested || calibrationChargeForced; var mustDoCalibrationCharge = batteryCalibrationChargeRequested || calibrationChargeForced == CalibrationChargeType.Yes || calibrationChargeForced == CalibrationChargeType.UntilEoc ;
if (statusRecord.Battery is not null)
{
if (calibrationChargeForced == CalibrationChargeType.UntilEoc && statusRecord.Battery.Eoc )
{
statusRecord.Config.ForceCalibrationCharge = CalibrationChargeType.No;
}
}
return mustDoCalibrationCharge; return mustDoCalibrationCharge;
} }
public static Double ControlGridPower(this StatusRecord status, Double targetPower) private static Double ControlGridPower(this StatusRecord status, Double targetPower)
{ {
return ControlPower return ControlPower
( (