Compare commits

..

No commits in common. "501a0584c58e8b240f76726ac093ae8992f21fb1" and "9ba33a6cf78c7c242c7cfc85074e71614b4620a1" have entirely different histories.

5 changed files with 81 additions and 93 deletions

View File

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

View File

@ -225,38 +225,38 @@ internal static class Program
/******************************************** For Battery Debug *************************************/ /******************************************** For Battery Debug *************************************/
var currentSalimaxState = GetSalimaxStateAlarm(record); var currentSalimaxState = GetSalimaxStateAlarm(record);
SendSalimaxStateAlarm(currentSalimaxState, record); SendSalimaxStateAlarm(currentSalimaxState, record);
record.ControlConstants(); //record.ControlPvPower(record.Config.CurtailP);
record.ControlSystemState();
record.ControlPvPower(record.Config.CurtailP); record.ControlConstants();
record.ControlSystemState();
var essControl = record.ControlEss().WriteLine(); var essControl = record.ControlEss().WriteLine();
record.EssControl = essControl; record.EssControl = essControl;
record.AcDc.SystemControl.ApplyAcDcDefaultSettings(); record.AcDc.SystemControl.ApplyAcDcDefaultSettings();
record.DcDc.SystemControl.ApplyDcDcDefaultSettings(); 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.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.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 // ReSharper disable once FunctionNeverReturns
@ -477,7 +477,6 @@ internal static class Program
var dcDevices = r.DcDc.Devices; var dcDevices = r.DcDc.Devices;
var configFile = r.Config; var configFile = r.Config;
var maxBatteryDischargingCurrentLive = 0.0; 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 // This adapting the max discharging current to the current Active Strings
if (r.Battery != null) if (r.Battery != null)
@ -485,7 +484,7 @@ internal static class Program
const Int32 stringsByBattery = 5; const Int32 stringsByBattery = 5;
var numberOfBatteriesConfigured = r.Config.Devices.BatteryNodes.Length; var numberOfBatteriesConfigured = r.Config.Devices.BatteryNodes.Length;
var numberOfTotalStrings = stringsByBattery * numberOfBatteriesConfigured; var numberOfTotalStrings = stringsByBattery * numberOfBatteriesConfigured;
var dischargingCurrentByString = devicesConfig.DcDc.MaxBatteryDischargingCurrent / numberOfTotalStrings; var dischargingCurrentByString = configFile.MaxBatteryDischargingCurrent / numberOfTotalStrings;
var boolList = new List<Boolean>(); var boolList = new List<Boolean>();
@ -508,6 +507,7 @@ internal static class Program
// TODO The discharging current is well calculated but not communicated to live. But Written in S3 // 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.MaxVoltage = devicesConfig.AcDc.MaxDcLinkVoltage);
inverters.ForEach(d => d.Control.Dc.MinVoltage = devicesConfig.AcDc.MinDcLinkVoltage); 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.LowerVoltage = devicesConfig.DcDc.LowerDcLinkVoltage);
dcDevices.ForEach(d => d.Control.DroopControl.ReferenceVoltage = devicesConfig.DcDc.ReferenceDcLinkVoltage); dcDevices.ForEach(d => d.Control.DroopControl.ReferenceVoltage = devicesConfig.DcDc.ReferenceDcLinkVoltage);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryChargingCurrent = devicesConfig.DcDc.MaxBatteryChargingCurrent); dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryChargingCurrent = configFile.MaxBatteryChargingCurrent);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryDischargingCurrent = maxBatteryDischargingCurrentLive); dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryDischargingCurrent = maxBatteryDischargingCurrentLive);
dcDevices.ForEach(d => d.Control.MaxDcPower = devicesConfig.DcDc.MaxDcPower); dcDevices.ForEach(d => d.Control.MaxDcPower = configFile.MaxDcPower);
dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = devicesConfig.DcDc.MaxChargeBatteryVoltage); dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = configFile.MaxChargeBatteryVoltage);
dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = devicesConfig.DcDc.MinDischargeBatteryVoltage); dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = configFile.MinDischargeBatteryVoltage);
dcDevices.ForEach(d => d.Control.ControlMode = DcControlMode.VoltageDroop); dcDevices.ForEach(d => d.Control.ControlMode = DcControlMode.VoltageDroop);
r.DcDc.ResetAlarms(); r.DcDc.ResetAlarms();
@ -532,12 +532,13 @@ internal static class Program
} }
// This will be used for provider throttling, this example is only for either 100% or 0 % // This will be used for provider throttling, this example is only for either 100% or 0 %
private static void ControlPvPower(this StatusRecord r, UInt16 exportLimit = 100) private static void ControlPvPower(this StatusRecord r, Int16 exportLimit = 100)
{ {
const UInt16 stableFactor = 500; UInt16 stableFactor = 500;
var inverters = r.AcDc.Devices; var inverters = r.AcDc.Devices;
var dcDevices = r.DcDc.Devices;
var configFile = r.Config; var configFile = r.Config;
var systemProduction = inverters.Count * 25000; // this should be from to the PV var systemProduction = inverters.Count * 25000;
var limitSystemProduction = systemProduction * exportLimit / 100; 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 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; var targetReferenceVoltage = devicesConfig.AcDc.ReferenceDcLinkVoltage;
@ -547,7 +548,7 @@ internal static class Program
{ {
exportLimit.WriteLine(" exportLimit"); exportLimit.WriteLine(" exportLimit");
systemProduction.WriteLine(" systemProduction"); systemProduction.WriteLine(" systemProduction");
limitSystemProduction.WriteLine(" limit System export"); limitSystemProduction.WriteLine(" limitSystemexport");
targetReferenceVoltage.WriteLine("targetReferenceVoltage"); targetReferenceVoltage.WriteLine("targetReferenceVoltage");
if (r.GridMeter?.Ac.Power.Active != null) if (r.GridMeter?.Ac.Power.Active != null)
@ -556,26 +557,45 @@ internal static class Program
{ {
"We are openning the window".WriteLine(); "We are openning the window".WriteLine();
//r.Config.GridSetPoint = -limitSystemProduction + stableFactor; r.Config.GridSetPoint = -limitSystemProduction + stableFactor;
//r.Config.GridSetPoint.WriteLine(" Grid set point"); r.Config.GridSetPoint.WriteLine(" Grid set point");
var maxDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MaxDcLinkVoltage + 10); 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.MaxDcLinkVoltage = maxDcLinkVoltage;
r.Config.GridTie.AcDc.MinDcLinkVoltage = minDcLinkVoltage;
r.Config.GridTie.DcDc.UpperDcLinkVoltage = maxDcDcLinkVoltage;
r.Config.GridTie.DcDc.LowerDcLinkVoltage = minDcDcLinkVoltage;
maxDcLinkVoltage.WriteLine("maxDcLinkVoltage"); maxDcLinkVoltage.WriteLine("maxDcLinkVoltage");
minDcLinkVoltage.WriteLine("minxDcLinkVoltage");
maxDcDcLinkVoltage.WriteLine("maxDcDcLinkVoltage");
minDcDcLinkVoltage.WriteLine("minDcDcLinkVoltage");
} }
else if (r.GridMeter.Ac.Power.Active > -limitSystemProduction + stableFactor * 4) else if (r.GridMeter.Ac.Power.Active > -limitSystemProduction + stableFactor * 2)
{ {
"We are closing the window".WriteLine(); "We are closing the window".WriteLine();
//r.Config.GridSetPoint = -limitSystemProduction + stableFactor; r.Config.GridSetPoint = -limitSystemProduction + stableFactor;
//r.Config.GridSetPoint.WriteLine(" Grid set point"); r.Config.GridSetPoint.WriteLine(" Grid set point");
if ((r.Config.GridTie.AcDc.MaxDcLinkVoltage - r.Config.GridTie.AcDc.MinDcLinkVoltage) > 60) if ((r.Config.GridTie.AcDc.MaxDcLinkVoltage - r.Config.GridTie.AcDc.MinDcLinkVoltage) > 60)
{ {
var maxDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MaxDcLinkVoltage - 10); var maxDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MaxDcLinkVoltage - 10);
r.Config.GridTie.AcDc.MaxDcLinkVoltage = maxDcLinkVoltage; 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;
maxDcLinkVoltage.WriteLine("maxDcLinkVoltage"); maxDcLinkVoltage.WriteLine("maxDcLinkVoltage");
minDcLinkVoltage.WriteLine("minxDcLinkVoltage");
maxDcDcLinkVoltage.WriteLine("maxDcDcLinkVoltage");
minDcDcLinkVoltage.WriteLine("minDcDcLinkVoltage");
} }
else else
{ {
@ -586,14 +606,16 @@ internal static class Program
else else
{ {
r.Config.GridTie.AcDc.MaxDcLinkVoltage.WriteLine("maxDcLinkVoltage"); 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.UpperDcLinkVoltage.WriteLine("maxDcDcLinkVoltage");
r.Config.GridTie.DcDc.LowerDcLinkVoltage.WriteLine("minDcDcLinkVoltage");
} }
} }
//if (exportLimit == 100) if (exportLimit == 100)
//{ {
// r.Config.GridSetPoint = 0; 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 }; private static readonly JsonSerializerOptions JsonOptions = new() { WriteIndented = true };
public required Double MinSoc { get; set; } public required Double MinSoc { get; set; }
public required UInt16 CurtailP { get; set; } public required Int16 CurtailP { get; set; }
public required CalibrationChargeType ForceCalibrationChargeState { get; set; } public required CalibrationChargeType ForceCalibrationChargeState { get; set; }
public required DateTime DayAndTimeForRepetitiveCalibration { get; set; } public required DateTime DayAndTimeForRepetitiveCalibration { get; set; }
public required DateTime DayAndTimeForAdditionalCalibration { get; set; } public required DateTime DayAndTimeForAdditionalCalibration { get; set; }
@ -28,6 +28,13 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
public required DevicesConfig IslandMode { get; set; } public required DevicesConfig IslandMode { get; set; }
public required DevicesConfig GridTie { 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 DeviceConfig Devices { get; set; }
public required S3Config? S3 { get; set; } public required S3Config? S3 { get; set; }
@ -59,13 +66,6 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
UpperDcLinkVoltage = 50, UpperDcLinkVoltage = 50,
LowerDcLinkVoltage = 50, LowerDcLinkVoltage = 50,
ReferenceDcLinkVoltage = 750, ReferenceDcLinkVoltage = 750,
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
}, },
}, },
@ -83,13 +83,6 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
UpperDcLinkVoltage = 50, UpperDcLinkVoltage = 50,
LowerDcLinkVoltage = 50, LowerDcLinkVoltage = 50,
ReferenceDcLinkVoltage = 750, ReferenceDcLinkVoltage = 750,
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
}, },
}, },
@ -153,13 +146,6 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
UpperDcLinkVoltage = 50, UpperDcLinkVoltage = 50,
LowerDcLinkVoltage = 50, LowerDcLinkVoltage = 50,
ReferenceDcLinkVoltage = 750, ReferenceDcLinkVoltage = 750,
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
}, },
}, },
@ -177,16 +163,16 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
UpperDcLinkVoltage = 20, UpperDcLinkVoltage = 20,
LowerDcLinkVoltage = 20, LowerDcLinkVoltage = 20,
ReferenceDcLinkVoltage = 750, ReferenceDcLinkVoltage = 750,
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
}, },
}, },
MaxBatteryChargingCurrent = 210,
MaxBatteryDischargingCurrent = 210,
MaxDcPower = 10000,
MaxChargeBatteryVoltage = 57,
MinDischargeBatteryVoltage = 0,
S3 = new() S3 = new()
{ {

View File

@ -2,14 +2,7 @@ namespace InnovEnergy.App.SaliMax.SystemConfig;
public class DcDcConfig public class DcDcConfig
{ {
public required Double LowerDcLinkVoltage { get; set; } public required Double LowerDcLinkVoltage { get; set; }
public required Double ReferenceDcLinkVoltage { get; init; } public required Double ReferenceDcLinkVoltage { get; init; }
public required Double UpperDcLinkVoltage { get; set; } 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

@ -1,13 +0,0 @@
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;
}