Skip to content

Commit

Permalink
Fix GW1000 station dew point calculation incorrect on the first packe…
Browse files Browse the repository at this point in the history
…t read at start-up
  • Loading branch information
mcrossley committed Dec 29, 2020
1 parent 3d2f4f9 commit 1dd9636
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CumulusMX/Cumulus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,7 @@ internal async void UpdateOpenWeatherMap(DateTime timestamp)
HttpResponseMessage response = await client.PostAsync(url, data);
var responseBodyAsText = await response.Content.ReadAsStringAsync();
var status = response.StatusCode == HttpStatusCode.NoContent ? "OK" : "Error"; // Returns a 204 reponse for OK!
LogDebugMessage($"OpenWeatherMap: Response code = {status} - {response.StatusCode}");
LogMessage($"OpenWeatherMap: Response code = {status} - {response.StatusCode}");
if (response.StatusCode != HttpStatusCode.NoContent)
LogDataMessage($"OpenWeatherMap: Response data = {responseBodyAsText}");
}
Expand Down
8 changes: 7 additions & 1 deletion CumulusMX/GW1000Station.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ private void GetLiveData()

double windSpeedLast = -999, rainRateLast = -999, rainLast = -999, gustLast = -999, gustLastCal = -999;
int windDirLast = -999;
double outdoortemp = -999;

bool batteryLow = false;

Expand All @@ -592,7 +593,8 @@ private void GetLiveData()
break;
case 0x02: //Outdoor Temperature (℃)
tempInt16 = ConvertBigEndianInt16(data, idx);
DoOutdoorTemp(ConvertTempCToUser(tempInt16 / 10.0), dateTime);
// do not process temperature here as if "MX calculates DP" is enabled, we have not yet read the humidity value. Have to do it at the end.
outdoortemp = tempInt16 / 10.0;
idx += 2;
break;
case 0x03: //Dew point (℃)
Expand Down Expand Up @@ -869,6 +871,10 @@ private void GetLiveData()
}
} while (idx < size);

// Process outdoor temperature here, as GW1000 currently does not supply Dew Point so we have to calculate it in DoOutdoorTemp()
if (outdoortemp > -999)
DoOutdoorTemp(ConvertTempCToUser(outdoortemp), dateTime);

if (tenMinuteChanged) tenMinuteChanged = false;

// Now do the stuff that requires more than one input parameter
Expand Down
7 changes: 4 additions & 3 deletions CumulusMX/InternetSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ public string UpdateInternetConfig(IHttpContext context)
cumulus.WCloud.SendUV = settings.weathercloud.includeuv;
cumulus.WCloud.SynchronisedUpdate = (60 % cumulus.WCloud.Interval == 0);

//cumulus.WCloudTimer.Interval = cumulus.WCloudInterval * 60 * 1000;
//cumulus.WCloudTimer.Enabled = cumulus.WCloudEnabled && !cumulus.SynchronisedWCloudUpdate && !String.IsNullOrWhiteSpace(cumulus.WCloudWid) && !String.IsNullOrWhiteSpace(cumulus.WCloudKey);
cumulus.WCloudTimer.Interval = cumulus.WCloud.Interval * 60 * 1000;
cumulus.WCloudTimer.Enabled = cumulus.WCloud.Enabled && !cumulus.WCloud.SynchronisedUpdate && !String.IsNullOrWhiteSpace(cumulus.WCloud.ID) && !String.IsNullOrWhiteSpace(cumulus.WCloud.PW);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -312,7 +312,8 @@ public string UpdateInternetConfig(IHttpContext context)
cumulus.OpenWeatherMap.Interval = settings.openweathermap.interval;
cumulus.OpenWeatherMap.SynchronisedUpdate = (60 % cumulus.OpenWeatherMap.Interval == 0);

cumulus.OpenWeatherMap.Enabled = cumulus.OpenWeatherMap.Enabled && !string.IsNullOrWhiteSpace(cumulus.OpenWeatherMap.PW);
cumulus.OpenWeatherMapTimer.Interval = cumulus.OpenWeatherMap.Interval * 60 * 1000;
cumulus.OpenWeatherMapTimer.Enabled = cumulus.OpenWeatherMap.Enabled && !string.IsNullOrWhiteSpace(cumulus.OpenWeatherMap.PW);
}
catch (Exception ex)
{
Expand Down
1 change: 1 addition & 0 deletions Updates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fix: Historic charts wind run tooltip suffix
- Fix: High Min Temp and Low Max Temp records editors were not displaying and allowing input of the time
- Fix: This Month/This Year records editors were showing records for the entire day file rather than the specific period
- Fix: GW1000 station dewpoint calculation incorrect on first packet read at start-up

- New: Settings page: Program Settings. Moved Debug/Data logging options and Prevent Second Instance to here from Station Settings.
Note: These settings still remain in the [Station] section of the Cumulus.ini file for backwards compatibility
Expand Down

0 comments on commit 1dd9636

Please sign in to comment.