Skip to content

Commit

Permalink
Merge pull request #170 from mcrossley/master
Browse files Browse the repository at this point in the history
v3.24.1
  • Loading branch information
mcrossley authored Mar 11, 2023
2 parents 71d18cd + ce26e92 commit a12b575
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 688 deletions.
129 changes: 67 additions & 62 deletions CumulusMX/Cumulus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,7 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
{
LocalPath = WebPath,
LocalFileName = "airquality.json",
RemoteFileName = "airquality.json",
Incremental = true
RemoteFileName = "airquality.json"
},
new FileGenerationOptions() // 13
{
Expand Down Expand Up @@ -4039,8 +4038,11 @@ private void ReadIniFile()
CultureInfo.DefaultThreadCurrentCulture = newCulture;
}

ProgramOptions.TimeFormat = ini.GetValue("Program", "TimeFormat", "t");

ProgramOptions.WarnMultiple = ini.GetValue("Station", "WarnMultiple", true);
ProgramOptions.ListWebTags = ini.GetValue("Station", "ListWebTags", false);

SmtpOptions.Logging = ini.GetValue("SMTP", "Logging", false);
if (DebuggingEnabled)
{
Expand Down Expand Up @@ -5617,13 +5619,15 @@ internal void WriteIniFile()

ini.SetValue("Program", "DataStoppedExit", ProgramOptions.DataStoppedExit);
ini.SetValue("Program", "DataStoppedMins", ProgramOptions.DataStoppedMins);
ini.SetValue("Program", "TimeFormat", ProgramOptions.TimeFormat);

ini.SetValue("Culture", "RemoveSpaceFromDateSeparator", ProgramOptions.Culture.RemoveSpaceFromDateSeparator);

ini.SetValue("Station", "WarnMultiple", ProgramOptions.WarnMultiple);
ini.SetValue("Station", "ListWebTags", ProgramOptions.ListWebTags);



ini.SetValue("Station", "Type", StationType);
ini.SetValue("Station", "Model", StationModel);
ini.SetValue("Station", "ComportName", ComportName);
Expand Down Expand Up @@ -8995,8 +8999,8 @@ public void DoLocalCopy()
File.WriteAllText(dstfile, text);
}
// The config files only need uploading once per change
if (GraphDataFiles[i].LocalFileName == "availabledata.json" ||
GraphDataFiles[i].LocalFileName == "graphconfig.json")
// 0=graphconfig, 1=availabledata, 8=dailyrain, 9=dailytemp, 11=sunhours
if (i == 0 || i == 1 || i == 8 || i == 9 || i == 11)
{
GraphDataFiles[i].CopyRequired = false;
}
Expand Down Expand Up @@ -9031,7 +9035,7 @@ public void DoLocalCopy()
}
else
{
var text = station.CreateEodGraphDataJson(GraphDataFiles[i].LocalFileName);
var text = station.CreateEodGraphDataJson(GraphDataEodFiles[i].LocalFileName);
File.WriteAllText(dstfile, text);
}
// Uploaded OK, reset the upload required flag
Expand All @@ -9052,10 +9056,10 @@ public void DoLocalCopy()
{
try
{
LogDebugMessage("LocalCopy: Copying Moon image file");
LogDebugMessage("LocalCopy: Copying Moon image file to " + MoonImage.CopyDest);
File.Copy("web" + DirectorySeparator + "moon.png", MoonImage.CopyDest, true);
LogDebugMessage("LocalCopy: Done copying Moon image file");
// clear the image ready for FTP flag, only upload once an hour
// clear the image ready for copy flag, only upload once an hour
MoonImage.ReadyToCopy = false;
}
catch (Exception e)
Expand Down Expand Up @@ -9722,16 +9726,14 @@ public async Task DoIntervalUpload()
{
if (StdWebFiles[i].FTP)
{
try
{
LogDebugMessage("PHP[Int]: Uploading standard Data file: " + StdWebFiles[i].RemoteFileName);


var idx = i;
var idx = i;

tasklist.Add(Task.Run(async () =>
tasklist.Add(Task.Run(async () =>
{
string data;
try
{
string data;
LogDebugMessage("PHP[Int]: Uploading standard Data file: " + StdWebFiles[idx].RemoteFileName);

if (StdWebFiles[idx].LocalFileName == "wxnow.txt")
{
Expand All @@ -9747,12 +9749,12 @@ public async Task DoIntervalUpload()
// No standard files are "one offs" at present
//StdWebFiles[i].FtpRequired = false;
}
}));
}
catch (Exception e)
{
LogMessage($"PHP[Int]: Error uploading file {StdWebFiles[i].RemoteFileName}: {e}");
}
}
catch (Exception e)
{
LogMessage($"PHP[Int]: Error uploading file {StdWebFiles[idx].RemoteFileName}: {e}");
}
}));
}
}

