diff --git a/csharp/App/SaliMax/src/AggregationService/Aggregator.cs b/csharp/App/SaliMax/src/AggregationService/Aggregator.cs index 8226b890e..6bb6c4a0c 100644 --- a/csharp/App/SaliMax/src/AggregationService/Aggregator.cs +++ b/csharp/App/SaliMax/src/AggregationService/Aggregator.cs @@ -29,7 +29,7 @@ public static class Aggregator { try { - AggregatedData hourlyAggregatedData=CreateAverage("LogDirectory",DateTime.Now.AddHours(-1).ToUnixTime(),DateTime.Now.ToUnixTime()); + AggregatedData hourlyAggregatedData = CreateAverage("LogDirectory",DateTime.Now.AddHours(-1).ToUnixTime(),DateTime.Now.ToUnixTime()); hourlyAggregatedData.Save("HourlyData"); } catch (Exception e) @@ -63,7 +63,7 @@ public static class Aggregator { try { - AggregatedData dailyAggregatedData=CreateAverage("HourlyData",DateTime.Now.AddDays(-1).ToUnixTime(),DateTime.Now.ToUnixTime()); + AggregatedData dailyAggregatedData = CreateAverage("HourlyData",DateTime.Now.AddDays(-1).ToUnixTime(),DateTime.Now.ToUnixTime()); dailyAggregatedData.Save("DailyData"); } catch (Exception e) @@ -74,10 +74,10 @@ public static class Aggregator } } - private static AggregatedData CreateAverage(string myDirectory,long afterTimestamp,long beforeTimestamp) + private static AggregatedData CreateAverage(String myDirectory, Int64 afterTimestamp, Int64 beforeTimestamp) { // Get all CSV files in the specified directory - var csvFiles = Directory.GetFiles(myDirectory, "*.csv"); + var csvFiles = Directory.GetFiles(myDirectory, "*.csv"); var socAverage = new List(); var pvPowerAverage = new List(); var batteryPowerAverage = new List(); @@ -102,7 +102,6 @@ public static class Aggregator var line = reader.ReadLine(); var lines = line?.Split(';'); - // Assuming there are always three columns (variable name and its value) if (lines is { Length: 3 }) { @@ -112,15 +111,15 @@ public static class Aggregator { switch (variableName) { - case var _ when variableName is "/Battery/Soc" or "/AvgSoc" : + case "/Battery/Soc" or "/AvgSoc": socAverage.Add(value); break; - case var _ when variableName is "/PvOnDc/Dc/Power" or "/AvgPvPower": + case "/PvOnDc/Dc/Power" or "/AvgPvPower": pvPowerAverage.Add(value); break; - case var _ when variableName is "/Battery/Dc/Power" or "/BatteryPowerAverage": + case "/Battery/Dc/Power" or "/BatteryPowerAverage": batteryPowerAverage.Add(value); break; @@ -149,8 +148,8 @@ public static class Aggregator AggregatedData aggregatedData = new AggregatedData { - AvgSoc = socAverage.Any() ? socAverage.Average() : 0.0, - AvgPvPower = pvPowerAverage.Any() ? pvPowerAverage.Average() : 0.0, + AvgSoc = socAverage.Any() ? socAverage.Average() : 0.0, + AvgPvPower = pvPowerAverage.Any() ? pvPowerAverage.Average() : 0.0, BatteryPowerAverage = batteryPowerAverage.Any() ? batteryPowerAverage.Average() : 0.0 };