From 77158997507836e85cd26bd003a98b94ba791c03 Mon Sep 17 00:00:00 2001 From: Mark Crossley Date: Sun, 3 Feb 2019 15:03:13 +0000 Subject: [PATCH] b3047 See Updates.txt --- CumulusMX/CalibrationSettings.cs | 16 +- CumulusMX/Cumulus.cs | 152 +++++++++++-- CumulusMX/CumulusMX.csproj | 11 +- CumulusMX/DataEditor.cs | 14 +- CumulusMX/DavisStation.cs | 23 +- CumulusMX/FOStation.cs | 42 ++-- CumulusMX/ImetStation.cs | 204 ++++++++++++----- CumulusMX/InternetSettings.cs | 22 +- CumulusMX/MysqlSettings.cs | 16 +- CumulusMX/NOAASettings.cs | 16 +- CumulusMX/Properties/AssemblyInfo.cs | 4 +- CumulusMX/StationSettings.cs | 20 +- CumulusMX/TokenParser.cs | 2 +- CumulusMX/WMR100Station.cs | 20 +- CumulusMX/WMR200Station.cs | 20 +- CumulusMX/WeatherStation.cs | 320 ++++++++++++++------------- CumulusMX/packages.config | 5 +- CumulusMX/webtags.cs | 65 ++++-- Updates.txt | 55 ++++- 19 files changed, 651 insertions(+), 376 deletions(-) diff --git a/CumulusMX/CalibrationSettings.cs b/CumulusMX/CalibrationSettings.cs index 1a543132..bb9c5b1f 100644 --- a/CumulusMX/CalibrationSettings.cs +++ b/CumulusMX/CalibrationSettings.cs @@ -6,7 +6,7 @@ using System.Net; using System.Text; using System.Threading.Tasks; -using fastJSON; +using Newtonsoft.Json; using Unosquare.Labs.EmbedIO; namespace CumulusMX @@ -34,10 +34,10 @@ public string UpdateCalibrationConfig(IHttpContext context) var json = WebUtility.UrlDecode(data.Substring(5)); - // de-serialize it to the settings structure - var settings = JSON.ToObject(json); - // process the settings - cumulus.LogMessage("Updating calibration settings"); + // de-serialize it to the settings structure + var settings = JsonConvert.DeserializeObject(json); + // process the settings + cumulus.LogMessage("Updating calibration settings"); // offsets cumulus.PressOffset = Convert.ToDouble(settings.offsets.pressure,InvC); @@ -124,10 +124,10 @@ public string GetCalibrationAlpacaFormData() spikeremoval = spikeremoval }; - return JSON.ToJSON(data); - } + return JsonConvert.SerializeObject(data); + } - public string GetCalibrationAlpacaFormOptions() + public string GetCalibrationAlpacaFormOptions() { using (StreamReader sr = new StreamReader(calibrationOptionsFile)) { diff --git a/CumulusMX/Cumulus.cs b/CumulusMX/Cumulus.cs index a996423d..f8101e61 100644 --- a/CumulusMX/Cumulus.cs +++ b/CumulusMX/Cumulus.cs @@ -30,7 +30,7 @@ public class Cumulus { ///////////////////////////////// public string Version = "3.0.0"; - public string Build = "3047test"; + public string Build = "3047"; ///////////////////////////////// private static string appGuid = "57190d2e-7e45-4efb-8c09-06a176cef3f3"; @@ -147,6 +147,7 @@ public struct TExtraFiles public bool process; public bool binary; public bool realtime; + public bool endofday; public bool FTP; public bool UTF8; } @@ -367,6 +368,7 @@ public struct TExtraFiles public string ComportName; public string DefaultComportName; public int ImetBaudRate; + public int DavisBaudRate; public int VendorID; public int ProductID; @@ -643,6 +645,8 @@ public struct TExtraFiles public double NOAARainNormNov; public double NOAARainNormDec; + public bool EODfilesNeedFTP = false; + public bool IsOSX; private const double DEFAULTFCLOWPRESS = 950.0; @@ -2652,6 +2656,9 @@ private string GetLoggingFileName(string directory) private void ReadIniFile() { + var DavisBaudRates = new List { 1200, 2400, 4800, 9600, 14400, 19200 }; + var ImetBaudRates = new List { 19200, 115200 }; + LogMessage("Reading Cumulus.ini file"); //DateTimeToString(LongDate, "ddddd", Now); @@ -2679,6 +2686,22 @@ private void ReadIniFile() ComportName = ini.GetValue("Station", "ComportName", DefaultComportName); ImetBaudRate = ini.GetValue("Station", "ImetBaudRate", 19200); + // Check we have a valid value + if (!ImetBaudRates.Contains(ImetBaudRate)) + { + // nope, that isn't allowed, set the default + LogMessage("Error, the value for ImetBaudRate in the ini file " + ImetBaudRate + " is not valid, using default 19200."); + ImetBaudRate = 19200; + } + + DavisBaudRate = ini.GetValue("Station", "DavisBaudRate", 19200); + // Check we have a valid value + if (!DavisBaudRates.Contains(DavisBaudRate)) + { + // nope, that isn't allowed, set the default + LogMessage("Error, the value for DavisBaudRate in the ini file " + DavisBaudRate + " is not valid, using default 19200."); + DavisBaudRate = 19200; + } VendorID = ini.GetValue("Station", "VendorID", -1); ProductID = ini.GetValue("Station", "ProductID", -1); @@ -2775,7 +2798,7 @@ private void ReadIniFile() DataLogInterval = 2; } - SyncFOReads = ini.GetValue("Station", "SyncFOReads", false); + SyncFOReads = ini.GetValue("Station", "SyncFOReads", true); FOReadAvoidPeriod = ini.GetValue("Station", "FOReadAvoidPeriod", 3); FineOffsetReadTime = ini.GetValue("Station", "FineOffsetReadTime", 150); @@ -2964,6 +2987,7 @@ private void ReadIniFile() ExtraFiles[i].realtime = ini.GetValue("FTP site", "ExtraRealtime" + i, false); ExtraFiles[i].FTP = ini.GetValue("FTP site", "ExtraFTP" + i, true); ExtraFiles[i].UTF8 = ini.GetValue("FTP site", "ExtraUTF" + i, false); + ExtraFiles[i].endofday = ini.GetValue("FTP site", "ExtraEOD" + i, false); } ExternalProgram = ini.GetValue("FTP site", "ExternalProgram", ""); @@ -3434,6 +3458,7 @@ internal void WriteIniFile() ini.SetValue("Station", "ErrorLogSpikeRemoval", ErrorLogSpikeRemoval); //ini.SetValue("Station", "ImetBaudRate", ImetBaudRate); + //ini.SetValue("Station", "DavisBaudRate", DavisBaudRate); ini.SetValue("Station", "RG11portName", RG11Port); ini.SetValue("Station", "RG11TBRmode", RG11TBRmode); @@ -3490,6 +3515,7 @@ internal void WriteIniFile() ini.SetValue("FTP site", "ExtraRealtime" + i, ExtraFiles[i].realtime); ini.SetValue("FTP site", "ExtraFTP" + i, ExtraFiles[i].FTP); ini.SetValue("FTP site", "ExtraUTF" + i, ExtraFiles[i].UTF8); + ini.SetValue("FTP site", "ExtraEOD" + i, ExtraFiles[i].endofday); } ini.SetValue("FTP site", "ExternalProgram", ExternalProgram); @@ -4418,6 +4444,8 @@ private WeatherStation Station public string ReportPath = "Reports"; public string LatestError; public DateTime LatestErrorTS = DateTime.MinValue; + //public DateTime defaultRecordTS = new DateTime(2000, 1, 1, 0, 0, 0); + public DateTime defaultRecordTS = DateTime.MinValue; public string wxnowfile = "wxnow.txt"; private readonly string IndexTFile; private readonly string TodayTFile; @@ -5379,7 +5407,7 @@ public void DoHTMLFiles() // handle any extra files for (int i = 0; i < numextrafiles; i++) { - if (!ExtraFiles[i].realtime) + if (!ExtraFiles[i].realtime && !ExtraFiles[i].endofday) { var uploadfile = ExtraFiles[i].local; if (uploadfile == "") @@ -5509,20 +5537,26 @@ private void DoFTPLogin() string remotePath = (ftp_directory.EndsWith("/") ? ftp_directory : ftp_directory + "/"); if (NOAANeedFTP) { - // upload NOAA reports - LogMessage("Uploading NOAA reports"); - FtpTrace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " Uploading NOAA reports"); - - var uploadfile = ReportPath + NOAALatestMonthlyReport; - var remotefile = NOAAFTPDirectory + '/' + NOAALatestMonthlyReport; + try + { + // upload NOAA reports + LogMessage("Uploading NOAA reports"); + FtpTrace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " Uploading NOAA reports"); - UploadFile(conn, uploadfile, remotefile); + var uploadfile = ReportPath + NOAALatestMonthlyReport; + var remotefile = NOAAFTPDirectory + '/' + NOAALatestMonthlyReport; - uploadfile = ReportPath + NOAALatestYearlyReport; - remotefile = NOAAFTPDirectory + '/' + NOAALatestYearlyReport; + UploadFile(conn, uploadfile, remotefile); - UploadFile(conn, uploadfile, remotefile); + uploadfile = ReportPath + NOAALatestYearlyReport; + remotefile = NOAAFTPDirectory + '/' + NOAALatestYearlyReport; + UploadFile(conn, uploadfile, remotefile); + } + catch (Exception e) + { + LogMessage(e.Message); + } NOAANeedFTP = false; } @@ -5540,7 +5574,12 @@ private void DoFTPLogin() remotefile = remotefile.Replace("", Path.GetFileName(GetLogFileName(DateTime.Now))); - if ((uploadfile != "") && (File.Exists(uploadfile)) && (remotefile != "") && !ExtraFiles[i].realtime && ExtraFiles[i].FTP) + if ((uploadfile != "") && + (File.Exists(uploadfile)) && + (remotefile != "") && + !ExtraFiles[i].realtime && + EODfilesNeedFTP == ExtraFiles[i].endofday && + ExtraFiles[i].FTP) { // all checks OK, file needs to be uploaded if (ExtraFiles[i].process) @@ -5548,10 +5587,21 @@ private void DoFTPLogin() // we've already processed the file uploadfile = uploadfile + "tmp"; } + try + { + UploadFile(conn, uploadfile, remotefile); + } + catch (Exception e) + { + LogMessage(e.Message); + } - UploadFile(conn, uploadfile, remotefile); } } + if (EODfilesNeedFTP) + { + EODfilesNeedFTP = false; + } //LogDebugMessage("Done uploading extra files"); // standard files if (IncludeStandardFiles) @@ -6163,6 +6213,77 @@ internal void CustomMysqlRolloverTimerTick() } } + public void DoExtraEndOfDayFiles() + { + int i; + + // handle any extra files that only require EOD processing + for (i = 0; i < numextrafiles; i++) + { + if (ExtraFiles[i].endofday) + { + var uploadfile = ExtraFiles[i].local; + if (uploadfile == "") + { + uploadfile = GetLogFileName(DateTime.Now); + } + var remotefile = ExtraFiles[i].remote; + remotefile = remotefile.Replace("", Path.GetFileName(GetLogFileName(DateTime.Now))); + + if ((uploadfile != "") && (File.Exists(uploadfile)) && (remotefile != "")) + { + if (ExtraFiles[i].process) + { + LogDebugMessage("Processing extra file "+uploadfile); + // process the file + var utf8WithoutBom = new System.Text.UTF8Encoding(false); + var encoding = UTF8encode ? utf8WithoutBom : System.Text.Encoding.GetEncoding("iso-8859-1"); + tokenParser.encoding = encoding; + tokenParser.SourceFile = uploadfile; + var output = tokenParser.ToString(); + uploadfile += "tmp"; + try + { + using (StreamWriter file = new StreamWriter(uploadfile, false, encoding)) + { + file.Write(output); + + file.Close(); + } + } + catch (Exception ex) + { + LogDebugMessage("Error writing file " + uploadfile); + LogDebugMessage(ex.Message); + } + //LogDebugMessage("Finished processing extra file " + uploadfile); + } + + if (ExtraFiles[i].FTP) + { + // FTP the file at the next interval + EODfilesNeedFTP = true; + } + else + { + // just copy the file + LogDebugMessage("Copying extra file " + uploadfile); + try + { + File.Copy(uploadfile, remotefile, true); + } + catch (Exception ex) + { + LogDebugMessage("Error copying extra file: " + ex.Message); + } + //LogDebugMessage("Finished copying extra file " + uploadfile); + } + } + } + } + } + + private void MySqlCatchup() { var mySqlConn = new MySqlConnection(); @@ -6708,7 +6829,6 @@ public class DiaryData { [PrimaryKey] public DateTime Timestamp { get; set; } - public string entry { get; set; } public int snowFalling { get; set; } public int snowLying { get; set; } diff --git a/CumulusMX/CumulusMX.csproj b/CumulusMX/CumulusMX.csproj index e7037a5d..cfb9c8fd 100644 --- a/CumulusMX/CumulusMX.csproj +++ b/CumulusMX/CumulusMX.csproj @@ -80,14 +80,11 @@ ..\packages\Devart.Data.MySql.dll - - ..\packages\fastJSON.2.2.0.1\lib\net40\fastJSON.dll + + ..\packages\FluentFTP.19.2.3\lib\net45\FluentFTP.dll - - ..\packages\FluentFTP.19.2.2\lib\net45\FluentFTP.dll - - - ..\packages\HidSharp.2.0.5\lib\net35\HidSharp.dll + + ..\packages\HidSharp.2.0.8\lib\net35\HidSharp.dll False diff --git a/CumulusMX/DataEditor.cs b/CumulusMX/DataEditor.cs index a4cb76a7..d90da3f9 100644 --- a/CumulusMX/DataEditor.cs +++ b/CumulusMX/DataEditor.cs @@ -1,4 +1,4 @@ -using fastJSON; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Globalization; @@ -15,12 +15,12 @@ internal class DataEditor { private WeatherStation station; private Cumulus cumulus; - + internal DataEditor(Cumulus cumulus, WeatherStation station) { this.station = station; this.cumulus = cumulus; - + } //internal string EditRainToday(HttpListenerContext context) @@ -37,7 +37,7 @@ internal string EditRainToday(IHttpContext context) string[] kvPair = text.Split('='); string key = kvPair[0]; string raintodaystring = kvPair[1]; - + if (!String.IsNullOrEmpty(raintodaystring)) { try @@ -69,7 +69,7 @@ internal string GetRainTodayEditData() var json = "{\"raintoday\":\"" + station.RainToday.ToString(cumulus.RainFormat, InvC) + "\",\"raincounter\":\"" + station.Raincounter.ToString(cumulus.RainFormat, InvC) + "\",\"startofdayrain\":\"" + station.raindaystart.ToString(cumulus.RainFormat, InvC) + - "\",\"rainmult\":\"" + cumulus.RainMult.ToString("F3", InvC) + + "\",\"rainmult\":\"" + cumulus.RainMult.ToString("F3", InvC) + "\",\"step\":\"" + step + "\"}"; return json; @@ -87,7 +87,7 @@ internal string EditDiary(IHttpContext context) text = reader.ReadToEnd(); } - var newData = JSON.ToObject(text); + var newData = JsonConvert.DeserializeObject(text); // write new/updated entry to the database var result = cumulus.DiaryDB.InsertOrReplace(newData); @@ -114,7 +114,7 @@ internal string DeleteDiary(IHttpContext context) text = reader.ReadToEnd(); } - var record = JSON.ToObject(text); + var record = JsonConvert.DeserializeObject(text); // Delete the corresponding entry from the database var result = cumulus.DiaryDB.Delete(record); diff --git a/CumulusMX/DavisStation.cs b/CumulusMX/DavisStation.cs index 01201a41..b11e40d9 100644 --- a/CumulusMX/DavisStation.cs +++ b/CumulusMX/DavisStation.cs @@ -45,8 +45,9 @@ public DavisStation(Cumulus cumulus) : base(cumulus) if (IsSerial) { cumulus.LogMessage("Serial device = " + cumulus.ComportName); + cumulus.LogMessage("Serial speed = " + cumulus.DavisBaudRate); - comport = new SerialPort(cumulus.ComportName, 19200, Parity.None, 8, StopBits.One) {Handshake = Handshake.None, DtrEnable = true}; + comport = new SerialPort(cumulus.ComportName, cumulus.DavisBaudRate, Parity.None, 8, StopBits.One) {Handshake = Handshake.None, DtrEnable = true}; //comport.DataReceived += new SerialDataReceivedEventHandler(portDataReceived); @@ -101,9 +102,8 @@ public DavisStation(Cumulus cumulus) : base(cumulus) cumulus.LogMessage("FW version = " + DavisFirmwareVersion); if ((DavisFirmwareVersion == "???" || float.Parse(DavisFirmwareVersion, CultureInfo.InvariantCulture.NumberFormat) < 1.9) && cumulus.UseDavisLoop2) { - cumulus.UseDavisLoop2 = false; - cumulus.LogMessage("LOOP2 disabled. It is enabled in Cumulus.ini but this firmare version does not support it."); - Console.WriteLine("FW version does not support LOOP2, disabling it"); + cumulus.LogMessage("LOOP2 is enabled in Cumulus.ini but this firmare version does not support it. Consider disabling it in Cumulus.ini"); + Console.WriteLine("Your console firmware version does not support LOOP2. Consider disabling it in Cumulus.ini"); } if (cumulus.DavisReadReceptionStats) @@ -1045,14 +1045,18 @@ private void GetAndProcessLoopData(int number) double avgwind = ConvertWindMPHToUser(loopData.AvgWindSpeed); // Check for sensible figures (spec says max for large cups is 175mph) - if (loopData.CurrentWindSpeed < 200 && loopData.AvgWindSpeed < 200) + if (loopData.CurrentWindSpeed < 175 && loopData.AvgWindSpeed < 175) { int winddir = loopData.WindDirection; - if (winddir > 360) + if (winddir == 0x7FFF) // no reading + { + cumulus.LogDebugMessage("Wind direction = 0x7FFF = no reading, using zero instead"); + winddir = 0; + } + else if (winddir > 360) { - cumulus.LogMessage("Wind direction = "+winddir+", using zero instead"); - + cumulus.LogDebugMessage("Wind direction = "+winddir+", using zero instead"); winddir = 0; } @@ -2211,9 +2215,8 @@ private byte[] GetData(SerialPort serialPort, string commandString, int returnLe { return null; } - catch (Exception ex) + catch { - //MessageBox.Show(ex.ToString()); return null; } } diff --git a/CumulusMX/FOStation.cs b/CumulusMX/FOStation.cs index dc3a4810..09d826e0 100644 --- a/CumulusMX/FOStation.cs +++ b/CumulusMX/FOStation.cs @@ -85,8 +85,8 @@ internal FOStation(Cumulus cumulus) : base(cumulus) int VID = (cumulus.VendorID < 0 ? defaultVID : cumulus.VendorID); int PID = (cumulus.ProductID < 0 ? defaultPID : cumulus.ProductID); - cumulus.LogMessage("Looking for Fine Offset station, VendorID=0x"+VID.ToString("X4")+" ProductID=0x"+PID.ToString("X4")); - Console.WriteLine("Looking for Fine Offset station, VendorID=0x" + VID.ToString("X4") + " ProductID=0x" + PID.ToString("X4")); + cumulus.LogMessage("Looking for Fine Offset station, VendorID=0x"+VID.ToString("X4")+" ProductID=0x"+PID.ToString("X4")); + Console.WriteLine("Looking for Fine Offset station"); hidDevice = devicelist.GetHidDeviceOrNull(vendorID: VID, productID: PID); @@ -102,8 +102,8 @@ internal FOStation(Cumulus cumulus) : base(cumulus) // Get the block of data containing the abs and rel pressures cumulus.LogMessage("Reading pressure offset"); ReadAddress(0x20, data); - double relpressure = ((data[1]*256) + data[0])/10.0f; - double abspressure = ((data[3]*256) + data[2])/10.0f; + double relpressure = (((data[1] & 0x3f)*256) + data[0])/10.0f; + double abspressure = (((data[3] & 0x3f)*256) + data[2])/10.0f; pressureOffset = relpressure - abspressure; cumulus.LogMessage("Rel pressure = " + relpressure); cumulus.LogMessage("Abs pressure = " + abspressure); @@ -211,16 +211,20 @@ public override void getAndProcessHistoryData() // add history data to collection var histData = new HistoryData(); - string msg = DateTime.Now.ToLongTimeString() + " Read logger entry for " + timestamp + " address " + addr.ToString("X4") + ": "; + string msg = "Read logger entry for " + timestamp + " address " + addr.ToString("X4"); int numBytes = hasSolar ? 20 : 16; - for (int i = 0; i < numBytes; i++) + cumulus.LogMessage(msg); + + msg = "Data block: "; + + for (int i = 0; i < numBytes; i++) { msg += data[i].ToString("X2"); msg += " "; } - cumulus.LogMessage(msg); + cumulus.LogDataMessage(msg); histData.timestamp = timestamp; histData.interval = interval; @@ -579,22 +583,12 @@ private void ReadAddress(int address, byte[] buff) var highbyte = (byte) (address >> 8); byte[] request; - var response = new byte[9]; - int responseLength; - int startByte; + // Returns 9-byte usb packet, with report ID in first byte + var response = new byte[9]; + int responseLength = 9; + int startByte = 1; - if (cumulus.IsOSX) - { - request = new byte[] {0xa1, highbyte, lowbyte, 0x20, 0xa1, highbyte, lowbyte, 0x20}; - responseLength = 8; - startByte = 0; - } - else - { - request = new byte[] {0, 0xa1, highbyte, lowbyte, 0x20, 0xa1, highbyte, lowbyte, 0x20}; - responseLength = 9; - startByte = 1; - } + request = new byte[] {0, 0xa1, highbyte, lowbyte, 0x20, 0xa1, highbyte, lowbyte, 0x20}; int ptr = 0; String rec_data = ""; @@ -626,7 +620,7 @@ private void ReadAddress(int address, byte[] buff) rec_data += " "; buff[ptr++] = response[j]; } - //cumulus.LogMessage(DateTime.Now.ToLongTimeString() + rec_data); + cumulus.LogDataMessage(rec_data); } } } @@ -839,7 +833,7 @@ private void GetAndProcessData() } // Pressure ========================================================= - double pressure = (data[7] + (data[8]*256))/10.0f + pressureOffset; + double pressure = (data[7] + ((data[8] & 0x3f)*256))/10.0f + pressureOffset; if ((pressure < cumulus.EWminpressureMB) || (pressure > cumulus.EWmaxpressureMB)) { diff --git a/CumulusMX/ImetStation.cs b/CumulusMX/ImetStation.cs index 3d1bb2e8..477c3ba0 100644 --- a/CumulusMX/ImetStation.cs +++ b/CumulusMX/ImetStation.cs @@ -14,17 +14,19 @@ namespace CumulusMX { internal class ImetStation : WeatherStation { - private string sLineBreak = "\r\n"; + private const string sLineBreak = "\r\n"; private bool midnightraindone; private double prevraintotal = -1; private int previousminute = 60; + private string currentWritePointer = ""; public ImetStation(Cumulus cumulus) : base(cumulus) { cumulus.Manufacturer = cumulus.INSTROMET; - cumulus.LogMessage("ImetWaitTime="+cumulus.ImetWaitTime); - cumulus.LogMessage("ImetBaudRate="+cumulus.ImetBaudRate); + cumulus.LogMessage("ImetUpdateLogPointer=" + cumulus.ImetUpdateLogPointer); + cumulus.LogMessage("ImetWaitTime=" + cumulus.ImetWaitTime); + cumulus.LogMessage("ImetBaudRate=" + cumulus.ImetBaudRate); cumulus.LogMessage("Instromet: Attempting to open " + cumulus.ComportName); calculaterainrate = true; @@ -61,10 +63,9 @@ private void ImetSetLoggerInterval(int interval) { cumulus.LogMessage("Setting logger interval to " + interval + " minutes"); - comport.Write("WRST,11," + interval*60 + sLineBreak); - Thread.Sleep(cumulus.ImetWaitTime); + SendCommand("WRST,11," + interval * 60); // read the response - string response = getResponse("wrst"); + string response = GetResponse("wrst"); string data = ExtractText(response, "wrst"); cumulus.LogMessage("Response: " + data); @@ -78,10 +79,9 @@ private void SetStationClock() cumulus.LogMessage("WRTM," + datestr + ',' + timestr); - comport.Write("WRTM," + datestr + ',' + timestr + sLineBreak); - Thread.Sleep(cumulus.ImetWaitTime); + SendCommand("WRTM," + datestr + ',' + timestr); // read the response - string response = getResponse("wrtm"); + string response = GetResponse("wrtm"); string data = ExtractText(response, "wrtm"); cumulus.LogMessage("Response: " + data); @@ -89,8 +89,8 @@ private void SetStationClock() private string ReadStationClock() { - comport.Write("RDTM" + sLineBreak); - string response = getResponse("rdtm"); + SendCommand("RDTM"); + string response = GetResponse("rdtm"); string data = ExtractText(response, "rdtm"); return data; } @@ -99,13 +99,11 @@ private void ProgressLogs() { // MainForm.LogMessage('Advance log pointer'); // advance the pointer - comport.Write("PRLG,1" + sLineBreak); - Thread.Sleep(cumulus.ImetWaitTime); + SendCommand("PRLG,1"); // read the response - getResponse("prlg"); + GetResponse("prlg"); } - private void RegressLogs(DateTime ts) // Move the log pointer back until the archive record timestamp is earlier // than the supplied ts, or the logs cannot be regressed any further { @@ -119,9 +117,9 @@ private void RegressLogs(DateTime ts) // Move the log pointer back until the arc cumulus.LogMessage("Regressing logs to before " + ts); // regress the pointer - comport.Write("RGLG,1" + sLineBreak); + SendCommand("RGLG,1"); // read the response - string response = getResponse("rglg"); + string response = GetResponse("rglg"); do { List sl = GetArchiveRecord(); @@ -138,7 +136,7 @@ private void RegressLogs(DateTime ts) // Move the log pointer back until the arc entryTS = new DateTime(year, month, day, hour, minute, sec, 0); dataOK = true; } - catch (Exception Ex) + catch { cumulus.LogMessage("Error in timestamp, unable to process logger data"); dataOK = false; @@ -156,9 +154,9 @@ private void RegressLogs(DateTime ts) // Move the log pointer back until the arc else { // regress the pointer - comport.Write("RGLG,1" + sLineBreak); + SendCommand("RGLG,1"); // read the response - response = getResponse("rglg"); + response = GetResponse("rglg"); previousnumlogs = numlogs; numlogs = GetNumberOfLogs(); cumulus.LogMessage("Number of logs = " + numlogs); @@ -172,28 +170,112 @@ private void RegressLogs(DateTime ts) // Move the log pointer back until the arc } while (!done); } - private string getResponse(string expected) + private void UpdateReadPointer() { - string response = ""; + string response1, response2; + List sl; + string currPtr; - int attempts = 0; + // If required, update the logger read pointer to match the current write pointer + // It means the read pointer will always point to the last live record we read. + SendCommand("RDST,14"); + // read the response + response1 = GetResponse("rdst"); + if (ValidChecksum(response1)) + { + try + { + // Response: rdst,adr,dat + // split the data + sl = new List(Regex.Split(response1, ",")); + currPtr = sl[2]; + if (!currentWritePointer.Equals(currPtr)) + { + // The write pointer does not equal the read pointer + // write it back to the logger memory + cumulus.LogDebugMessage("Updating logger read pointer"); + SendCommand("WRST,13," + currPtr); + response2 = GetResponse("wrst"); + if (ValidChecksum(response2)) + { + // and if it all worked, update our pointer record + currentWritePointer = currPtr; + } + } + } + catch + { + } + } + } - try - { - do + private void SendCommand(string command) + { + string response = String.Empty; + + // First flush the receive buffer + comport.DiscardInBuffer(); + comport.BaseStream.Flush(); + + // Send the command + cumulus.LogDebugMessage("Sending: " + command); + comport.Write(command + sLineBreak); + + // Flush the first response - should be the echo of the command + try { - attempts ++; - cumulus.LogDataMessage("Reading response from station, attempt "+attempts); - response = comport.ReadTo(sLineBreak); - cumulus.LogDataMessage("Response from station: "+response); - byte[] ba = Encoding.Default.GetBytes(response); - cumulus.LogDataMessage(BitConverter.ToString(ba)); - } while (!(response.Contains(expected))&&attempts<6); - } - catch (Exception e) - { - // Probably a timeout, just exit - } + response = comport.ReadTo(sLineBreak); + cumulus.LogDebugMessage("Discarding input: " + response); + } + catch + { + // probably a timeout - do nothing. + } + finally + { + Thread.Sleep(cumulus.ImetWaitTime); + } + } + + private string GetResponse(string expected) + { + string response = ""; + string ready = ""; + int attempts = 0; + + // The Instromet is odd, in that the serial connection is configured for human interaction rather than machine. + // Command to logger... + // RDLG,58 + // What is sent back... + // RDLG,58 + // rdlg,1,2,3,4,5,6,7,8,9,123 + // + // > + + try + { + do + { + attempts ++; + cumulus.LogDataMessage("Reading response from station, attempt " + attempts); + response = comport.ReadTo(sLineBreak); + byte[] ba = Encoding.Default.GetBytes(response); + + cumulus.LogDataMessage("Response from station: '" + response + "'"); + //cumulus.LogDebugMessage("Hex: '" + BitConverter.ToString(ba) + "'"); + } while (!(response.Contains(expected)) && attempts < 6); + + // If we got the response and didn't time out, then wait for the command prompt before + // returning so we know the logger is ready for the next command + if ((response.Contains(expected)) && attempts < 6) + { + ready = comport.ReadTo(">"); // just discard this + } + } + catch + { + // Probably a timeout, just exit + } return response; } @@ -203,10 +285,9 @@ private List GetArchiveRecord() List sl = new List(); cumulus.LogMessage("Get next log - RDLG,1"); // request the archive data - comport.Write("RDLG,1" + sLineBreak); - Thread.Sleep(cumulus.ImetWaitTime); + SendCommand("RDLG,1"); // read the response - string response = getResponse("rdlg"); + string response = GetResponse("rdlg"); // extract the bit we want from all the other crap (echo, newlines, prompt etc) string data = ExtractText(response, "rdlg"); cumulus.LogMessage(data); @@ -237,11 +318,10 @@ private int GetNumberOfLogs() attempts++; // read number of available archive entries - comport.Write("LGCT" + sLineBreak); + SendCommand("LGCT"); cumulus.LogMessage("Obtaining log count"); - Thread.Sleep(cumulus.ImetWaitTime); // read the response - string response = getResponse("lgct"); + string response = GetResponse("lgct"); // extract the bit we want from all the other crap (echo, newlines, prompt etc) data = ExtractText(response, "lgct"); cumulus.LogMessage("Response from LGCT=" + data); @@ -386,11 +466,11 @@ public override void getAndProcessHistoryData() const int INTERVALPOS = 3; const int TIMEPOS = 4; const int DATEPOS = 5; - const int TEMP1MINPOS = 6; - const int TEMP1MAXPOS = 7; + //const int TEMP1MINPOS = 6; + //const int TEMP1MAXPOS = 7; const int TEMP1AVGPOS = 8; - const int TEMP2MINPOS = 9; - const int TEMP2MAXPOS = 10; + //const int TEMP2MINPOS = 9; + //const int TEMP2MAXPOS = 10; const int TEMP2AVGPOS = 11; //const int RELHUMMINPOS = 12; //const int RELHUMMAXPOS = 13; @@ -405,7 +485,7 @@ public override void getAndProcessHistoryData() const int SUNPOS = 22; const int RAINPOS = 23; - string response; + //string response; bool rolloverdone; bool dataOK = false; DateTime timestamp = DateTime.MinValue; @@ -431,13 +511,17 @@ public override void getAndProcessHistoryData() { // First time Cumulus has run, "delete" all the log entries as there may be // vast numbers and they will take hours to download only to be discarded - cumulus.LogMessage("First run: PRLG,32760"); + + //cumulus.LogMessage("First run: PRLG,32760"); // regress the pointer - comport.Write("PRLG,32760" + sLineBreak); + //comport.Write("PRLG,32760" + sLineBreak); // read the response - response = getResponse("prlg"); - } + //response = GetResponse("prlg"); + // Do it by updating the read pointer to match the write pointer + // The recorded value for currentWritePointer will not have been set yet + UpdateReadPointer(); + } cumulus.LogMessage("Downloading history from " + startfrom); Console.WriteLine("Reading archive data from " + startfrom + " - please wait"); @@ -747,7 +831,7 @@ public override void portDataReceived(object sender, SerialDataReceivedEventArgs public override void Start() { - cumulus.LogMessage(DateTime.Now + "Starting Instromet data reading thread"); + cumulus.LogMessage("Starting Instromet data reading thread"); try { @@ -803,13 +887,12 @@ private void ImetGetData() } } - comport.Write("RDLV" + sLineBreak); + SendCommand("RDLV"); // read the response - var response = getResponse("rdlv"); + var response = GetResponse("rdlv"); if (ValidChecksum(response)) { - cumulus.LogDataMessage(response); // split the data var sl = new List(Regex.Split(response, ",")); @@ -894,9 +977,10 @@ private void ImetGetData() if (cumulus.ImetUpdateLogPointer) { - // Keep the log pointer current, to avoid large numbers of logs - // being downloaded at next startup - ProgressLogs(); + // Keep the log pointer current, to avoid large numbers of logs + // being downloaded at next startup + //ProgressLogs(); + UpdateReadPointer(); } } } diff --git a/CumulusMX/InternetSettings.cs b/CumulusMX/InternetSettings.cs index 5625156e..7d745d36 100644 --- a/CumulusMX/InternetSettings.cs +++ b/CumulusMX/InternetSettings.cs @@ -3,7 +3,7 @@ using System.IO; using System.Net; using System.Web; -using fastJSON; +using Newtonsoft.Json; using Unosquare.Labs.EmbedIO; @@ -13,8 +13,8 @@ namespace CumulusMX public class InternetSettings { private Cumulus cumulus; - private string internetOptionsFile; - private string internetSchemaFile; + private readonly string internetOptionsFile; + private readonly string internetSchemaFile; public InternetSettings(Cumulus cumulus) { @@ -34,8 +34,7 @@ public string UpdateInternetConfig(IHttpContext context) var json = WebUtility.UrlDecode(data.Substring(5)); // de-serialize it to the settings structure - //JsonInternetSettingsData settings = new JavaScriptSerializer().Deserialize(json); - var settings = JSON.ToObject(json); + var settings = JsonConvert.DeserializeObject(json); // process the settings cumulus.LogMessage("Updating internet settings"); @@ -393,7 +392,7 @@ public string GetInternetAlpacaFormData() customhttp = customhttp }; - return JSON.ToJSON(data); + return JsonConvert.SerializeObject(data); } public string GetInternetAlpacaFormOptions() @@ -417,7 +416,7 @@ public string GetInternetAlpacaFormSchema() public string GetExtraWebFilesData() { string json = - "{\"metadata\":[{\"name\":\"local\",\"label\":\"LOCAL FILENAME\",\"datatype\":\"string\",\"editable\":true},{\"name\":\"remote\",\"label\":\"REMOTE FILENAME\",\"datatype\":\"string\",\"editable\":true},{\"name\":\"process\",\"label\":\"PROCESS\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"realtime\",\"label\":\"REALTIME\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"ftp\",\"label\":\"FTP\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"utf8\",\"label\":\"UTF8\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"binary\",\"label\":\"BINARY\",\"datatype\":\"boolean\",\"editable\":true}],\"data\":["; + "{\"metadata\":[{\"name\":\"local\",\"label\":\"LOCAL FILENAME\",\"datatype\":\"string\",\"editable\":true},{\"name\":\"remote\",\"label\":\"REMOTE FILENAME\",\"datatype\":\"string\",\"editable\":true},{\"name\":\"process\",\"label\":\"PROCESS\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"realtime\",\"label\":\"REALTIME\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"ftp\",\"label\":\"FTP\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"utf8\",\"label\":\"UTF8\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"binary\",\"label\":\"BINARY\",\"datatype\":\"boolean\",\"editable\":true},{\"name\":\"endofday\",\"label\":\"END OF DAY\",\"datatype\":\"boolean\",\"editable\":true}],\"data\":["; int numfiles = Cumulus.numextrafiles; @@ -431,9 +430,9 @@ public string GetExtraWebFilesData() string ftp = cumulus.ExtraFiles[i].FTP ? "true" : "false"; string utf8 = cumulus.ExtraFiles[i].UTF8 ? "true" : "false"; string binary = cumulus.ExtraFiles[i].binary ? "true" : "false"; - + string endofday = cumulus.ExtraFiles[i].endofday ? "true" : "false"; json = json + "{\"id\":" + (i + 1) + ",\"values\":[\"" + local + "\",\"" + remote + "\",\"" + process + "\",\"" + realtime + "\",\"" + ftp + "\",\"" + utf8 + "\",\"" + - binary + "\"]}"; + binary + "\",\"" + endofday + "\"]}"; if (i < numfiles - 1) { @@ -490,7 +489,10 @@ public string UpdateExtraWebFiles(IHttpContext context) // binary cumulus.ExtraFiles[entry].binary = value == "true"; break; - + case 7: + // end of day + cumulus.ExtraFiles[entry].endofday = value == "true"; + break; } // Save the settings cumulus.WriteIniFile(); diff --git a/CumulusMX/MysqlSettings.cs b/CumulusMX/MysqlSettings.cs index 0459ed84..ca345bce 100644 --- a/CumulusMX/MysqlSettings.cs +++ b/CumulusMX/MysqlSettings.cs @@ -2,7 +2,7 @@ using System.IO; using System.Net; using Devart.Data.MySql; -using fastJSON; +using Newtonsoft.Json; using Unosquare.Labs.EmbedIO; namespace CumulusMX @@ -64,10 +64,10 @@ public string GetMySqlAlpacaFormData() customrollover = customrollover }; - return JSON.ToJSON(data); - } + return JsonConvert.SerializeObject(data); + } - public string GetMySqAlpacaFormOptions() + public string GetMySqAlpacaFormOptions() { using (StreamReader sr = new StreamReader(mySqlOptionsFile)) { @@ -95,10 +95,10 @@ public object UpdateMysqlConfig(IHttpContext context) // Start at char 5 to skip the "json:" prefix var json = WebUtility.UrlDecode(data.Substring(5)); - // de-serialize it to the settings structure - var settings = JSON.ToObject(json); - // process the settings - cumulus.LogMessage("Updating MySQL settings"); + // de-serialize it to the settings structure + var settings = JsonConvert.DeserializeObject(json); + // process the settings + cumulus.LogMessage("Updating MySQL settings"); // server cumulus.MySqlHost = settings.server.host; diff --git a/CumulusMX/NOAASettings.cs b/CumulusMX/NOAASettings.cs index d8ba252d..17e7e6be 100644 --- a/CumulusMX/NOAASettings.cs +++ b/CumulusMX/NOAASettings.cs @@ -7,7 +7,7 @@ using System.Net; using System.Text; using System.Threading.Tasks; -using fastJSON; +using Newtonsoft.Json; using Unosquare.Labs.EmbedIO; @@ -86,10 +86,10 @@ public string GetNoaaAlpacaFormData() normalrain = normalrain }; - return JSON.ToJSON(data); - } + return JsonConvert.SerializeObject(data); + } - public string GetNoaaAlpacaFormOptions() + public string GetNoaaAlpacaFormOptions() { using (StreamReader sr = new StreamReader(noaaOptionsFile)) { @@ -117,10 +117,10 @@ public string UpdateNoaaConfig(IHttpContext context) // Start at char 5 to skip the "json:" prefix var json = WebUtility.UrlDecode(data.Substring(5)); - // de-serialize it to the settings structure - var settings = JSON.ToObject(json); - // process the settings - cumulus.LogMessage("Updating NOAA settings"); + // de-serialize it to the settings structure + var settings = JsonConvert.DeserializeObject(json); + // process the settings + cumulus.LogMessage("Updating NOAA settings"); var InvC = new CultureInfo(""); cumulus.NOAAname = settings.sitename; diff --git a/CumulusMX/Properties/AssemblyInfo.cs b/CumulusMX/Properties/AssemblyInfo.cs index 6df605db..a0f0d69b 100644 --- a/CumulusMX/Properties/AssemblyInfo.cs +++ b/CumulusMX/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.0.3046")] -[assembly: AssemblyFileVersion("3.0.0.3046")] +[assembly: AssemblyVersion("3.0.0.3047")] +[assembly: AssemblyFileVersion("3.0.0.3047")] diff --git a/CumulusMX/StationSettings.cs b/CumulusMX/StationSettings.cs index 83ecd1a6..40a4657d 100644 --- a/CumulusMX/StationSettings.cs +++ b/CumulusMX/StationSettings.cs @@ -6,7 +6,7 @@ using System.Net; using System.Text; using System.Threading.Tasks; -using fastJSON; +using Newtonsoft.Json; using System.Web.UI; using Unosquare.Labs.EmbedIO; @@ -145,10 +145,10 @@ public string GetStationAlpacaFormData() Graphs = graphs }; - return JSON.ToJSON(data); - } + return JsonConvert.SerializeObject(data); + } - public string GetStationAlpacaFormOptions() + public string GetStationAlpacaFormOptions() { using (StreamReader sr = new StreamReader(stationOptionsFile)) { @@ -225,12 +225,12 @@ public string UpdateStationConfig(IHttpContext context) // Start at char 5 to skip the "json:" prefix var json = WebUtility.UrlDecode(data.Substring(5)); - - // de-serialize it to the settings structure - var settings = JSON.ToObject(json); - // process the settings - - cumulus.GraphHours = settings.Graphs.graphhours; + + // de-serialize it to the settings structure + var settings = JsonConvert.DeserializeObject(json); + // process the settings + + cumulus.GraphHours = settings.Graphs.graphhours; cumulus.GraphDays = settings.Graphs.graphdays; // Annual Rainfall diff --git a/CumulusMX/TokenParser.cs b/CumulusMX/TokenParser.cs index c36fa243..b5e20fec 100644 --- a/CumulusMX/TokenParser.cs +++ b/CumulusMX/TokenParser.cs @@ -211,7 +211,7 @@ private String Parse3() int i = 0; int len = InputText.Length; - Regex rx = new Regex("<#[^>]*?(?:(?:(\")[^\"]*?\\1)[^>]*?)*>", RegexOptions.Compiled | RegexOptions.IgnoreCase); + Regex rx = new Regex("<#[^>]*?(?:(?:(\")[^\"]*?\\1)[^>]*?)*>", RegexOptions.Compiled); // Find matches. MatchCollection matches = rx.Matches(InputText); diff --git a/CumulusMX/WMR100Station.cs b/CumulusMX/WMR100Station.cs index b852d69f..5d922d63 100644 --- a/CumulusMX/WMR100Station.cs +++ b/CumulusMX/WMR100Station.cs @@ -89,20 +89,10 @@ public override void Start() int startByte; int offset; - if (cumulus.IsOSX) - { - // OS X returns 8-byte usb packet, without report ID in first byte - responseLength = 8; - startByte = 0; - offset = 1; - } - else - { - // Others return 9-byte usb packet, with report ID in first byte - responseLength = 9; - startByte = 1; - offset = 0; - } + // Returns 9-byte usb packet, with report ID in first byte + responseLength = 9; + startByte = 1; + offset = 0; try { @@ -192,7 +182,7 @@ public override void Start() cumulus.LogDebugMessage("Data read loop: " + ex.Message); } } - Thread.Sleep(100); + //Thread.Sleep(100); } // Catch the ThreadAbortException diff --git a/CumulusMX/WMR200Station.cs b/CumulusMX/WMR200Station.cs index 91515c65..7db785aa 100644 --- a/CumulusMX/WMR200Station.cs +++ b/CumulusMX/WMR200Station.cs @@ -173,18 +173,10 @@ public override void Start() int startByte; int offset; - if (cumulus.IsOSX) - { - responseLength = 8; - startByte = 0; - offset = 1; - } - else - { - responseLength = 9; - startByte = 1; - offset = 0; - } + // Returns 9-byte usb packet, with report ID in first byte + responseLength = 9; + startByte = 1; + offset = 0; try { @@ -313,7 +305,7 @@ public override void Start() cumulus.LogDebugMessage("Data read loop: " + ex.Message); } } - Thread.Sleep(100); + //Thread.Sleep(100); } // Catch the ThreadAbortException @@ -1406,7 +1398,7 @@ private void ProcessHistoryDataPacket() timestamp = new DateTime(2000 + y, mo, d, h, m, 0, 0); cumulus.LogMessage("History data for: " + timestamp); } - catch (Exception ex) + catch { cumulus.LogMessage("Invalid date, ignoring"); return; diff --git a/CumulusMX/WeatherStation.cs b/CumulusMX/WeatherStation.cs index 9941ef22..1bbcc808 100644 --- a/CumulusMX/WeatherStation.cs +++ b/CumulusMX/WeatherStation.cs @@ -1287,6 +1287,11 @@ public void SecondTimer(object sender, ElapsedEventArgs e) { lastMinute = minute; + if ((minute % 10) == 0) + { + TenMinuteChanged(); + } + var hour = DateTime.Now.Hour; if (hour != lastHour) @@ -1379,7 +1384,6 @@ private void HourChanged(int hour) { cumulus.LogMessage("Hour changed:" + hour); cumulus.DoSunriseAndSunset(); - cumulus.DoMoonPhase(); if (cumulus.HourlyForecast) { @@ -1600,6 +1604,11 @@ private void MinuteChanged() } } + private void TenMinuteChanged() + { + cumulus.DoMoonPhase(); + } + private void CheckForDataStopped() { // Check whether we have read data since the last clock minute. @@ -3988,7 +3997,7 @@ public void ReadYesterdayFile() highrainyesterday = ini.GetValue("Rain", "High", 0.0); highrainyesterdaytime = ini.GetValue("Rain", "HTime", DateTime.MinValue); highhourlyrainyesterday = ini.GetValue("Rain", "HourlyHigh", 0.0); - highhourlyrainyesterdaytime = ini.GetValue("Rain", "HHourlyTime", DateTime.Now); + highhourlyrainyesterdaytime = ini.GetValue("Rain", "HHourlyTime", DateTime.MinValue); RG11RainYesterday = ini.GetValue("Rain", "RG11Yesterday", 0.0); // humidity lowhumidityyesterday = ini.GetValue("Humidity", "Low", 0); @@ -4672,6 +4681,13 @@ public void DayReset(DateTime timestamp) } } + // Do the End of day Extra files + // This will set a flag to transfer on next FTP if required + cumulus.DoExtraEndOfDayFiles(); + if (cumulus.EODfilesNeedFTP) + { + cumulus.LogMessage("Extra files will be uploaded at next web update"); + } CurrentDay = timestamp.Day; CurrentMonth = timestamp.Month; @@ -6641,107 +6657,105 @@ public void ReadAlltimeIniFile() cumulus.LogMessage(Path.GetFullPath(cumulus.AlltimeIniFile)); IniFile ini = new IniFile(cumulus.AlltimeIniFile); - var defaultTS = DateTime.Now; - alltimerecarray[WeatherStation.AT_hightemp].data_type = WeatherStation.AT_hightemp; alltimerecarray[WeatherStation.AT_hightemp].value = ini.GetValue("Temperature", "hightempvalue", -999.0); - alltimerecarray[WeatherStation.AT_hightemp].timestamp = ini.GetValue("Temperature", "hightemptime", defaultTS); + alltimerecarray[WeatherStation.AT_hightemp].timestamp = ini.GetValue("Temperature", "hightemptime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_lowtemp].data_type = WeatherStation.AT_lowtemp; alltimerecarray[WeatherStation.AT_lowtemp].value = ini.GetValue("Temperature", "lowtempvalue", 999.0); - alltimerecarray[WeatherStation.AT_lowtemp].timestamp = ini.GetValue("Temperature", "lowtemptime", defaultTS); + alltimerecarray[WeatherStation.AT_lowtemp].timestamp = ini.GetValue("Temperature", "lowtemptime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_lowchill].data_type = WeatherStation.AT_lowchill; alltimerecarray[WeatherStation.AT_lowchill].value = ini.GetValue("Temperature", "lowchillvalue", 999.0); - alltimerecarray[WeatherStation.AT_lowchill].timestamp = ini.GetValue("Temperature", "lowchilltime", defaultTS); + alltimerecarray[WeatherStation.AT_lowchill].timestamp = ini.GetValue("Temperature", "lowchilltime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highmintemp].data_type = WeatherStation.AT_highmintemp; alltimerecarray[WeatherStation.AT_highmintemp].value = ini.GetValue("Temperature", "highmintempvalue", -999.0); - alltimerecarray[WeatherStation.AT_highmintemp].timestamp = ini.GetValue("Temperature", "highmintemptime", defaultTS); + alltimerecarray[WeatherStation.AT_highmintemp].timestamp = ini.GetValue("Temperature", "highmintemptime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_lowmaxtemp].data_type = WeatherStation.AT_lowmaxtemp; alltimerecarray[WeatherStation.AT_lowmaxtemp].value = ini.GetValue("Temperature", "lowmaxtempvalue", 999.0); - alltimerecarray[WeatherStation.AT_lowmaxtemp].timestamp = ini.GetValue("Temperature", "lowmaxtemptime", defaultTS); + alltimerecarray[WeatherStation.AT_lowmaxtemp].timestamp = ini.GetValue("Temperature", "lowmaxtemptime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highapptemp].data_type = WeatherStation.AT_highapptemp; alltimerecarray[WeatherStation.AT_highapptemp].value = ini.GetValue("Temperature", "highapptempvalue", -999.0); - alltimerecarray[WeatherStation.AT_highapptemp].timestamp = ini.GetValue("Temperature", "highapptemptime", defaultTS); + alltimerecarray[WeatherStation.AT_highapptemp].timestamp = ini.GetValue("Temperature", "highapptemptime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_lowapptemp].data_type = WeatherStation.AT_lowapptemp; alltimerecarray[WeatherStation.AT_lowapptemp].value = ini.GetValue("Temperature", "lowapptempvalue", 999.0); - alltimerecarray[WeatherStation.AT_lowapptemp].timestamp = ini.GetValue("Temperature", "lowapptemptime", defaultTS); + alltimerecarray[WeatherStation.AT_lowapptemp].timestamp = ini.GetValue("Temperature", "lowapptemptime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highheatindex].data_type = WeatherStation.AT_highheatindex; alltimerecarray[WeatherStation.AT_highheatindex].value = ini.GetValue("Temperature", "highheatindexvalue", -999.0); - alltimerecarray[WeatherStation.AT_highheatindex].timestamp = ini.GetValue("Temperature", "highheatindextime", defaultTS); + alltimerecarray[WeatherStation.AT_highheatindex].timestamp = ini.GetValue("Temperature", "highheatindextime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highdewpoint].data_type = WeatherStation.AT_highdewpoint; alltimerecarray[WeatherStation.AT_highdewpoint].value = ini.GetValue("Temperature", "highdewpointvalue", -999.0); - alltimerecarray[WeatherStation.AT_highdewpoint].timestamp = ini.GetValue("Temperature", "highdewpointtime", defaultTS); + alltimerecarray[WeatherStation.AT_highdewpoint].timestamp = ini.GetValue("Temperature", "highdewpointtime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_lowdewpoint].data_type = WeatherStation.AT_lowdewpoint; alltimerecarray[WeatherStation.AT_lowdewpoint].value = ini.GetValue("Temperature", "lowdewpointvalue", 999.0); - alltimerecarray[WeatherStation.AT_lowdewpoint].timestamp = ini.GetValue("Temperature", "lowdewpointtime", defaultTS); + alltimerecarray[WeatherStation.AT_lowdewpoint].timestamp = ini.GetValue("Temperature", "lowdewpointtime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highdailytemprange].data_type = WeatherStation.AT_highdailytemprange; alltimerecarray[WeatherStation.AT_highdailytemprange].value = ini.GetValue("Temperature", "hightemprangevalue", 0.0); - alltimerecarray[WeatherStation.AT_highdailytemprange].timestamp = ini.GetValue("Temperature", "hightemprangetime", defaultTS); + alltimerecarray[WeatherStation.AT_highdailytemprange].timestamp = ini.GetValue("Temperature", "hightemprangetime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_lowdailytemprange].data_type = WeatherStation.AT_lowdailytemprange; alltimerecarray[WeatherStation.AT_lowdailytemprange].value = ini.GetValue("Temperature", "lowtemprangevalue", 999.0); - alltimerecarray[WeatherStation.AT_lowdailytemprange].timestamp = ini.GetValue("Temperature", "lowtemprangetime", defaultTS); + alltimerecarray[WeatherStation.AT_lowdailytemprange].timestamp = ini.GetValue("Temperature", "lowtemprangetime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highwind].data_type = WeatherStation.AT_highwind; alltimerecarray[WeatherStation.AT_highwind].value = ini.GetValue("Wind", "highwindvalue", 0.0); - alltimerecarray[WeatherStation.AT_highwind].timestamp = ini.GetValue("Wind", "highwindtime", defaultTS); + alltimerecarray[WeatherStation.AT_highwind].timestamp = ini.GetValue("Wind", "highwindtime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highgust].data_type = WeatherStation.AT_highgust; alltimerecarray[WeatherStation.AT_highgust].value = ini.GetValue("Wind", "highgustvalue", 0.0); - alltimerecarray[WeatherStation.AT_highgust].timestamp = ini.GetValue("Wind", "highgusttime", defaultTS); + alltimerecarray[WeatherStation.AT_highgust].timestamp = ini.GetValue("Wind", "highgusttime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highwindrun].data_type = WeatherStation.AT_highwindrun; alltimerecarray[WeatherStation.AT_highwindrun].value = ini.GetValue("Wind", "highdailywindrunvalue", 0.0); - alltimerecarray[WeatherStation.AT_highwindrun].timestamp = ini.GetValue("Wind", "highdailywindruntime", defaultTS); + alltimerecarray[WeatherStation.AT_highwindrun].timestamp = ini.GetValue("Wind", "highdailywindruntime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highrainrate].data_type = WeatherStation.AT_highrainrate; alltimerecarray[WeatherStation.AT_highrainrate].value = ini.GetValue("Rain", "highrainratevalue", 0.0); - alltimerecarray[WeatherStation.AT_highrainrate].timestamp = ini.GetValue("Rain", "highrainratetime", defaultTS); + alltimerecarray[WeatherStation.AT_highrainrate].timestamp = ini.GetValue("Rain", "highrainratetime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_dailyrain].data_type = WeatherStation.AT_dailyrain; alltimerecarray[WeatherStation.AT_dailyrain].value = ini.GetValue("Rain", "highdailyrainvalue", 0.0); - alltimerecarray[WeatherStation.AT_dailyrain].timestamp = ini.GetValue("Rain", "highdailyraintime", defaultTS); + alltimerecarray[WeatherStation.AT_dailyrain].timestamp = ini.GetValue("Rain", "highdailyraintime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_hourlyrain].data_type = WeatherStation.AT_hourlyrain; alltimerecarray[WeatherStation.AT_hourlyrain].value = ini.GetValue("Rain", "highhourlyrainvalue", 0.0); - alltimerecarray[WeatherStation.AT_hourlyrain].timestamp = ini.GetValue("Rain", "highhourlyraintime", defaultTS); + alltimerecarray[WeatherStation.AT_hourlyrain].timestamp = ini.GetValue("Rain", "highhourlyraintime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_wetmonth].data_type = WeatherStation.AT_wetmonth; alltimerecarray[WeatherStation.AT_wetmonth].value = ini.GetValue("Rain", "highmonthlyrainvalue", 0.0); - alltimerecarray[WeatherStation.AT_wetmonth].timestamp = ini.GetValue("Rain", "highmonthlyraintime", defaultTS); + alltimerecarray[WeatherStation.AT_wetmonth].timestamp = ini.GetValue("Rain", "highmonthlyraintime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_longestdryperiod].data_type = WeatherStation.AT_longestdryperiod; alltimerecarray[WeatherStation.AT_longestdryperiod].value = ini.GetValue("Rain", "longestdryperiodvalue", 0); - alltimerecarray[WeatherStation.AT_longestdryperiod].timestamp = ini.GetValue("Rain", "longestdryperiodtime", defaultTS); + alltimerecarray[WeatherStation.AT_longestdryperiod].timestamp = ini.GetValue("Rain", "longestdryperiodtime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_longestwetperiod].data_type = WeatherStation.AT_longestwetperiod; alltimerecarray[WeatherStation.AT_longestwetperiod].value = ini.GetValue("Rain", "longestwetperiodvalue", 0); - alltimerecarray[WeatherStation.AT_longestwetperiod].timestamp = ini.GetValue("Rain", "longestwetperiodtime", defaultTS); + alltimerecarray[WeatherStation.AT_longestwetperiod].timestamp = ini.GetValue("Rain", "longestwetperiodtime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highpress].data_type = WeatherStation.AT_highpress; alltimerecarray[WeatherStation.AT_highpress].value = ini.GetValue("Pressure", "highpressurevalue", 0.0); - alltimerecarray[WeatherStation.AT_highpress].timestamp = ini.GetValue("Pressure", "highpressuretime", defaultTS); + alltimerecarray[WeatherStation.AT_highpress].timestamp = ini.GetValue("Pressure", "highpressuretime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_lowpress].data_type = WeatherStation.AT_lowpress; alltimerecarray[WeatherStation.AT_lowpress].value = ini.GetValue("Pressure", "lowpressurevalue", 9999.0); - alltimerecarray[WeatherStation.AT_lowpress].timestamp = ini.GetValue("Pressure", "lowpressuretime", defaultTS); + alltimerecarray[WeatherStation.AT_lowpress].timestamp = ini.GetValue("Pressure", "lowpressuretime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_highhumidity].data_type = WeatherStation.AT_highhumidity; alltimerecarray[WeatherStation.AT_highhumidity].value = ini.GetValue("Humidity", "highhumidityvalue", 0); - alltimerecarray[WeatherStation.AT_highhumidity].timestamp = ini.GetValue("Humidity", "highhumiditytime", defaultTS); + alltimerecarray[WeatherStation.AT_highhumidity].timestamp = ini.GetValue("Humidity", "highhumiditytime", cumulus.defaultRecordTS); alltimerecarray[WeatherStation.AT_lowhumidity].data_type = WeatherStation.AT_lowhumidity; alltimerecarray[WeatherStation.AT_lowhumidity].value = ini.GetValue("Humidity", "lowhumidityvalue", 999); - alltimerecarray[WeatherStation.AT_lowhumidity].timestamp = ini.GetValue("Humidity", "lowhumiditytime", defaultTS); + alltimerecarray[WeatherStation.AT_lowhumidity].timestamp = ini.GetValue("Humidity", "lowhumiditytime", cumulus.defaultRecordTS); cumulus.LogMessage("Alltime.ini file read"); } @@ -6818,107 +6832,105 @@ public void ReadMonthlyAlltimeIniFile() { string monthstr = month.ToString("D2"); - var defaultTS = DateTime.Now; - monthlyrecarray[WeatherStation.AT_hightemp, month].data_type = WeatherStation.AT_hightemp; monthlyrecarray[WeatherStation.AT_hightemp, month].value = ini.GetValue("Temperature" + monthstr, "hightempvalue", -999.0); - monthlyrecarray[WeatherStation.AT_hightemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "hightemptime", defaultTS); + monthlyrecarray[WeatherStation.AT_hightemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "hightemptime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_lowtemp, month].data_type = WeatherStation.AT_lowtemp; monthlyrecarray[WeatherStation.AT_lowtemp, month].value = ini.GetValue("Temperature" + monthstr, "lowtempvalue", 999.0); - monthlyrecarray[WeatherStation.AT_lowtemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowtemptime", defaultTS); + monthlyrecarray[WeatherStation.AT_lowtemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowtemptime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_lowchill, month].data_type = WeatherStation.AT_lowchill; monthlyrecarray[WeatherStation.AT_lowchill, month].value = ini.GetValue("Temperature" + monthstr, "lowchillvalue", 999.0); - monthlyrecarray[WeatherStation.AT_lowchill, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowchilltime", defaultTS); + monthlyrecarray[WeatherStation.AT_lowchill, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowchilltime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highmintemp, month].data_type = WeatherStation.AT_highmintemp; monthlyrecarray[WeatherStation.AT_highmintemp, month].value = ini.GetValue("Temperature" + monthstr, "highmintempvalue", -999.0); - monthlyrecarray[WeatherStation.AT_highmintemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "highmintemptime", defaultTS); + monthlyrecarray[WeatherStation.AT_highmintemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "highmintemptime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_lowmaxtemp, month].data_type = WeatherStation.AT_lowmaxtemp; monthlyrecarray[WeatherStation.AT_lowmaxtemp, month].value = ini.GetValue("Temperature" + monthstr, "lowmaxtempvalue", 999.0); - monthlyrecarray[WeatherStation.AT_lowmaxtemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowmaxtemptime", defaultTS); + monthlyrecarray[WeatherStation.AT_lowmaxtemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowmaxtemptime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highapptemp, month].data_type = WeatherStation.AT_highapptemp; monthlyrecarray[WeatherStation.AT_highapptemp, month].value = ini.GetValue("Temperature" + monthstr, "highapptempvalue", -999.0); - monthlyrecarray[WeatherStation.AT_highapptemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "highapptemptime", defaultTS); + monthlyrecarray[WeatherStation.AT_highapptemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "highapptemptime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_lowapptemp, month].data_type = WeatherStation.AT_lowapptemp; monthlyrecarray[WeatherStation.AT_lowapptemp, month].value = ini.GetValue("Temperature" + monthstr, "lowapptempvalue", 999.0); - monthlyrecarray[WeatherStation.AT_lowapptemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowapptemptime", defaultTS); + monthlyrecarray[WeatherStation.AT_lowapptemp, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowapptemptime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highheatindex, month].data_type = WeatherStation.AT_highheatindex; monthlyrecarray[WeatherStation.AT_highheatindex, month].value = ini.GetValue("Temperature" + monthstr, "highheatindexvalue", -999.0); - monthlyrecarray[WeatherStation.AT_highheatindex, month].timestamp = ini.GetValue("Temperature" + monthstr, "highheatindextime", defaultTS); + monthlyrecarray[WeatherStation.AT_highheatindex, month].timestamp = ini.GetValue("Temperature" + monthstr, "highheatindextime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highdewpoint, month].data_type = WeatherStation.AT_highdewpoint; monthlyrecarray[WeatherStation.AT_highdewpoint, month].value = ini.GetValue("Temperature" + monthstr, "highdewpointvalue", -999.0); - monthlyrecarray[WeatherStation.AT_highdewpoint, month].timestamp = ini.GetValue("Temperature" + monthstr, "highdewpointtime", defaultTS); + monthlyrecarray[WeatherStation.AT_highdewpoint, month].timestamp = ini.GetValue("Temperature" + monthstr, "highdewpointtime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_lowdewpoint, month].data_type = WeatherStation.AT_lowdewpoint; monthlyrecarray[WeatherStation.AT_lowdewpoint, month].value = ini.GetValue("Temperature" + monthstr, "lowdewpointvalue", 999.0); - monthlyrecarray[WeatherStation.AT_lowdewpoint, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowdewpointtime", defaultTS); + monthlyrecarray[WeatherStation.AT_lowdewpoint, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowdewpointtime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highdailytemprange, month].data_type = WeatherStation.AT_highdailytemprange; monthlyrecarray[WeatherStation.AT_highdailytemprange, month].value = ini.GetValue("Temperature" + monthstr, "hightemprangevalue", 0.0); - monthlyrecarray[WeatherStation.AT_highdailytemprange, month].timestamp = ini.GetValue("Temperature" + monthstr, "hightemprangetime", defaultTS); + monthlyrecarray[WeatherStation.AT_highdailytemprange, month].timestamp = ini.GetValue("Temperature" + monthstr, "hightemprangetime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_lowdailytemprange, month].data_type = WeatherStation.AT_lowdailytemprange; monthlyrecarray[WeatherStation.AT_lowdailytemprange, month].value = ini.GetValue("Temperature" + monthstr, "lowtemprangevalue", 999.0); - monthlyrecarray[WeatherStation.AT_lowdailytemprange, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowtemprangetime", defaultTS); + monthlyrecarray[WeatherStation.AT_lowdailytemprange, month].timestamp = ini.GetValue("Temperature" + monthstr, "lowtemprangetime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highwind, month].data_type = WeatherStation.AT_highwind; monthlyrecarray[WeatherStation.AT_highwind, month].value = ini.GetValue("Wind" + monthstr, "highwindvalue", 0.0); - monthlyrecarray[WeatherStation.AT_highwind, month].timestamp = ini.GetValue("Wind" + monthstr, "highwindtime", defaultTS); + monthlyrecarray[WeatherStation.AT_highwind, month].timestamp = ini.GetValue("Wind" + monthstr, "highwindtime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highgust, month].data_type = WeatherStation.AT_highgust; monthlyrecarray[WeatherStation.AT_highgust, month].value = ini.GetValue("Wind" + monthstr, "highgustvalue", 0.0); - monthlyrecarray[WeatherStation.AT_highgust, month].timestamp = ini.GetValue("Wind" + monthstr, "highgusttime", defaultTS); + monthlyrecarray[WeatherStation.AT_highgust, month].timestamp = ini.GetValue("Wind" + monthstr, "highgusttime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highwindrun, month].data_type = WeatherStation.AT_highwindrun; monthlyrecarray[WeatherStation.AT_highwindrun, month].value = ini.GetValue("Wind" + monthstr, "highdailywindrunvalue", 0.0); - monthlyrecarray[WeatherStation.AT_highwindrun, month].timestamp = ini.GetValue("Wind" + monthstr, "highdailywindruntime", defaultTS); + monthlyrecarray[WeatherStation.AT_highwindrun, month].timestamp = ini.GetValue("Wind" + monthstr, "highdailywindruntime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highrainrate, month].data_type = WeatherStation.AT_highrainrate; monthlyrecarray[WeatherStation.AT_highrainrate, month].value = ini.GetValue("Rain" + monthstr, "highrainratevalue", 0.0); - monthlyrecarray[WeatherStation.AT_highrainrate, month].timestamp = ini.GetValue("Rain" + monthstr, "highrainratetime", defaultTS); + monthlyrecarray[WeatherStation.AT_highrainrate, month].timestamp = ini.GetValue("Rain" + monthstr, "highrainratetime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_dailyrain, month].data_type = WeatherStation.AT_dailyrain; monthlyrecarray[WeatherStation.AT_dailyrain, month].value = ini.GetValue("Rain" + monthstr, "highdailyrainvalue", 0.0); - monthlyrecarray[WeatherStation.AT_dailyrain, month].timestamp = ini.GetValue("Rain" + monthstr, "highdailyraintime", defaultTS); + monthlyrecarray[WeatherStation.AT_dailyrain, month].timestamp = ini.GetValue("Rain" + monthstr, "highdailyraintime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_hourlyrain, month].data_type = WeatherStation.AT_hourlyrain; monthlyrecarray[WeatherStation.AT_hourlyrain, month].value = ini.GetValue("Rain" + monthstr, "highhourlyrainvalue", 0.0); - monthlyrecarray[WeatherStation.AT_hourlyrain, month].timestamp = ini.GetValue("Rain" + monthstr, "highhourlyraintime", defaultTS); + monthlyrecarray[WeatherStation.AT_hourlyrain, month].timestamp = ini.GetValue("Rain" + monthstr, "highhourlyraintime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_wetmonth, month].data_type = WeatherStation.AT_wetmonth; monthlyrecarray[WeatherStation.AT_wetmonth, month].value = ini.GetValue("Rain" + monthstr, "highmonthlyrainvalue", 0.0); - monthlyrecarray[WeatherStation.AT_wetmonth, month].timestamp = ini.GetValue("Rain" + monthstr, "highmonthlyraintime", defaultTS); + monthlyrecarray[WeatherStation.AT_wetmonth, month].timestamp = ini.GetValue("Rain" + monthstr, "highmonthlyraintime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_longestdryperiod, month].data_type = WeatherStation.AT_longestdryperiod; monthlyrecarray[WeatherStation.AT_longestdryperiod, month].value = ini.GetValue("Rain" + monthstr, "longestdryperiodvalue", 0); - monthlyrecarray[WeatherStation.AT_longestdryperiod, month].timestamp = ini.GetValue("Rain" + monthstr, "longestdryperiodtime", defaultTS); + monthlyrecarray[WeatherStation.AT_longestdryperiod, month].timestamp = ini.GetValue("Rain" + monthstr, "longestdryperiodtime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_longestwetperiod, month].data_type = WeatherStation.AT_longestwetperiod; monthlyrecarray[WeatherStation.AT_longestwetperiod, month].value = ini.GetValue("Rain" + monthstr, "longestwetperiodvalue", 0); - monthlyrecarray[WeatherStation.AT_longestwetperiod, month].timestamp = ini.GetValue("Rain" + monthstr, "longestwetperiodtime", defaultTS); + monthlyrecarray[WeatherStation.AT_longestwetperiod, month].timestamp = ini.GetValue("Rain" + monthstr, "longestwetperiodtime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highpress, month].data_type = WeatherStation.AT_highpress; monthlyrecarray[WeatherStation.AT_highpress, month].value = ini.GetValue("Pressure" + monthstr, "highpressurevalue", 0.0); - monthlyrecarray[WeatherStation.AT_highpress, month].timestamp = ini.GetValue("Pressure" + monthstr, "highpressuretime", defaultTS); + monthlyrecarray[WeatherStation.AT_highpress, month].timestamp = ini.GetValue("Pressure" + monthstr, "highpressuretime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_lowpress, month].data_type = WeatherStation.AT_lowpress; monthlyrecarray[WeatherStation.AT_lowpress, month].value = ini.GetValue("Pressure" + monthstr, "lowpressurevalue", 9999.0); - monthlyrecarray[WeatherStation.AT_lowpress, month].timestamp = ini.GetValue("Pressure" + monthstr, "lowpressuretime", defaultTS); + monthlyrecarray[WeatherStation.AT_lowpress, month].timestamp = ini.GetValue("Pressure" + monthstr, "lowpressuretime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_highhumidity, month].data_type = WeatherStation.AT_highhumidity; monthlyrecarray[WeatherStation.AT_highhumidity, month].value = ini.GetValue("Humidity" + monthstr, "highhumidityvalue", 0.0); - monthlyrecarray[WeatherStation.AT_highhumidity, month].timestamp = ini.GetValue("Humidity" + monthstr, "highhumiditytime", defaultTS); + monthlyrecarray[WeatherStation.AT_highhumidity, month].timestamp = ini.GetValue("Humidity" + monthstr, "highhumiditytime", cumulus.defaultRecordTS); monthlyrecarray[WeatherStation.AT_lowhumidity, month].data_type = WeatherStation.AT_lowhumidity; monthlyrecarray[WeatherStation.AT_lowhumidity, month].value = ini.GetValue("Humidity" + monthstr, "lowhumidityvalue", 999.0); - monthlyrecarray[WeatherStation.AT_lowhumidity, month].timestamp = ini.GetValue("Humidity" + monthstr, "lowhumiditytime", defaultTS); + monthlyrecarray[WeatherStation.AT_lowhumidity, month].timestamp = ini.GetValue("Humidity" + monthstr, "lowhumiditytime", cumulus.defaultRecordTS); } cumulus.LogMessage("MonthlyAlltime.ini file read"); @@ -7019,28 +7031,28 @@ public void SetDefaultMonthlyHighsAndLows() HighDailyTempRangeThisMonth = -999; // this Month highs and lows - timestamps - HighGustThisMonthTS = DateTime.Now; - HighWindThisMonthTS = DateTime.Now; - HighTempThisMonthTS = DateTime.Now; - LowTempThisMonthTS = DateTime.Now; - HighAppTempThisMonthTS = DateTime.Now; - LowAppTempThisMonthTS = DateTime.Now; - HighDewpointThisMonthTS = DateTime.Now; - LowDewpointThisMonthTS = DateTime.Now; - HighPressThisMonthTS = DateTime.Now; - LowPressThisMonthTS = DateTime.Now; - HighRainThisMonthTS = DateTime.Now; - HighHourlyRainThisMonthTS = DateTime.Now; - HighDailyRainThisMonthTS = DateTime.Now; - HighHumidityThisMonthTS = DateTime.Now; - LowHumidityThisMonthTS = DateTime.Now; - HighHeatIndexThisMonthTS = DateTime.Now; - LowWindChillThisMonthTS = DateTime.Now; - HighMinTempThisMonthTS = DateTime.Now; - LowMaxTempThisMonthTS = DateTime.Now; - HighDailyRainThisMonthTS = DateTime.Now; - LowDailyTempRangeThisMonthTS = DateTime.Now; - HighDailyTempRangeThisMonthTS = DateTime.Now; + HighGustThisMonthTS = cumulus.defaultRecordTS; + HighWindThisMonthTS = cumulus.defaultRecordTS; + HighTempThisMonthTS = cumulus.defaultRecordTS; + LowTempThisMonthTS = cumulus.defaultRecordTS; + HighAppTempThisMonthTS = cumulus.defaultRecordTS; + LowAppTempThisMonthTS = cumulus.defaultRecordTS; + HighDewpointThisMonthTS = cumulus.defaultRecordTS; + LowDewpointThisMonthTS = cumulus.defaultRecordTS; + HighPressThisMonthTS = cumulus.defaultRecordTS; + LowPressThisMonthTS = cumulus.defaultRecordTS; + HighRainThisMonthTS = cumulus.defaultRecordTS; + HighHourlyRainThisMonthTS = cumulus.defaultRecordTS; + HighDailyRainThisMonthTS = cumulus.defaultRecordTS; + HighHumidityThisMonthTS = cumulus.defaultRecordTS; + LowHumidityThisMonthTS = cumulus.defaultRecordTS; + HighHeatIndexThisMonthTS = cumulus.defaultRecordTS; + LowWindChillThisMonthTS = cumulus.defaultRecordTS; + HighMinTempThisMonthTS = cumulus.defaultRecordTS; + LowMaxTempThisMonthTS = cumulus.defaultRecordTS; + HighDailyRainThisMonthTS = cumulus.defaultRecordTS; + LowDailyTempRangeThisMonthTS = cumulus.defaultRecordTS; + HighDailyTempRangeThisMonthTS = cumulus.defaultRecordTS; } public void ReadMonthIniFile() @@ -7049,8 +7061,6 @@ public void ReadMonthIniFile() SetDefaultMonthlyHighsAndLows(); - DateTime defaultTS = new DateTime(2000, 1, 1, 0, 0, 0); - if (File.Exists(cumulus.MonthIniFile)) { int hourInc = cumulus.GetHourInc(); @@ -7058,64 +7068,64 @@ public void ReadMonthIniFile() IniFile ini = new IniFile(cumulus.MonthIniFile); // Date - timestamp = ini.GetValue("General", "Date", defaultTS); + timestamp = ini.GetValue("General", "Date", cumulus.defaultRecordTS); HighWindThisMonth = ini.GetValue("Wind", "Speed", 0.0); - HighWindThisMonthTS = ini.GetValue("Wind", "SpTime", defaultTS); + HighWindThisMonthTS = ini.GetValue("Wind", "SpTime", cumulus.defaultRecordTS); HighGustThisMonth = ini.GetValue("Wind", "Gust", 0.0); - HighGustThisMonthTS = ini.GetValue("Wind", "Time", defaultTS); + HighGustThisMonthTS = ini.GetValue("Wind", "Time", cumulus.defaultRecordTS); HighDailyWindrunThisMonth = ini.GetValue("Wind", "Windrun", 0.0); - HighDailyWindrunThisMonthTS = ini.GetValue("Wind", "WindrunTime", defaultTS); + HighDailyWindrunThisMonthTS = ini.GetValue("Wind", "WindrunTime", cumulus.defaultRecordTS); // Temperature LowTempThisMonth = ini.GetValue("Temp", "Low", 999.0); - LowTempThisMonthTS = ini.GetValue("Temp", "LTime", defaultTS); + LowTempThisMonthTS = ini.GetValue("Temp", "LTime", cumulus.defaultRecordTS); HighTempThisMonth = ini.GetValue("Temp", "High", -999.0); - HighTempThisMonthTS = ini.GetValue("Temp", "HTime", defaultTS); + HighTempThisMonthTS = ini.GetValue("Temp", "HTime", cumulus.defaultRecordTS); LowMaxTempThisMonth = ini.GetValue("Temp", "LowMax", 999.0); - LowMaxTempThisMonthTS = ini.GetValue("Temp", "LMTime", defaultTS); + LowMaxTempThisMonthTS = ini.GetValue("Temp", "LMTime", cumulus.defaultRecordTS); HighMinTempThisMonth = ini.GetValue("Temp", "HighMin", -999.0); - HighMinTempThisMonthTS = ini.GetValue("Temp", "HMTime", defaultTS); + HighMinTempThisMonthTS = ini.GetValue("Temp", "HMTime", cumulus.defaultRecordTS); LowDailyTempRangeThisMonth = ini.GetValue("Temp", "LowRange", 999.0); - LowDailyTempRangeThisMonthTS = ini.GetValue("Temp", "LowRangeTime", defaultTS); + LowDailyTempRangeThisMonthTS = ini.GetValue("Temp", "LowRangeTime", cumulus.defaultRecordTS); HighDailyTempRangeThisMonth = ini.GetValue("Temp", "HighRange", -999.0); - HighDailyTempRangeThisMonthTS = ini.GetValue("Temp", "HighRangeTime", defaultTS); + HighDailyTempRangeThisMonthTS = ini.GetValue("Temp", "HighRangeTime", cumulus.defaultRecordTS); // Pressure LowPressThisMonth = ini.GetValue("Pressure", "Low", 9999.0); - LowPressThisMonthTS = ini.GetValue("Pressure", "LTime", defaultTS); + LowPressThisMonthTS = ini.GetValue("Pressure", "LTime", cumulus.defaultRecordTS); HighPressThisMonth = ini.GetValue("Pressure", "High", -9999.0); - HighPressThisMonthTS = ini.GetValue("Pressure", "HTime", defaultTS); + HighPressThisMonthTS = ini.GetValue("Pressure", "HTime", cumulus.defaultRecordTS); // rain rate HighRainThisMonth = ini.GetValue("Rain", "High", 0.0); - HighRainThisMonthTS = ini.GetValue("Rain", "HTime", defaultTS); + HighRainThisMonthTS = ini.GetValue("Rain", "HTime", cumulus.defaultRecordTS); HighHourlyRainThisMonth = ini.GetValue("Rain", "HourlyHigh", 0.0); - HighHourlyRainThisMonthTS = ini.GetValue("Rain", "HHourlyTime", defaultTS); + HighHourlyRainThisMonthTS = ini.GetValue("Rain", "HHourlyTime", cumulus.defaultRecordTS); HighDailyRainThisMonth = ini.GetValue("Rain", "DailyHigh", 0.0); - HighDailyRainThisMonthTS = ini.GetValue("Rain", "HDailyTime", defaultTS); + HighDailyRainThisMonthTS = ini.GetValue("Rain", "HDailyTime", cumulus.defaultRecordTS); LongestDryPeriodThisMonth = ini.GetValue("Rain", "LongestDryPeriod", 0); - LongestDryPeriodThisMonthTS = ini.GetValue("Rain", "LongestDryPeriodTime", defaultTS); + LongestDryPeriodThisMonthTS = ini.GetValue("Rain", "LongestDryPeriodTime", cumulus.defaultRecordTS); LongestWetPeriodThisMonth = ini.GetValue("Rain", "LongestWetPeriod", 0); - LongestWetPeriodThisMonthTS = ini.GetValue("Rain", "LongestWetPeriodTime", defaultTS); + LongestWetPeriodThisMonthTS = ini.GetValue("Rain", "LongestWetPeriodTime", cumulus.defaultRecordTS); // humidity LowHumidityThisMonth = ini.GetValue("Humidity", "Low", 999); - LowHumidityThisMonthTS = ini.GetValue("Humidity", "LTime", defaultTS); + LowHumidityThisMonthTS = ini.GetValue("Humidity", "LTime", cumulus.defaultRecordTS); HighHumidityThisMonth = ini.GetValue("Humidity", "High", -999); - HighHumidityThisMonthTS = ini.GetValue("Humidity", "HTime", defaultTS); + HighHumidityThisMonthTS = ini.GetValue("Humidity", "HTime", cumulus.defaultRecordTS); // heat index HighHeatIndexThisMonth = ini.GetValue("HeatIndex", "High", -999.0); - HighHeatIndexThisMonthTS = ini.GetValue("HeatIndex", "HTime", defaultTS); + HighHeatIndexThisMonthTS = ini.GetValue("HeatIndex", "HTime", cumulus.defaultRecordTS); // App temp LowAppTempThisMonth = ini.GetValue("AppTemp", "Low", 999.0); - LowAppTempThisMonthTS = ini.GetValue("AppTemp", "LTime", defaultTS); + LowAppTempThisMonthTS = ini.GetValue("AppTemp", "LTime", cumulus.defaultRecordTS); HighAppTempThisMonth = ini.GetValue("AppTemp", "High", -999.0); - HighAppTempThisMonthTS = ini.GetValue("AppTemp", "HTime", defaultTS); + HighAppTempThisMonthTS = ini.GetValue("AppTemp", "HTime", cumulus.defaultRecordTS); // Dewpoint LowDewpointThisMonth = ini.GetValue("Dewpoint", "Low", 999.0); - LowDewpointThisMonthTS = ini.GetValue("Dewpoint", "LTime", defaultTS); + LowDewpointThisMonthTS = ini.GetValue("Dewpoint", "LTime", cumulus.defaultRecordTS); HighDewpointThisMonth = ini.GetValue("Dewpoint", "High", -999.0); - HighDewpointThisMonthTS = ini.GetValue("Dewpoint", "HTime", defaultTS); + HighDewpointThisMonthTS = ini.GetValue("Dewpoint", "HTime", cumulus.defaultRecordTS); // wind chill LowWindChillThisMonth = ini.GetValue("WindChill", "Low", 999.0); - LowWindChillThisMonthTS = ini.GetValue("WindChill", "LTime", defaultTS); + LowWindChillThisMonthTS = ini.GetValue("WindChill", "LTime", cumulus.defaultRecordTS); cumulus.LogMessage("Month.ini file read"); } @@ -7206,8 +7216,6 @@ public void ReadYearIniFile() SetDefaultYearlyHighsAndLows(); - DateTime defaultTS = new DateTime(2000, 1, 1, 0, 0, 0); - if (File.Exists(cumulus.YearIniFile)) { int hourInc = cumulus.GetHourInc(); @@ -7215,66 +7223,66 @@ public void ReadYearIniFile() IniFile ini = new IniFile(cumulus.YearIniFile); // Date - timestamp = ini.GetValue("General", "Date", defaultTS); + timestamp = ini.GetValue("General", "Date", cumulus.defaultRecordTS); HighWindThisYear = ini.GetValue("Wind", "Speed", 0.0); - HighWindThisYearTS = ini.GetValue("Wind", "SpTime", defaultTS); + HighWindThisYearTS = ini.GetValue("Wind", "SpTime", cumulus.defaultRecordTS); HighGustThisYear = ini.GetValue("Wind", "Gust", 0.0); - HighGustThisYearTS = ini.GetValue("Wind", "Time", defaultTS); + HighGustThisYearTS = ini.GetValue("Wind", "Time", cumulus.defaultRecordTS); HighDailyWindrunThisYear = ini.GetValue("Wind", "Windrun", 0.0); - HighDailyWindrunThisYearTS = ini.GetValue("Wind", "WindrunTime", defaultTS); + HighDailyWindrunThisYearTS = ini.GetValue("Wind", "WindrunTime", cumulus.defaultRecordTS); // Temperature LowTempThisYear = ini.GetValue("Temp", "Low", 999.0); - LowTempThisYearTS = ini.GetValue("Temp", "LTime", defaultTS); + LowTempThisYearTS = ini.GetValue("Temp", "LTime", cumulus.defaultRecordTS); HighTempThisYear = ini.GetValue("Temp", "High", -999.0); - HighTempThisYearTS = ini.GetValue("Temp", "HTime", defaultTS); + HighTempThisYearTS = ini.GetValue("Temp", "HTime", cumulus.defaultRecordTS); LowMaxTempThisYear = ini.GetValue("Temp", "LowMax", 999.0); - LowMaxTempThisYearTS = ini.GetValue("Temp", "LMTime", defaultTS); + LowMaxTempThisYearTS = ini.GetValue("Temp", "LMTime", cumulus.defaultRecordTS); HighMinTempThisYear = ini.GetValue("Temp", "HighMin", -999.0); - HighMinTempThisYearTS = ini.GetValue("Temp", "HMTime", defaultTS); + HighMinTempThisYearTS = ini.GetValue("Temp", "HMTime", cumulus.defaultRecordTS); LowDailyTempRangeThisYear = ini.GetValue("Temp", "LowRange", 999.0); - LowDailyTempRangeThisYearTS = ini.GetValue("Temp", "LowRangeTime", defaultTS); + LowDailyTempRangeThisYearTS = ini.GetValue("Temp", "LowRangeTime", cumulus.defaultRecordTS); HighDailyTempRangeThisYear = ini.GetValue("Temp", "HighRange", -999.0); - HighDailyTempRangeThisYearTS = ini.GetValue("Temp", "HighRangeTime", defaultTS); + HighDailyTempRangeThisYearTS = ini.GetValue("Temp", "HighRangeTime", cumulus.defaultRecordTS); // Pressure LowPressThisYear = ini.GetValue("Pressure", "Low", 9999.0); - LowPressThisYearTS = ini.GetValue("Pressure", "LTime", defaultTS); + LowPressThisYearTS = ini.GetValue("Pressure", "LTime", cumulus.defaultRecordTS); HighPressThisYear = ini.GetValue("Pressure", "High", -9999.0); - HighPressThisYearTS = ini.GetValue("Pressure", "HTime", defaultTS); + HighPressThisYearTS = ini.GetValue("Pressure", "HTime", cumulus.defaultRecordTS); // rain rate HighRainThisYear = ini.GetValue("Rain", "High", 0.0); - HighRainThisYearTS = ini.GetValue("Rain", "HTime", defaultTS); + HighRainThisYearTS = ini.GetValue("Rain", "HTime", cumulus.defaultRecordTS); HighHourlyRainThisYear = ini.GetValue("Rain", "HourlyHigh", 0.0); - HighHourlyRainThisYearTS = ini.GetValue("Rain", "HHourlyTime", defaultTS); + HighHourlyRainThisYearTS = ini.GetValue("Rain", "HHourlyTime", cumulus.defaultRecordTS); HighDailyRainThisYear = ini.GetValue("Rain", "DailyHigh", 0.0); - HighDailyRainThisYearTS = ini.GetValue("Rain", "HDailyTime", defaultTS); + HighDailyRainThisYearTS = ini.GetValue("Rain", "HDailyTime", cumulus.defaultRecordTS); HighMonthlyRainThisYear = ini.GetValue("Rain", "MonthlyHigh", 0.0); - HighMonthlyRainThisYearTS = ini.GetValue("Rain", "HMonthlyTime", defaultTS); + HighMonthlyRainThisYearTS = ini.GetValue("Rain", "HMonthlyTime", cumulus.defaultRecordTS); LongestDryPeriodThisYear = ini.GetValue("Rain", "LongestDryPeriod", 0); - LongestDryPeriodThisYearTS = ini.GetValue("Rain", "LongestDryPeriodTime", defaultTS); + LongestDryPeriodThisYearTS = ini.GetValue("Rain", "LongestDryPeriodTime", cumulus.defaultRecordTS); LongestWetPeriodThisYear = ini.GetValue("Rain", "LongestWetPeriod", 0); - LongestWetPeriodThisYearTS = ini.GetValue("Rain", "LongestWetPeriodTime", defaultTS); + LongestWetPeriodThisYearTS = ini.GetValue("Rain", "LongestWetPeriodTime", cumulus.defaultRecordTS); // humidity LowHumidityThisYear = ini.GetValue("Humidity", "Low", 999); - LowHumidityThisYearTS = ini.GetValue("Humidity", "LTime", defaultTS); + LowHumidityThisYearTS = ini.GetValue("Humidity", "LTime", cumulus.defaultRecordTS); HighHumidityThisYear = ini.GetValue("Humidity", "High", -999); - HighHumidityThisYearTS = ini.GetValue("Humidity", "HTime", defaultTS); + HighHumidityThisYearTS = ini.GetValue("Humidity", "HTime", cumulus.defaultRecordTS); // heat index HighHeatIndexThisYear = ini.GetValue("HeatIndex", "High", -999.0); - HighHeatIndexThisYearTS = ini.GetValue("HeatIndex", "HTime", defaultTS); + HighHeatIndexThisYearTS = ini.GetValue("HeatIndex", "HTime", cumulus.defaultRecordTS); // App temp LowAppTempThisYear = ini.GetValue("AppTemp", "Low", 999.0); - LowAppTempThisYearTS = ini.GetValue("AppTemp", "LTime", defaultTS); + LowAppTempThisYearTS = ini.GetValue("AppTemp", "LTime", cumulus.defaultRecordTS); HighAppTempThisYear = ini.GetValue("AppTemp", "High", -999.0); - HighAppTempThisYearTS = ini.GetValue("AppTemp", "HTime", defaultTS); + HighAppTempThisYearTS = ini.GetValue("AppTemp", "HTime", cumulus.defaultRecordTS); // Dewpoint LowDewpointThisYear = ini.GetValue("Dewpoint", "Low", 999.0); - LowDewpointThisYearTS = ini.GetValue("Dewpoint", "LTime", defaultTS); + LowDewpointThisYearTS = ini.GetValue("Dewpoint", "LTime", cumulus.defaultRecordTS); HighDewpointThisYear = ini.GetValue("Dewpoint", "High", -999.0); - HighDewpointThisYearTS = ini.GetValue("Dewpoint", "HTime", defaultTS); + HighDewpointThisYearTS = ini.GetValue("Dewpoint", "HTime", cumulus.defaultRecordTS); // wind chill LowWindChillThisYear = ini.GetValue("WindChill", "Low", 999.0); - LowWindChillThisYearTS = ini.GetValue("WindChill", "LTime", defaultTS); + LowWindChillThisYearTS = ini.GetValue("WindChill", "LTime", cumulus.defaultRecordTS); cumulus.LogMessage("Year.ini file read"); } @@ -7389,29 +7397,29 @@ public void SetDefaultYearlyHighsAndLows() HighDailyTempRangeThisYear = -999; // this Year highs and lows - timestamps - HighGustThisYearTS = DateTime.Now; - HighWindThisYearTS = DateTime.Now; - HighTempThisYearTS = DateTime.Now; - LowTempThisYearTS = DateTime.Now; - HighAppTempThisYearTS = DateTime.Now; - LowAppTempThisYearTS = DateTime.Now; - HighDewpointThisYearTS = DateTime.Now; - LowDewpointThisYearTS = DateTime.Now; - HighPressThisYearTS = DateTime.Now; - LowPressThisYearTS = DateTime.Now; - HighRainThisYearTS = DateTime.Now; - HighHourlyRainThisYearTS = DateTime.Now; - HighDailyRainThisYearTS = DateTime.Now; - HighMonthlyRainThisYearTS = DateTime.Now; - HighHumidityThisYearTS = DateTime.Now; - LowHumidityThisYearTS = DateTime.Now; - HighHeatIndexThisYearTS = DateTime.Now; - LowWindChillThisYearTS = DateTime.Now; - HighMinTempThisYearTS = DateTime.Now; - LowMaxTempThisYearTS = DateTime.Now; - HighDailyRainThisYearTS = DateTime.Now; - LowDailyTempRangeThisYearTS = DateTime.Now; - HighDailyTempRangeThisYearTS = DateTime.Now; + HighGustThisYearTS = cumulus.defaultRecordTS; + HighWindThisYearTS = cumulus.defaultRecordTS; + HighTempThisYearTS = cumulus.defaultRecordTS; + LowTempThisYearTS = cumulus.defaultRecordTS; + HighAppTempThisYearTS = cumulus.defaultRecordTS; + LowAppTempThisYearTS = cumulus.defaultRecordTS; + HighDewpointThisYearTS = cumulus.defaultRecordTS; + LowDewpointThisYearTS = cumulus.defaultRecordTS; + HighPressThisYearTS = cumulus.defaultRecordTS; + LowPressThisYearTS = cumulus.defaultRecordTS; + HighRainThisYearTS = cumulus.defaultRecordTS; + HighHourlyRainThisYearTS = cumulus.defaultRecordTS; + HighDailyRainThisYearTS = cumulus.defaultRecordTS; + HighMonthlyRainThisYearTS = cumulus.defaultRecordTS; + HighHumidityThisYearTS = cumulus.defaultRecordTS; + LowHumidityThisYearTS = cumulus.defaultRecordTS; + HighHeatIndexThisYearTS = cumulus.defaultRecordTS; + LowWindChillThisYearTS = cumulus.defaultRecordTS; + HighMinTempThisYearTS = cumulus.defaultRecordTS; + LowMaxTempThisYearTS = cumulus.defaultRecordTS; + HighDailyRainThisYearTS = cumulus.defaultRecordTS; + LowDailyTempRangeThisYearTS = cumulus.defaultRecordTS; + HighDailyTempRangeThisYearTS = cumulus.defaultRecordTS; } public string GetWCloudURL(out string pwstring, DateTime timestamp) diff --git a/CumulusMX/packages.config b/CumulusMX/packages.config index 7bea9b5e..ee0384f7 100644 --- a/CumulusMX/packages.config +++ b/CumulusMX/packages.config @@ -1,9 +1,8 @@  - - - + + diff --git a/CumulusMX/webtags.cs b/CumulusMX/webtags.cs index 951a1d1f..986506a2 100644 --- a/CumulusMX/webtags.cs +++ b/CumulusMX/webtags.cs @@ -246,7 +246,7 @@ private string GetFormattedDateTime(DateTime dt, Dictionary TagPa private string GetFormattedDateTime(DateTime dt, string defaultFormat, Dictionary TagParams) { string s; - if (dt <= DateTime.MinValue) + if (dt <= cumulus.defaultRecordTS) { s = "----"; } @@ -283,7 +283,7 @@ private string GetFormattedDateTime(string dtstr, Dictionary TagP private string GetMonthlyAlltimeValueStr(int identifier, int month, string format) { - if (station.monthlyrecarray[identifier, month].timestamp <= DateTime.MinValue) + if (station.monthlyrecarray[identifier, month].timestamp <= cumulus.defaultRecordTS) { return "---"; } @@ -295,7 +295,7 @@ private string GetMonthlyAlltimeValueStr(int identifier, int month, string forma private string GetMonthlyAlltimeTSStr(int identifier, int month, string format) { - if (station.monthlyrecarray[identifier, month].timestamp <= DateTime.MinValue) + if (station.monthlyrecarray[identifier, month].timestamp <= cumulus.defaultRecordTS) { return "----"; } @@ -2489,20 +2489,59 @@ private string TagLatestNOAAYearlyReport(Dictionary TagParams) private string TagMoonPercent(Dictionary TagParams) { - return ((int)cumulus.MoonPercent).ToString(); - } + var dpstr = TagParams.Get("dp"); + var rcstr = TagParams.Get("rc"); + int i, dp = 0; + string res; + + dp = Int32.TryParse(dpstr, out i) ? i : 0; + + res = Math.Round(cumulus.MoonPercent, dp).ToString(); + + if (rcstr == "y") + { + res = ReplaceCommas(res); + } + return res; + } private string TagMoonPercentAbs(Dictionary TagParams) { - return ((int)Math.Abs(cumulus.MoonPercent)).ToString(); - } + var dpstr = TagParams.Get("dp"); + var rcstr = TagParams.Get("rc"); + int i, dp = 0; + string res; + + dp = Int32.TryParse(dpstr, out i) ? i : 0; + + res = Math.Round(Math.Abs(cumulus.MoonPercent), dp).ToString(); - private string TagMoonAge(Dictionary TagParams) + if (rcstr == "y") + { + res = ReplaceCommas(res); + } + return res; + } + + private string TagMoonAge(Dictionary TagParams) { - return ((int) cumulus.MoonAge).ToString(); - } + var dpstr = TagParams.Get("dp"); + var rcstr = TagParams.Get("rc"); + int i, dp; + string res; + + dp = Int32.TryParse(dpstr, out i) ? i : 0; - private string TagLastRainTipISO(Dictionary TagParams) + res = Math.Round(cumulus.MoonAge, dp).ToString(); + + if (rcstr == "y") + { + res = ReplaceCommas(res); + } + return res; + } + + private string TagLastRainTipISO(Dictionary TagParams) { return GetFormattedDateTime(station.LastRainTip, TagParams); } @@ -3703,7 +3742,7 @@ private string TagYearHourlyRainHD(Dictionary TagParams) private string TagYearHighDailyTempRangeD(Dictionary TagParams) { - if (station.HighDailyTempRangeThisYear < 999) + if (station.HighDailyTempRangeThisYear > -999) { return GetFormattedDateTime(station.HighDailyTempRangeThisYearTS, "dd MMMM", TagParams); } @@ -3712,7 +3751,7 @@ private string TagYearHighDailyTempRangeD(Dictionary TagParams) private string TagYearLowDailyTempRangeD(Dictionary TagParams) { - if (station.LowDailyTempRangeThisYear > -999) + if (station.LowDailyTempRangeThisYear > 999) { return GetFormattedDateTime(station.LowDailyTempRangeThisYearTS, "dd MMMM", TagParams); } diff --git a/Updates.txt b/Updates.txt index ddd920fb..fcf42e1c 100644 --- a/Updates.txt +++ b/Updates.txt @@ -9,7 +9,7 @@ - Updated HidSharp to ver 2.0.5 - Now uses libudev1 for Fine Offset and WMR200 stations -- Fixed corrupt/missing MySQL port causing CumulusMX to crash on startup +- Fixed corrupt/missing MySQL port causing CumulusMX to crash on start-up - Attempt to reconnect to Davis IP logger on connection failure (only a possible fix) @@ -84,12 +84,12 @@ - Web Tags - Added <#snowdepth> tag processing -- ET annual rollover fix +- ET annual roll-over fix - Fix to TLS 1.2 FTPS of the 'periodic' files -3047test -======== +3047 +==== - Web token parser updated to cope with html tag characters "<>" in the format string. - You can now do things like... <#TapptempH format="dd' 'MMM' 'yyyy' at 'HH:mm''"> @@ -98,3 +98,50 @@ Note: that you have to use single quotes for HTML entity names, and they have to be escaped "\'" +- New Davis Baud Rate setting + - Allows you to alter the speed of the serial connection to Davis loggers + - Configured manually in Cumulus.ini [Station] section + DavisBaudRate=19200 (default) Permitted values are 1200, 2400, 4800, 9600, 14400, 19200 + +- Added new option for the "Extra files" - End of Day + - Enabling this means that file will only be processed/copied/FTPed once a day during the end of day roll-over. + - There is a new Cumulus.ini file setting for each "extra" file associated with this setting + ExtraEOD[nn] + - Note there is currently no check between Realtime and End of Day settings, you could check both options and the file + will be processed at both the realtime interval AND end of day - which would not make much sense! + +- Improvement to Instromet logger protocol handling + +- Change the Fine Offset Synchronised Reads option to default to enabled + +- Change VP2 automatic disabling of LOOP2 to an advisory message, as the firmware version is not always detected. + +- Consistency: All record Value tags should now return '---' and Date tags '----' until they are first set. + +- The following web tags now support the "dp=N" "rc=y" parameters for the number of decimal places, and replace decimal commas with points. + #MoonPercent + #MoonPercentAbs + #MoonAge + +- Fix for Fine Offset & WMR100/200 stations on Mac operating systems (introduced in b3044) + +- Fix for invalid (extremely high) pressure readings from Fine Offset stations (thanks to 79669weather) + +- Fix to not updating the Instromet loggers memory pointer correctly + +- Fixed Weather Diary Time Zone issues + +- Bug fixes and performance improvements to the FTP component + +- Updated files + \CumulusMX.exe + \CumulusMX.exe.config + \CumulusMX.pub + \FluentFTP.dll + \HidSharp.dll + \interface\js\diaryeditor.js + \interface\json\StationOptions.json + +- Removed files + \fastJSON.dll +