Expand All @@ -9764,23 +9766,24 @@ public async Task DoIntervalUpload()
{
if (GraphDataFiles[i].FTP && GraphDataFiles[i].FtpRequired)
{
try
var idx = i;

tasklist.Add(Task.Run(async () =>
{
// we want incremental data for PHP
var json = station.CreateGraphDataJson(GraphDataFiles[i].LocalFileName, true);
var remotefile = GraphDataFiles[i].RemoteFileName;
LogDebugMessage("PHP[Int]: Uploading graph data file: " + GraphDataFiles[i].LocalFileName);
try
{

var idx = i;
// we want incremental data for PHP
var json = station.CreateGraphDataJson(GraphDataFiles[idx].LocalFileName, GraphDataFiles[idx].Incremental);
var remotefile = GraphDataFiles[idx].RemoteFileName;
LogDebugMessage("PHP[Int]: Uploading graph data file: " + GraphDataFiles[idx].LocalFileName);

tasklist.Add(Task.Run(async () =>
{
if (await UploadString(phpUploadHttpClient, GraphDataFiles[idx].Incremental, oldestTs, json, remotefile, -1, false, true))
//if (UploadString(phpUploadHttpClient, GraphDataFiles[i].Incremental, oldestTs, json, remotefile, -1, false, true))
{
// The config files only need uploading once per change
if (GraphDataFiles[idx].LocalFileName == "availabledata.json" ||
GraphDataFiles[idx].LocalFileName == "graphconfig.json")
// 0=graphconfig, 1=availabledata, 8=dailyrain, 9=dailytemp, 11=sunhours
if (idx == 0 || idx == 1 || idx == 8 || idx == 9 || idx == 11)
{
GraphDataFiles[idx].FtpRequired = false;
}
Expand All @@ -9790,63 +9793,64 @@ public async Task DoIntervalUpload()
GraphDataFiles[idx].Incremental = true;
}
}
}));
}
catch (Exception e)
{
LogMessage($"PHP[Int]: Error uploading graph data file [{GraphDataFiles[i].RemoteFileName}]");
LogMessage($"PHP[Int]: Error = {e}");
}
}
catch (Exception e)
{
LogMessage($"PHP[Int]: Error uploading graph data file [{GraphDataFiles[idx].RemoteFileName}]");
LogMessage($"PHP[Int]: Error = {e}");
}
}));
}
}

for (int i = 0; i < GraphDataEodFiles.Length; i++)
{
if (GraphDataEodFiles[i].FTP && GraphDataEodFiles[i].FtpRequired)
{
var remotefile = GraphDataEodFiles[i].RemoteFileName;
try
{
LogMessage("PHP[Int]: Uploading daily graph data file: " + GraphDataEodFiles[i].LocalFileName);
var json = station.CreateEodGraphDataJson(GraphDataEodFiles[i].LocalFileName);

var idx = i;
var idx = i;

tasklist.Add(Task.Run(async () =>
tasklist.Add(Task.Run(async () =>
{
var remotefile = GraphDataEodFiles[idx].RemoteFileName;
try
{
LogMessage("PHP[Int]: Uploading daily graph data file: " + GraphDataEodFiles[idx].LocalFileName);
var json = station.CreateEodGraphDataJson(GraphDataEodFiles[idx].LocalFileName);

if (await UploadString(phpUploadHttpClient, false, "", json, remotefile, -1, false, true))
{
// Uploaded OK, reset the upload required flag
GraphDataEodFiles[idx].FtpRequired = false;
}
}));
}
catch (Exception e)
{
LogMessage($"PHP[Int]: Error uploading daily graph data file [{GraphDataEodFiles[i].RemoteFileName}]");
LogMessage($"PHP[Int]: Error = {e}");
}
}
catch (Exception e)
{
LogMessage($"PHP[Int]: Error uploading daily graph data file [{GraphDataEodFiles[idx].RemoteFileName}]");
LogMessage($"PHP[Int]: Error = {e}");
}
}));
}
}

if (MoonImage.Ftp && MoonImage.ReadyToFtp)
{
try
tasklist.Add(Task.Run(async () =>
{
LogDebugMessage("PHP[Int]: Uploading Moon image file");
tasklist.Add(Task.Run(async () =>
try
{
LogDebugMessage("PHP[Int]: Uploading Moon image file");

if (await UploadFile(phpUploadHttpClient, "web" + DirectorySeparator + "moon.png", MoonImage.FtpDest, -1, true))
{
// clear the image ready for FTP flag, only upload once an hour
MoonImage.ReadyToFtp = false;
}
}));
}
catch (Exception e)
{
LogMessage($"PHP[Int]: Error uploading moon image - {e.Message}");
}
}
catch (Exception e)
{
LogMessage($"PHP[Int]: Error uploading moon image - {e.Message}");
}
}));
}

await Task.WhenAll(tasklist.ToArray());
Expand Down Expand Up @@ -12256,6 +12260,7 @@ public class ProgramOptionsClass
public CultureConfig Culture { get; set; }
public bool DataStoppedExit { get; set; }
public int DataStoppedMins { get; set; }
public string TimeFormat { get; set; }
}

public class CultureConfig
Expand Down
5 changes: 4 additions & 1 deletion CumulusMX/EasyWeather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace CumulusMX
* 8* Outdoor temp float Celsius
* 9* Dew point float Celsius
* 10* Wind chill float Celsius
* 11 Absolute press float mB/hPa
* 11* Absolute press float mB/hPa
* 12* Relative press float mB/hPa
* 13* Wind average float m/s
* 14 Wind average int Beaufort
Expand Down Expand Up @@ -57,6 +57,7 @@ internal class EasyWeather : WeatherStation
private const int EW_OUTDOOR_TEMP = 9;
private const int EW_DEW_POINT = 10;
private const int EW_WIND_CHILL = 11;
private const int EW_ABS_PRESSURE = 12;
private const int EW_REL_PRESSURE = 13;
private const int EW_AVERAGE_WIND = 14;
private const int EW_WIND_GUST = 16;
Expand Down Expand Up @@ -150,6 +151,8 @@ private void EWGetData(object sender, ElapsedEventArgs elapsedEventArgs)
DoPressure(ConvertPressMBToUser(GetConvertedValue(st[EW_REL_PRESSURE])), now);
UpdatePressureTrendString();

StationPressure = ConvertPressMBToUser(GetConvertedValue(st[EW_ABS_PRESSURE]));

DoIndoorTemp(ConvertTempCToUser(GetConvertedValue(st[EW_INDOOR_TEMP])));

DoOutdoorTemp(ConvertTempCToUser(GetConvertedValue(st[EW_OUTDOOR_TEMP])), now);
Expand Down
2 changes: 2 additions & 0 deletions CumulusMX/GW1000Station.cs
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ private void GetLiveData()
idx += 1;
break;
case 0x08: //Absolute Barometric (hPa)
tempUint16 = GW1000Api.ConvertBigEndianUInt16(data, idx);
StationPressure = ConvertPressMBToUser(tempUint16 / 10.0);
idx += 2;
break;
case 0x09: //Relative Barometric (hPa)
Expand Down
12 changes: 11 additions & 1 deletion CumulusMX/HttpStationAmbient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,27 @@ public string ProcessData(IHttpContext context, bool main)
// baromrelin

var press = data["baromrelin"];
var stnPress = data["baromabsin"];

if (press == null)
{
cumulus.LogMessage($"ProcessData: Error, missing baro pressure");
cumulus.LogMessage("ProcessData: Error, missing baro pressure");
}
else
{
var pressVal = ConvertPressINHGToUser(Convert.ToDouble(press, CultureInfo.InvariantCulture));
DoPressure(pressVal, recDate);
UpdatePressureTrendString();
}

if (stnPress == null)
{
cumulus.LogDebugMessage("ProcessData: Error, missing absolute baro pressure");
}
else
{
StationPressure = ConvertPressINHGToUser(Convert.ToDouble(stnPress, CultureInfo.InvariantCulture));
}
}
catch (Exception ex)
{
Expand Down
10 changes: 10 additions & 0 deletions CumulusMX/HttpStationEcowitt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public string ApplyData(string dataString, bool main, DateTime? ts = null)
// baromrelin

var press = data["baromrelin"];
var stnPress = data["baromabsin"];

if (press == null)
{
Expand All @@ -422,6 +423,15 @@ public string ApplyData(string dataString, bool main, DateTime? ts = null)
DoPressure(pressVal, recDate);
UpdatePressureTrendString();
}

if (stnPress == null)
{
cumulus.LogDebugMessage($"{procName}: Error, missing absolute baro pressure");
}
else
{
StationPressure = ConvertPressINHGToUser(Convert.ToDouble(stnPress, invNum));
}
}
catch (Exception ex)
{
Expand Down
3 changes: 3 additions & 0 deletions CumulusMX/InternetSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ public string UpdateConfig(IHttpContext context)
{
cumulus.GraphDataFiles[i].Create = settings.websettings.interval.graphfiles.files[i].create;
if (!cumulus.GraphDataFiles[i].FTP && settings.websettings.interval.graphfiles.files[i].ftp)
{
cumulus.GraphDataFiles[i].FtpRequired = true;
cumulus.GraphDataFiles[i].Incremental = false;
}
cumulus.GraphDataFiles[i].FTP = settings.websettings.interval.graphfiles.files[i].ftp;
if (!cumulus.GraphDataFiles[i].Copy && settings.websettings.interval.graphfiles.files[i].copy)
cumulus.GraphDataFiles[i].CopyRequired = true;
Expand Down
18 changes: 18 additions & 0 deletions CumulusMX/LangSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,24 @@ public string UpdateConfig(IHttpContext context)
context.Response.StatusCode = 500;
}

// Extra Sensors
try
{
cumulus.Trans.ExtraTempCaptions = settings.extraTemp;
cumulus.Trans.ExtraHumCaptions = settings.extraHum;
cumulus.Trans.ExtraDPCaptions = settings.extraDP;
cumulus.Trans.UserTempCaptions = settings.userTemp;
cumulus.Trans.SoilTempCaptions = settings.soilTemp;
cumulus.Trans.SoilMoistureCaptions = settings.soilMoist;
}
catch (Exception ex)
{
var msg = "Error processing Extra Sensor Names: " + ex.Message;
cumulus.LogMessage(msg);
errorMsg += msg + "\n\n";
context.Response.StatusCode = 500;
}

// CO2
try
{
Expand Down
Loading

0 comments on commit a12b575

Please sign in to comment.