From 445f7b64341b1219d6975f5834a6d80958b1a5cf Mon Sep 17 00:00:00 2001 From: atef Date: Mon, 29 Jan 2024 13:23:48 +0100 Subject: [PATCH] Adding heating powerto the aggregate data. --- .../src/AggregationService/Aggregator.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/csharp/App/SaliMax/src/AggregationService/Aggregator.cs b/csharp/App/SaliMax/src/AggregationService/Aggregator.cs index afeef3886..58589f380 100644 --- a/csharp/App/SaliMax/src/AggregationService/Aggregator.cs +++ b/csharp/App/SaliMax/src/AggregationService/Aggregator.cs @@ -102,6 +102,7 @@ public static class Aggregator var csvFiles = Directory.GetFiles(myDirectory, "*.csv"); var batterySoc = new List(); var pvPowerAverage = new List(); + var heatingPower = new List(); var gridPowerImport = new List(); var gridPowerExport = new List(); var batteryDischargePower = new List(); @@ -166,6 +167,9 @@ public static class Aggregator case "/GridMeter/ActivePowerImportT2": gridPowerImport.Add(value); break; + case "/Battery/HeatingPower": + heatingPower.Add(value); + break; // Add more cases as needed default: // Code to execute when variableName doesn't match any condition @@ -197,10 +201,10 @@ public static class Aggregator // // Dividing the Average power readings by 3600 converts the result from watt-seconds to kilowatt-hours. - var dischargingEnergy = (batteryDischargePower.Any() ? batteryDischargePower.Average() : 0.0) / 3600 ; - var chargingEnergy = (batteryChargePower.Any() ? batteryChargePower.Average() : 0.0) / 3600 ; + var dischargingEnergy = (batteryDischargePower.Any() ? batteryDischargePower.Average() : 0.0) / 3600; + var chargingEnergy = (batteryChargePower.Any() ? batteryChargePower.Average() : 0.0) / 3600; - + var heatingPowerAvg = (heatingPower.Any() ? heatingPower.Average() : 0.0) / 3600; var dMaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0; var dMinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0; var dSumGridExportPower = gridPowerExport.Any() ? (gridPowerExport.Max() - gridPowerExport.Min()) / 1000 : 0.0; @@ -213,9 +217,10 @@ public static class Aggregator MinSoc = dMinSoc, SumDischargingBatteryPower = dischargingEnergy, SumChargingBatteryPower = chargingEnergy, - SumGridExportPower = dSumGridExportPower, // divide it - SumGridImportPower = dSumGridImportPower, // divide it - SumPvPower = dSumPvPower + SumGridExportPower = dSumGridExportPower, + SumGridImportPower = dSumGridImportPower, + SumPvPower = dSumPvPower, + HeatingPowerAvg = heatingPowerAvg }; // Print the stored CSV data for verification @@ -247,6 +252,7 @@ public static class Aggregator var gridPowerExport = new List(); var batteryDischargePower = new List(); var batteryChargePower = new List(); + var heatingPowerAvg = new List(); Console.WriteLine("-----------------------------------------------------------------------------------------------------------------"); @@ -301,6 +307,10 @@ public static class Aggregator case "/SumGridImportPower": gridPowerImport.Add(value); break; + + case "/HeatingPowerAvg": + heatingPowerAvg.Add(value); + break; // Add more cases as needed default: // Code to execute when variableName doesn't match any condition @@ -333,6 +343,7 @@ public static class Aggregator SumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Average() : 0.0, SumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Average() : 0.0, SumPvPower = pvPowerAverage.Any() ? pvPowerAverage.Average() : 0.0, + HeatingPowerAvg = heatingPowerAvg.Any() ? heatingPowerAvg.Average() : 0.0, }; // Print the stored CSV data for verification