diff --git a/csharp/App/SaliMax/src/Logger.cs b/csharp/App/SaliMax/src/Logger.cs index e18ceb2e8..9e8c3fa90 100644 --- a/csharp/App/SaliMax/src/Logger.cs +++ b/csharp/App/SaliMax/src/Logger.cs @@ -6,7 +6,7 @@ public static class Logger { // Specify the maximum log file size in bytes (e.g., 1 MB) - private const Int32 MaxFileSizeBytes = 1024 * 30; // TODO: move to settings + private const Int32 MaxFileSizeBytes = 2024 * 30; // TODO: move to settings private const Int32 MaxLogFileCount = 5000; // TODO: move to settings private const String LogFilePath = "LogDirectory/log.csv"; // TODO: move to settings diff --git a/csharp/App/SaliMax/src/Program.cs b/csharp/App/SaliMax/src/Program.cs index ebb59569b..175546e0c 100644 --- a/csharp/App/SaliMax/src/Program.cs +++ b/csharp/App/SaliMax/src/Program.cs @@ -637,7 +637,6 @@ internal static class Program return true; } - private static async Task HourlyDataAggregationManager() { DateTime currentDateTime = DateTime.Now; @@ -692,7 +691,7 @@ internal static class Program { continue; } - var fileTimestamp = Int64.Parse(Path.GetFileNameWithoutExtension(csvFile).Replace("log_", "")); + var fileTimestamp = long.Parse(Path.GetFileNameWithoutExtension(csvFile).Replace("log_", "")); var oneHourBefore = DateTime.Now.AddHours(-1).ToUnixTime(); @@ -704,61 +703,62 @@ internal static class Program while (!reader.EndOfStream) { var line = reader.ReadLine(); - var values = line?.Split(';'); + var lines = line?.Split(';'); // Assuming there are always three columns (variable name and its value) - if (values is { Length: 3 }) + if (lines is { Length: 3 }) { - var variableName = values[0].Trim(); - var value = TryParse(values[1].Trim(), out var v) ? v : 0; - - // Check if variableValue is a valid number - if (IsSoc(variableName)) + var variableName = lines[0].Trim(); + + if (TryParse(lines[1].Trim(), out var value)) { - if (socAverage == 0) + // Check if variableValue is a valid number + if (IsSoc(variableName)) { - socAverage = value; + if (socAverage == 0) + { + socAverage = value; + } + else + { + socAverage = (socAverage + value) / 2; + } } - else - { - socAverage = (socAverage + value) / 2; - } - } - if (IsPvPower(variableName)) - { - if (pvPowerAverage == 0) + if (IsPvPower(variableName)) { - pvPowerAverage = value; + if (pvPowerAverage == 0) + { + pvPowerAverage = value; + } + else + { + pvPowerAverage = (pvPowerAverage + value) / 2; + } } - else - { - pvPowerAverage = (pvPowerAverage + value) / 2; - } - } - if (IsBatteryPower(variableName)) - { - if (batteryPowerAverage == 0) + if (IsBatteryPower(variableName)) { - batteryPowerAverage = value; - } - else - { - batteryPowerAverage = (batteryPowerAverage + value) / 2; + if (batteryPowerAverage == 0) + { + batteryPowerAverage = value; + } + else + { + batteryPowerAverage = (batteryPowerAverage + value) / 2; + } } } else { // Handle cases where variableValue is not a valid number - // Console.WriteLine($"Invalid numeric value for variable {variableName}: {variableValue}"); + Console.WriteLine($"Invalid numeric value for variable {variableName}:{lines[1].Trim()}"); } } else { - // Handle invalid CSV format - //Console.WriteLine($"Invalid format in file: {csvFile}"); - //break; + // Handle invalid column format + Console.WriteLine("Invalid format in column"); } } }