parent
9de0dda619
commit
907f8b66c6
|
@ -6,7 +6,7 @@ public static class Logger
|
||||||
{
|
{
|
||||||
// Specify the maximum log file size in bytes (e.g., 1 MB)
|
// 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 Int32 MaxLogFileCount = 5000; // TODO: move to settings
|
||||||
private const String LogFilePath = "LogDirectory/log.csv"; // TODO: move to settings
|
private const String LogFilePath = "LogDirectory/log.csv"; // TODO: move to settings
|
||||||
|
|
||||||
|
|
|
@ -637,7 +637,6 @@ internal static class Program
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static async Task HourlyDataAggregationManager()
|
private static async Task HourlyDataAggregationManager()
|
||||||
{
|
{
|
||||||
DateTime currentDateTime = DateTime.Now;
|
DateTime currentDateTime = DateTime.Now;
|
||||||
|
@ -692,7 +691,7 @@ internal static class Program
|
||||||
{
|
{
|
||||||
continue;
|
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();
|
var oneHourBefore = DateTime.Now.AddHours(-1).ToUnixTime();
|
||||||
|
|
||||||
|
|
||||||
|
@ -704,14 +703,15 @@ internal static class Program
|
||||||
while (!reader.EndOfStream)
|
while (!reader.EndOfStream)
|
||||||
{
|
{
|
||||||
var line = reader.ReadLine();
|
var line = reader.ReadLine();
|
||||||
var values = line?.Split(';');
|
var lines = line?.Split(';');
|
||||||
|
|
||||||
// Assuming there are always three columns (variable name and its value)
|
// 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 variableName = lines[0].Trim();
|
||||||
var value = TryParse(values[1].Trim(), out var v) ? v : 0;
|
|
||||||
|
|
||||||
|
if (TryParse(lines[1].Trim(), out var value))
|
||||||
|
{
|
||||||
// Check if variableValue is a valid number
|
// Check if variableValue is a valid number
|
||||||
if (IsSoc(variableName))
|
if (IsSoc(variableName))
|
||||||
{
|
{
|
||||||
|
@ -748,17 +748,17 @@ internal static class Program
|
||||||
batteryPowerAverage = (batteryPowerAverage + value) / 2;
|
batteryPowerAverage = (batteryPowerAverage + value) / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Handle cases where variableValue is not a valid number
|
// 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
|
else
|
||||||
{
|
{
|
||||||
// Handle invalid CSV format
|
// Handle invalid column format
|
||||||
//Console.WriteLine($"Invalid format in file: {csvFile}");
|
Console.WriteLine("Invalid format in column");
|
||||||
//break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue