update control constants.

This commit is contained in:
atef 2023-09-07 17:41:42 +02:00
parent b39b512a12
commit fd52a94d18
1 changed files with 12 additions and 12 deletions

View File

@ -205,21 +205,21 @@ internal static class Program
private static void ControlConstants(this StatusRecord r)
{
var inverters = r.AcDc.Devices;
var dcDevices = r.DcDc.Devices;
var configFile = r.Config;
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
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 = 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 = devicesConfig.AcDc.MaxDcLinkVoltage);
inverters.ForEach(d => d.Control.Dc.MinVoltage = devicesConfig.AcDc.MinDcLinkVoltage);
inverters.ForEach(d => d.Control.Dc.ReferenceVoltage = devicesConfig.AcDc.ReferenceDcLinkVoltage);
inverters.ForEach(d => d.Control.Dc.PrechargeConfig = DcPrechargeConfig.PrechargeDcWithInternal);
inverters.ForEach(d => d.Control.Dc.PrechargeConfig = DcPrechargeConfig.PrechargeDcWithInternal);
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.DroopControl.UpperVoltage = devicesConfig.DcDc.UpperDcLinkVoltage);
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.MaxBatteryDischargingCurrent = configFile.MaxBatteryDischargingCurrent);