54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
using InnovEnergy.Lib.Units.Power;
|
|
|
|
namespace InnovEnergy.App.SaliMax.Ess;
|
|
|
|
public record EssControl
|
|
{
|
|
public required EssMode Mode { get; init; }
|
|
public required EssLimit LimitedBy { get; init; }
|
|
public required ActivePower PowerCorrection { get; init; }
|
|
public required ActivePower PowerSetpoint { get; init; }
|
|
|
|
public static EssControl Default { get; } = new()
|
|
{
|
|
Mode = EssMode.Off,
|
|
LimitedBy = EssLimit.NoLimit,
|
|
PowerCorrection = 0,
|
|
PowerSetpoint = 0
|
|
};
|
|
|
|
|
|
public EssControl LimitChargePower(Double controlDelta, EssLimit reason)
|
|
{
|
|
var overload = PowerCorrection - controlDelta;
|
|
|
|
if (overload <= 0)
|
|
return this;
|
|
|
|
return this with
|
|
{
|
|
LimitedBy = reason,
|
|
PowerCorrection = controlDelta,
|
|
PowerSetpoint = PowerSetpoint - overload
|
|
};
|
|
}
|
|
|
|
public EssControl LimitDischargePower(Double controlDelta, EssLimit reason)
|
|
{
|
|
var overload = PowerCorrection - controlDelta;
|
|
|
|
if (overload >= 0)
|
|
return this;
|
|
|
|
return this with
|
|
{
|
|
LimitedBy = reason,
|
|
PowerCorrection = controlDelta,
|
|
PowerSetpoint = PowerSetpoint - overload
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|