Compare commits

...

6 Commits

5 changed files with 93 additions and 81 deletions

View File

@ -342,7 +342,7 @@ public static class Aggregator
ChargingBatteryPower = batteryChargePower.Any() ? batteryChargePower.Average() : 0.0,
GridExportPower = gridPowerExport.Any() ? gridPowerExport.Sum() : 0.0,
GridImportPower = gridPowerImport.Any() ? gridPowerImport.Sum() : 0.0,
PvPower = pvPower.Any() ? pvPower.Max() : 0.0,
PvPower = pvPower.Any() ? pvPower.Last() : 0.0,
HeatingPower = heatingPowerAvg.Any() ? heatingPowerAvg.Average() : 0.0,
};

View File

@ -225,38 +225,38 @@ internal static class Program
/******************************************** For Battery Debug *************************************/
var currentSalimaxState = GetSalimaxStateAlarm(record);
var currentSalimaxState = GetSalimaxStateAlarm(record);
SendSalimaxStateAlarm(currentSalimaxState, record);
SendSalimaxStateAlarm(currentSalimaxState, record);
//record.ControlPvPower(record.Config.CurtailP);
record.ControlConstants();
record.ControlSystemState();
record.ControlConstants();
record.ControlSystemState();
record.ControlPvPower(record.Config.CurtailP);
var essControl = record.ControlEss().WriteLine();
var essControl = record.ControlEss().WriteLine();
record.EssControl = essControl;
record.EssControl = essControl;
record.AcDc.SystemControl.ApplyAcDcDefaultSettings();
record.DcDc.SystemControl.ApplyDcDcDefaultSettings();
record.AcDc.SystemControl.ApplyAcDcDefaultSettings();
record.DcDc.SystemControl.ApplyDcDcDefaultSettings();
DistributePower(record, essControl);
DistributePower(record, essControl);
WriteControl(record);
WriteControl(record);
$"{DateTime.Now.Round(UpdateInterval).ToUnixTime()} : {record.StateMachine.State}: {record.StateMachine.Message}".WriteLine();
$"{DateTime.Now.Round(UpdateInterval).ToUnixTime()} : {record.StateMachine.State}: {record.StateMachine.Message}".WriteLine();
record.CreateTopologyTextBlock().WriteLine();
record.CreateTopologyTextBlock().WriteLine();
(record.Relays is null ? "No relay Data available" : record.Relays.FiWarning ? "Alert: Fi Warning Detected" : "No Fi Warning Detected").WriteLine();
(record.Relays is null ? "No relay Data available" : record.Relays.FiError ? "Alert: Fi Error Detected" : "No Fi Error Detected") .WriteLine();
(record.Relays is null ? "No relay Data available" : record.Relays.FiWarning ? "Alert: Fi Warning Detected" : "No Fi Warning Detected").WriteLine();
(record.Relays is null ? "No relay Data available" : record.Relays.FiError ? "Alert: Fi Error Detected" : "No Fi Error Detected") .WriteLine();
record.Config.Save();
record.Config.Save();
"===========================================".WriteLine();
"===========================================".WriteLine();
return record;
return record;
}
// ReSharper disable once FunctionNeverReturns
@ -477,6 +477,7 @@ internal static class Program
var dcDevices = r.DcDc.Devices;
var configFile = r.Config;
var maxBatteryDischargingCurrentLive = 0.0;
var devicesConfig = r.AcDc.Devices.All(d => d.Control.Ac.GridType == GridType.GridTied400V50Hz) ? configFile.GridTie : configFile.IslandMode; // TODO if any of the grid tie mode
// This adapting the max discharging current to the current Active Strings
if (r.Battery != null)
@ -484,7 +485,7 @@ internal static class Program
const Int32 stringsByBattery = 5;
var numberOfBatteriesConfigured = r.Config.Devices.BatteryNodes.Length;
var numberOfTotalStrings = stringsByBattery * numberOfBatteriesConfigured;
var dischargingCurrentByString = configFile.MaxBatteryDischargingCurrent / numberOfTotalStrings;
var dischargingCurrentByString = devicesConfig.DcDc.MaxBatteryDischargingCurrent / numberOfTotalStrings;
var boolList = new List<Boolean>();
@ -507,7 +508,6 @@ internal static class Program
// TODO The discharging current is well calculated but not communicated to live. But Written in S3
var devicesConfig = r.AcDc.Devices.All(d => d.Control.Ac.GridType == GridType.GridTied400V50Hz) ? configFile.GridTie : configFile.IslandMode; // TODO if any of the grid tie mode
inverters.ForEach(d => d.Control.Dc.MaxVoltage = devicesConfig.AcDc.MaxDcLinkVoltage);
inverters.ForEach(d => d.Control.Dc.MinVoltage = devicesConfig.AcDc.MinDcLinkVoltage);
@ -519,12 +519,12 @@ internal static class Program
dcDevices.ForEach(d => d.Control.DroopControl.LowerVoltage = devicesConfig.DcDc.LowerDcLinkVoltage);
dcDevices.ForEach(d => d.Control.DroopControl.ReferenceVoltage = devicesConfig.DcDc.ReferenceDcLinkVoltage);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryChargingCurrent = configFile.MaxBatteryChargingCurrent);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryChargingCurrent = devicesConfig.DcDc.MaxBatteryChargingCurrent);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryDischargingCurrent = maxBatteryDischargingCurrentLive);
dcDevices.ForEach(d => d.Control.MaxDcPower = configFile.MaxDcPower);
dcDevices.ForEach(d => d.Control.MaxDcPower = devicesConfig.DcDc.MaxDcPower);
dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = configFile.MaxChargeBatteryVoltage);
dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = configFile.MinDischargeBatteryVoltage);
dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = devicesConfig.DcDc.MaxChargeBatteryVoltage);
dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = devicesConfig.DcDc.MinDischargeBatteryVoltage);
dcDevices.ForEach(d => d.Control.ControlMode = DcControlMode.VoltageDroop);
r.DcDc.ResetAlarms();
@ -532,13 +532,12 @@ internal static class Program
}
// This will be used for provider throttling, this example is only for either 100% or 0 %
private static void ControlPvPower(this StatusRecord r, Int16 exportLimit = 100)
private static void ControlPvPower(this StatusRecord r, UInt16 exportLimit = 100)
{
UInt16 stableFactor = 500;
const UInt16 stableFactor = 500;
var inverters = r.AcDc.Devices;
var dcDevices = r.DcDc.Devices;
var configFile = r.Config;
var systemProduction = inverters.Count * 25000;
var systemProduction = inverters.Count * 25000; // this should be from to the PV
var limitSystemProduction = systemProduction * exportLimit / 100;
var devicesConfig = r.AcDc.Devices.All(d => d.Control.Ac.GridType == GridType.GridTied400V50Hz) ? configFile.GridTie : configFile.IslandMode; // TODO if any of the grid tie mode
var targetReferenceVoltage = devicesConfig.AcDc.ReferenceDcLinkVoltage;
@ -548,7 +547,7 @@ internal static class Program
{
exportLimit.WriteLine(" exportLimit");
systemProduction.WriteLine(" systemProduction");
limitSystemProduction.WriteLine(" limitSystemexport");
limitSystemProduction.WriteLine(" limit System export");
targetReferenceVoltage.WriteLine("targetReferenceVoltage");
if (r.GridMeter?.Ac.Power.Active != null)
@ -557,45 +556,26 @@ internal static class Program
{
"We are openning the window".WriteLine();
r.Config.GridSetPoint = -limitSystemProduction + stableFactor;
r.Config.GridSetPoint.WriteLine(" Grid set point");
var maxDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MaxDcLinkVoltage + 10);
var minDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MinDcLinkVoltage - 10);
var maxDcDcLinkVoltage = (UInt16)(r.Config.GridTie.DcDc.UpperDcLinkVoltage + 10);
var minDcDcLinkVoltage = (UInt16)(r.Config.GridTie.DcDc.LowerDcLinkVoltage + 10);
//r.Config.GridSetPoint = -limitSystemProduction + stableFactor;
//r.Config.GridSetPoint.WriteLine(" Grid set point");
var maxDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MaxDcLinkVoltage + 10);
r.Config.GridTie.AcDc.MaxDcLinkVoltage = maxDcLinkVoltage;
r.Config.GridTie.AcDc.MinDcLinkVoltage = minDcLinkVoltage;
r.Config.GridTie.DcDc.UpperDcLinkVoltage = maxDcDcLinkVoltage;
r.Config.GridTie.DcDc.LowerDcLinkVoltage = minDcDcLinkVoltage;
maxDcLinkVoltage.WriteLine("maxDcLinkVoltage");
minDcLinkVoltage.WriteLine("minxDcLinkVoltage");
maxDcDcLinkVoltage.WriteLine("maxDcDcLinkVoltage");
minDcDcLinkVoltage.WriteLine("minDcDcLinkVoltage");
}
else if (r.GridMeter.Ac.Power.Active > -limitSystemProduction + stableFactor * 2)
else if (r.GridMeter.Ac.Power.Active > -limitSystemProduction + stableFactor * 4)
{
"We are closing the window".WriteLine();
r.Config.GridSetPoint = -limitSystemProduction + stableFactor;
r.Config.GridSetPoint.WriteLine(" Grid set point");
//r.Config.GridSetPoint = -limitSystemProduction + stableFactor;
//r.Config.GridSetPoint.WriteLine(" Grid set point");
if ((r.Config.GridTie.AcDc.MaxDcLinkVoltage - r.Config.GridTie.AcDc.MinDcLinkVoltage) > 60)
{
var maxDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MaxDcLinkVoltage - 10);
var minDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MinDcLinkVoltage + 10);
var maxDcDcLinkVoltage = (UInt16)(r.Config.GridTie.DcDc.UpperDcLinkVoltage - 10);
var minDcDcLinkVoltage = (UInt16)(r.Config.GridTie.DcDc.LowerDcLinkVoltage - 10);
r.Config.GridTie.AcDc.MaxDcLinkVoltage = maxDcLinkVoltage;
r.Config.GridTie.AcDc.MinDcLinkVoltage = minDcLinkVoltage;
r.Config.GridTie.DcDc.UpperDcLinkVoltage = maxDcDcLinkVoltage;
r.Config.GridTie.DcDc.LowerDcLinkVoltage = minDcDcLinkVoltage;
var maxDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MaxDcLinkVoltage - 10);
r.Config.GridTie.AcDc.MaxDcLinkVoltage = maxDcLinkVoltage;
maxDcLinkVoltage.WriteLine("maxDcLinkVoltage");
minDcLinkVoltage.WriteLine("minxDcLinkVoltage");
maxDcDcLinkVoltage.WriteLine("maxDcDcLinkVoltage");
minDcDcLinkVoltage.WriteLine("minDcDcLinkVoltage");
}
else
{
@ -606,16 +586,14 @@ internal static class Program
else
{
r.Config.GridTie.AcDc.MaxDcLinkVoltage.WriteLine("maxDcLinkVoltage");
r.Config.GridTie.AcDc.MinDcLinkVoltage.WriteLine("minxDcLinkVoltage");
r.Config.GridTie.DcDc.UpperDcLinkVoltage.WriteLine("maxDcDcLinkVoltage");
r.Config.GridTie.DcDc.LowerDcLinkVoltage.WriteLine("minDcDcLinkVoltage");
}
}
if (exportLimit == 100)
{
r.Config.GridSetPoint = 0;
}
//if (exportLimit == 100)
//{
// r.Config.GridSetPoint = 0;
//}
}
}

View File

@ -16,7 +16,7 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
private static readonly JsonSerializerOptions JsonOptions = new() { WriteIndented = true };
public required Double MinSoc { get; set; }
public required Int16 CurtailP { get; set; }
public required UInt16 CurtailP { get; set; }
public required CalibrationChargeType ForceCalibrationChargeState { get; set; }
public required DateTime DayAndTimeForRepetitiveCalibration { get; set; }
public required DateTime DayAndTimeForAdditionalCalibration { get; set; }
@ -28,13 +28,6 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
public required DevicesConfig IslandMode { get; set; }
public required DevicesConfig GridTie { get; set; }
public required Double MaxBatteryChargingCurrent { get; set; }
public required Double MaxBatteryDischargingCurrent { get; set; }
public required Double MaxDcPower { get; set; }
public required Double MaxChargeBatteryVoltage { get; set; }
public required Double MinDischargeBatteryVoltage { get; set; }
public required DeviceConfig Devices { get; set; }
public required S3Config? S3 { get; set; }
@ -66,6 +59,13 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
UpperDcLinkVoltage = 50,
LowerDcLinkVoltage = 50,
ReferenceDcLinkVoltage = 750,
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
},
},
@ -83,6 +83,13 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
UpperDcLinkVoltage = 50,
LowerDcLinkVoltage = 50,
ReferenceDcLinkVoltage = 750,
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
},
},
@ -146,6 +153,13 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
UpperDcLinkVoltage = 50,
LowerDcLinkVoltage = 50,
ReferenceDcLinkVoltage = 750,
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
},
},
@ -163,16 +177,16 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
UpperDcLinkVoltage = 20,
LowerDcLinkVoltage = 20,
ReferenceDcLinkVoltage = 750,
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
},
},
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
S3 = new()
{

View File

@ -2,7 +2,14 @@ namespace InnovEnergy.App.SaliMax.SystemConfig;
public class DcDcConfig
{
public required Double LowerDcLinkVoltage { get; set; }
public required Double ReferenceDcLinkVoltage { get; init; }
public required Double UpperDcLinkVoltage { get; set; }
public required Double LowerDcLinkVoltage { get; set; }
public required Double ReferenceDcLinkVoltage { get; init; }
public required Double UpperDcLinkVoltage { get; set; }
public required Double MaxBatteryChargingCurrent { get; set; }
public required Double MaxBatteryDischargingCurrent { get; set; }
public required Double MaxDcPower { get; set; }
public required Double MaxChargeBatteryVoltage { get; set; }
public required Double MinDischargeBatteryVoltage { get; set; }
}

View File

@ -0,0 +1,13 @@
using InnovEnergy.Lib.Units;
namespace InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.Status;
public class ActiveVoltages
{
public Voltage ActiveUpperVoltage => _Self.DcMaxVoltage;
public Voltage ActiveLowerVoltage => _Self.DcMinVoltage;
public Voltage ActiveRefVoltage => _Self.DcReferenceVoltage;
internal ActiveVoltages(AcDcRecord self) => _Self = self;
private readonly AcDcRecord _Self;
}