Increase the max size of log file

Add comments
This commit is contained in:
atef 2023-12-12 14:21:42 +01:00
parent 9de0dda619
commit 907f8b66c6
2 changed files with 38 additions and 38 deletions

View File

@ -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

View File

@ -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");
}
}
}