diff --git a/csharp/App/SodiStoreMax/src/Program.cs b/csharp/App/SodiStoreMax/src/Program.cs index 066e9fc99..8d052e223 100644 --- a/csharp/App/SodiStoreMax/src/Program.cs +++ b/csharp/App/SodiStoreMax/src/Program.cs @@ -328,10 +328,10 @@ internal static class Program if (record.Battery != null) { - _oneTimeFlag.WriteLine(" onetime flag"); - if (record.Battery?.MonomerHighVoltageAlarm == true && !_oneTimeFlag) //this should be checked: the number 0 + //_oneTimeFlag.WriteLine(" onetime flag"); + if (record.Battery?.MonomerHighVoltageAlarm == true /*&& !_oneTimeFlag*/) //this should be checked: the number 0 { - _oneTimeFlag = true; + //_oneTimeFlag = true; warningList.Add(new AlarmOrWarning { Date = DateTime.Now.ToString("yyyy-MM-dd"), @@ -340,10 +340,6 @@ internal static class Program Description = "dynCCL Active: Max Battery Charging is 10 * N" }); } - else - { - _oneTimeFlag = false; - } /* if (record.Battery?.MonomerLowVoltageAlarm == true && !_oneTimeFlag) //this should be checked: the number 10 { @@ -526,45 +522,52 @@ internal static class Program var configFile = r.Config; 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 - Double maxBatteryChargingCurrentLive ; //used with deligreenBattery for limiting charging - Double maxBatteryDischargingCurrentLive; //used with deligreenBattery for limiting discharging - - r.Battery?.HighestCellVoltage.WriteLine(" HighestCellVoltage"); - r.Battery?.LowestCellVoltage.WriteLine(" LowestCellVoltage"); - - // TODO The discharging current is well calculated but not communicated to live. But Written in S3 - //r.Battery?.MonomerHighVoltageAlarm.WriteLine(" Monomer High Voltage "); - //r.Battery?.MonomerHighVoltageAlarm.WriteLine(" Monomer High Voltage "); - + Double maxBatteryChargingCurrentLiveByDcDc ; //used with deligreenBattery for limiting charging + Double maxBatteryDischargingCurrentLivebyDcDc; //used with deligreenBattery for limiting discharging + var dcCount = r.DcDc.Devices.Count; - // Deligreen upper current limitation dynCCL - if (r.DcDc.Devices.Count != 0 && r.Battery?.MonomerHighVoltageAlarm == true ) + if (r.Battery != null) { - var availableBattries = r.Battery?.AvailableChBatteries; - availableBattries?.WriteLine(" Available ChBatteries"); - - maxBatteryChargingCurrentLive = (10 * availableBattries.Value)/ r.DcDc.Devices.Count ; // Max charging current is 10 A * Number of batteries - Console.WriteLine("dynCCL Active: Max Battery Charging is "+ maxBatteryChargingCurrentLive); + r.Battery.HighestCellVoltage.WriteLine(" HighestCellVoltage"); + r.Battery.LowestCellVoltage.WriteLine(" LowestCellVoltage"); + + // Deligreen upper current limitation dynCCL + if ( dcCount != 0 && r.Battery.MonomerHighVoltageAlarm ) + { + maxBatteryChargingCurrentLiveByDcDc = 10.0 / dcCount ; // Max charging current is 10 A * Number of batteries + Console.WriteLine("dynCCL Active: Max Charging current for one Battery is "+ maxBatteryChargingCurrentLiveByDcDc * dcCount); // multiply by dcCount for display purpose + } + else + { + maxBatteryChargingCurrentLiveByDcDc = devicesConfig.DcDc.MaxBatteryChargingCurrent/r.Battery.Devices.Count; + } + + // Deligreen lower current limitation dynDCL + if ( dcCount != 0 && r.Battery.MonomerLowVoltageAlarm ) // this 10 comparison need to be checked + { + maxBatteryDischargingCurrentLivebyDcDc = 10.0 / dcCount ; // Max discharging current is 10 A * Number of batteries + Console.WriteLine("dynDCL Active: Max disCharging current for one Battery is "+ maxBatteryDischargingCurrentLivebyDcDc * dcCount); // multiply by dcCount for display purpose + } + else + { + maxBatteryDischargingCurrentLivebyDcDc = devicesConfig.DcDc.MaxBatteryDischargingCurrent/r.Battery.Devices.Count; + } + + maxBatteryChargingCurrentLiveByDcDc *= r.Battery.AvailableChBatteries; // Adapt the current to the number of available battery + maxBatteryDischargingCurrentLivebyDcDc *= r.Battery.AvailableDischBatteries; // Adapt the current to the number of available battery + + (r.Battery?.AvailableChBatteries)?.WriteLine(" Available Charging Batteries"); + (r.Battery?.AvailableDischBatteries)?.WriteLine(" Available Discharging Batteries"); + + maxBatteryChargingCurrentLiveByDcDc.WriteLine(" maxBatteryChargingCurrentLive by DcDC"); + maxBatteryDischargingCurrentLivebyDcDc.WriteLine(" maxBatteryDischargingCurrentLive by DcDc"); + } else { - maxBatteryChargingCurrentLive = devicesConfig.DcDc.MaxBatteryChargingCurrent; + maxBatteryChargingCurrentLiveByDcDc = 0; + maxBatteryDischargingCurrentLivebyDcDc = 0; } - - // Deligreen lower current limitation dynDCL - // if (r.Battery?.Voltage != null && (r.Battery?.LowestCellVoltage ?? 10) < 2.0 ) // this 10 comparison need to be checked - // { - // maxBatteryDischargingCurrentLive =(r.Battery.Devices.Count * 10)/ r.DcDc.Devices.Count ; // Max discharging current is 10 A * Number of batteries - // maxBatteryDischargingCurrentLive.WriteLine("dynDCL Active: Max Battery disCharging is "+ maxBatteryDischargingCurrentLive); - // } - // else. - // { - maxBatteryDischargingCurrentLive = devicesConfig.DcDc.MaxBatteryDischargingCurrent; - // } - - maxBatteryChargingCurrentLive.WriteLine(" maxBatteryChargingCurrentLive by DcDC"); - maxBatteryDischargingCurrentLive.WriteLine(" maxBatteryDischargingCurrentLive by DcDc"); - 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); @@ -575,8 +578,8 @@ internal static class Program 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 = maxBatteryChargingCurrentLive); - dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryDischargingCurrent = maxBatteryDischargingCurrentLive); + dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryChargingCurrent = maxBatteryChargingCurrentLiveByDcDc); + dcDevices.ForEach(d => d.Control.CurrentControl.MaxBatteryDischargingCurrent = maxBatteryDischargingCurrentLivebyDcDc); dcDevices.ForEach(d => d.Control.MaxDcPower = devicesConfig.DcDc.MaxDcPower); dcDevices.ForEach(d => d.Control.VoltageLimits.MaxBatteryVoltage = devicesConfig.DcDc.MaxChargeBatteryVoltage);