Fix control constants, we assign the Dc bus Voltage info depends on the mode

This commit is contained in:
atef 2023-09-07 17:28:10 +02:00
parent f8b13a9814
commit b39b512a12
1 changed files with 18 additions and 13 deletions

View File

@ -205,21 +205,26 @@ internal static class Program
private static void ControlConstants(this StatusRecord r) private static void ControlConstants(this StatusRecord r)
{ {
var inverters = r.AcDc.Devices; var inverters = r.AcDc.Devices;
var dcDevices = r.DcDc.Devices; var dcDevices = r.DcDc.Devices;
var configFile = r.Config;
inverters.ForEach(d => d.Control.Dc.MaxVoltage = r.Config.MaxDcLinkVoltageFromAcDc); var gridTie = r.AcDc.Devices.All(d => d.Control.Ac.GridType == GridType.GridTied400V50Hz); // TODO if any of the grid tie mode
inverters.ForEach(d => d.Control.Dc.MinVoltage = r.Config.MinDcLinkVoltageFromAcDc);
inverters.ForEach(d => d.Control.Dc.ReferenceVoltage = r.Config.ReferenceDcLinkVoltageFromAcDc);
inverters.ForEach(d => d.Control.Dc.PrechargeConfig = DcPrechargeConfig.PrechargeDcWithInternal);
dcDevices.ForEach(d => d.Control.DroopControl.UpperVoltage = r.Config.UpperDcLinkVoltageFromDc); inverters.ForEach(d => d.Control.Dc.MaxVoltage = gridTie ? configFile.GridTie.AcDc.MaxDcLinkVoltage : configFile.IslandMode.AcDc.MaxDcLinkVoltage);
dcDevices.ForEach(d => d.Control.DroopControl.LowerVoltage = r.Config.LowerDcLinkVoltageFromDc); inverters.ForEach(d => d.Control.Dc.MinVoltage = gridTie ? configFile.GridTie.AcDc.MinDcLinkVoltage : configFile.IslandMode.AcDc.MinDcLinkVoltage);
dcDevices.ForEach(d => d.Control.DroopControl.ReferenceVoltage = r.Config.ReferenceDcLinkVoltageFromDc); inverters.ForEach(d => d.Control.Dc.ReferenceVoltage = gridTie ? configFile.GridTie.AcDc.ReferenceDcLinkVoltage : configFile.IslandMode.AcDc.ReferenceDcLinkVoltage);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryChargingCurrent = r.Config.MaxBatteryChargingCurrent);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryDischargingCurrent = r.Config.MaxBatteryDischargingCurrent); inverters.ForEach(d => d.Control.Dc.PrechargeConfig = DcPrechargeConfig.PrechargeDcWithInternal);
dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = r.Config.MaxChargeBatteryVoltage);
dcDevices.ForEach(d => d.Control.VoltageLimits.MinBatteryVoltage = r.Config.MinDischargeBatteryVoltage); dcDevices.ForEach(d => d.Control.DroopControl.UpperVoltage = gridTie ? configFile.GridTie.DcDc.UpperDcLinkVoltage : configFile.IslandMode.DcDc.UpperDcLinkVoltage);
dcDevices.ForEach(d => d.Control.DroopControl.LowerVoltage = gridTie ? configFile.GridTie.DcDc.LowerDcLinkVoltage : configFile.IslandMode.DcDc.LowerDcLinkVoltage);
dcDevices.ForEach(d => d.Control.DroopControl.ReferenceVoltage = gridTie ? configFile.GridTie.DcDc.ReferenceDcLinkVoltage : configFile.IslandMode.DcDc.ReferenceDcLinkVoltage);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryChargingCurrent = configFile.MaxBatteryChargingCurrent);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryDischargingCurrent = configFile.MaxBatteryDischargingCurrent);
dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = configFile.MaxChargeBatteryVoltage);
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();