From a6504fe00ae578c0c8a8345d68eaa02b633f355d Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Tue, 14 Jun 2022 11:50:05 +0100
Subject: [PATCH 01/21] Package updates
---
CumulusMX/App.config | 6 +++++-
CumulusMX/CumulusMX.csproj | 22 +++++++++++-----------
CumulusMX/packages.config | 12 ++++++------
3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/CumulusMX/App.config b/CumulusMX/App.config
index 6996fdc6..024653f4 100644
--- a/CumulusMX/App.config
+++ b/CumulusMX/App.config
@@ -25,6 +25,10 @@
-
+
+
+
+
+
diff --git a/CumulusMX/CumulusMX.csproj b/CumulusMX/CumulusMX.csproj
index 9efb51fb..2490252d 100644
--- a/CumulusMX/CumulusMX.csproj
+++ b/CumulusMX/CumulusMX.csproj
@@ -110,20 +110,20 @@
False
..\packages\linqtotwitter.3.1.1\lib\net45\LinqToTwitterPcl.dll
-
- ..\packages\MailKit.3.2.0\lib\net48\MailKit.dll
+
+ ..\packages\MailKit.3.3.0\lib\net48\MailKit.dll
-
- ..\packages\MimeKit.3.2.0\lib\net48\MimeKit.dll
+
+ ..\packages\MimeKit.3.3.0\lib\net48\MimeKit.dll
-
- ..\packages\MQTTnet.3.1.2\lib\net461\MQTTnet.dll
+
+ ..\packages\MQTTnet.4.0.0.167\lib\net461\MQTTnet.dll
- ..\packages\MySqlConnector.2.1.9\lib\net471\MySqlConnector.dll
+ ..\packages\MySqlConnector.2.1.10\lib\net471\MySqlConnector.dll
-
- ..\packages\SSH.NET.2020.0.1\lib\net40\Renci.SshNet.dll
+
+ ..\packages\SSH.NET.2020.0.2\lib\net40\Renci.SshNet.dll
..\packages\ServiceStack.Text.6.1.0\lib\net472\ServiceStack.Text.dll
@@ -143,8 +143,8 @@
-
- ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
+
+ ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll
diff --git a/CumulusMX/packages.config b/CumulusMX/packages.config
index 64c4137e..b5898cc3 100644
--- a/CumulusMX/packages.config
+++ b/CumulusMX/packages.config
@@ -3,15 +3,15 @@
-
+
-
-
-
+
+
+
@@ -19,10 +19,10 @@
-
+
-
+
From a792c8b788ae7f28f937f31dcb87555a57bc317a Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Tue, 14 Jun 2022 13:02:43 +0100
Subject: [PATCH 02/21] Version number uplift
---
CumulusMX/Properties/AssemblyInfo.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/CumulusMX/Properties/AssemblyInfo.cs b/CumulusMX/Properties/AssemblyInfo.cs
index 4a38d019..6beb8c1a 100644
--- a/CumulusMX/Properties/AssemblyInfo.cs
+++ b/CumulusMX/Properties/AssemblyInfo.cs
@@ -6,7 +6,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Cumulus MX")]
-[assembly: AssemblyDescription("Version 3.18.0 - Build 3189")]
+[assembly: AssemblyDescription("Version 3.18.1 - Build 3190")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Cumulus MX")]
@@ -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.18.0.3189")]
-[assembly: AssemblyFileVersion("3.18.0.3189")]
+[assembly: AssemblyVersion("3.18.1.3190")]
+[assembly: AssemblyFileVersion("3.18.1.3190")]
From ffe0163b47e4011fc9de42fa1f23254bd92f80f0 Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Tue, 14 Jun 2022 13:19:46 +0100
Subject: [PATCH 03/21] Remove redundant call to CurrentSolarMax in DoSolar() -
it is already updated once a minute
---
CumulusMX/WeatherStation.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CumulusMX/WeatherStation.cs b/CumulusMX/WeatherStation.cs
index 2ff245b1..5b274f55 100644
--- a/CumulusMX/WeatherStation.cs
+++ b/CumulusMX/WeatherStation.cs
@@ -4307,7 +4307,7 @@ public void DoSolarRad(int value, DateTime timestamp)
HiLoToday.HighSolar = SolarRad;
HiLoToday.HighSolarTime = timestamp;
}
- CurrentSolarMax = AstroLib.SolarMax(timestamp, cumulus.Longitude, cumulus.Latitude, AltitudeM(cumulus.Altitude), out SolarElevation, cumulus.SolarOptions);
+ //CurrentSolarMax = AstroLib.SolarMax(timestamp, cumulus.Longitude, cumulus.Latitude, AltitudeM(cumulus.Altitude), out SolarElevation, cumulus.SolarOptions);
if (!cumulus.SolarOptions.UseBlakeLarsen)
{
From 1e9ee36cfef55b5cf93094e5dce78bdf360cf2dd Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Tue, 14 Jun 2022 13:19:46 +0100
Subject: [PATCH 04/21] Remove redundant call to CurrentSolarMax in DoSolar() -
it is already updated once a minute
---
CumulusMX/WeatherStation.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/CumulusMX/WeatherStation.cs b/CumulusMX/WeatherStation.cs
index 2ff245b1..8e0dbc61 100644
--- a/CumulusMX/WeatherStation.cs
+++ b/CumulusMX/WeatherStation.cs
@@ -4300,14 +4300,12 @@ public void DoUV(double value, DateTime timestamp)
public void DoSolarRad(int value, DateTime timestamp)
{
SolarRad = (value * cumulus.Calib.Solar.Mult) + cumulus.Calib.Solar.Offset;
- // Update display
if (SolarRad > HiLoToday.HighSolar)
{
HiLoToday.HighSolar = SolarRad;
HiLoToday.HighSolarTime = timestamp;
}
- CurrentSolarMax = AstroLib.SolarMax(timestamp, cumulus.Longitude, cumulus.Latitude, AltitudeM(cumulus.Altitude), out SolarElevation, cumulus.SolarOptions);
if (!cumulus.SolarOptions.UseBlakeLarsen)
{
From 6f5fa813a9b96aa3bff39473775ab75e9ff1aa8b Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Tue, 14 Jun 2022 13:37:30 +0100
Subject: [PATCH 05/21] MQTTnet updates to support ver 4
---
CumulusMX/MqttPublisher.cs | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/CumulusMX/MqttPublisher.cs b/CumulusMX/MqttPublisher.cs
index 1201b7f8..8dcd8206 100644
--- a/CumulusMX/MqttPublisher.cs
+++ b/CumulusMX/MqttPublisher.cs
@@ -25,11 +25,11 @@ public static void Setup(Cumulus cumulus)
var clientId = Guid.NewGuid().ToString();
- var mqttTcpOptions = new MQTTnet.Client.Options.MqttClientTcpOptions
+ var mqttTcpOptions = new MQTTnet.Client.MqttClientTcpOptions
{
Server = cumulus.MQTT.Server,
Port = cumulus.MQTT.Port,
- TlsOptions = new MQTTnet.Client.Options.MqttClientTlsOptions { UseTls = cumulus.MQTT.UseTLS }
+ TlsOptions = new MQTTnet.Client.MqttClientTlsOptions { UseTls = cumulus.MQTT.UseTLS }
};
switch (cumulus.MQTT.IpVersion)
@@ -45,23 +45,19 @@ public static void Setup(Cumulus cumulus)
break;
}
- var mqttOptions = new MQTTnet.Client.Options.MqttClientOptions
+ var mqttOptions = new MQTTnet.Client.MqttClientOptions
{
ChannelOptions = mqttTcpOptions,
ClientId = clientId,
Credentials = string.IsNullOrEmpty(cumulus.MQTT.Password)
? null
- : new MQTTnet.Client.Options.MqttClientCredentials
- {
- Username = cumulus.MQTT.Username,
- Password = System.Text.Encoding.UTF8.GetBytes(cumulus.MQTT.Password)
- },
+ : new MQTTnet.Client.MqttClientCredentials(cumulus.MQTT.Username, System.Text.Encoding.UTF8.GetBytes(cumulus.MQTT.Password)),
CleanSession = true
};
Connect(mqttOptions);
- mqttClient.UseDisconnectedHandler(async e =>
+ mqttClient.DisconnectedAsync += (async e =>
{
cumulus.LogMessage("Error: MQTT disconnected from the server");
await Task.Delay(TimeSpan.FromSeconds(5));
@@ -101,7 +97,7 @@ private static async Task SendMessageAsync(string topic, string message, bool re
}
}
- private static async void Connect(MQTTnet.Client.Options.IMqttClientOptions options)
+ private static async void Connect(MQTTnet.Client.MqttClientOptions options)
{
try
{
From 62afe66cbdc22c766d6d299be60fa48fd354dc2a Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Wed, 15 Jun 2022 11:36:02 +0100
Subject: [PATCH 06/21] Version uplift
---
CumulusMX/Properties/AssemblyInfo.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/CumulusMX/Properties/AssemblyInfo.cs b/CumulusMX/Properties/AssemblyInfo.cs
index 6beb8c1a..c4d94696 100644
--- a/CumulusMX/Properties/AssemblyInfo.cs
+++ b/CumulusMX/Properties/AssemblyInfo.cs
@@ -6,7 +6,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Cumulus MX")]
-[assembly: AssemblyDescription("Version 3.18.1 - Build 3190")]
+[assembly: AssemblyDescription("Version 3.18.1 - Build 3191")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Cumulus MX")]
@@ -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.18.1.3190")]
-[assembly: AssemblyFileVersion("3.18.1.3190")]
+[assembly: AssemblyVersion("3.18.1.3191")]
+[assembly: AssemblyFileVersion("3.18.1.3191")]
From 34f203d6aac3cce54a17477e956872fa762e3ea6 Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Thu, 16 Jun 2022 14:04:19 +0100
Subject: [PATCH 07/21] Code tidying
---
CumulusMX/Cumulus.cs | 27 ++--
CumulusMX/WeatherStation.cs | 315 ++++++++++++++++--------------------
2 files changed, 153 insertions(+), 189 deletions(-)
diff --git a/CumulusMX/Cumulus.cs b/CumulusMX/Cumulus.cs
index 2aa1c65e..399aa071 100644
--- a/CumulusMX/Cumulus.cs
+++ b/CumulusMX/Cumulus.cs
@@ -8333,8 +8333,6 @@ public void DoFTPLogin()
}
// Extra files
- LogFtpDebugMessage("SFTP[Int]: Uploading extra files");
- var cnt = 0;
for (int i = 0; i < numextrafiles; i++)
{
var uploadfile = ExtraFiles[i].local;
@@ -8353,7 +8351,8 @@ public void DoFTPLogin()
if (File.Exists(uploadfile))
{
- cnt++;
+ LogFtpDebugMessage("FTP[Int]: Uploading Extra file: " + uploadfile);
+
remotefile = GetRemoteFileName(remotefile, logDay);
// all checks OK, file needs to be uploaded
@@ -8383,20 +8382,18 @@ public void DoFTPLogin()
{
EODfilesNeedFTP = false;
}
- LogFtpDebugMessage($"SFTP[Int]: Done uploading {cnt} extra files");
// standard files
- LogFtpDebugMessage("SFTP[Int]: Uploading standard web files");
- cnt = 0;
for (var i = 0; i < StdWebFiles.Length; i++)
{
if (StdWebFiles[i].FTP && StdWebFiles[i].FtpRequired)
{
try
{
- cnt++;
var localFile = StdWebFiles[i].LocalPath + StdWebFiles[i].LocalFileName;
var remotefile = remotePath + StdWebFiles[i].RemoteFileName;
+ LogFtpDebugMessage("FTP[Int]: Uploading standard Data file: " + localFile);
+
UploadFile(conn, localFile, remotefile, -1);
}
catch (Exception e)
@@ -8406,9 +8403,6 @@ public void DoFTPLogin()
}
}
}
- LogFtpDebugMessage($"SFTP[Int]: Done uploading {0} standard web files");
-
- LogFtpDebugMessage("SFTP[Int]: Uploading graph data files");
for (int i = 0; i < GraphDataFiles.Length; i++)
{
@@ -8419,6 +8413,8 @@ public void DoFTPLogin()
try
{
+ LogFtpDebugMessage("FTP[Int]: Uploading graph data file: " + uploadfile);
+
UploadFile(conn, uploadfile, remotefile, -1);
// The config files only need uploading once per change
if (GraphDataFiles[i].LocalFileName == "availabledata.json" ||
@@ -8434,19 +8430,17 @@ public void DoFTPLogin()
}
}
}
- LogFtpDebugMessage("SFTP[Int]: Done uploading graph data files");
- LogFtpMessage("SFTP[Int]: Uploading daily graph data files");
- cnt = 0;
for (int i = 0; i < GraphDataEodFiles.Length; i++)
{
if (GraphDataEodFiles[i].FTP && GraphDataEodFiles[i].FtpRequired)
{
- cnt++;
var uploadfile = GraphDataEodFiles[i].LocalPath + GraphDataEodFiles[i].LocalFileName;
var remotefile = remotePath + GraphDataEodFiles[i].RemoteFileName;
try
{
+ LogFtpMessage("FTP[Int]: Uploading daily graph data file: " + uploadfile);
+
UploadFile(conn, uploadfile, remotefile, -1);
// Uploaded OK, reset the upload required flag
GraphDataEodFiles[i].FtpRequired = false;
@@ -8458,7 +8452,6 @@ public void DoFTPLogin()
}
}
}
- LogFtpMessage($"SFTP[Int]: Done uploading {cnt} daily graph data files");
if (MoonImage.Ftp && MoonImage.ReadyToFtp)
{
@@ -9657,6 +9650,10 @@ private void RealtimeFTPLogin()
RealtimeFTP.DataConnectionType = FtpDataConnectionType.PASV;
LogDebugMessage("RealtimeFTPLogin: Disabling EPSV mode");
}
+ else
+ {
+ RealtimeFTP.DataConnectionType = FtpDataConnectionType.EPSV;
+ }
if (FtpOptions.Enabled)
{
diff --git a/CumulusMX/WeatherStation.cs b/CumulusMX/WeatherStation.cs
index 8e0dbc61..a8a369f8 100644
--- a/CumulusMX/WeatherStation.cs
+++ b/CumulusMX/WeatherStation.cs
@@ -10892,11 +10892,13 @@ public string GetDailyRainGraphData()
var data = DayFile.Where(rec => rec.Date >= datefrom).ToList();
for (var i = 0; i < data.Count; i++)
{
- sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{data[i].TotalRain.ToString(cumulus.RainFormat, InvC)}]");
-
- if (i < data.Count - 1)
- sb.Append(",");
+ sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{data[i].TotalRain.ToString(cumulus.RainFormat, InvC)}],");
}
+
+ // remove trailing comma
+ if (sb[sb.Length - 1] == ',')
+ sb.Length--;
+
sb.Append("]}");
return sb.ToString();
}
@@ -10914,13 +10916,15 @@ public string GetSunHoursGraphData()
for (var i = 0; i < data.Count; i++)
{
var sunhrs = data[i].SunShineHours >= 0 ? data[i].SunShineHours : 0;
- sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{sunhrs.ToString(cumulus.SunFormat, InvC)}]");
-
- if (i < data.Count - 1)
- sb.Append(",");
+ sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{sunhrs.ToString(cumulus.SunFormat, InvC)}],");
}
sb.Append("]");
}
+
+ // remove trailing comma
+ if (sb[sb.Length - 1] == ',')
+ sb.Length--;
+
sb.Append("}");
return sb.ToString();
}
@@ -10939,11 +10943,13 @@ public string GetDailyTempGraphData()
for (var i = 0; i < data.Count; i++)
{
- sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{data[i].LowTemp.ToString(cumulus.TempFormat, InvC)}]");
- if (i < data.Count - 1)
- sb.Append(",");
+ sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{data[i].LowTemp.ToString(cumulus.TempFormat, InvC)}],");
}
+ // remove trailing comma
+ if (sb[sb.Length - 1] == ',')
+ sb.Length--;
+
sb.Append("]");
append = true;
}
@@ -10957,11 +10963,13 @@ public string GetDailyTempGraphData()
for (var i = 0; i < data.Count; i++)
{
- sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{data[i].HighTemp.ToString(cumulus.TempFormat, InvC)}]");
- if (i < data.Count - 1)
- sb.Append(",");
+ sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{data[i].HighTemp.ToString(cumulus.TempFormat, InvC)}],");
}
+ // remove trailing comma
+ if (sb[sb.Length - 1] == ',')
+ sb.Length--;
+
sb.Append("]");
append = true;
}
@@ -10974,11 +10982,13 @@ public string GetDailyTempGraphData()
sb.Append("\"avgtemp\":[");
for (var i = 0; i < data.Count; i++)
{
- sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{data[i].AvgTemp.ToString(cumulus.TempFormat, InvC)}]");
- if (i < data.Count - 1)
- sb.Append(",");
+ sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{data[i].AvgTemp.ToString(cumulus.TempFormat, InvC)}],");
}
+ // remove trailing comma
+ if (sb[sb.Length - 1] == ',')
+ sb.Length--;
+
sb.Append("]");
}
@@ -11021,119 +11031,92 @@ public string GetAllDailyTempGraphData()
var recDate = DateTimeToUnix(DayFile[i].Date) * 1000;
// lo temp
if (cumulus.GraphOptions.DailyMinTempVisible)
- minTemp.Append($"[{recDate},{DayFile[i].LowTemp.ToString(cumulus.TempFormat, InvC)}]");
+ minTemp.Append($"[{recDate},{DayFile[i].LowTemp.ToString(cumulus.TempFormat, InvC)}],");
// hi temp
if (cumulus.GraphOptions.DailyMaxTempVisible)
- maxTemp.Append($"[{recDate},{DayFile[i].HighTemp.ToString(cumulus.TempFormat, InvC)}]");
+ maxTemp.Append($"[{recDate},{DayFile[i].HighTemp.ToString(cumulus.TempFormat, InvC)}],");
// avg temp
if (cumulus.GraphOptions.DailyAvgTempVisible)
- avgTemp.Append($"[{recDate},{DayFile[i].AvgTemp.ToString(cumulus.TempFormat, InvC)}]");
-
- if (i < len)
- {
- minTemp.Append(",");
- maxTemp.Append(",");
- avgTemp.Append(",");
- }
+ avgTemp.Append($"[{recDate},{DayFile[i].AvgTemp.ToString(cumulus.TempFormat, InvC)}],");
if (cumulus.GraphOptions.HIVisible)
{
// hi heat index
if (DayFile[i].HighHeatIndex > -999)
- heatIdx.Append($"[{recDate},{DayFile[i].HighHeatIndex.ToString(cumulus.TempFormat, InvC)}]");
+ heatIdx.Append($"[{recDate},{DayFile[i].HighHeatIndex.ToString(cumulus.TempFormat, InvC)}],");
else
- heatIdx.Append($"[{recDate},null]");
-
- if (i < len)
- heatIdx.Append(",");
+ heatIdx.Append($"[{recDate},null],");
}
if (cumulus.GraphOptions.AppTempVisible)
{
// hi app temp
if (DayFile[i].HighAppTemp > -999)
- maxApp.Append($"[{recDate},{DayFile[i].HighAppTemp.ToString(cumulus.TempFormat, InvC)}]");
+ maxApp.Append($"[{recDate},{DayFile[i].HighAppTemp.ToString(cumulus.TempFormat, InvC)}],");
else
- maxApp.Append($"[{recDate},null]");
+ maxApp.Append($"[{recDate},null],");
// lo app temp
if (DayFile[i].LowAppTemp < 999)
- minApp.Append($"[{recDate},{DayFile[i].LowAppTemp.ToString(cumulus.TempFormat, InvC)}]");
+ minApp.Append($"[{recDate},{DayFile[i].LowAppTemp.ToString(cumulus.TempFormat, InvC)}],");
else
- minApp.Append($"[{recDate},null]");
-
- if (i < len)
- {
- maxApp.Append(",");
- minApp.Append(",");
- }
+ minApp.Append($"[{recDate},null],");
}
// lo wind chill
if (cumulus.GraphOptions.WCVisible)
{
if (DayFile[i].LowWindChill < 999)
- windChill.Append($"[{recDate},{DayFile[i].LowWindChill.ToString(cumulus.TempFormat, InvC)}]");
+ windChill.Append($"[{recDate},{DayFile[i].LowWindChill.ToString(cumulus.TempFormat, InvC)}],");
else
- windChill.Append($"[{recDate},null]");
-
- if (i < len)
- windChill.Append(",");
+ windChill.Append($"[{recDate},null],");
}
if (cumulus.GraphOptions.DPVisible)
{
// hi dewpt
if (DayFile[i].HighDewPoint > -999)
- maxDew.Append($"[{recDate},{DayFile[i].HighDewPoint.ToString(cumulus.TempFormat, InvC)}]");
+ maxDew.Append($"[{recDate},{DayFile[i].HighDewPoint.ToString(cumulus.TempFormat, InvC)}],");
else
- maxDew.Append($"[{recDate},null]");
+ maxDew.Append($"[{recDate},null],");
// lo dewpt
if (DayFile[i].LowDewPoint < 999)
- minDew.Append($"[{recDate},{DayFile[i].LowDewPoint.ToString(cumulus.TempFormat, InvC)}]");
+ minDew.Append($"[{recDate},{DayFile[i].LowDewPoint.ToString(cumulus.TempFormat, InvC)}],");
else
- minDew.Append($"[{recDate},null]");
-
- if (i < len)
- {
- maxDew.Append(",");
- minDew.Append(",");
- }
+ minDew.Append($"[{recDate},null],");
}
if (cumulus.GraphOptions.FeelsLikeVisible)
{
// hi feels like
if (DayFile[i].HighFeelsLike > -999)
- maxFeels.Append($"[{recDate},{DayFile[i].HighFeelsLike.ToString(cumulus.TempFormat, InvC)}]");
+ maxFeels.Append($"[{recDate},{DayFile[i].HighFeelsLike.ToString(cumulus.TempFormat, InvC)}],");
else
- maxFeels.Append($"[{recDate},null]");
+ maxFeels.Append($"[{recDate},null],");
// lo feels like
if (DayFile[i].LowFeelsLike < 999)
- minFeels.Append($"[{recDate},{DayFile[i].LowFeelsLike.ToString(cumulus.TempFormat, InvC)}]");
+ minFeels.Append($"[{recDate},{DayFile[i].LowFeelsLike.ToString(cumulus.TempFormat, InvC)}],");
else
- minFeels.Append($"[{recDate},null]");
-
- if (i < len)
- {
- maxFeels.Append(",");
- minFeels.Append(",");
- }
+ minFeels.Append($"[{recDate},null],");
}
if (cumulus.GraphOptions.HumidexVisible)
{
// hi humidex
if (DayFile[i].HighHumidex > -999)
- humidex.Append($"[{recDate},{DayFile[i].HighHumidex.ToString(cumulus.TempFormat, InvC)}]");
+ humidex.Append($"[{recDate},{DayFile[i].HighHumidex.ToString(cumulus.TempFormat, InvC)}],");
else
- humidex.Append($"[{recDate},null]");
-
- if (i < len)
- humidex.Append(",");
+ humidex.Append($"[{recDate},null],");
}
}
}
+
+ // remove trailing commas
+ minTemp.Length--;
+ maxTemp.Length--;
+ avgTemp.Length--;
+
+
if (cumulus.GraphOptions.DailyMinTempVisible)
sb.Append("\"minTemp\":" + minTemp.ToString() + "],");
if (cumulus.GraphOptions.DailyMaxTempVisible)
@@ -11141,26 +11124,41 @@ public string GetAllDailyTempGraphData()
if (cumulus.GraphOptions.DailyAvgTempVisible)
sb.Append("\"avgTemp\":" + avgTemp.ToString() + "],");
if (cumulus.GraphOptions.HIVisible)
+ {
+ heatIdx.Length--;
sb.Append("\"heatIndex\":" + heatIdx.ToString() + "],");
+ }
if (cumulus.GraphOptions.AppTempVisible)
{
+ maxApp.Length--;
+ minApp.Length--;
sb.Append("\"maxApp\":" + maxApp.ToString() + "],");
sb.Append("\"minApp\":" + minApp.ToString() + "],");
}
if (cumulus.GraphOptions.WCVisible)
+ {
+ windChill.Length--;
sb.Append("\"windChill\":" + windChill.ToString() + "],");
+ }
if (cumulus.GraphOptions.DPVisible)
{
+ maxDew.Length--;
+ minDew.Length--;
sb.Append("\"maxDew\":" + maxDew.ToString() + "],");
sb.Append("\"minDew\":" + minDew.ToString() + "],");
}
if (cumulus.GraphOptions.FeelsLikeVisible)
{
+ maxFeels.Length--;
+ minFeels.Length--;
sb.Append("\"maxFeels\":" + maxFeels.ToString() + "],");
sb.Append("\"minFeels\":" + minFeels.ToString() + "],");
}
if (cumulus.GraphOptions.HumidexVisible)
+ {
+ humidex.Length--;
sb.Append("\"humidex\":" + humidex.ToString() + "],");
+ }
sb.Length--;
sb.Append("}");
@@ -11195,20 +11193,18 @@ public string GetAllDailyWindGraphData()
var recDate = DateTimeToUnix(DayFile[i].Date) * 1000;
// hi gust
- maxGust.Append($"[{recDate},{DayFile[i].HighGust.ToString(cumulus.WindFormat, InvC)}]");
+ maxGust.Append($"[{recDate},{DayFile[i].HighGust.ToString(cumulus.WindFormat, InvC)}],");
// hi wind run
- windRun.Append($"[{recDate},{DayFile[i].WindRun.ToString(cumulus.WindRunFormat, InvC)}]");
+ windRun.Append($"[{recDate},{DayFile[i].WindRun.ToString(cumulus.WindRunFormat, InvC)}],");
// hi wind
- maxWind.Append($"[{recDate},{DayFile[i].HighAvgWind.ToString(cumulus.WindAvgFormat, InvC)}]");
-
- if (i < len)
- {
- maxGust.Append(",");
- windRun.Append(",");
- maxWind.Append(",");
- }
+ maxWind.Append($"[{recDate},{DayFile[i].HighAvgWind.ToString(cumulus.WindAvgFormat, InvC)}],");
}
}
+
+ maxGust.Length--;
+ windRun.Length--;
+ maxWind.Length--;
+
sb.Append("\"maxGust\":" + maxGust.ToString() + "],");
sb.Append("\"windRun\":" + windRun.ToString() + "],");
sb.Append("\"maxWind\":" + maxWind.ToString() + "]");
@@ -11244,17 +11240,15 @@ public string GetAllDailyRainGraphData()
long recDate = DateTimeToUnix(DayFile[i].Date) * 1000;
// hi rain rate
- maxRRate.Append($"[{recDate},{DayFile[i].HighRainRate.ToString(cumulus.RainFormat, InvC)}]");
+ maxRRate.Append($"[{recDate},{DayFile[i].HighRainRate.ToString(cumulus.RainFormat, InvC)}],");
// total rain
- rain.Append($"[{recDate},{DayFile[i].TotalRain.ToString(cumulus.RainFormat, InvC)}]");
-
- if (i < len)
- {
- maxRRate.Append(",");
- rain.Append(",");
- }
+ rain.Append($"[{recDate},{DayFile[i].TotalRain.ToString(cumulus.RainFormat, InvC)}],");
}
}
+
+ maxRRate.Length--;
+ rain.Length--;
+
sb.Append("\"maxRainRate\":" + maxRRate.ToString() + "],");
sb.Append("\"rain\":" + rain.ToString() + "]");
sb.Append("}");
@@ -11290,17 +11284,15 @@ public string GetAllDailyPressGraphData()
long recDate = DateTimeToUnix(DayFile[i].Date) * 1000;
// lo baro
- minBaro.Append($"[{recDate},{DayFile[i].LowPress.ToString(cumulus.PressFormat, InvC)}]");
+ minBaro.Append($"[{recDate},{DayFile[i].LowPress.ToString(cumulus.PressFormat, InvC)}],");
// hi baro
- maxBaro.Append($"[{recDate},{DayFile[i].HighPress.ToString(cumulus.PressFormat, InvC)}]");
-
- if (i < len)
- {
- maxBaro.Append(",");
- minBaro.Append(",");
- }
+ maxBaro.Append($"[{recDate},{DayFile[i].HighPress.ToString(cumulus.PressFormat, InvC)}],");
}
}
+
+ // Remove trailing commas
+ minBaro.Length--;
+ maxBaro.Length--;
sb.Append("\"minBaro\":" + minBaro.ToString() + "],");
sb.Append("\"maxBaro\":" + maxBaro.ToString() + "]");
sb.Append("}");
@@ -11308,65 +11300,42 @@ public string GetAllDailyPressGraphData()
return sb.ToString();
}
- //public string GetAllDailyWindDirGraphData()
- //{
- // int linenum = 0;
- // int valInt;
-
- // /* returns:
- // * {
- // * highgust:[[date1,val1],[date2,val2]...],
- // * mintemp:[[date1,val1],[date2,val2]...],
- // * etc
- // * }
- // */
-
- // StringBuilder sb = new StringBuilder("{");
- // StringBuilder windDir = new StringBuilder("[");
-
- // var watch = Stopwatch.StartNew();
-
- // // Read the dayfile and extract the records from there
- // if (File.Exists(cumulus.DayFile))
- // {
- // try
- // {
- // var dayfile = File.ReadAllLines(cumulus.DayFile);
-
- // foreach (var line in dayfile)
- // {
- // linenum++;
- // List st = new List(Regex.Split(line, CultureInfo.CurrentCulture.TextInfo.ListSeparator));
-
- // if (st.Count <= 0) continue;
-
- // // dominant wind direction
- // if (st.Count > 39)
- // {
- // long recDate = DateTimeToUnix(ddmmyyStrToDate(st[0])) * 1000;
-
- // if (int.TryParse(st[39], out valInt))
- // windDir.Append($"[{recDate},{valInt}]");
- // else
- // windDir.Append($"[{recDate},null]");
- // if (linenum < dayfile.Length)
- // windDir.Append(",");
- // }
- // }
- // }
- // catch (Exception e)
- // {
- // cumulus.LogMessage("GetAllDailyWindDirGraphData: Error on line " + linenum + " of " + cumulus.DayFile + ": " + e.Message);
- // }
- // }
- // sb.Append("\"windDir\":" + windDir.ToString() + "]");
- // sb.Append("}");
-
- // watch.Stop();
- // cumulus.LogDebugMessage($"GetAllDailyWindDirGraphData: Dayfile parse = {watch.ElapsedMilliseconds} ms");
-
- // return sb.ToString();
- //}
+ public string GetAllDailyWindDirGraphData()
+ {
+
+ /* returns:
+ * {
+ * highgust:[[date1,val1],[date2,val2]...],
+ * mintemp:[[date1,val1],[date2,val2]...],
+ * etc
+ * }
+ */
+
+ StringBuilder sb = new StringBuilder("{");
+ StringBuilder windDir = new StringBuilder("[");
+
+
+ // Read the dayfile and extract the records from there
+ if (DayFile.Count() > 0)
+ {
+ var len = DayFile.Count() - 1;
+
+ for (var i = 0; i < DayFile.Count(); i++)
+ {
+ long recDate = DateTimeToUnix(DayFile[i].Date) * 1000;
+
+ windDir.Append($"[{recDate},{DayFile[i].DominantWindBearing.ToString()}],");
+
+ }
+ }
+
+ // Remove trailing commas
+ windDir.Length--;
+ sb.Append("\"windDir\":" + windDir.ToString() + "]");
+ sb.Append("}");
+
+ return sb.ToString();
+ }
public string GetAllDailyHumGraphData()
{
@@ -11393,17 +11362,15 @@ public string GetAllDailyHumGraphData()
long recDate = DateTimeToUnix(DayFile[i].Date) * 1000;
// lo humidity
- minHum.Append($"[{recDate},{DayFile[i].LowHumidity}]");
+ minHum.Append($"[{recDate},{DayFile[i].LowHumidity}],");
// hi humidity
- maxHum.Append($"[{recDate},{DayFile[i].HighHumidity}]");
-
- if (i < len)
- {
- minHum.Append(",");
- maxHum.Append(",");
- }
+ maxHum.Append($"[{recDate},{DayFile[i].HighHumidity}],");
}
}
+ // Remove trailing commas
+ minHum.Length--;
+ maxHum.Length--;
+
sb.Append("\"minHum\":" + minHum.ToString() + "],");
sb.Append("\"maxHum\":" + maxHum.ToString() + "]");
sb.Append("}");
@@ -11440,36 +11407,35 @@ public string GetAllDailySolarGraphData()
if (cumulus.GraphOptions.SunshineVisible)
{
// sunshine hours
- sunHours.Append($"[{recDate},{DayFile[i].SunShineHours.ToString(InvC)}]");
- if (i < len)
- sunHours.Append(",");
+ sunHours.Append($"[{recDate},{DayFile[i].SunShineHours.ToString(InvC)}],");
}
if (cumulus.GraphOptions.SolarVisible)
{
// hi solar rad
- solarRad.Append($"[{recDate},{DayFile[i].HighSolar}]");
- if (i < len)
- solarRad.Append(",");
+ solarRad.Append($"[{recDate},{DayFile[i].HighSolar}],");
}
if (cumulus.GraphOptions.UVVisible)
{
// hi UV-I
- uvi.Append($"[{recDate},{DayFile[i].HighUv.ToString(cumulus.UVFormat, InvC)}]");
- if (i < len)
- uvi.Append(",");
+ uvi.Append($"[{recDate},{DayFile[i].HighUv.ToString(cumulus.UVFormat, InvC)}],");
}
}
}
+
if (cumulus.GraphOptions.SunshineVisible)
+ {
+ sunHours.Length--;
sb.Append("\"sunHours\":" + sunHours.ToString() + "]");
+ }
if (cumulus.GraphOptions.SolarVisible)
{
if (cumulus.GraphOptions.SunshineVisible)
sb.Append(",");
+ solarRad.Length--;
sb.Append("\"solarRad\":" + solarRad.ToString() + "]");
}
@@ -11478,6 +11444,7 @@ public string GetAllDailySolarGraphData()
if (cumulus.GraphOptions.SunshineVisible || cumulus.GraphOptions.SolarVisible)
sb.Append(",");
+ uvi.Length--;
sb.Append("\"uvi\":" + uvi.ToString() + "]");
}
sb.Append("}");
From d43e0ed1c48a034735a62eea93c58dfac1d48637 Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Mon, 20 Jun 2022 11:14:31 +0100
Subject: [PATCH 08/21] Fix: Ecowitt Extra Sensors setup error 500
---
CumulusMX/Api.cs | 6 +++---
CumulusMX/ExtraSensorSettings.cs | 10 +++++-----
CumulusMX/StationSettings.cs | 2 +-
Updates.txt | 7 +++++++
4 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/CumulusMX/Api.cs b/CumulusMX/Api.cs
index 6e23eca6..671a9fce 100644
--- a/CumulusMX/Api.cs
+++ b/CumulusMX/Api.cs
@@ -481,9 +481,9 @@ public async Task GetDailyGraphData(string req)
case "pressdata.json":
await writer.WriteAsync(Station.GetAllDailyPressGraphData());
break;
- //case "wdirdata.json":
- //await writer.WriteAsync(Station.GetAllDailyWindDirGraphData());
- //break;
+ case "wdirdata.json":
+ await writer.WriteAsync(Station.GetAllDailyWindDirGraphData());
+ break;
case "humdata.json":
await writer.WriteAsync(Station.GetAllDailyHumGraphData());
break;
diff --git a/CumulusMX/ExtraSensorSettings.cs b/CumulusMX/ExtraSensorSettings.cs
index f659d169..58911686 100644
--- a/CumulusMX/ExtraSensorSettings.cs
+++ b/CumulusMX/ExtraSensorSettings.cs
@@ -519,11 +519,11 @@ public class JsonExtraSensorAmbient
public class JsonExtraSensorEcowitt : JsonExtraSensorAmbient
{
- internal bool setcustom { get; set; }
- internal string gwaddr { get; set; }
- internal string localaddr { get; set; }
- internal int interval { get; set; }
- internal JsonStationSettingsEcowittMappings mappings { get; set; }
+ public bool setcustom { get; set; }
+ public string gwaddr { get; set; }
+ public string localaddr { get; set; }
+ public int interval { get; set; }
+ public JsonStationSettingsEcowittMappings mappings { get; set; }
}
diff --git a/CumulusMX/StationSettings.cs b/CumulusMX/StationSettings.cs
index 25c23d60..32f43324 100644
--- a/CumulusMX/StationSettings.cs
+++ b/CumulusMX/StationSettings.cs
@@ -1675,7 +1675,7 @@ internal class JsonStationSettingsEcowittApi
public string mac { get; set; }
}
- internal class JsonStationSettingsEcowittMappings
+ public class JsonStationSettingsEcowittMappings
{
public int primaryTHsensor { get; set; }
public int primaryRainSensor { get; set; }
diff --git a/Updates.txt b/Updates.txt
index d53a8024..54266966 100644
--- a/Updates.txt
+++ b/Updates.txt
@@ -1,3 +1,10 @@
+3.18.1 - b3191
+——————————————
+- Fix: Ecowitt Extra Sensors setup error 500
+
+- Change: Migrate the log file viewers to the new date picker
+
+
3.18.0 - b3190
——————————————
- Fix: Adds Ecowitt Wh40 battery state decode
From 416c43e00f3f45e68e54f73a081c16f843fb3a15 Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Mon, 20 Jun 2022 13:21:27 +0100
Subject: [PATCH 09/21] StringBuilder optimisations
---
CumulusMX/WeatherStation.cs | 56 ++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/CumulusMX/WeatherStation.cs b/CumulusMX/WeatherStation.cs
index a8a369f8..652b7dbc 100644
--- a/CumulusMX/WeatherStation.cs
+++ b/CumulusMX/WeatherStation.cs
@@ -10708,7 +10708,7 @@ public string GetUnits()
public string GetGraphConfig()
{
var json = new StringBuilder(200);
- json.Append("{");
+ json.Append('{');
json.Append($"\"temp\":{{\"units\":\"{cumulus.Units.TempText[1]}\",\"decimals\":{cumulus.TempDPlaces}}},");
json.Append($"\"wind\":{{\"units\":\"{cumulus.Units.WindText}\",\"decimals\":{cumulus.WindAvgDPlaces},\"rununits\":\"{cumulus.Units.WindRunText}\"}},");
json.Append($"\"rain\":{{\"units\":\"{cumulus.Units.RainText}\",\"decimals\":{cumulus.RainDPlaces}}},");
@@ -10793,7 +10793,7 @@ public string GetAvailGraphData()
if (json[json.Length - 1] == ',')
json.Length--;
- json.Append("]");
+ json.Append(']');
}
@@ -10811,7 +10811,7 @@ public string GetAvailGraphData()
if (json[json.Length - 1] == ',')
json.Length--;
- json.Append("]");
+ json.Append(']');
}
// Sunshine
@@ -10835,7 +10835,7 @@ public string GetAvailGraphData()
{
json.Append(",\"PM 10\"");
}
- json.Append("]");
+ json.Append(']');
}
// Degree Days
@@ -10851,7 +10851,7 @@ public string GetAvailGraphData()
if (json[json.Length - 1] == ',')
json.Length--;
- json.Append("]");
+ json.Append(']');
}
// Temp Sum
@@ -10868,10 +10868,10 @@ public string GetAvailGraphData()
if (json[json.Length - 1] == ',')
json.Length--;
- json.Append("]");
+ json.Append(']');
}
- json.Append("}");
+ json.Append('}');
return json.ToString();
}
@@ -10918,14 +10918,14 @@ public string GetSunHoursGraphData()
var sunhrs = data[i].SunShineHours >= 0 ? data[i].SunShineHours : 0;
sb.Append($"[{DateTimeToUnix(data[i].Date) * 1000},{sunhrs.ToString(cumulus.SunFormat, InvC)}],");
}
- sb.Append("]");
+ sb.Append(']');
}
// remove trailing comma
if (sb[sb.Length - 1] == ',')
sb.Length--;
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -10950,14 +10950,14 @@ public string GetDailyTempGraphData()
if (sb[sb.Length - 1] == ',')
sb.Length--;
- sb.Append("]");
+ sb.Append(']');
append = true;
}
if (cumulus.GraphOptions.DailyMaxTempVisible)
{
if (append)
- sb.Append(",");
+ sb.Append(',');
sb.Append("\"maxtemp\":[");
@@ -10970,14 +10970,14 @@ public string GetDailyTempGraphData()
if (sb[sb.Length - 1] == ',')
sb.Length--;
- sb.Append("]");
+ sb.Append(']');
append = true;
}
if (cumulus.GraphOptions.DailyAvgTempVisible)
{
if (append)
- sb.Append(",");
+ sb.Append(',');
sb.Append("\"avgtemp\":[");
for (var i = 0; i < data.Count; i++)
@@ -10989,10 +10989,10 @@ public string GetDailyTempGraphData()
if (sb[sb.Length - 1] == ',')
sb.Length--;
- sb.Append("]");
+ sb.Append(']');
}
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11161,7 +11161,7 @@ public string GetAllDailyTempGraphData()
}
sb.Length--;
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11208,7 +11208,7 @@ public string GetAllDailyWindGraphData()
sb.Append("\"maxGust\":" + maxGust.ToString() + "],");
sb.Append("\"windRun\":" + windRun.ToString() + "],");
sb.Append("\"maxWind\":" + maxWind.ToString() + "]");
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11251,7 +11251,7 @@ public string GetAllDailyRainGraphData()
sb.Append("\"maxRainRate\":" + maxRRate.ToString() + "],");
sb.Append("\"rain\":" + rain.ToString() + "]");
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11295,7 +11295,7 @@ public string GetAllDailyPressGraphData()
maxBaro.Length--;
sb.Append("\"minBaro\":" + minBaro.ToString() + "],");
sb.Append("\"maxBaro\":" + maxBaro.ToString() + "]");
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11332,7 +11332,7 @@ public string GetAllDailyWindDirGraphData()
// Remove trailing commas
windDir.Length--;
sb.Append("\"windDir\":" + windDir.ToString() + "]");
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11373,7 +11373,7 @@ public string GetAllDailyHumGraphData()
sb.Append("\"minHum\":" + minHum.ToString() + "],");
sb.Append("\"maxHum\":" + maxHum.ToString() + "]");
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11433,7 +11433,7 @@ public string GetAllDailySolarGraphData()
if (cumulus.GraphOptions.SolarVisible)
{
if (cumulus.GraphOptions.SunshineVisible)
- sb.Append(",");
+ sb.Append(',');
solarRad.Length--;
sb.Append("\"solarRad\":" + solarRad.ToString() + "]");
@@ -11442,12 +11442,12 @@ public string GetAllDailySolarGraphData()
if (cumulus.GraphOptions.UVVisible)
{
if (cumulus.GraphOptions.SunshineVisible || cumulus.GraphOptions.SolarVisible)
- sb.Append(",");
+ sb.Append(',');
uvi.Length--;
sb.Append("\"uvi\":" + uvi.ToString() + "]");
}
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11621,7 +11621,7 @@ public string GetAllDegreeDaysGraphData()
sb.Append(options);
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11789,7 +11789,7 @@ public string GetAllTempSumGraphData()
sb.Append("\"Sum0\":" + tempSumYears0 + "}");
if (cumulus.GraphOptions.TempSumVisible1 || cumulus.GraphOptions.TempSumVisible2)
- sb.Append(",");
+ sb.Append(',');
}
if (cumulus.GraphOptions.TempSumVisible1)
{
@@ -11830,7 +11830,7 @@ public string GetAllTempSumGraphData()
sb.Append(options);
- sb.Append("}");
+ sb.Append('}');
return sb.ToString();
}
@@ -11844,7 +11844,7 @@ internal string GetCurrentData()
{
for (var i = 1; i < cumulus.NumWindRosePoints; i++)
{
- windRoseData.Append(",");
+ windRoseData.Append(',');
windRoseData.Append((windcounts[i] * cumulus.Calib.WindGust.Mult).ToString(cumulus.WindFormat, CultureInfo.InvariantCulture));
}
}
From a724dd970a1df41675090527633b55187015e892 Mon Sep 17 00:00:00 2001
From: Mark Crossley <1196094+mcrossley@users.noreply.github.com>
Date: Mon, 20 Jun 2022 13:28:07 +0100
Subject: [PATCH 10/21] StringBuilder optimisations
---
CumulusMX/ApiTagProcessor.cs | 2 +-
CumulusMX/Cumulus.cs | 6 +-
CumulusMX/DataEditor.cs | 6 +-
CumulusMX/DavisAirLink.cs | 16 +--
CumulusMX/DavisWllStation.cs | 16 +--
CumulusMX/IniFile.cs | 2 +-
CumulusMX/InternetSettings.cs | 6 +-
CumulusMX/SQLite.cs | 6 +-
CumulusMX/WMR200Station.cs | 2 +-
CumulusMX/WS2300Station.cs | 2 +-
CumulusMX/WeatherStation.cs | 258 +++++++++++++++++-----------------
11 files changed, 161 insertions(+), 161 deletions(-)
diff --git a/CumulusMX/ApiTagProcessor.cs b/CumulusMX/ApiTagProcessor.cs
index 35003543..c4ef777f 100644
--- a/CumulusMX/ApiTagProcessor.cs
+++ b/CumulusMX/ApiTagProcessor.cs
@@ -67,7 +67,7 @@ public string ProcessJson(IHttpRequest request)
// remove trailing ","
output.Remove(output.Length - 1, 1);
}
- output.Append("}");
+ output.Append('}');
cumulus.LogDataMessage("API tag: Output string = " + output);
}
diff --git a/CumulusMX/Cumulus.cs b/CumulusMX/Cumulus.cs
index 399aa071..fcabdf86 100644
--- a/CumulusMX/Cumulus.cs
+++ b/CumulusMX/Cumulus.cs
@@ -7061,7 +7061,7 @@ public async void DoLogFile(DateTime timestamp, bool live)
values.Append(station.CompassPoint(station.Bearing) + "',");
values.Append(station.FeelsLike.ToString(TempFormat, InvC) + ",");
values.Append(station.Humidex.ToString(TempFormat, InvC));
- values.Append(")");
+ values.Append(')');
string queryString = values.ToString();
@@ -7371,7 +7371,7 @@ public async void DoAirLinkLogFile(DateTime timestamp)
{
sb.Append("0" + ListSeparator);
}
- sb.Append("0");
+ sb.Append('0');
}
var success = false;
@@ -9156,7 +9156,7 @@ public void MySqlRealtimeFile(int cycle, bool live, DateTime? logdate = null)
values.Append(((int)Math.Round(station.CurrentSolarMax)).ToString() + ",'");
values.Append((station.IsSunny ? "1" : "0") + "',");
values.Append(station.FeelsLike.ToString(TempFormat, InvC));
- values.Append(")");
+ values.Append(')');
string valuesString = values.ToString();
List cmds = new List() { valuesString };
diff --git a/CumulusMX/DataEditor.cs b/CumulusMX/DataEditor.cs
index 8b23f741..569e970a 100644
--- a/CumulusMX/DataEditor.cs
+++ b/CumulusMX/DataEditor.cs
@@ -233,7 +233,7 @@ internal string GetAllTimeRecData()
json.Append($"\"highMonthlyRainTime\":\"{station.AllTime.MonthlyRain.GetTsString("MM/yyyy")}\",");
json.Append($"\"longestDryPeriodTime\":\"{station.AllTime.LongestDryPeriod.GetTsString(dateStampFormat)}\",");
json.Append($"\"longestWetPeriodTime\":\"{station.AllTime.LongestWetPeriod.GetTsString(dateStampFormat)}\"");
- json.Append("}");
+ json.Append('}');
return json.ToString();
}
@@ -1651,7 +1651,7 @@ internal string GetMonthlyRecData()
json.Append($"\"{m}-longestWetPeriodTime\":\"{station.MonthlyRecs[m].LongestWetPeriod.GetTsString(dateStampFormat)}\",");
}
json.Length--;
- json.Append("}");
+ json.Append('}');
return json.ToString();
}
@@ -2582,7 +2582,7 @@ internal string GetMonthlyRecLogFile()
}
json.Length--;
- json.Append("}");
+ json.Append('}');
watch.Stop();
var elapsed = watch.ElapsedMilliseconds;
diff --git a/CumulusMX/DavisAirLink.cs b/CumulusMX/DavisAirLink.cs
index 5a664ac3..bb5f3451 100644
--- a/CumulusMX/DavisAirLink.cs
+++ b/CumulusMX/DavisAirLink.cs
@@ -672,9 +672,9 @@ private void GetWlHistoricData()
foreach (KeyValuePair entry in parameters)
{
historicUrl.Append(entry.Key);
- historicUrl.Append("=");
+ historicUrl.Append('=');
historicUrl.Append(entry.Value);
- historicUrl.Append("&");
+ historicUrl.Append('&');
}
// remove the trailing "&"
historicUrl.Remove(historicUrl.Length - 1, 1);
@@ -1114,9 +1114,9 @@ private void GetWlHistoricHealth()
foreach (KeyValuePair entry in parameters)
{
historicUrl.Append(entry.Key);
- historicUrl.Append("=");
+ historicUrl.Append('=');
historicUrl.Append(entry.Value);
- historicUrl.Append("&");
+ historicUrl.Append('&');
}
// remove the trailing "&"
historicUrl.Remove(historicUrl.Length - 1, 1);
@@ -1379,9 +1379,9 @@ private bool GetAvailableStationIds()
foreach (KeyValuePair entry in parameters)
{
stationsUrl.Append(entry.Key);
- stationsUrl.Append("=");
+ stationsUrl.Append('=');
stationsUrl.Append(entry.Value);
- stationsUrl.Append("&");
+ stationsUrl.Append('&');
}
// remove the trailing "&"
stationsUrl.Remove(stationsUrl.Length - 1, 1);
@@ -1498,9 +1498,9 @@ private void GetAvailableSensors()
foreach (KeyValuePair entry in parameters)
{
sensorsUrl.Append(entry.Key);
- sensorsUrl.Append("=");
+ sensorsUrl.Append('=');
sensorsUrl.Append(entry.Value);
- sensorsUrl.Append("&");
+ sensorsUrl.Append('&');
}
// remove the trailing "&"
sensorsUrl.Remove(sensorsUrl.Length - 1, 1);
diff --git a/CumulusMX/DavisWllStation.cs b/CumulusMX/DavisWllStation.cs
index 64bcfd69..a5249630 100644
--- a/CumulusMX/DavisWllStation.cs
+++ b/CumulusMX/DavisWllStation.cs
@@ -1568,9 +1568,9 @@ private void GetWlHistoricData(BackgroundWorker worker)
foreach (KeyValuePair entry in parameters)
{
historicUrl.Append(entry.Key);
- historicUrl.Append("=");
+ historicUrl.Append('=');
historicUrl.Append(entry.Value);
- historicUrl.Append("&");
+ historicUrl.Append('&');
}
// remove the trailing "&"
historicUrl.Remove(historicUrl.Length - 1, 1);
@@ -2915,9 +2915,9 @@ private void GetWlHistoricHealth()
foreach (KeyValuePair entry in parameters)
{
historicUrl.Append(entry.Key);
- historicUrl.Append("=");
+ historicUrl.Append('=');
historicUrl.Append(entry.Value);
- historicUrl.Append("&");
+ historicUrl.Append('&');
}
// remove the trailing "&"
historicUrl.Remove(historicUrl.Length - 1, 1);
@@ -3094,9 +3094,9 @@ private void GetAvailableStationIds(bool logToConsole = false)
foreach (KeyValuePair entry in parameters)
{
stationsUrl.Append(entry.Key);
- stationsUrl.Append("=");
+ stationsUrl.Append('=');
stationsUrl.Append(entry.Value);
- stationsUrl.Append("&");
+ stationsUrl.Append('&');
}
// remove the trailing "&"
stationsUrl.Remove(stationsUrl.Length - 1, 1);
@@ -3207,9 +3207,9 @@ private void GetAvailableSensors()
foreach (KeyValuePair entry in parameters)
{
stationsUrl.Append(entry.Key);
- stationsUrl.Append("=");
+ stationsUrl.Append('=');
stationsUrl.Append(entry.Value);
- stationsUrl.Append("&");
+ stationsUrl.Append('&');
}
// remove the trailing "&"
stationsUrl.Remove(stationsUrl.Length - 1, 1);
diff --git a/CumulusMX/IniFile.cs b/CumulusMX/IniFile.cs
index 2877ade6..b04048c7 100644
--- a/CumulusMX/IniFile.cs
+++ b/CumulusMX/IniFile.cs
@@ -321,7 +321,7 @@ private string EncodeByteArray(byte[] Value)
}
else
{
- if (l < 2) sb.Append("0");
+ if (l < 2) sb.Append('0');
sb.Append(hex);
}
}
diff --git a/CumulusMX/InternetSettings.cs b/CumulusMX/InternetSettings.cs
index 05359e00..ea4293f6 100644
--- a/CumulusMX/InternetSettings.cs
+++ b/CumulusMX/InternetSettings.cs
@@ -559,13 +559,13 @@ public string GetExtraWebFilesData()
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.Append("{");
+ json.Append('{');
json.Append($"\"id\":{(i + 1)},\"values\":[\"{local}\",\"{remote}\",\"{process}\",\"{realtime}\",\"{ftp}\",\"{utf8}\",\"{binary}\",\"{endofday}\"]");
- json.Append("}");
+ json.Append('}');
if (i < Cumulus.numextrafiles - 1)
{
- json.Append(",");
+ json.Append(',');
}
}
diff --git a/CumulusMX/SQLite.cs b/CumulusMX/SQLite.cs
index 502d069c..76e460a5 100644
--- a/CumulusMX/SQLite.cs
+++ b/CumulusMX/SQLite.cs
@@ -2803,15 +2803,15 @@ private CompileResult CompileExpr (Expression expr, List