From 5e00714313394f560d2147f65e6d6ae042ed2d0a Mon Sep 17 00:00:00 2001 From: atef Date: Wed, 11 Jun 2025 16:00:11 +0200 Subject: [PATCH] add doepke to the main function --- csharp/App/SodiStoreMax/src/Program.cs | 48 ++++++++++++++++++-------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/csharp/App/SodiStoreMax/src/Program.cs b/csharp/App/SodiStoreMax/src/Program.cs index fc9fefa29..c15375287 100644 --- a/csharp/App/SodiStoreMax/src/Program.cs +++ b/csharp/App/SodiStoreMax/src/Program.cs @@ -27,10 +27,12 @@ using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc; using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes; using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc; using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc.Control; +using InnovEnergy.Lib.Devices.Doepke; using InnovEnergy.Lib.Protocols.Modbus.Channels; using InnovEnergy.Lib.Units; using InnovEnergy.Lib.Utils; using InnovEnergy.App.SodiStoreMax.DataTypes; +using InnovEnergy.Lib.Devices.Doepke; using Newtonsoft.Json; using static InnovEnergy.App.SodiStoreMax.AggregationService.Aggregator; using static InnovEnergy.App.SodiStoreMax.MiddlewareClasses.MiddlewareAgent; @@ -59,6 +61,8 @@ internal static class Program private static readonly Channel PvOnAcIsland; private static readonly Channel RelaysChannel; private static readonly Channel BatteriesChannel; + private static readonly Channel DoepkeChannel; + // private static Boolean _curtailFlag = false; @@ -91,7 +95,8 @@ internal static class Program PvOnAcIsland = CreateChannel(d.PvOnAcIsland); RelaysChannel = CreateChannel(d.RelaysIp); BatteriesChannel = CreateChannel(d.BatteryIp); - + DoepkeChannel = CreateChannel(d.DoepkeIp); + BatteryNodes = config .Devices .BatteryNodes @@ -143,6 +148,8 @@ internal static class Program var pvOnDcDevice = new AmptDevices(PvOnDc); var pvOnAcGridDevice = new AmptDevices(PvOnAcGrid); var pvOnAcIslandDevice = new AmptDevices(PvOnAcIsland); + var doepkeDevice = new DoepkeDevice(DoepkeChannel); + #if Amax var saliMaxRelaysDevice = new RelaysDeviceAmax(RelaysChannel); @@ -164,6 +171,7 @@ internal static class Program var battery = batteryDevices.Read(); var pvOnAcGrid = pvOnAcGridDevice.Read(); var pvOnAcIsland = pvOnAcIslandDevice.Read(); + var doepek = doepkeDevice.Read(); var gridBusToIslandBus = Topology.CalculateGridBusToIslandBusPower(pvOnAcIsland, loadOnAcIsland, acDc); @@ -195,6 +203,7 @@ internal static class Program LoadOnAcGrid = gridBusLoad, LoadOnAcIsland = loadOnAcIsland, LoadOnDc = dcLoad, + Doepke = doepek, StateMachine = StateMachine.Default, EssControl = EssControl.Default, Log = new SystemLog { SalimaxAlarmState = SalimaxAlarmState.Green, Message = null, SalimaxAlarms = null, SalimaxWarnings = null}, //TODO: Put real stuff @@ -236,20 +245,21 @@ internal static class Program Watchdog.NotifyAlive(); var record = ReadStatus(); - SendSalimaxStateAlarm(GetSalimaxStateAlarm(record), record); // to improve - + record.ControlConstants(); record.ControlSystemState(); record.AcDc.SystemControl.ApplyAcDcDefaultSettings(); record.DcDc.SystemControl.ApplyDcDcDefaultSettings(); - /* Console.WriteLine(" Fails Counter = " + _failsCounter); + Console.WriteLine(" Fails Counter = " + _failsCounter); // Retries Control - if (record.StateMachine.State is not (28 or 23) ) + /* if (record.StateMachine.State is not (28 or 23) ) { + // add a case 1 > RCD fail + // add a case 2 > overload if (_failsCounter > 60) // 2 min { Console.WriteLine(" Fails retries reached threshold"); @@ -261,9 +271,9 @@ internal static class Program else { _failsCounter = 0; - }*/ + } //record.ControlPvPower(record.Config.CurtailP, record.Config.PvInstalledPower); - +*/ var essControl = record.ControlEss().WriteLine(); record.EssControl = essControl; @@ -364,7 +374,7 @@ internal static class Program Description = alarmCondition }); } - + alarmList.AddRange(record.AcDc.Alarms .Select(alarm => new AlarmOrWarning { Date = DateTime.Now.ToString("yyyy-MM-dd"), @@ -443,9 +453,6 @@ internal static class Program if (r.Battery != null) { - r.Battery.HighestCellVoltage.WriteLine(" HighestCellVoltage"); - r.Battery.LowestCellVoltage.WriteLine(" LowestCellVoltage"); - // Deligreen upper current limitation dynCCL if ( dcCount != 0 && r.Battery.MonomerHighVoltageAlarm ) { @@ -458,7 +465,7 @@ internal static class Program } // Deligreen lower current limitation dynDCL - if ( dcCount != 0 && r.Battery.MonomerLowVoltageAlarm ) // this 10 comparison need to be checked + if ( dcCount != 0 && r.Battery.MonomerLowVoltageAlarm ) { 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 @@ -468,12 +475,15 @@ internal static class Program 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 + maxBatteryChargingCurrentLiveByDcDc = 5 + (maxBatteryChargingCurrentLiveByDcDc * r.Battery.AvailableChBatteries); // Adapt the current to the number of available battery + maxBatteryDischargingCurrentLivebyDcDc = 5 + (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"); + (r.Battery?.ChargeModeBatteries)?.WriteLine(" Batteries on charge mode"); + (r.Battery?.DischargeModeBatteries)?.WriteLine(" Batteries on discharge mode"); + maxBatteryChargingCurrentLiveByDcDc.WriteLine(" maxBatteryChargingCurrentLive by DcDC"); maxBatteryDischargingCurrentLivebyDcDc.WriteLine(" maxBatteryDischargingCurrentLive by DcDc"); @@ -601,7 +611,7 @@ internal static class Program Console.WriteLine(" ****************** "); } - // why this is not in Controller? + // why is not in Controller? private static void DistributePower(StatusRecord record, EssControl essControl) { var nInverters = record.AcDc.Devices.Count; @@ -938,5 +948,13 @@ internal static class Program { status.Config.DayAndTimeForAdditionalCalibration = config.CalibrationChargeDate; } + if (config.CalibrationDischargeState == CalibrationDischargeType.RepetitivelyEvery) + { + status.Config.DownDayAndTimeForRepetitiveCalibration = config.CalibrationDischargeDate; + } + else if (config.CalibrationDischargeState == CalibrationDischargeType.AdditionallyOnce) + { + status.Config.DownDayAndTimeForAdditionalCalibration = config.CalibrationDischargeDate; + } } } \ No newline at end of file