Introduce ClampMin and ClampMax
This commit is contained in:
parent
789780791f
commit
8feee5db43
|
@ -85,8 +85,8 @@ 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
|
||||
? control with { PowerCorrection = clampedPowerDelta.Clamp(-maxStep, -correction), LimitedBy = EssLimit.ChargeLimitedByMaxDcBusVoltage }
|
||||
: control with { PowerCorrection = clampedPowerDelta.Clamp(correction, maxStep), LimitedBy = EssLimit.DischargeLimitedByMinDcBusVoltage };
|
||||
? control with { PowerCorrection = clampedPowerDelta.ClampMax(-correction), LimitedBy = EssLimit.ChargeLimitedByMaxDcBusVoltage }
|
||||
: control with { PowerCorrection = clampedPowerDelta.ClampMin(correction), LimitedBy = EssLimit.DischargeLimitedByMinDcBusVoltage };
|
||||
}
|
||||
|
||||
// private static Double AdjustMaxChargePower(StatusRecord s, Double powerDelta)
|
||||
|
|
|
@ -124,6 +124,15 @@ public static class Utils
|
|||
return clamped;
|
||||
}
|
||||
|
||||
public static Double ClampMax(this Double value, Double maxValue)
|
||||
{
|
||||
return Math.Min(maxValue, value);
|
||||
}
|
||||
|
||||
public static Double ClampMin(this Double value, Double minValue)
|
||||
{
|
||||
return Math.Max(minValue, value);
|
||||
}
|
||||
|
||||
public static Decimal Clamp(this Decimal value, Decimal minValue, Decimal maxValue)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue