diff --git a/csharp/App/SaliMax/src/Ess/Controller.cs b/csharp/App/SaliMax/src/Ess/Controller.cs index 7d6601450..90ee95552 100644 --- a/csharp/App/SaliMax/src/Ess/Controller.cs +++ b/csharp/App/SaliMax/src/Ess/Controller.cs @@ -9,6 +9,7 @@ namespace InnovEnergy.App.SaliMax.Ess; public static class Controller { private static readonly UnixTimeSpan MaxTimeWithoutEoc = UnixTimeSpan.FromDays(7); // TODO: move to config + private static readonly Double BatteryHeatingPower = 200.0; // TODO: move to config public static EssMode SelectControlMode(this StatusRecord s) { @@ -85,7 +86,7 @@ public static class Controller // find out if we reach the lower or upper Dc limit by comparing the current Dc voltage to the reference voltage - return s.AcDc.Dc.Voltage > s.Config.ReferenceDcBusVoltage + return s.AcDc.Dc.Voltage > s.Config.ReferenceDcLinkVoltageFromAcDc ? control with { PowerCorrection = clampedPowerDelta.ClampMax(-correction), LimitedBy = EssLimit.ChargeLimitedByMaxDcBusVoltage } : control with { PowerCorrection = clampedPowerDelta.ClampMin(correction), LimitedBy = EssLimit.DischargeLimitedByMinDcBusVoltage }; } @@ -122,7 +123,7 @@ public static class Controller private static Double ComputePowerDelta(this StatusRecord s, EssMode mode) { var chargePower = s.AcDc.Devices.Sum(d => d.Status.Nominal.Power.Value); - + return mode switch { EssMode.HeatBatteries => s.ControlInverterPower(chargePower), @@ -153,7 +154,19 @@ public static class Controller private static Double MaxBatteryChargePower(this StatusRecord s) { - return s.Battery.Devices.Sum(b => b.MaxChargePower); + // This introduce a limit when we don't have communication with batteries + // Otherwise the limit will be 0 and the batteries will be not heated + + var maxChargePower = s.Config.Devices.BatteryNodes.Length * BatteryHeatingPower; + + if (s.Battery.Devices.Count != 0) + { + maxChargePower = s.Battery.Devices.Sum(b => b.MaxChargePower); + } + + maxChargePower.WriteLine(" Max Charge Power"); + + return maxChargePower; } private static Double CurrentPowerSetPoint(this StatusRecord s)