public WMR100Station(Cumulus cumulus) : base(cumulus) { cumulus.Manufacturer = cumulus.OREGONUSB; var devicelist = DeviceList.Local; var station = devicelist.GetHidDeviceOrNull(Vendorid, Productid); if (station != null) { cumulus.LogMessage("WMR100 station found"); if (station.TryOpen(out stream)) { cumulus.LogMessage("Stream opened"); } packetBuffer = new byte[PacketBufferBound]; WMR200ExtraTempValues = new double[11]; WMR200ExtraHumValues = new double[11]; WMR200ChannelPresent = new bool[11]; WMR200ExtraDPValues = new double[11]; LoadLastHoursFromDataLogs(DateTime.Now); } else { cumulus.LogMessage("WMR100 station not found!"); cumulus.LogConsoleMessage("WMR100 station not found!"); } }
private static void Main(string[] args) { var Windows = Type.GetType("Mono.Runtime") == null; //var ci = new CultureInfo("en-GB"); //System.Threading.Thread.CurrentThread.CurrentCulture = ci; if (!Windows) { // Use reflection, so no attempt to load Mono dll on Windows Assembly _posixAsm; Type _unixSignalType, _signumType; MethodInfo _unixSignalWaitAny; _posixAsm = Assembly.Load("Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"); _unixSignalType = _posixAsm.GetType("Mono.Unix.UnixSignal"); _unixSignalWaitAny = _unixSignalType.GetMethod("WaitAny", new[] { _unixSignalType.MakeArrayType() }); _signumType = _posixAsm.GetType("Mono.Unix.Native.Signum"); Array _signals = Array.CreateInstance(_unixSignalType, 1); _signals.SetValue(Activator.CreateInstance(_unixSignalType, _signumType.GetField("SIGTERM").GetValue(null)), 0); Thread signal_thread = new Thread(delegate() { while (!exitSystem) { // Wait for a signal to be delivered var id = (int)_unixSignalWaitAny.Invoke(null, new object[] { _signals }); cumulus.LogConsoleMessage("\nExiting system due to external SIGTERM signal"); exitSystem = true; } }); signal_thread.Start(); // Now we need to catch the console Ctrl-C Console.CancelKeyPress += (s, ev) => { cumulus.LogConsoleMessage("Ctrl+C pressed"); cumulus.LogConsoleMessage("\nCumulus terminating"); cumulus.Stop(); Trace.WriteLine("Cumulus has shutdown"); ev.Cancel = true; exitSystem = true; }; } else { // set the working path to the exe location Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); } int httpport = 8998; bool debug = false; AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper; for (int i = 0; i < args.Length; i++) { try { if (args[i] == "-lang" && args.Length >= i) { var lang = args[++i]; CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(lang); CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(lang); } else if (args[i] == "-port" && args.Length >= i) { httpport = Convert.ToInt32(args[++i]); } else if (args[i] == "-debug") { // Switch on debug and and data logging from the start debug = true; } else if (args[i] == "-wsport") { i++; Console.WriteLine("The use of the -wsport command line parameter is deprecated"); } else if (args[i] == "-install") { if (Windows) { if (SelfInstaller.InstallMe()) { Console.WriteLine("Cumulus MX is now installed to run as service"); Environment.Exit(0); } else { Console.WriteLine("Cumulus MX failed to install as service"); Environment.Exit(1); } } else { Console.WriteLine("You can only install Cumulus MX as a service in Windows"); Environment.Exit(1); } } else if (args[i] == "-uninstall") { if (Windows) { if (SelfInstaller.UninstallMe()) { Console.WriteLine("Cumulus MX is no longer installed to run as service"); Environment.Exit(0); } else { Console.WriteLine("Cumulus MX failed uninstall itself as service"); Environment.Exit(1); } } else { Console.WriteLine("You can only uninstall Cumulus MX as a service in Windows"); Environment.Exit(1); } } else if (args[i] == "-service") { service = true; } else { Console.WriteLine($"Invalid command line argument \"{args[i]}\""); usage(); } } catch { usage(); } } #if DEBUG debug = true; //Debugger.Launch(); #endif using (appMutex = new Mutex(false, "Global\\" + appGuid)) { // Interactive seems to be always false under mono :( // So we need the no service flag & mono if (Environment.UserInteractive || (!service && !Windows)) { service = false; RunAsAConsole(httpport, debug); } else { var logfile = "MXdiags" + Path.DirectorySeparatorChar + "ServiceConsoleLog.txt"; svcTextListener = new TextWriterTraceListener(logfile); service = true; if (File.Exists(logfile)) { File.Delete(logfile); } svcTextListener = new TextWriterTraceListener(logfile); RunAsAService(); } while (!exitSystem) { Thread.Sleep(500); } Environment.Exit(0); } }
//public string UpdateStationConfig(HttpListenerContext context) public string UpdateStationConfig(IHttpContext context) { var ErrorMsg = ""; context.Response.StatusCode = 200; // get the response try { cumulus.LogMessage("Updating station settings"); var data = new StreamReader(context.Request.InputStream).ReadToEnd(); // Start at char 5 to skip the "json:" prefix var json = WebUtility.UrlDecode(data.Substring(5)); // de-serialize it to the settings structure var settings = JsonConvert.DeserializeObject <JsonStationSettingsData>(json); // process the settings // Graph Config try { cumulus.GraphHours = settings.Graphs.graphhours; cumulus.GraphDays = settings.Graphs.graphdays; cumulus.GraphOptions.TempVisible = settings.Graphs.graphTempVis; cumulus.GraphOptions.InTempVisible = settings.Graphs.graphInTempVis; cumulus.GraphOptions.HIVisible = settings.Graphs.graphHeatIndexVis; cumulus.GraphOptions.DPVisible = settings.Graphs.graphDewPointVis; cumulus.GraphOptions.WCVisible = settings.Graphs.graphWindChillVis; cumulus.GraphOptions.AppTempVisible = settings.Graphs.graphAppTempVis; cumulus.GraphOptions.FeelsLikeVisible = settings.Graphs.graphFeelsLikeVis; cumulus.GraphOptions.HumidexVisible = settings.Graphs.graphHumidexVis; cumulus.GraphOptions.OutHumVisible = settings.Graphs.graphHumVis; cumulus.GraphOptions.InHumVisible = settings.Graphs.graphInHumVis; cumulus.GraphOptions.UVVisible = settings.Graphs.graphUvVis; } catch (Exception ex) { var msg = "Error processing Graph hours: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Annual Rainfall try { cumulus.RainSeasonStart = settings.AnnualRainfall.rainseasonstart; cumulus.YTDrain = settings.AnnualRainfall.ytdamount; cumulus.YTDrainyear = settings.AnnualRainfall.ytdyear; } catch (Exception ex) { var msg = "Error processing Rainfall settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Solar try { cumulus.SolarMinimum = settings.Solar.solarmin; cumulus.RStransfactor = settings.Solar.transfactor; cumulus.SunThreshold = settings.Solar.sunthreshold; cumulus.UseBlakeLarsen = settings.Solar.useblakelarsen; cumulus.SolarCalc = settings.Solar.solarcalc; cumulus.BrasTurbidity = settings.Solar.turbidity; } catch (Exception ex) { var msg = "Error processing Solar settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Forecast try { cumulus.FChighpress = settings.Forecast.highpressureextreme; cumulus.FClowpress = settings.Forecast.lowpressureextreme; cumulus.HourlyForecast = settings.Forecast.updatehourly; cumulus.UseCumulusForecast = settings.Forecast.usecumulusforecast; cumulus.FCpressinMB = (settings.Forecast.pressureunit == "mb/hPa"); } catch (Exception ex) { var msg = "Error processing Forecast settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Location try { cumulus.Altitude = settings.Location.altitude; cumulus.AltitudeInFeet = (settings.Location.altitudeunit == "feet"); cumulus.LocationName = settings.Location.sitename ?? string.Empty; cumulus.LocationDesc = settings.Location.description ?? string.Empty; cumulus.Latitude = settings.Location.Latitude.degrees + (settings.Location.Latitude.minutes / 60.0) + (settings.Location.Latitude.seconds / 3600.0); if (settings.Location.Latitude.hemisphere == "South") { cumulus.Latitude = -cumulus.Latitude; } cumulus.LatTxt = String.Format("{0} {1:D2}° {2:D2}' {3:D2}"", settings.Location.Latitude.hemisphere[0], settings.Location.Latitude.degrees, settings.Location.Latitude.minutes, settings.Location.Latitude.seconds); cumulus.Longitude = settings.Location.Longitude.degrees + (settings.Location.Longitude.minutes / 60.0) + (settings.Location.Longitude.seconds / 3600.0); if (settings.Location.Longitude.hemisphere == "West") { cumulus.Longitude = -cumulus.Longitude; } cumulus.LonTxt = String.Format("{0} {1:D2}° {2:D2}' {3:D2}"", settings.Location.Longitude.hemisphere[0], settings.Location.Longitude.degrees, settings.Location.Longitude.minutes, settings.Location.Longitude.seconds); } catch (Exception ex) { var msg = "Error processing Location settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Options try { cumulus.UseZeroBearing = settings.Options.usezerobearing; cumulus.UseWind10MinAve = settings.Options.calcwindaverage; cumulus.UseSpeedForAvgCalc = settings.Options.usespeedforavg; cumulus.Humidity98Fix = settings.Options.use100for98hum; cumulus.CalculatedDP = settings.Options.calculatedewpoint; cumulus.CalculatedWC = settings.Options.calculatewindchill; cumulus.SyncTime = settings.Options.syncstationclock; cumulus.UseCumulusPresstrendstr = settings.Options.cumuluspresstrendnames; cumulus.ForceVPBarUpdate = settings.Options.vp1minbarupdate; cumulus.LogExtraSensors = settings.Options.extrasensors; cumulus.WS2300IgnoreStationClock = settings.Options.ignorelacrosseclock; cumulus.RoundWindSpeed = settings.Options.roundwindspeeds; cumulus.SyncFOReads = settings.Options.synchroniseforeads; cumulus.logging = settings.Options.debuglogging; cumulus.DataLogging = settings.Options.datalogging; cumulus.WarnMultiple = settings.Options.stopsecondinstance; cumulus.DavisReadReceptionStats = settings.Options.readreceptionstats; } catch (Exception ex) { var msg = "Error processing Options settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Log rollover try { if (settings.logrollover.time == "9am") { cumulus.RolloverHour = 9; } else { cumulus.RolloverHour = 0; } cumulus.Use10amInSummer = settings.logrollover.summer10am; } catch (Exception ex) { var msg = "Error processing Log rollover settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // WLL try { cumulus.WLLAutoUpdateIpAddress = settings.daviswll.network.autoDiscover; cumulus.WllApiKey = settings.daviswll.api.apiKey; cumulus.WllApiSecret = settings.daviswll.api.apiSecret; cumulus.WllStationId = settings.daviswll.api.apiStationId == "-1" ? "" : settings.daviswll.api.apiStationId; cumulus.WllPrimaryRain = settings.daviswll.primary.rain; cumulus.WllPrimarySolar = settings.daviswll.primary.solar; cumulus.WllPrimaryTempHum = settings.daviswll.primary.temphum; cumulus.WllPrimaryUV = settings.daviswll.primary.uv; cumulus.WllPrimaryWind = settings.daviswll.primary.wind; cumulus.WllExtraLeafTx1 = settings.daviswll.soilLeaf.extraLeaf.leafTx1; cumulus.WllExtraLeafTx2 = settings.daviswll.soilLeaf.extraLeaf.leafTx2; cumulus.WllExtraLeafIdx1 = settings.daviswll.soilLeaf.extraLeaf.leafIdx1; cumulus.WllExtraLeafIdx2 = settings.daviswll.soilLeaf.extraLeaf.leafIdx2; cumulus.WllExtraSoilMoistureIdx1 = settings.daviswll.soilLeaf.extraSoilMoist.soilMoistIdx1; cumulus.WllExtraSoilMoistureIdx2 = settings.daviswll.soilLeaf.extraSoilMoist.soilMoistIdx2; cumulus.WllExtraSoilMoistureIdx3 = settings.daviswll.soilLeaf.extraSoilMoist.soilMoistIdx3; cumulus.WllExtraSoilMoistureIdx4 = settings.daviswll.soilLeaf.extraSoilMoist.soilMoistIdx4; cumulus.WllExtraSoilMoistureTx1 = settings.daviswll.soilLeaf.extraSoilMoist.soilMoistTx1; cumulus.WllExtraSoilMoistureTx2 = settings.daviswll.soilLeaf.extraSoilMoist.soilMoistTx2; cumulus.WllExtraSoilMoistureTx3 = settings.daviswll.soilLeaf.extraSoilMoist.soilMoistTx3; cumulus.WllExtraSoilMoistureTx4 = settings.daviswll.soilLeaf.extraSoilMoist.soilMoistTx4; cumulus.WllExtraSoilTempIdx1 = settings.daviswll.soilLeaf.extraSoilTemp.soilTempIdx1; cumulus.WllExtraSoilTempIdx2 = settings.daviswll.soilLeaf.extraSoilTemp.soilTempIdx2; cumulus.WllExtraSoilTempIdx3 = settings.daviswll.soilLeaf.extraSoilTemp.soilTempIdx3; cumulus.WllExtraSoilTempIdx4 = settings.daviswll.soilLeaf.extraSoilTemp.soilTempIdx4; cumulus.WllExtraSoilTempTx1 = settings.daviswll.soilLeaf.extraSoilTemp.soilTempTx1; cumulus.WllExtraSoilTempTx2 = settings.daviswll.soilLeaf.extraSoilTemp.soilTempTx2; cumulus.WllExtraSoilTempTx3 = settings.daviswll.soilLeaf.extraSoilTemp.soilTempTx3; cumulus.WllExtraSoilTempTx4 = settings.daviswll.soilLeaf.extraSoilTemp.soilTempTx4; cumulus.WllExtraTempTx[0] = settings.daviswll.extraTemp.extraTempTx1; cumulus.WllExtraTempTx[1] = settings.daviswll.extraTemp.extraTempTx2; cumulus.WllExtraTempTx[2] = settings.daviswll.extraTemp.extraTempTx3; cumulus.WllExtraTempTx[3] = settings.daviswll.extraTemp.extraTempTx4; cumulus.WllExtraTempTx[4] = settings.daviswll.extraTemp.extraTempTx5; cumulus.WllExtraTempTx[5] = settings.daviswll.extraTemp.extraTempTx6; cumulus.WllExtraTempTx[6] = settings.daviswll.extraTemp.extraTempTx7; cumulus.WllExtraTempTx[7] = settings.daviswll.extraTemp.extraTempTx8; cumulus.WllExtraHumTx[0] = settings.daviswll.extraTemp.extraHumTx1; cumulus.WllExtraHumTx[1] = settings.daviswll.extraTemp.extraHumTx2; cumulus.WllExtraHumTx[2] = settings.daviswll.extraTemp.extraHumTx3; cumulus.WllExtraHumTx[3] = settings.daviswll.extraTemp.extraHumTx4; cumulus.WllExtraHumTx[4] = settings.daviswll.extraTemp.extraHumTx5; cumulus.WllExtraHumTx[5] = settings.daviswll.extraTemp.extraHumTx6; cumulus.WllExtraHumTx[6] = settings.daviswll.extraTemp.extraHumTx7; cumulus.WllExtraHumTx[7] = settings.daviswll.extraTemp.extraHumTx8; } catch (Exception ex) { var msg = "Error processing WLL settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // log interval try { cumulus.DataLogInterval = settings.loginterval; } catch (Exception ex) { var msg = "Error processing Log interval setting: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // com port try { cumulus.ComportName = settings.comportname ?? string.Empty; } catch (Exception ex) { var msg = "Error processing COM port setting: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Davis connection details try { cumulus.VP2ConnectionType = settings.davisconn.conntype; cumulus.VP2IPAddr = settings.davisconn.tcpsettings.ipaddress ?? string.Empty; cumulus.VP2TCPPort = settings.davisconn.tcpsettings.tcpport; cumulus.VP2PeriodicDisconnectInterval = settings.davisconn.tcpsettings.disconperiod; } catch (Exception ex) { var msg = "Error processing Davis settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // GW1000 connection details try { cumulus.Gw1000IpAddress = settings.gw1000.ipaddress; cumulus.Gw1000AutoUpdateIpAddress = settings.gw1000.autoDiscover; } catch (Exception ex) { var msg = "Error processing GW1000 settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Units try { cumulus.WindUnit = settings.units.wind; cumulus.PressUnit = settings.units.pressure; cumulus.TempUnit = settings.units.temp; cumulus.RainUnit = settings.units.rain; cumulus.SetupUnitText(); } catch (Exception ex) { var msg = "Error processing Units settings: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Station type try { if (cumulus.StationType != settings.stationtype) { cumulus.LogMessage("Station type changed, restart required"); cumulus.LogConsoleMessage("*** Station type changed, restart required ***"); } cumulus.StationType = settings.stationtype; } catch (Exception ex) { var msg = "Error processing Station Type setting: " + ex.Message; cumulus.LogMessage(msg); ErrorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Save the settings cumulus.WriteIniFile(); } catch (Exception ex) { cumulus.LogMessage(ex.Message); context.Response.StatusCode = 500; return(ex.Message); } if (context.Response.StatusCode == 200) { return("success"); } else { return(ErrorMsg); } }
public string UpdateConfig(IHttpContext context) { var errorMsg = ""; var json = ""; JsonWizard settings; cumulus.LogMessage("Updating settings from the First Time Wizard"); context.Response.StatusCode = 200; try { var data = new StreamReader(context.Request.InputStream).ReadToEnd(); // Start at char 5 to skip the "json:" prefix json = WebUtility.UrlDecode(data.Substring(5)); // de-serialize it to the settings structure settings = json.FromJson <JsonWizard>(); } catch (Exception ex) { var msg = "Error de-serializing Set-up Wizard Settings JSON: " + ex.Message; cumulus.LogMessage(msg); cumulus.LogDebugMessage("Wizard Data: " + json); context.Response.StatusCode = 500; return(msg); } // process the settings try { cumulus.LogMessage("Updating internet settings"); // website settings try { cumulus.FtpOptions.Enabled = settings.internet.ftp.enabled; if (cumulus.FtpOptions.Enabled) { cumulus.FtpOptions.Directory = settings.internet.ftp.directory ?? string.Empty; cumulus.FtpOptions.Port = settings.internet.ftp.ftpport; cumulus.FtpOptions.Hostname = settings.internet.ftp.hostname ?? string.Empty; cumulus.FtpOptions.FtpMode = (Cumulus.FtpProtocols)settings.internet.ftp.sslftp; cumulus.FtpOptions.Password = settings.internet.ftp.password ?? string.Empty; cumulus.FtpOptions.Username = settings.internet.ftp.username ?? string.Empty; cumulus.FtpOptions.SshAuthen = settings.internet.ftp.sshAuth ?? string.Empty; cumulus.FtpOptions.SshPskFile = settings.internet.ftp.pskFile ?? string.Empty; } cumulus.FtpOptions.LocalCopyEnabled = settings.internet.copy.localcopy; if (cumulus.FtpOptions.LocalCopyEnabled) { cumulus.FtpOptions.LocalCopyFolder = settings.internet.copy.localcopyfolder; } // Now flag all the standard files to FTP/Copy or not // do not process last entry = wxnow.txt, it is not used by the standard site for (var i = 0; i < cumulus.StdWebFiles.Length - 1; i++) { cumulus.StdWebFiles[i].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.StdWebFiles[i].FTP = cumulus.FtpOptions.Enabled; cumulus.StdWebFiles[i].Copy = cumulus.FtpOptions.LocalCopyEnabled; } // and graph data files for (var i = 0; i < cumulus.GraphDataFiles.Length; i++) { cumulus.GraphDataFiles[i].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.GraphDataFiles[i].FTP = cumulus.FtpOptions.Enabled; cumulus.GraphDataFiles[i].Copy = cumulus.FtpOptions.LocalCopyEnabled; } // and EOD data files for (var i = 0; i < cumulus.GraphDataEodFiles.Length; i++) { cumulus.GraphDataEodFiles[i].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.GraphDataEodFiles[i].FTP = cumulus.FtpOptions.Enabled; cumulus.GraphDataEodFiles[i].Copy = cumulus.FtpOptions.LocalCopyEnabled; } // and Realtime files // realtime.txt is not used by the standard site //cumulus.RealtimeFiles[0].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; //cumulus.RealtimeFiles[0].FTP = cumulus.FtpOptions.Enabled; //cumulus.RealtimeFiles[0].Copy = cumulus.FtpOptions.LocalCopyEnabled; // realtimegauges.txt IS used by the standard site cumulus.RealtimeFiles[1].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.RealtimeFiles[1].FTP = cumulus.FtpOptions.Enabled; cumulus.RealtimeFiles[1].Copy = cumulus.FtpOptions.LocalCopyEnabled; // and Moon image cumulus.MoonImage.Enabled = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.MoonImage.Ftp = cumulus.FtpOptions.Enabled; cumulus.MoonImage.Copy = cumulus.FtpOptions.LocalCopyEnabled; if (cumulus.MoonImage.Enabled) { cumulus.MoonImage.CopyDest = cumulus.FtpOptions.LocalCopyFolder + "images" + cumulus.DirectorySeparator + "moon.png"; } // and NOAA reports cumulus.NOAAconf.Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.NOAAconf.AutoFtp = cumulus.FtpOptions.Enabled; cumulus.NOAAconf.AutoCopy = cumulus.FtpOptions.LocalCopyEnabled; if (cumulus.NOAAconf.AutoCopy) { cumulus.NOAAconf.CopyFolder = cumulus.FtpOptions.LocalCopyFolder + "Reports"; } if (cumulus.NOAAconf.AutoFtp) { cumulus.NOAAconf.FtpFolder = cumulus.FtpOptions.Directory + (cumulus.FtpOptions.Directory.EndsWith("/") ? "" : "/") + "Reports"; } } catch (Exception ex) { var msg = "Error processing internet settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // web settings try { cumulus.RealtimeIntervalEnabled = settings.website.realtime.enabled; if (cumulus.RealtimeIntervalEnabled) { cumulus.FtpOptions.RealtimeEnabled = settings.website.realtime.enablerealtimeftp; cumulus.RealtimeInterval = settings.website.realtime.realtimeinterval * 1000; if (cumulus.RealtimeTimer.Interval != cumulus.RealtimeInterval) { cumulus.RealtimeTimer.Interval = cumulus.RealtimeInterval; } } cumulus.RealtimeTimer.Enabled = cumulus.RealtimeIntervalEnabled; if (!cumulus.RealtimeTimer.Enabled || !cumulus.FtpOptions.RealtimeEnabled) { cumulus.RealtimeTimer.Stop(); cumulus.RealtimeFTPDisconnect(); } cumulus.WebIntervalEnabled = settings.website.interval.enabled; if (cumulus.WebIntervalEnabled) { cumulus.FtpOptions.IntervalEnabled = settings.website.interval.enableintervalftp; cumulus.UpdateInterval = settings.website.interval.ftpinterval; if (cumulus.WebTimer.Interval != cumulus.UpdateInterval * 60 * 1000) { cumulus.WebTimer.Interval = cumulus.UpdateInterval * 60 * 1000; } } } catch (Exception ex) { var msg = "Error processing web settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Location try { cumulus.Altitude = settings.location.altitude; cumulus.AltitudeInFeet = (settings.location.altitudeunit == "feet"); cumulus.LocationName = settings.location.sitename ?? string.Empty; cumulus.LocationDesc = settings.location.description ?? string.Empty; cumulus.Latitude = settings.location.latitude; cumulus.LatTxt = degToString(cumulus.Latitude, true); cumulus.Longitude = settings.location.longitude; cumulus.LonTxt = degToString(cumulus.Longitude, false); } catch (Exception ex) { var msg = "Error processing Location settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Units try { if (cumulus.Units.Wind != settings.units.wind) { cumulus.Units.Wind = settings.units.wind; cumulus.ChangeWindUnits(); cumulus.WindDPlaces = cumulus.StationOptions.RoundWindSpeed ? 0 : cumulus.WindDPlaceDefaults[cumulus.Units.Wind]; cumulus.WindAvgDPlaces = cumulus.WindDPlaces; } if (cumulus.Units.Press != settings.units.pressure) { cumulus.Units.Press = settings.units.pressure; cumulus.ChangePressureUnits(); cumulus.PressDPlaces = cumulus.PressDPlaceDefaults[cumulus.Units.Press]; } if (cumulus.Units.Temp != settings.units.temp) { cumulus.Units.Temp = settings.units.temp; cumulus.ChangeTempUnits(); } if (cumulus.Units.Rain != settings.units.rain) { cumulus.Units.Rain = settings.units.rain; cumulus.ChangeRainUnits(); cumulus.RainDPlaces = cumulus.RainDPlaceDefaults[cumulus.Units.Rain]; } } catch (Exception ex) { var msg = "Error processing Units settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // data logging try { cumulus.DataLogInterval = settings.logs.loginterval; cumulus.RolloverHour = settings.logs.logrollover.time == "9am" ? 9 : 0; if (cumulus.RolloverHour == 9) { cumulus.Use10amInSummer = settings.logs.logrollover.summer10am; } } catch (Exception ex) { var msg = "Error processing Logging setting: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Station type try { if (cumulus.StationType != settings.station.stationtype) { cumulus.LogMessage("Station type changed, restart required"); cumulus.LogConsoleMessage("*** Station type changed, restart required ***", ConsoleColor.Yellow); } cumulus.StationType = settings.station.stationtype; cumulus.StationModel = settings.station.stationmodel; } catch (Exception ex) { var msg = "Error processing Station Type setting: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Davis VP/VP2/Vue try { if (settings.station.davisvp2 != null) { cumulus.DavisOptions.ConnectionType = settings.station.davisvp2.conntype; if (settings.station.davisvp2.tcpsettings != null) { cumulus.DavisOptions.IPAddr = settings.station.davisvp2.tcpsettings.ipaddress ?? string.Empty; cumulus.DavisOptions.PeriodicDisconnectInterval = settings.station.davisvp2.tcpsettings.disconperiod; } if (cumulus.DavisOptions.ConnectionType == 0) { cumulus.ComportName = settings.station.davisvp2.comportname; } // set defaults for Davis cumulus.UVdecimals = 1; if (settings.units.rain == 1) { cumulus.RainDPlaces = 2; } } } catch (Exception ex) { var msg = "Error processing Davis VP/VP2/Vue settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // WLL try { if (settings.station.daviswll != null) { cumulus.DavisOptions.ConnectionType = 2; // Always TCP/IP for WLL cumulus.WLLAutoUpdateIpAddress = settings.station.daviswll.network.autoDiscover; cumulus.DavisOptions.IPAddr = settings.station.daviswll.network.ipaddress ?? string.Empty; cumulus.WllApiKey = settings.station.daviswll.api.apiKey; cumulus.WllApiSecret = settings.station.daviswll.api.apiSecret; cumulus.WllStationId = settings.station.daviswll.api.apiStationId; cumulus.WllPrimaryRain = settings.station.daviswll.primary.rain; cumulus.WllPrimarySolar = settings.station.daviswll.primary.solar; cumulus.WllPrimaryTempHum = settings.station.daviswll.primary.temphum; cumulus.WllPrimaryUV = settings.station.daviswll.primary.uv; cumulus.WllPrimaryWind = settings.station.daviswll.primary.wind; } } catch (Exception ex) { var msg = "Error processing WLL settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // GW1000 connection details try { if (settings.station.gw1000 != null) { cumulus.Gw1000IpAddress = settings.station.gw1000.ipaddress; cumulus.Gw1000AutoUpdateIpAddress = settings.station.gw1000.autoDiscover; cumulus.Gw1000MacAddress = settings.station.gw1000.macaddress; } } catch (Exception ex) { var msg = "Error processing GW1000 settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // weatherflow connection details try { if (settings.station.weatherflow != null) { cumulus.WeatherFlowOptions.WFDeviceId = settings.station.weatherflow.deviceid; cumulus.WeatherFlowOptions.WFTcpPort = settings.station.weatherflow.tcpport; cumulus.WeatherFlowOptions.WFToken = settings.station.weatherflow.token; cumulus.WeatherFlowOptions.WFDaysHist = settings.station.weatherflow.dayshistory; } } catch (Exception ex) { var msg = $"Error processing WeatherFlow settings: {ex.Message}"; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // FineOffset try { if (settings.station.fineoffset != null) { cumulus.FineOffsetOptions.SyncReads = settings.station.fineoffset.syncreads; cumulus.FineOffsetOptions.ReadAvoidPeriod = settings.station.fineoffset.readavoid; } } catch (Exception ex) { var msg = "Error processing Fine Offset settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // EasyWeather try { if (settings.station.easyw != null) { cumulus.EwOptions.Interval = settings.station.easyw.interval; cumulus.EwOptions.Filename = settings.station.easyw.filename; } } catch (Exception ex) { var msg = "Error processing EasyWeather settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Instromet try { if (settings.station.imet != null) { cumulus.ComportName = settings.station.imet.comportname ?? cumulus.ComportName; cumulus.ImetOptions.BaudRate = settings.station.imet.baudrate; } } catch (Exception ex) { var msg = "Error processing Instromet settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // WMR928 try { if (settings.station.wmr928 != null) { cumulus.ComportName = settings.station.wmr928.comportname ?? cumulus.ComportName; } } catch (Exception ex) { var msg = "Error processing WMR928 settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Save the settings cumulus.WriteIniFile(); } catch (Exception ex) { var msg = "Error processing Wizard settings: " + ex.Message; cumulus.LogMessage(msg); cumulus.LogDebugMessage("Station Data: " + json); errorMsg += msg; context.Response.StatusCode = 500; } return(context.Response.StatusCode == 200 ? "success" : errorMsg); }
private static void Main(string[] args) { StartTime = DateTime.Now; var windows = Type.GetType("Mono.Runtime") == null; //var ci = new CultureInfo("en-GB"); //System.Threading.Thread.CurrentThread.CurrentCulture = ci; if (windows) { // set the working path to the exe location Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); } var logfile = "MXdiags" + Path.DirectorySeparatorChar + "ServiceConsoleLog.txt"; var logfileOld = "MXdiags" + Path.DirectorySeparatorChar + "ServiceConsoleLog-Old.txt"; if (File.Exists(logfileOld)) { File.Delete(logfileOld); } if (File.Exists(logfile)) { File.Move(logfile, logfileOld); } svcTextListener = new TextWriterTraceListener(logfile); svcTextListener.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Starting on " + (windows ? "Windows" : "Linux")); svcTextListener.Flush(); if (!windows) { // Use reflection, so no attempt to load Mono dll on Windows svcTextListener.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Creating SIGTERM monitor"); svcTextListener.Flush(); var posixAsm = Assembly.Load("Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"); var unixSignalType = posixAsm.GetType("Mono.Unix.UnixSignal"); var unixSignalWaitAny = unixSignalType.GetMethod("WaitAny", new[] { unixSignalType.MakeArrayType() }); var signumType = posixAsm.GetType("Mono.Unix.Native.Signum"); var signals = Array.CreateInstance(unixSignalType, 1); signals.SetValue(Activator.CreateInstance(unixSignalType, signumType.GetField("SIGTERM").GetValue(null)), 0); Thread signalThread = new Thread(delegate() { while (!exitSystem) { // Wait for a signal to be delivered unixSignalWaitAny?.Invoke(null, new object[] { signals }); var msg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Exiting system due to external SIGTERM signal"; Console.WriteLine(msg); svcTextListener.WriteLine(msg); if (cumulus != null) { msg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Cumulus terminating"; Console.WriteLine(msg); svcTextListener.WriteLine(msg); cumulus.LogMessage("Exiting system due to external SIGTERM signal"); cumulus.LogMessage("Cumulus terminating"); cumulus.Stop(); //allow main to run off Thread.Sleep(500); msg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Cumulus has shutdown"; Console.WriteLine(msg); svcTextListener.WriteLine(msg); } exitSystem = true; } }); signalThread.Start(); // Now we need to catch the console Ctrl-C Console.CancelKeyPress += (s, ev) => { if (cumulus != null) { cumulus.LogConsoleMessage("Ctrl+C pressed"); cumulus.LogConsoleMessage("\nCumulus terminating"); cumulus.Stop(); //allow main to run off Thread.Sleep(500); } Trace.WriteLine("Cumulus has shutdown"); ev.Cancel = true; exitSystem = true; }; } AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper; #if DEBUG debug = true; //Debugger.Launch(); #endif for (int i = 0; i < args.Length; i++) { try { switch (args[i]) { case "-lang" when args.Length >= i: { var lang = args[++i]; CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(lang); CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(lang); break; } case "-port" when args.Length >= i: httpport = Convert.ToInt32(args[++i]); break; case "-debug": // Switch on debug and and data logging from the start debug = true; break; case "-wsport": i++; Console.WriteLine("The use of the -wsport command line parameter is deprecated"); break; case "-install" when windows: { if (SelfInstaller.InstallMe()) { Console.WriteLine("Cumulus MX is now installed to run as service"); Environment.Exit(0); } else { Console.WriteLine("Cumulus MX failed to install as service"); Environment.Exit(1); } break; } case "-install": Console.WriteLine("You can only install Cumulus MX as a service in Windows"); Environment.Exit(1); break; case "-uninstall" when windows: { if (SelfInstaller.UninstallMe()) { Console.WriteLine("Cumulus MX is no longer installed to run as service"); Environment.Exit(0); } else { Console.WriteLine("Cumulus MX failed uninstall itself as service"); Environment.Exit(1); } break; } case "-uninstall": Console.WriteLine("You can only uninstall Cumulus MX as a service in Windows"); Environment.Exit(1); break; case "-service": service = true; break; default: Console.WriteLine($"Invalid command line argument \"{args[i]}\""); Usage(); break; } } catch { Usage(); } } using (appMutex = new Mutex(false, "Global\\" + AppGuid)) { // Interactive seems to be always false under mono :( if (windows && !Environment.UserInteractive) { // Windows and not interactive - must be a service svcTextListener.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Running as a Windows service"); svcTextListener.Flush(); service = true; // Launch as a Windows Service ServiceBase.Run(new CumulusService()); } else { if (Environment.UserInteractive || (!windows && !service)) { // Windows interactive or Linux and no service flag svcTextListener.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Running interactively"); service = false; } else { // Must be a Linux service svcTextListener.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff ") + "Running as a Linux service"); service = true; } svcTextListener.Flush(); // Lauch normally - Linux Service runs like this too RunAsAConsole(httpport, debug); } while (!exitSystem) { Thread.Sleep(500); } Environment.Exit(0); } }
internal FOStation(Cumulus cumulus) : base(cumulus) { cumulus.Manufacturer = cumulus.EW; var data = new byte[32]; tmrDataRead = new Timer(); calculaterainrate = true; hasSolar = cumulus.StationType == StationTypes.FineOffsetSolar; if (hasSolar) { foEntrysize = 0x14; foMaxAddr = 0xFFEC; //maxHistoryEntries = 3264; } else { foEntrysize = 0x10; foMaxAddr = 0xFFF0; //maxHistoryEntries = 4080; } do { if (OpenHidDevice()) { // Get the block of data containing the logging interval cumulus.LogMessage("Reading station logging interval"); if (ReadAddress(0x10, data)) { int logint = data[0]; if (logint != cumulus.logints[cumulus.DataLogInterval]) { var msg = $"Warning, your console logging interval ({logint} mins) does not match the Cumulus logging interval ({cumulus.logints[cumulus.DataLogInterval]} mins)"; cumulus.LogConsoleMessage(msg); cumulus.LogMessage(msg); if (cumulus.FineOffsetOptions.SetLoggerInterval) { WriteAddress(0x10, (byte)cumulus.logints[cumulus.DataLogInterval]); // write the logging new logging interval WriteAddress(0x1A, 0xAA); // tell the station to read the new parameter do { Thread.Sleep(1000); // sleep to let it reconfigure ReadAddress(0x10, data); } while (data[9] != 0); } } } // Get the block of data containing the abs and rel pressures cumulus.LogMessage("Reading station pressure offset"); double relpressure = (((data[17] & 0x3f) * 256) + data[16]) / 10.0f; double abspressure = (((data[19] & 0x3f) * 256) + data[18]) / 10.0f; pressureOffset = relpressure - abspressure; cumulus.LogMessage("Rel pressure = " + relpressure); cumulus.LogMessage("Abs pressure = " + abspressure); cumulus.LogMessage("Calculated Offset = " + pressureOffset); if (cumulus.EwOptions.PressOffset < 9999.0) { cumulus.LogMessage("Ignoring calculated offset, using offset value from cumulus.ini file"); cumulus.LogMessage("EWpressureoffset = " + cumulus.EwOptions.PressOffset); pressureOffset = cumulus.EwOptions.PressOffset; } // Read the data from the logger startReadingHistoryData(); } else { // pause for 10 seconds then try again Thread.Sleep(10000); } } while (hidDevice == null || stream == null || !stream.CanRead); }
internal FOStation(Cumulus cumulus) : base(cumulus) { cumulus.Manufacturer = cumulus.EW; var data = new byte[32]; tmrDataRead = new Timer(); calculaterainrate = true; hasSolar = cumulus.StationType == StationTypes.FineOffsetSolar; if (hasSolar) { foEntrysize = 0x14; foMaxAddr = 0xFFEC; maxHistoryEntries = 3264; } else { foEntrysize = 0x10; foMaxAddr = 0xFFF0; maxHistoryEntries = 4080; } var devicelist = DeviceList.Local; int vid = (cumulus.FineOffsetOptions.VendorID < 0 ? DefaultVid : cumulus.FineOffsetOptions.VendorID); int pid = (cumulus.FineOffsetOptions.ProductID < 0 ? DefaultPid : cumulus.FineOffsetOptions.ProductID); cumulus.LogMessage("Looking for Fine Offset station, VendorID=0x" + vid.ToString("X4") + " ProductID=0x" + pid.ToString("X4")); cumulus.LogConsoleMessage("Looking for Fine Offset station"); hidDevice = devicelist.GetHidDeviceOrNull(vendorID: vid, productID: pid); if (hidDevice != null) { cumulus.LogMessage("Fine Offset station found"); cumulus.LogConsoleMessage("Fine Offset station found"); if (hidDevice.TryOpen(out stream)) { cumulus.LogMessage("Stream opened"); cumulus.LogConsoleMessage("Connected to station"); // Get the block of data containing the abs and rel pressures cumulus.LogMessage("Reading pressure offset"); ReadAddress(0x20, data); double relpressure = (((data[1] & 0x3f) * 256) + data[0]) / 10.0f; double abspressure = (((data[3] & 0x3f) * 256) + data[2]) / 10.0f; pressureOffset = relpressure - abspressure; cumulus.LogMessage("Rel pressure = " + relpressure); cumulus.LogMessage("Abs pressure = " + abspressure); cumulus.LogMessage("Calculated Offset = " + pressureOffset); if (cumulus.EwOptions.PressOffset < 9999.0) { cumulus.LogMessage("Ignoring calculated offset, using offset value from cumulus.ini file"); cumulus.LogMessage("EWpressureoffset = " + cumulus.EwOptions.PressOffset); pressureOffset = cumulus.EwOptions.PressOffset; } // Read the data from the logger startReadingHistoryData(); } else { cumulus.LogMessage("Stream open failed"); cumulus.LogConsoleMessage("Unable to connect to station"); } } else { cumulus.LogMessage("*** Fine Offset station not found ***"); cumulus.LogConsoleMessage("Fine Offset station not found"); cumulus.LogMessage("Found the following USB HID Devices..."); int cnt = 0; foreach (HidDevice device in devicelist.GetHidDevices()) { cumulus.LogMessage($" {device}"); cnt++; } if (cnt == 0) { cumulus.LogMessage("No USB HID devices found!"); } } }
public static List <Observation> GetRestPacket(string url, string token, int deviceId, DateTime start, DateTime end, Cumulus c) { List <Observation> ret = new List <Observation>(); cumulus = c; using (var httpClient = new HttpClient()) { var tpStart = start; var tpEnd = end; double ts = tpEnd.Subtract(tpStart).TotalDays; while (ts > 0) { long st; long end_time; st = WeatherPacket.ToUnixTimeSeconds(tpStart); end_time = WeatherPacket.ToUnixTimeSeconds(end); if (ts > 4) // load max 4 days at a time { tpStart = tpStart.AddDays(4); end_time = WeatherPacket.ToUnixTimeSeconds(tpStart) - 1; // subtract a second so we don't overlap ts = tpEnd.Subtract(tpStart).TotalDays; } else { ts = 0; } using (var response = httpClient.GetAsync($"{url}device/{deviceId}?token={token}&time_start={st}&time_end={end_time}") ) { string apiResponse = response.Result.Content.ReadAsStringAsync().Result; var rp = JsonSerializer.DeserializeFromString <RestPacket>(apiResponse); if (rp != null && rp.status.status_message.Equals("SUCCESS") && rp.obs != null) { foreach (var ob in rp.obs) { ret.Add(new Observation(ob)); } } else if (rp != null && rp.status.status_message.Equals("SUCCESS")) { // no data for time period, ignore //cumulus.LogConsoleMessage($"No data for time period from {tpStart} to {end}"); } else { var msg = $"Error downloading tempest history: {apiResponse}"; cumulus.LogMessage(msg); cumulus.LogConsoleMessage(msg); if (rp.status.status_code == 404) { cumulus.LogConsoleMessage("Normally indicates incorrect Device ID"); ts = -1; // force a stop, fatal error } if (rp.status.status_code == 401) { cumulus.LogConsoleMessage("Normally indicates incorrect Token"); ts = -1; // force a stop, fatal error } } } } } return(ret); }
internal FOStation(Cumulus cumulus) : base(cumulus) { cumulus.Manufacturer = cumulus.EW; var data = new byte[32]; tmrDataRead = new Timer(); calculaterainrate = true; hasSolar = cumulus.StationType == StationTypes.FineOffsetSolar; if (hasSolar) { FOentrysize = 0x14; FOMaxAddr = 0xFFEC; maxHistoryEntries = 3264; } else { FOentrysize = 0x10; FOMaxAddr = 0xFFF0; maxHistoryEntries = 4080; } devicelist = DeviceList.Local; int VID = (cumulus.VendorID < 0 ? defaultVID : cumulus.VendorID); int PID = (cumulus.ProductID < 0 ? defaultPID : cumulus.ProductID); cumulus.LogMessage("Looking for Fine Offset station, VendorID=0x" + VID.ToString("X4") + " ProductID=0x" + PID.ToString("X4")); cumulus.LogConsoleMessage("Looking for Fine Offset station"); hidDevice = devicelist.GetHidDeviceOrNull(vendorID: VID, productID: PID); if (hidDevice != null) { cumulus.LogMessage("Fine Offset station found"); cumulus.LogConsoleMessage("Fine Offset station found"); if (hidDevice.TryOpen(out stream)) { cumulus.LogMessage("Stream opened"); cumulus.LogConsoleMessage("Connected to station"); // Get the block of data containing the abs and rel pressures cumulus.LogMessage("Reading pressure offset"); ReadAddress(0x20, data); double relpressure = (((data[1] & 0x3f) * 256) + data[0]) / 10.0f; double abspressure = (((data[3] & 0x3f) * 256) + data[2]) / 10.0f; pressureOffset = relpressure - abspressure; cumulus.LogMessage("Rel pressure = " + relpressure); cumulus.LogMessage("Abs pressure = " + abspressure); cumulus.LogMessage("Calculated Offset = " + pressureOffset); if (cumulus.EWpressureoffset < 9999.0) { cumulus.LogMessage("Ignoring calculated offset, using offset value from cumulus.ini file"); cumulus.LogMessage("EWpressureoffset = " + cumulus.EWpressureoffset); pressureOffset = cumulus.EWpressureoffset; } // Read the data from the logger startReadingHistoryData(); } else { cumulus.LogMessage("Stream open failed"); cumulus.LogConsoleMessage("Unable to connect to station"); } } else { cumulus.LogMessage("Fine Offset station not found"); cumulus.LogConsoleMessage("Fine Offset station not found"); } }