fix bugs introduced by 'required' changes
This commit is contained in:
parent
7f97ab8e14
commit
a761e46686
|
@ -28,13 +28,19 @@ public static class Controller
|
||||||
var mode = s.SelectControlMode();
|
var mode = s.SelectControlMode();
|
||||||
|
|
||||||
mode.WriteLine();
|
mode.WriteLine();
|
||||||
|
|
||||||
if (mode is EssMode.Off or EssMode.NoGridMeter)
|
if (mode is EssMode.Off or EssMode.NoGridMeter)
|
||||||
return new EssControl(mode, EssLimit.NoLimit, PowerCorrection: 0, PowerSetpoint: 0);
|
return EssControl.Default;
|
||||||
|
|
||||||
var essDelta = s.ComputePowerDelta(mode);
|
var essDelta = s.ComputePowerDelta(mode);
|
||||||
|
|
||||||
var unlimitedControl = new EssControl(mode, EssLimit.NoLimit, essDelta, 0);
|
var unlimitedControl = new EssControl
|
||||||
|
{
|
||||||
|
Mode = mode,
|
||||||
|
LimitedBy = EssLimit.NoLimit,
|
||||||
|
PowerCorrection = essDelta,
|
||||||
|
PowerSetpoint = 0
|
||||||
|
};
|
||||||
|
|
||||||
var limitedControl = unlimitedControl
|
var limitedControl = unlimitedControl
|
||||||
.LimitChargePower(s)
|
.LimitChargePower(s)
|
||||||
|
|
|
@ -3,13 +3,21 @@ using InnovEnergy.Lib.Units.Power;
|
||||||
namespace InnovEnergy.App.SaliMax.Ess;
|
namespace InnovEnergy.App.SaliMax.Ess;
|
||||||
|
|
||||||
public record EssControl
|
public record EssControl
|
||||||
(
|
|
||||||
EssMode Mode,
|
|
||||||
EssLimit LimitedBy,
|
|
||||||
ActivePower PowerCorrection,
|
|
||||||
ActivePower PowerSetpoint
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
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)
|
public EssControl LimitChargePower(Double controlDelta, EssLimit reason)
|
||||||
{
|
{
|
||||||
var overload = PowerCorrection - controlDelta;
|
var overload = PowerCorrection - controlDelta;
|
||||||
|
|
|
@ -25,7 +25,7 @@ public record StatusRecord
|
||||||
public required RelaysRecord? Relays { get; init; }
|
public required RelaysRecord? Relays { get; init; }
|
||||||
public required AmptStatus PvOnDc { get; init; }
|
public required AmptStatus PvOnDc { get; init; }
|
||||||
public required Config Config { get; init; }
|
public required Config Config { get; init; }
|
||||||
public required EssControl EssControl { get; init; }
|
public required EssControl EssControl { get; set; } // TODO: init only
|
||||||
public required StateMachine StateMachine { get; init; }
|
public required StateMachine StateMachine { get; init; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,9 @@ internal static class Program
|
||||||
LoadOnAcIsland = loadOnAcIsland,
|
LoadOnAcIsland = loadOnAcIsland,
|
||||||
LoadOnDc = loadOnDc,
|
LoadOnDc = loadOnDc,
|
||||||
|
|
||||||
Config = Config.Load() // load from disk every iteration, so config can be changed while running
|
StateMachine = StateMachine.Default,
|
||||||
|
EssControl = EssControl.Default,
|
||||||
|
Config = Config.Load() // load from disk every iteration, so config can be changed while running
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,17 +230,17 @@ internal static class Program
|
||||||
var islandToGridBusPower = inverterPower + islandLoadPower;
|
var islandToGridBusPower = inverterPower + islandLoadPower;
|
||||||
var gridLoadPower = s.LoadOnAcGrid is null ? 0: s.LoadOnAcGrid.Power.Active;
|
var gridLoadPower = s.LoadOnAcGrid is null ? 0: s.LoadOnAcGrid.Power.Active;
|
||||||
|
|
||||||
var gridPowerByPhase = TextBlock.AlignLeft(s.GridMeter.Ac.L1.Power.Active.ToStringRounded(),
|
var gridPowerByPhase = TextBlock.AlignLeft(s.GridMeter.Ac.L1.Power.Active.ToDisplayString(),
|
||||||
s.GridMeter.Ac.L2.Power.Active.ToStringRounded(),
|
s.GridMeter.Ac.L2.Power.Active.ToDisplayString(),
|
||||||
s.GridMeter.Ac.L3.Power.Active.ToStringRounded());
|
s.GridMeter.Ac.L3.Power.Active.ToDisplayString());
|
||||||
|
|
||||||
var gridVoltageByPhase = TextBlock.AlignLeft(s.GridMeter.Ac.L1.Voltage.ToStringRounded(),
|
var gridVoltageByPhase = TextBlock.AlignLeft(s.GridMeter.Ac.L1.Voltage.ToDisplayString(),
|
||||||
s.GridMeter.Ac.L2.Voltage.ToStringRounded(),
|
s.GridMeter.Ac.L2.Voltage.ToDisplayString(),
|
||||||
s.GridMeter.Ac.L3.Voltage.ToStringRounded());
|
s.GridMeter.Ac.L3.Voltage.ToDisplayString());
|
||||||
|
|
||||||
var inverterPowerByPhase = TextBlock.AlignLeft(s.AcDc.Ac.L1.Power.Active.ToStringRounded(),
|
var inverterPowerByPhase = TextBlock.AlignLeft(s.AcDc.Ac.L1.Power.Active.ToDisplayString(),
|
||||||
s.AcDc.Ac.L2.Power.Active.ToStringRounded(),
|
s.AcDc.Ac.L2.Power.Active.ToDisplayString(),
|
||||||
s.AcDc.Ac.L3.Power.Active.ToStringRounded());
|
s.AcDc.Ac.L3.Power.Active.ToDisplayString());
|
||||||
|
|
||||||
// ReSharper disable once CoVariantArrayConversion
|
// ReSharper disable once CoVariantArrayConversion
|
||||||
var inverterPowerByAcDc = TextBlock.AlignLeft(s.AcDc.Devices
|
var inverterPowerByAcDc = TextBlock.AlignLeft(s.AcDc.Devices
|
||||||
|
@ -246,7 +248,7 @@ internal static class Program
|
||||||
.ToArray());
|
.ToArray());
|
||||||
|
|
||||||
var dcLinkVoltage = TextBlock.CenterHorizontal("",
|
var dcLinkVoltage = TextBlock.CenterHorizontal("",
|
||||||
s.DcDc.Dc.Link.Voltage.ToStringRounded(),
|
s.DcDc.Dc.Link.Voltage.ToDisplayString(),
|
||||||
"");
|
"");
|
||||||
|
|
||||||
//var inverterPowerByPhase = new ActivePower[(Int32)s.AcDc.Ac.L1.Power.Active, (Int32)s.AcDc.Ac.L2.Power.Active, (Int32)s.AcDc.Ac.L3.Power.Active];
|
//var inverterPowerByPhase = new ActivePower[(Int32)s.AcDc.Ac.L1.Power.Active, (Int32)s.AcDc.Ac.L2.Power.Active, (Int32)s.AcDc.Ac.L3.Power.Active];
|
||||||
|
@ -273,7 +275,7 @@ internal static class Program
|
||||||
var gridBox = TextBlock.AlignLeft(gridPowerByPhase).TitleBox("Grid");
|
var gridBox = TextBlock.AlignLeft(gridPowerByPhase).TitleBox("Grid");
|
||||||
var inverterBox = TextBlock.AlignLeft(inverterPowerByAcDc).TitleBox("Inverter");
|
var inverterBox = TextBlock.AlignLeft(inverterPowerByAcDc).TitleBox("Inverter");
|
||||||
var dcDcBox = TextBlock.AlignLeft(dc48Voltage).TitleBox("DC/DC");
|
var dcDcBox = TextBlock.AlignLeft(dc48Voltage).TitleBox("DC/DC");
|
||||||
var batteryBox = TextBlock.AlignLeft(batteryVoltage.ToStringRounded(), batterySoc.ToStringRounded(), batteryCurrent.ToStringRounded(), batteryTemp.ToStringRounded()).TitleBox("Battery");
|
var batteryBox = TextBlock.AlignLeft(batteryVoltage.ToDisplayString(), batterySoc.ToDisplayString(), batteryCurrent.ToDisplayString(), batteryTemp.ToDisplayString()).TitleBox("Battery");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ namespace InnovEnergy.Lib.WebServer;
|
||||||
|
|
||||||
public static class Default
|
public static class Default
|
||||||
{
|
{
|
||||||
public static IPEndPoint EndPoint { get; } = new IPEndPoint(0, 0);
|
public static IPEndPoint EndPoint { get; } = new IPEndPoint(0, 0);
|
||||||
public static Url Url { get; } = new Url("");
|
public static Url Url { get; } = new Url("");
|
||||||
public static HttpResponse HttpNotFound { get; } = new HttpResponse { StatusCode = 404 };
|
public static HttpResponse HttpNotFound { get; } = new HttpResponse { StatusCode = 404 };
|
||||||
public static HttpResponse HttpForbidden { get; } = new HttpResponse { StatusCode = 403 };
|
public static HttpResponse HttpForbidden { get; } = new HttpResponse { StatusCode = 403 };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue