Update Program file with Control PV and Control Constant
This commit is contained in:
parent
d32ffc9696
commit
736af37475
|
@ -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.ControlPvPower(record.Config.CurtailP);
|
record.ControlConstants();
|
||||||
|
record.ControlSystemState();
|
||||||
|
|
||||||
record.ControlConstants();
|
record.ControlPvPower(record.Config.CurtailP);
|
||||||
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,6 +477,7 @@ 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)
|
||||||
|
@ -484,7 +485,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 = configFile.MaxBatteryDischargingCurrent / numberOfTotalStrings;
|
var dischargingCurrentByString = devicesConfig.DcDc.MaxBatteryDischargingCurrent / numberOfTotalStrings;
|
||||||
|
|
||||||
var boolList = new List<Boolean>();
|
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
|
// 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 = 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.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.MaxBatteryVoltage = devicesConfig.DcDc.MaxChargeBatteryVoltage);
|
||||||
dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = configFile.MinDischargeBatteryVoltage);
|
dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = devicesConfig.DcDc.MinDischargeBatteryVoltage);
|
||||||
dcDevices.ForEach(d => d.Control.ControlMode = DcControlMode.VoltageDroop);
|
dcDevices.ForEach(d => d.Control.ControlMode = DcControlMode.VoltageDroop);
|
||||||
|
|
||||||
r.DcDc.ResetAlarms();
|
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 %
|
// 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 inverters = r.AcDc.Devices;
|
||||||
var dcDevices = r.DcDc.Devices;
|
|
||||||
var configFile = r.Config;
|
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 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;
|
||||||
|
@ -548,7 +547,7 @@ internal static class Program
|
||||||
{
|
{
|
||||||
exportLimit.WriteLine(" exportLimit");
|
exportLimit.WriteLine(" exportLimit");
|
||||||
systemProduction.WriteLine(" systemProduction");
|
systemProduction.WriteLine(" systemProduction");
|
||||||
limitSystemProduction.WriteLine(" limitSystemexport");
|
limitSystemProduction.WriteLine(" limit System export");
|
||||||
targetReferenceVoltage.WriteLine("targetReferenceVoltage");
|
targetReferenceVoltage.WriteLine("targetReferenceVoltage");
|
||||||
|
|
||||||
if (r.GridMeter?.Ac.Power.Active != null)
|
if (r.GridMeter?.Ac.Power.Active != null)
|
||||||
|
@ -557,45 +556,26 @@ 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 * 2)
|
else if (r.GridMeter.Ac.Power.Active > -limitSystemProduction + stableFactor * 4)
|
||||||
{
|
{
|
||||||
"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);
|
||||||
var minDcLinkVoltage = (UInt16)(r.Config.GridTie.AcDc.MinDcLinkVoltage + 10);
|
r.Config.GridTie.AcDc.MaxDcLinkVoltage = maxDcLinkVoltage;
|
||||||
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
|
||||||
{
|
{
|
||||||
|
@ -606,16 +586,14 @@ 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;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue