Skip to content

Commit

Permalink
Add data date to Web Socket data
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Crossley committed Jul 21, 2024
1 parent 4a07315 commit da4ea07
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
12 changes: 10 additions & 2 deletions CumulusMX/DataStruct.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

Expand All @@ -17,7 +18,7 @@ public class DataStruct(Cumulus cumulus, double outdoorTemp, int outdoorHum, dou
string highUVindexTodayTime, string forecast, string sunrise, string sunset, string moonrise, string moonset, double highHeatIndexToday,
string highHeatIndexTodayTime, double highAppTempToday, double lowAppTempToday, string highAppTempTodayTime, string lowAppTempTodayTime,
int currentSolarMax, double alltimeHighPressure, double alltimeLowPressure, double sunshineHours, string domWindDir, string lastRainTipISO,
double highHourlyRainToday, string highHourlyRainTodayTime, string highBeaufortToday, string beaufort, string beaufortDesc, string lastDataRead,
double highHourlyRainToday, string highHourlyRainTodayTime, string highBeaufortToday, string beaufort, string beaufortDesc, DateTime lastDataRead,
bool dataStopped, double stormRain, string stormRainStart, int cloudbase, string cloudbaseUnit, double last24hourRain,
double feelsLike, double highFeelsLikeToday, string highFeelsLikeTodayTime, double lowFeelsLikeToday, string lowFeelsLikeTodayTime,
double highHumidexToday, string highHumidexTodayTime, List<DashboardAlarms> alarms)
Expand Down Expand Up @@ -603,7 +604,14 @@ public string Build
public string BeaufortDesc { get; } = beaufortDesc;

[DataMember]
public string LastDataRead { get; } = lastDataRead;
public string LastDataRead { get; } = lastDataRead.ToLocalTime().ToString(cumulus.ProgramOptions.TimeFormatLong);

[DataMember]
public string LastDataReadDate
{
get => lastDataRead.ToLocalTime().ToString("d");
}


[DataMember]
public bool DataStopped { get; } = dataStopped;
Expand Down
5 changes: 0 additions & 5 deletions CumulusMX/JsonStation.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using EmbedIO;

using FluentFTP.Helpers;

using MQTTnet;

using ServiceStack;
Expand Down
15 changes: 9 additions & 6 deletions CumulusMX/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ private static async Task Main(string[] args)
var lang = string.Empty;
var servicename = string.Empty;

for (int i = 0; i < args.Length; i++)
try
{
try
int i = 0;
while (i < args.Length)
{
switch (args[i])
{
Expand Down Expand Up @@ -184,11 +185,13 @@ private static async Task Main(string[] args)
Usage();
break;
}

i++;
}
catch
{
Usage();
}
}
catch
{
Usage();
}


Expand Down
12 changes: 7 additions & 5 deletions CumulusMX/WeatherStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2057,9 +2057,6 @@ private void TenMinuteChanged()
cumulus.RotateLogFiles();

ClearAlarms();

System.Runtime.GCSettings.LargeObjectHeapCompactionMode = System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized, false);
}

private void HourChanged(DateTime now)
Expand Down Expand Up @@ -2089,6 +2086,9 @@ private void HourChanged(DateTime now)
}

RemoveOldRecentData(now);

System.Runtime.GCSettings.LargeObjectHeapCompactionMode = System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce;
//GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized, false)
}

private void CheckForDataStopped()
Expand All @@ -2112,7 +2112,7 @@ private void CheckForDataStopped()
{
cumulus.LogErrorMessage("*** Data input appears to have stopped");
}
}
} // Calculates evapotranspiration based on the data for the last hour and updates the running annual total.
else
{
DataStopped = false;
Expand Down Expand Up @@ -2146,6 +2146,8 @@ private void ReadBlakeLarsenData()
}
}


// Calculates evapotranspiration based on the data for the last hour and updates the running annual total.
public void CalculateEvapotranspiration(DateTime date)
{
cumulus.LogDebugMessage("Calculating ET from data");
Expand Down Expand Up @@ -13797,7 +13799,7 @@ internal string GetCurrentData()
HiLoToday.LowAppTemp, HiLoToday.HighAppTempTime.ToString(cumulus.ProgramOptions.TimeFormat), HiLoToday.LowAppTempTime.ToString(cumulus.ProgramOptions.TimeFormat), CurrentSolarMax,
AllTime.HighPress.Val, AllTime.LowPress.Val, SunshineHours, CompassPoint(DominantWindBearing), LastRainTip,
HiLoToday.HighHourlyRain, HiLoToday.HighHourlyRainTime.ToString(cumulus.ProgramOptions.TimeFormat), "F" + Cumulus.Beaufort(HiLoToday.HighWind), "F" + Cumulus.Beaufort(WindAverage),
cumulus.BeaufortDesc(WindAverage), LastDataReadTimestamp.ToLocalTime().ToString(cumulus.ProgramOptions.TimeFormatLong), DataStopped, StormRain, stormRainStart, CloudBase, cumulus.CloudBaseInFeet ? "ft" : "m", RainLast24Hour,
cumulus.BeaufortDesc(WindAverage), LastDataReadTimestamp, DataStopped, StormRain, stormRainStart, CloudBase, cumulus.CloudBaseInFeet ? "ft" : "m", RainLast24Hour,
FeelsLike, HiLoToday.HighFeelsLike, HiLoToday.HighFeelsLikeTime.ToString(cumulus.ProgramOptions.TimeFormat), HiLoToday.LowFeelsLike, HiLoToday.LowFeelsLikeTime.ToString(cumulus.ProgramOptions.TimeFormat),
HiLoToday.HighHumidex, HiLoToday.HighHumidexTime.ToString(cumulus.ProgramOptions.TimeFormat), alarms);

Expand Down

0 comments on commit da4ea07

Please sign in to comment.