Change the max charge batteries limit when we are in heating mode
This commit is contained in:
parent
a10193592f
commit
e6f1263e4b
|
@ -1,14 +1,16 @@
|
||||||
using InnovEnergy.App.SaliMax.Ess;
|
using InnovEnergy.App.SaliMax.Ess;
|
||||||
using InnovEnergy.App.SaliMax.SaliMaxRelays;
|
using InnovEnergy.App.SaliMax.SaliMaxRelays;
|
||||||
using InnovEnergy.Lib.Devices.Battery48TL;
|
|
||||||
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc;
|
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc;
|
||||||
|
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes;
|
||||||
using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc;
|
using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc;
|
||||||
|
using InnovEnergy.Lib.Utils;
|
||||||
using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.GridType;
|
using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.GridType;
|
||||||
|
|
||||||
namespace InnovEnergy.App.SaliMax.System;
|
namespace InnovEnergy.App.SaliMax.System;
|
||||||
|
|
||||||
public static class Controller
|
public static class Controller
|
||||||
{
|
{
|
||||||
|
private static Boolean _intermediateState;
|
||||||
private static Int32 GetSystemState(this StatusRecord r)
|
private static Int32 GetSystemState(this StatusRecord r)
|
||||||
{
|
{
|
||||||
var relays = r.Relays;
|
var relays = r.Relays;
|
||||||
|
@ -17,17 +19,42 @@ public static class Controller
|
||||||
return 101; // Message = "Panic: relay device is not available!",
|
return 101; // Message = "Panic: relay device is not available!",
|
||||||
|
|
||||||
var acDcs = r.AcDc;
|
var acDcs = r.AcDc;
|
||||||
|
// var dcDcs = r.DcDc;
|
||||||
|
|
||||||
if (acDcs.NotAvailable())
|
if (acDcs.NotAvailable())
|
||||||
return 102;
|
return 102;
|
||||||
|
|
||||||
var k4 = acDcs.AllDisabled() ? 0
|
var i = 0;
|
||||||
: acDcs.AllGridTied() ? 1
|
|
||||||
: acDcs.AllIsland() ? 2
|
foreach (var s in acDcs.Devices)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
s.Control.PowerStageEnable.WriteLine(" Inverter "+ i + ": Power Stage");
|
||||||
|
String.Join(Environment.NewLine + i, s.Status.Alarms).LogInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
var allDisabled = acDcs.AllDisabled();
|
||||||
|
var allGridTied = acDcs.AllGridTied();
|
||||||
|
var allIsland = acDcs.AllIsland();
|
||||||
|
|
||||||
|
|
||||||
|
var k4 = allDisabled ? 0
|
||||||
|
: allGridTied ? 1
|
||||||
|
: allIsland ? 2
|
||||||
: 4;
|
: 4;
|
||||||
|
|
||||||
|
//if (!acDcs.AllTheSame())
|
||||||
|
//{
|
||||||
|
// k4 = 4;
|
||||||
|
// "Panic: ACDCs have unequal power stage".LogError();
|
||||||
|
//}
|
||||||
|
|
||||||
|
// we need to check for dcdc unequal power stage
|
||||||
|
|
||||||
if (k4 == 4)
|
if (k4 == 4)
|
||||||
return 103; //Message = "Panic: ACDCs have unequal grid types",
|
{
|
||||||
|
return 103; //Message = "Panic: ACDCs have unequal grid types or power stage",
|
||||||
|
}
|
||||||
|
|
||||||
var nInverters = r.AcDc.Devices.Count;
|
var nInverters = r.AcDc.Devices.Count;
|
||||||
|
|
||||||
|
@ -54,7 +81,6 @@ public static class Controller
|
||||||
4 => State4(s),
|
4 => State4(s),
|
||||||
6 => State6(s),
|
6 => State6(s),
|
||||||
9 => State9(s),
|
9 => State9(s),
|
||||||
//10 => State10(s),
|
|
||||||
12 => State12(s),
|
12 => State12(s),
|
||||||
13 => State13(s),
|
13 => State13(s),
|
||||||
15 => State15(s),
|
15 => State15(s),
|
||||||
|
@ -76,34 +102,44 @@ public static class Controller
|
||||||
return acDcs.SystemControl == null || acDcs.Devices.Count == 0;
|
return acDcs.SystemControl == null || acDcs.Devices.Count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean NotAvailable(this DcDcDevicesRecord dcDcs)
|
|
||||||
{
|
|
||||||
return dcDcs.SystemControl == null || dcDcs.Devices.Count == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static Boolean NotAvailable(this Battery48TlRecords batteries)
|
|
||||||
{
|
|
||||||
return batteries.Devices.Count <= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Boolean State1(StatusRecord s)
|
private static Boolean State1(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Inverters are off. Switching to Island Mode.";
|
s.StateMachine.Message = "Ac/Dc are off. Switching to Island Mode.";
|
||||||
|
|
||||||
|
if (!_intermediateState)
|
||||||
|
{
|
||||||
|
s.DcDc.Disable();
|
||||||
|
s.AcDc.Disable();
|
||||||
|
s.AcDc.EnableIslandMode();
|
||||||
|
s.Relays.DisconnectIslandBusFromGrid();
|
||||||
|
_intermediateState = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_intermediateState = false;
|
||||||
|
State1Intermediate(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// => Intermediate State
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void State1Intermediate(StatusRecord s)
|
||||||
|
{
|
||||||
|
s.StateMachine.Message = "Intermediate State 1 ";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
s.AcDc.EnableIslandMode();
|
s.AcDc.EnableIslandMode();
|
||||||
s.Relays.DisconnectIslandBusFromGrid();
|
s.Relays.DisconnectIslandBusFromGrid();
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// => 17
|
// => 17
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean State2(StatusRecord s)
|
private static Boolean State2(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Inverters are disconnected from Island Bus. Switching to GridTie Mode. C";
|
s.StateMachine.Message = "Ac/Dc are disconnected from Island Bus. Switching to GridTie Mode. C";
|
||||||
|
|
||||||
s.DcDc.Disable();
|
s.DcDc.Disable();
|
||||||
s.AcDc.Disable();
|
s.AcDc.Disable();
|
||||||
|
@ -112,12 +148,12 @@ public static class Controller
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// => 10
|
// => 4
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean State4(StatusRecord s)
|
private static Boolean State4(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Turning on Inverters";
|
s.StateMachine.Message = "Turning on Ac/Dc";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -132,7 +168,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State6(StatusRecord s)
|
private static Boolean State6(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Inverters are off. Waiting for them to disconnect from Island Bus.";
|
s.StateMachine.Message = "Ac/Dc are off. Waiting for them to disconnect from Island Bus.";
|
||||||
|
|
||||||
s.DcDc.Disable();
|
s.DcDc.Disable();
|
||||||
s.AcDc.Disable();
|
s.AcDc.Disable();
|
||||||
|
@ -148,7 +184,7 @@ public static class Controller
|
||||||
private static Boolean State9(StatusRecord s)
|
private static Boolean State9(StatusRecord s)
|
||||||
{
|
{
|
||||||
|
|
||||||
s.StateMachine.Message = "Inverters have disconnected from Island Bus. Turning them off.";
|
s.StateMachine.Message = "Ac/Dc have disconnected from Island Bus. Turning them off.";
|
||||||
|
|
||||||
s.DcDc.Disable(); // TODO: leave enabled?
|
s.DcDc.Disable(); // TODO: leave enabled?
|
||||||
s.AcDc.Disable();
|
s.AcDc.Disable();
|
||||||
|
@ -179,7 +215,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State12(StatusRecord s)
|
private static Boolean State12(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Waiting for Inverters to connect to Island Bus";
|
s.StateMachine.Message = "Waiting for Ac/Dc to connect to Island Bus";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -195,7 +231,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State13(StatusRecord s)
|
private static Boolean State13(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Disconnected from AcIn (K2), awaiting inverters to disconnect from AcOut (K3)";
|
s.StateMachine.Message = "Disconnected from AcIn (K2), awaiting Ac/Dc to disconnect from AcOut (K3)";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -223,20 +259,12 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State16(StatusRecord s)
|
private static Boolean State16(StatusRecord s)
|
||||||
{
|
{
|
||||||
// return new
|
|
||||||
// (
|
|
||||||
// " Inverter is in grid-tie\n Waiting for K1AcInIsConnectedToGrid to open to leave it",
|
|
||||||
// AcPowerStageEnable: true,
|
|
||||||
// DcPowerStageEnable: true,
|
|
||||||
// GridType.GridTied400V50Hz,
|
|
||||||
// HighActivePinState.Closed
|
|
||||||
// );
|
|
||||||
|
|
||||||
s.StateMachine.Message = "ESS";
|
s.StateMachine.Message = "ESS";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
s.AcDc.EnableGridTieMode();
|
s.AcDc.EnableGridTieMode();
|
||||||
|
s.EnableDcLinkGridTie();
|
||||||
s.Relays.ConnectIslandBusToGrid();
|
s.Relays.ConnectIslandBusToGrid();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -247,7 +275,7 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State17(StatusRecord s)
|
private static Boolean State17(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Inverters are in Island Mode. Waiting for them to connect to AcIn.";
|
s.StateMachine.Message = "Ac/Dc are in Island Mode. Waiting for them to connect to AcIn.";
|
||||||
|
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
|
@ -287,6 +315,7 @@ public static class Controller
|
||||||
s.DcDc.Enable();
|
s.DcDc.Enable();
|
||||||
s.AcDc.Enable();
|
s.AcDc.Enable();
|
||||||
s.AcDc.EnableIslandMode();
|
s.AcDc.EnableIslandMode();
|
||||||
|
s.EnableDcLinkIslandMode();
|
||||||
s.Relays.DisconnectIslandBusFromGrid();
|
s.Relays.DisconnectIslandBusFromGrid();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -294,24 +323,6 @@ public static class Controller
|
||||||
// => 22
|
// => 22
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean State22(StatusRecord s)
|
|
||||||
{
|
|
||||||
s.StateMachine.Message = "Grid became available (K1). Turning off inverters.";
|
|
||||||
|
|
||||||
s.DcDc.Disable();
|
|
||||||
s.AcDc.Disable();
|
|
||||||
s.AcDc.EnableIslandMode();
|
|
||||||
s.Relays.DisconnectIslandBusFromGrid();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// => 6
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static Boolean State101(StatusRecord s)
|
private static Boolean State101(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Relay device is not available";
|
s.StateMachine.Message = "Relay device is not available";
|
||||||
|
@ -327,15 +338,15 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean State103(StatusRecord s)
|
private static Boolean State103(StatusRecord s)
|
||||||
{
|
{
|
||||||
s.StateMachine.Message = "Panic: ACDCs have unequal grid types";
|
s.StateMachine.Message = "Panic: ACDCs have unequal grid types or PowerStage";
|
||||||
return s.EnableSafeDefaults();
|
return s.EnableSafeDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean State104(StatusRecord s)
|
// private static Boolean State104(StatusRecord s)
|
||||||
{
|
// {
|
||||||
s.StateMachine.Message = "Panic: DCDCs not available";
|
// s.StateMachine.Message = "Panic: DCDCs not available";
|
||||||
return s.EnableSafeDefaults();
|
// return s.EnableSafeDefaults();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
private static Boolean UnknownState(StatusRecord s)
|
private static Boolean UnknownState(StatusRecord s)
|
||||||
|
@ -352,6 +363,14 @@ public static class Controller
|
||||||
return acDcs.Devices.All(d => !d.Control.PowerStageEnable);
|
return acDcs.Devices.All(d => !d.Control.PowerStageEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Boolean AllTheSame(this AcDcDevicesRecord acDcs)
|
||||||
|
{
|
||||||
|
return acDcs.Devices
|
||||||
|
.Select(d => d.Control.PowerStageEnable)
|
||||||
|
.Distinct()
|
||||||
|
.Count() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
private static Boolean AllGridTied(this AcDcDevicesRecord acDcs)
|
private static Boolean AllGridTied(this AcDcDevicesRecord acDcs)
|
||||||
{
|
{
|
||||||
return acDcs.Devices.All(d => d.Status.ActiveGridType is GridTied380V60Hz)
|
return acDcs.Devices.All(d => d.Status.ActiveGridType is GridTied380V60Hz)
|
||||||
|
@ -381,9 +400,9 @@ public static class Controller
|
||||||
|
|
||||||
private static void Disable(this DcDcDevicesRecord dcDc)
|
private static void Disable(this DcDcDevicesRecord dcDc)
|
||||||
{
|
{
|
||||||
dcDc.Devices
|
// dcDc.Devices
|
||||||
.Select(d => d.Control)
|
// .Select(d => d.Control)
|
||||||
.ForAll(c => c.PowerStageEnable = false);
|
// .ForAll(c => c.PowerStageEnable = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Enable(this AcDcDevicesRecord acDc)
|
private static void Enable(this AcDcDevicesRecord acDc)
|
||||||
|
@ -393,7 +412,6 @@ public static class Controller
|
||||||
.ForAll(c => c.PowerStageEnable = true);
|
.ForAll(c => c.PowerStageEnable = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void Enable(this DcDcDevicesRecord dcDc)
|
private static void Enable(this DcDcDevicesRecord dcDc)
|
||||||
{
|
{
|
||||||
dcDc.Devices
|
dcDc.Devices
|
||||||
|
@ -401,6 +419,18 @@ public static class Controller
|
||||||
.ForAll(c => c.PowerStageEnable = true);
|
.ForAll(c => c.PowerStageEnable = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private static void Enable(this DcDcDevicesRecord dcDc, AcDcDevicesRecord acDc)
|
||||||
|
// {
|
||||||
|
// var enableDc = acDc
|
||||||
|
// .Devices
|
||||||
|
// .Select(ac => ac.Status.InverterState.Current)
|
||||||
|
// .All(s => s > InverterState.DcLinkChargeDischargeTest );
|
||||||
|
//
|
||||||
|
// dcDc.Devices
|
||||||
|
// .Select(d => d.Control)
|
||||||
|
// .ForAll(c => c.PowerStageEnable = enableDc);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void EnableGridTieMode(this AcDcDevicesRecord acDc)
|
private static void EnableGridTieMode(this AcDcDevicesRecord acDc)
|
||||||
|
@ -418,6 +448,32 @@ public static class Controller
|
||||||
.ForAll(c => c.Ac.GridType = Island400V50Hz); // TODO: config grid type
|
.ForAll(c => c.Ac.GridType = Island400V50Hz); // TODO: config grid type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void EnableDcLinkIslandMode(this StatusRecord s)
|
||||||
|
{
|
||||||
|
// Dc Link Windows on AcDc +- 60
|
||||||
|
s.Config.ReferenceDcLinkVoltageFromAcDc = 750;
|
||||||
|
s.Config.MinDcLinkVoltageFromAcDc = 690;
|
||||||
|
s.Config.MaxDcLinkVoltageFromAcDc = 810;
|
||||||
|
|
||||||
|
// Dc Link Windows on DcDc +-55
|
||||||
|
s.Config.ReferenceDcLinkVoltageFromDc = 750;
|
||||||
|
s.Config.UpperDcLinkVoltageFromDc = 55;
|
||||||
|
s.Config.LowerDcLinkVoltageFromDc = 55;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnableDcLinkGridTie(this StatusRecord s)
|
||||||
|
{
|
||||||
|
// Dc Link Windows on DcDc +-55
|
||||||
|
|
||||||
|
s.Config.ReferenceDcLinkVoltageFromAcDc = 750;
|
||||||
|
s.Config.MinDcLinkVoltageFromAcDc = 720;
|
||||||
|
s.Config.MaxDcLinkVoltageFromAcDc = 780;
|
||||||
|
|
||||||
|
s.Config.ReferenceDcLinkVoltageFromDc = 750;
|
||||||
|
s.Config.UpperDcLinkVoltageFromDc = 20;
|
||||||
|
s.Config.LowerDcLinkVoltageFromDc = 20;
|
||||||
|
}
|
||||||
|
|
||||||
private static void DisconnectIslandBusFromGrid(this RelaysRecord? relays)
|
private static void DisconnectIslandBusFromGrid(this RelaysRecord? relays)
|
||||||
{
|
{
|
||||||
if (relays is not null)
|
if (relays is not null)
|
||||||
|
@ -433,15 +489,15 @@ public static class Controller
|
||||||
|
|
||||||
private static Boolean EnableSafeDefaults(this StatusRecord s)
|
private static Boolean EnableSafeDefaults(this StatusRecord s)
|
||||||
{
|
{
|
||||||
s.DcDc.Disable();
|
// s.DcDc.Disable();
|
||||||
s.AcDc.Disable();
|
s.AcDc.Disable();
|
||||||
s.AcDc.EnableGridTieMode();
|
// s.AcDc.EnableGridTieMode();
|
||||||
s.Relays.DisconnectIslandBusFromGrid();
|
// s.Relays.DisconnectIslandBusFromGrid();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DcDcDevicesRecord ResetAlarms(this DcDcDevicesRecord dcDcStatus)
|
public static DcDcDevicesRecord ResetAlarms(this DcDcDevicesRecord dcDcStatus)
|
||||||
{
|
{
|
||||||
var sc = dcDcStatus.SystemControl;
|
var sc = dcDcStatus.SystemControl;
|
||||||
|
|
||||||
|
@ -454,7 +510,7 @@ public static class Controller
|
||||||
return dcDcStatus;
|
return dcDcStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AcDcDevicesRecord ResetAlarms(this AcDcDevicesRecord acDcStatus)
|
public static AcDcDevicesRecord ResetAlarms(this AcDcDevicesRecord acDcStatus)
|
||||||
{
|
{
|
||||||
var sc = acDcStatus.SystemControl;
|
var sc = acDcStatus.SystemControl;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue