Skip to content

Commit

Permalink
Merge pull request #145 from mcrossley/master
Browse files Browse the repository at this point in the history
v3.17.0
  • Loading branch information
mcrossley committed May 23, 2022
2 parents 0d5d201 + 42211f0 commit 8d2aa53
Show file tree
Hide file tree
Showing 30 changed files with 1,174 additions and 322 deletions.
571 changes: 525 additions & 46 deletions CumulusMX/AstroLib.cs

Large diffs are not rendered by default.

31 changes: 21 additions & 10 deletions CumulusMX/Cumulus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ public struct TExtraFiles
private List<string> OWMList = new List<string>();

// Use thread safe queues for the MySQL command lists
private ConcurrentQueue<string> MySqlList = new ConcurrentQueue<string>();
private ConcurrentQueue<string> MySqlFailedList = new ConcurrentQueue<string>();
private readonly ConcurrentQueue<string> MySqlList = new ConcurrentQueue<string>();
private readonly ConcurrentQueue<string> MySqlFailedList = new ConcurrentQueue<string>();

// Calibration settings
/// <summary>
Expand Down Expand Up @@ -749,14 +749,15 @@ public struct MqttSettings
"HTTP WUnderground", // 13
"HTTP Ecowitt", // 14
"HTTP Ambient", // 15
"WeatherFlow Tempest" // 16
"WeatherFlow Tempest", // 16
"Simulator"
};

public string[] APRSstationtype = { "DsVP", "DsVP", "WMR928", "WM918", "EW", "FO", "WS2300", "FOs", "WMR100", "WMR200", "IMET", "DsVP", "Ecow", "Unkn", "Ecow", "Ambt", "Tmpt" };
public string[] APRSstationtype = { "DsVP", "DsVP", "WMR928", "WM918", "EW", "FO", "WS2300", "FOs", "WMR100", "WMR200", "IMET", "DsVP", "Ecow", "Unkn", "Ecow", "Ambt", "Tmpt", "Simul" };

public string loggingfile;

private PingReply pingReply;
//private PingReply pingReply;

public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
{
Expand Down Expand Up @@ -1478,9 +1479,9 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
}
Console.WriteLine();

LogDebugMessage("Lock: Cumulus waiting for the lock");
//LogDebugMessage("Lock: Cumulus waiting for the lock");
syncInit.Wait();
LogDebugMessage("Lock: Cumulus has lock");
//LogDebugMessage("Lock: Cumulus has lock");

LogMessage("Opening station");

Expand Down Expand Up @@ -1549,6 +1550,10 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
Manufacturer = AMBIENT;
station = new HttpStationAmbient(this);
break;
case StationTypes.Simulator:
Manufacturer = SIMULATOR;
station = new Simulator(this);
break;
default:
LogConsoleMessage("Station type not set", ConsoleColor.Red);
LogMessage("Station type not set");
Expand Down Expand Up @@ -1652,7 +1657,7 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
StartTimersAndSensors();
}

if ((StationType == StationTypes.WMR100) || (StationType == StationTypes.EasyWeather) || (Manufacturer == OREGON))
if ((StationType == StationTypes.WMR100) || (StationType == StationTypes.EasyWeather) || (Manufacturer == OREGON) || StationType == StationTypes.Simulator)
{
station.StartLoop();
}
Expand All @@ -1662,7 +1667,7 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
station.CreateEodGraphDataFiles();
}

LogDebugMessage("Lock: Cumulus releasing the lock");
//LogDebugMessage("Lock: Cumulus releasing the lock");
syncInit.Release();
}

Expand Down Expand Up @@ -6638,6 +6643,7 @@ private void ReadStringsFile()
public int HTTPSTATION = 7;
public int AMBIENT = 8;
public int WEATHERFLOW = 9;
public int SIMULATOR = 10;

//public bool startingup = true;
public string ReportPath;
Expand Down Expand Up @@ -10138,6 +10144,10 @@ public async void CustomHttpSecondsUpdate()
updatingCustomHttpSeconds = false;
}
}
else
{
LogDebugMessage("CustomHttpSeconds: Query already in progress, skipping this attempt");
}
}

public async void CustomHttpMinutesUpdate()
Expand Down Expand Up @@ -10506,7 +10516,7 @@ private void PingCompletedCallback(object sender, PingCompletedEventArgs e)
LogMessage("Ping reply: " + e.Reply.Status);
}

pingReply = e.Reply;
//pingReply = e.Reply;
}

private void CreateRequiredFolders()
Expand Down Expand Up @@ -10577,6 +10587,7 @@ public static class StationTypes
public const int HttpEcowitt = 14;
public const int HttpAmbient = 15;
public const int Tempest = 16;
public const int Simulator = 17;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion CumulusMX/CumulusMX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
<Compile Include="ServiceCumulusInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Simulator.cs" />
<Compile Include="SQLite.cs" />
<Compile Include="ProgramSettings.cs" />
<Compile Include="StationSettings.cs" />
Expand Down Expand Up @@ -265,7 +266,6 @@
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="CumulusMX_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions CumulusMX/DataEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace CumulusMX
internal class DataEditor
{
private WeatherStation station;
private Cumulus cumulus;
private readonly Cumulus cumulus;
private WebTags webtags;

private readonly List<LastHourRainLog> hourRainLog = new List<LastHourRainLog>();
Expand Down Expand Up @@ -1758,7 +1758,7 @@ internal string GetMonthlyRecDayFile()
var isDryNow = false;
var thisDateDry = DateTime.MinValue;
var thisDateWet = DateTime.MinValue;
var monthOffset = 0;
int monthOffset;
var firstEntry = true;

var json = new StringBuilder("{", 25500);
Expand Down
14 changes: 7 additions & 7 deletions CumulusMX/DavisAirLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ namespace CumulusMX
{
internal class DavisAirLink
{
private Cumulus cumulus;
private WeatherStation station;
private readonly Cumulus cumulus;
private readonly WeatherStation station;

private string ipaddr;
private readonly string ipaddr;
private readonly System.Timers.Timer tmrCurrent;
private System.Timers.Timer tmrHealth;
private readonly object threadSafer = new object();
Expand All @@ -42,7 +42,7 @@ internal class DavisAirLink
private readonly bool standaloneHistory; // Used to flag if we need to get history data on catch-up
private DateTime airLinkLastUpdateTime;

private DiscoveredDevices discovered = new DiscoveredDevices();
private readonly DiscoveredDevices discovered = new DiscoveredDevices();

public DavisAirLink(Cumulus cumulus, bool indoor, WeatherStation station)
{
Expand Down Expand Up @@ -312,9 +312,9 @@ private async void GetAlCurrent(object source, ElapsedEventArgs e)

var urlCurrent = $"http://{ip}/v1/current_conditions";

cumulus.LogDebugMessage($"GetAlCurrent: {locationStr} - Waiting for lock");
//cumulus.LogDebugMessage($"GetAlCurrent: {locationStr} - Waiting for lock");
WebReq.Wait();
cumulus.LogDebugMessage($"GetAlCurrent: {locationStr} - Has the lock");
//cumulus.LogDebugMessage($"GetAlCurrent: {locationStr} - Has the lock");

// The AL will error if already responding to a request from another device, so add a retry
do
Expand Down Expand Up @@ -356,7 +356,7 @@ private async void GetAlCurrent(object source, ElapsedEventArgs e)
}
} while (retry < 3);

cumulus.LogDebugMessage($"GetAlCurrent: {locationStr} - Releasing lock");
//cumulus.LogDebugMessage($"GetAlCurrent: {locationStr} - Releasing lock");
WebReq.Release();
}
else
Expand Down
14 changes: 8 additions & 6 deletions CumulusMX/DavisStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -772,24 +772,24 @@ private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)

private void bw_DoStart(object sender, DoWorkEventArgs e)
{
cumulus.LogDebugMessage("Lock: Station waiting for lock");
//cumulus.LogDebugMessage("Lock: Station waiting for lock");
Cumulus.syncInit.Wait();
cumulus.LogDebugMessage("Lock: Station has the lock");
//cumulus.LogDebugMessage("Lock: Station has the lock");

// Wait a short while for Cumulus initialisation to complete
Thread.Sleep(500);
StartLoop();

cumulus.LogDebugMessage("Lock: Station releasing lock");
//cumulus.LogDebugMessage("Lock: Station releasing lock");
Cumulus.syncInit.Release();
}

private void bw_DoWork(object sender, DoWorkEventArgs e)
{
int archiveRun = 0;
cumulus.LogDebugMessage("Lock: Station waiting for the lock");
//cumulus.LogDebugMessage("Lock: Station waiting for the lock");
Cumulus.syncInit.Wait();
cumulus.LogDebugMessage("Lock: Station has the lock");
//cumulus.LogDebugMessage("Lock: Station has the lock");
try
{
// set this temporarily, so speed is done from average and not peak gust from logger
Expand All @@ -805,7 +805,7 @@ private void bw_DoWork(object sender, DoWorkEventArgs e)
{
cumulus.LogMessage("Exception occurred reading archive data: "+ex.Message);
}
cumulus.LogDebugMessage("Lock: Station releasing the lock");
//cumulus.LogDebugMessage("Lock: Station releasing the lock");
Cumulus.syncInit.Release();
}

Expand Down Expand Up @@ -1636,6 +1636,7 @@ private void GetAndProcessLoopData(int number)
DoApparentTemp(now);
DoFeelsLike(now);
DoHumidex(now);
DoCloudBaseHeatIndex(now);

var forecastRule = loopData.ForecastRule < cumulus.DavisForecastLookup.Length ? loopData.ForecastRule : cumulus.DavisForecastLookup.Length - 1;

Expand Down Expand Up @@ -2507,6 +2508,7 @@ private void GetArchiveData()
DoApparentTemp(timestamp);
DoFeelsLike(timestamp);
DoHumidex(timestamp);
DoCloudBaseHeatIndex(timestamp);

// add in 'archivePeriod' minutes worth of wind speed to windrun
WindRunToday += ((WindAverage * WindRunHourMult[cumulus.Units.Wind] * interval) / 60.0);
Expand Down
Loading

0 comments on commit 8d2aa53

Please sign in to comment.