Skip to content

Commit

Permalink
Merge pull request #204 from mcrossley/main
Browse files Browse the repository at this point in the history
Davis Cloud Station wind processing changed, instead of MX trying to …
  • Loading branch information
mcrossley authored Jul 23, 2024
2 parents 5bcca9d + 45e23e8 commit 010c67d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CumulusMX/CumulusMX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>4.1.2.4026</Version>
<Version>4.1.2.4027</Version>
<Copyright>Copyright © 2015-$([System.DateTime]::Now.ToString('yyyy')) Cumulus MX</Copyright>
</PropertyGroup>

Expand Down
32 changes: 22 additions & 10 deletions CumulusMX/DavisCloudStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ public DavisCloudStation(Cumulus cumulus) : base(cumulus)
cumulus.LeafWetDPlaces = 1;
cumulus.LeafWetFormat = "F1";

CalcRecentMaxGust = true;
cumulus.StationOptions.CalcuateAverageWindSpeed = true;
CalcRecentMaxGust = false;
cumulus.StationOptions.CalcuateAverageWindSpeed = false;
cumulus.StationOptions.UseSpeedForAvgCalc = true;
cumulus.StationOptions.UseSpeedForLatest = true;
cumulus.StationOptions.CalculatedDP = false;
cumulus.StationOptions.CalculatedWC = false;

Expand Down Expand Up @@ -750,6 +751,7 @@ private void GetHistoricData(BackgroundWorker worker)
private void DecodeCurrent(List<WlCurrentSensor> sensors)
{
// The WLL sends the timestamp in Unix ticks, and in UTC
var dataUpdated = false;

foreach (var sensor in sensors)
{
Expand Down Expand Up @@ -779,6 +781,7 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)
continue;
}
cumulus.LogDebugMessage($"DecodeCurrent: Using Leaf/Soil {txid}");
dataUpdated = true;
}
catch (KeyNotFoundException)
{
Expand Down Expand Up @@ -1000,6 +1003,7 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)
continue;
}
cumulus.LogDebugMessage("DecodeCurrent: Using barometer");
dataUpdated = true;
}
catch (KeyNotFoundException)
{
Expand Down Expand Up @@ -1069,6 +1073,7 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)
continue;
}
cumulus.LogDebugMessage($"DecodeCurrent: Using Inside temp/hum");
dataUpdated = true;
}
catch (KeyNotFoundException)
{
Expand Down Expand Up @@ -1132,6 +1137,7 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)
continue;
}
cumulus.LogDebugMessage("DecodeCurrent: Using WLL health");
dataUpdated = true;
}
catch (KeyNotFoundException)
{
Expand Down Expand Up @@ -1163,6 +1169,7 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)
continue;
}
cumulus.LogDebugMessage("DecodeCurrent: Using WLC health");
dataUpdated = true;
}
catch (KeyNotFoundException)
{
Expand Down Expand Up @@ -1211,6 +1218,7 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)
continue;
}
cumulus.LogDebugMessage($"DecodeCurrent: Using this record type {sensor.data_structure_type}");
dataUpdated = true;
}
catch (KeyNotFoundException)
{
Expand Down Expand Up @@ -1361,20 +1369,17 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)

try
{
if (data.wind_speed.HasValue && data.wind_dir.HasValue)
if (data.wind_gust_10_min.HasValue && data.wind_speed.HasValue && data.wind_dir.HasValue)
{
var gust = ConvertUnits.WindMPHToUser(data.wind_speed.Value);
// The cloud data isn't coming in a a rapid enough rate to perform averaging, so just use the Davis values
var gust = ConvertUnits.WindMPHToUser(data.wind_gust_10_min.Value);
var spd = ConvertUnits.WindMPHToUser(data.wind_speed.Value);
// dir is a direction code: 0=N, 1=NNE, ... 14=NW, 15=NNW - convert to degress
var dir = (int) ((data.wind_dir ?? 0) * 22.5);

cumulus.LogDebugMessage("DecodeCurrent: using wind data");

DoWind(gust, dir, -1, lastRecordTime);

if (data.wind_gust_10_min.HasValue)
{
CheckHighGust(ConvertUnits.WindMPHToUser(data.wind_gust_10_min.Value), dir, lastRecordTime);
}
DoWind(gust, dir, spd, lastRecordTime);
}
else
{
Expand Down Expand Up @@ -1674,6 +1679,7 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)
continue;
}
cumulus.LogDebugMessage($"DecodeCurrent: Using ISS {rec.tx_id}, type {sensor.data_structure_type}");
dataUpdated = true;
}
catch (KeyNotFoundException)
{
Expand Down Expand Up @@ -2052,6 +2058,12 @@ private void DecodeCurrent(List<WlCurrentSensor> sensors)
}
}

if (!dataUpdated)
{
// no new data, bail out
return;
}

var dateTime = DateTime.Now;

// Now we have the primary data, calculate the derived data
Expand Down
4 changes: 3 additions & 1 deletion Updates.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
4.1.2 - b4026
4.1.2 - b4027
—————————————
New
- Adds wind run to the dashboard "now" page
Expand All @@ -24,6 +24,8 @@ Fixed
- Remove UV/Solar missing data messages from Davis Cloud (VP2)
- A new version of MigrateData3to4 (1.0.3) to fix issues migrating the day file
- Negative 0.0 appearing when no rainfall has occurred
- Davis Cloud Station wind processing changed, instead of MX trying to calculate an average wind speed, MX now uses the wind speed data from Davis directly.
The data rate from the cloud is not fast enough for the average to be calculated.



Expand Down

0 comments on commit 010c67d

Please sign in to comment.