Skip to content

Commit

Permalink
Now skips (with a warning in the diags log) blank lines in the monthl…
Browse files Browse the repository at this point in the history
…y log files
  • Loading branch information
Mark Crossley committed Dec 20, 2022
1 parent 74cec37 commit 71eff87
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CreateMissing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<AssemblyVersion>1.3.1.2</AssemblyVersion>
<FileVersion>1.3.1.2</FileVersion>
<AssemblyVersion>1.3.1.3</AssemblyVersion>
<FileVersion>1.3.2.3</FileVersion>
<Version></Version>
<StartupObject>CreateMissing.Program</StartupObject>
<TargetFramework>net48</TargetFramework>
Expand Down
25 changes: 21 additions & 4 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Program
{
public static Cumulus cumulus;
public static string location;
public static ConsoleColor defConsoleColour;

private static ConsoleColor defConsoleColour;

private static DayFile dayfile;
private static readonly List<string> CurrentLogLines = new List<string>();
Expand Down Expand Up @@ -409,6 +410,14 @@ private static Dayfilerec GetDayRecFromMonthly(DateTime date)
// we use idx 0 & 1 together (date/time), set the idx to 1
idx = 1;
// process each record in the file
// first a sanity check for an empty line!
if (string.IsNullOrWhiteSpace(CurrentLogLines[CurrentLogLineNum]))
{
CurrentLogLineNum++;
LogMessage($"LogFile: Error at line {CurrentLogLineNum}, an empty line was detected!");
continue;
}

//var st = new List<string>(Regex.Split(line, CultureInfo.CurrentCulture.TextInfo.ListSeparator));
// Regex is very expensive, let's assume the separator is always a single character
var st = new List<string>(CurrentLogLines[CurrentLogLineNum++].Split(dayfile.FieldSep[0]));
Expand Down Expand Up @@ -831,7 +840,7 @@ private static Dayfilerec GetDayRecFromMonthly(DateTime date)
raintoday += (raincounter - lastentrycounter) * cumulus.CalibRainMult;
}

// add last hours rain for this last record.
// add last hours rain for this last record.
AddLastHoursRainEntry(entrydate, totalRainfall + raintoday, ref rain1hLog, ref rain24hLog);

// rainfall in last hour
Expand All @@ -858,8 +867,8 @@ private static Dayfilerec GetDayRecFromMonthly(DateTime date)
finished = true;
}
}


if (started && recCount >= 5) // need at least five records to create a day
{
// we were in the right day, now we aren't
Expand Down Expand Up @@ -1014,6 +1023,14 @@ private static Dayfilerec GetSolarDayRecFromMonthly(DateTime date, Dayfilerec re
while (CurrentSolarLogLineNum < CurrentSolarLogLines.Count)
{
// process each record in the file
// first a sanity check for an empty line!
if (string.IsNullOrWhiteSpace(CurrentLogLines[CurrentLogLineNum]))
{
CurrentLogLineNum++;
LogMessage($"Solar: Error at line {CurrentLogLineNum}, an empty line was detected!");
continue;
}

// Regex is very expensive, let's assume the separator is always a single character
var st = new List<string>(CurrentSolarLogLines[CurrentSolarLogLineNum].Split(dayfile.FieldSep[0]));
var entrydate = Utils.DdmmyyhhmmStrToDate(st[0], st[1]);
Expand Down
4 changes: 4 additions & 0 deletions Updates.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.3.1
—————
- Now skips (with a warning in the diags log) blank lines in the monthly log files

1.3.0
—————
- Support for CMX v3.20.0 - adds 24 hour rainfall
Expand Down

0 comments on commit 71eff87

Please sign in to comment.