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

@ -207,19 +207,24 @@ internal static class Program
{
var inverters = r.AcDc.Devices;
var dcDevices = r.DcDc.Devices;
var configFile = r.Config;
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.MaxVoltage = gridTie ? configFile.GridTie.AcDc.MaxDcLinkVoltage : configFile.IslandMode.AcDc.MaxDcLinkVoltage);
inverters.ForEach(d => d.Control.Dc.MinVoltage = gridTie ? configFile.GridTie.AcDc.MinDcLinkVoltage : configFile.IslandMode.AcDc.MinDcLinkVoltage);
inverters.ForEach(d => d.Control.Dc.ReferenceVoltage = gridTie ? configFile.GridTie.AcDc.ReferenceDcLinkVoltage : configFile.IslandMode.AcDc.ReferenceDcLinkVoltage);
inverters.ForEach(d => d.Control.Dc.MaxVoltage = r.Config.MaxDcLinkVoltageFromAcDc);
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);
dcDevices.ForEach(d => d.Control.DroopControl.LowerVoltage = r.Config.LowerDcLinkVoltageFromDc);
dcDevices.ForEach(d => d.Control.DroopControl.ReferenceVoltage = r.Config.ReferenceDcLinkVoltageFromDc);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryChargingCurrent = r.Config.MaxBatteryChargingCurrent);
dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryDischargingCurrent = r.Config.MaxBatteryDischargingCurrent);
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);
r.DcDc.ResetAlarms();