diff --git a/plugins/feature/startracker/readme.md b/plugins/feature/startracker/readme.md index 1866aca76..0442e218f 100644 --- a/plugins/feature/startracker/readme.md +++ b/plugins/feature/startracker/readme.md @@ -36,6 +36,7 @@ Pressing this button displays a settings dialog, that allows you to set: * Height above sea level in metres for use in refraction correction. * Temperature lapse rate in Kelvin per kilometer for use in refraction correction. * Radio frequency being observed in MHz for use in refraction correction. +* The units to display the solar flux in. * The update period in seconds, which controls how frequently azimuth and elevation are re-calculated. * The IP port number the Stellarium server listens on. * Whether to start a Stellarium telescope server. @@ -55,7 +56,17 @@ Specifies the longitude in decimal degrees of the observation point (antenna loc Select the date and time at which the position of the target should be calculated. Select either Now, for the current time, or Custom to manually enter a date and time. -

8: Target

+

8: LST - Local Sidereal Time

+ +The LST field displays the local sidereal time at the specified location (5&6) and Solar time (7). + +

9: Solar Flux

+ +The Canadian Solar Radio Monitoring Program measures the Solar flux at 10.7cm three times a day, and is reported in Solar Flux Units (sfu), where 1 SFU equals 10,000 Jansky or 10^-22 Wm^-2Hz-1. + +The Solar flux field displays this flux value, using units that can be set in the settings dialog. The field is updated every 24 hours. + +

10: Target

Select a target object to track from the list. To manually enter RA (right ascension) and Dec (declination) of an unlisted target, select Custom. @@ -80,19 +91,19 @@ References: * Cassiopeia A, Cygnus A, Taurus A, and Virgo A at ultra-low radio frequencies - https://research.chalmers.se/publication/516438/file/516438_Fulltext.pdf * Repeating Jansky - https://www.gb.nrao.edu/~fghigo/JanskyAntenna/RepeatingJansky_memo10.pdf -

9: Right Ascension

+

11: Right Ascension

When target is set to Custom, you can specify the right ascension in hours of the target object. This can be specified as a decimal (E.g. 12.23, from 0 to 24) or in hours, minutes and seconds (E.g. 12h05m10.2s or 12 05 10.2). Whether the epoch is J2000 or JNOW can be set in the Star Tracker Settings dialog. -

10: Declination

+

12: Declination

When target is set to Custom, you can specify the declination in degrees of the target object. This can be specified as a decimal (E.g. 34.6, from -90.0 to 90.0) or in degrees, minutes and seconds (E.g. 34d12m5.6s, 34d12'5.6" 34 12 5.6). Whether the epoch is J2000 or JNOW can be set in the Star Tracker Settings dialog. -

11: Azimuth

+

13: Azimuth

Displays the calculated azimuth (angle in degrees, clockwise from North) to the object. -

12: Elevation

+

14: Elevation

Displays the calculated elevation (angle in degrees - 0 to horizon and 90 to zenith) to the object. @@ -139,6 +150,8 @@ Then select the SDRangel telescope reticle and press Ocular view.

Attribution

+Solar radio flux measurement at 10.7cm is from National Research Council Canada and Natural Resources Canada: https://www.spaceweather.gc.ca/solarflux/sx-4-en.php + Icons are by Adnen Kadri and Erik Madsen, from the Noun Project Noun Project: https://thenounproject.com/ Icons are by Freepik from Flaticon https://www.flaticon.com/ diff --git a/plugins/feature/startracker/startrackergui.cpp b/plugins/feature/startracker/startrackergui.cpp index 8686cc4c0..f7c66e7c0 100644 --- a/plugins/feature/startracker/startrackergui.cpp +++ b/plugins/feature/startracker/startrackergui.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -147,7 +149,9 @@ StarTrackerGUI::StarTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, m_pluginAPI(pluginAPI), m_featureUISet(featureUISet), m_doApplySettings(true), - m_lastFeatureState(0) + m_lastFeatureState(0), + m_networkManager(nullptr), + m_solarFlux(0.0) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); @@ -197,10 +201,19 @@ StarTrackerGUI::StarTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, m_settings.m_temperatureLapseRate)); printf("];\n"); */ + + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + + connect(&m_solarFluxTimer, SIGNAL(timeout()), this, SLOT(updateSolarFlux())); + m_solarFluxTimer.start(1000*60*60*24); // Update every 24hours + updateSolarFlux(); } StarTrackerGUI::~StarTrackerGUI() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; delete ui; } @@ -475,6 +488,7 @@ void StarTrackerGUI::on_displaySettings_clicked() if (dialog.exec() == QDialog::Accepted) { applySettings(); + displaySolarFlux(); } } @@ -582,3 +596,60 @@ void StarTrackerGUI::on_viewOnMap_clicked() QString target = m_settings.m_target == "Sun" || m_settings.m_target == "Moon" ? m_settings.m_target : "Star"; FeatureWebAPIUtils::mapFind(target); } + +void StarTrackerGUI::updateSolarFlux() +{ + qDebug() << "StarTrackerGUI: Updating flux"; + m_networkRequest.setUrl(QUrl("https://www.spaceweather.gc.ca/solarflux/sx-4-en.php")); + m_networkManager->get(m_networkRequest); +} + +void StarTrackerGUI::displaySolarFlux() +{ + if (m_solarFlux <= 0.0) + ui->solarFlux->setText(""); + else + { + switch (m_settings.m_solarFluxUnits) + { + case StarTrackerSettings::SFU: + ui->solarFlux->setText(QString("%1 sfu").arg(m_solarFlux)); + break; + case StarTrackerSettings::JANSKY: + ui->solarFlux->setText(QString("%1 Jy").arg(Units::solarFluxUnitsToJansky(m_solarFlux))); + break; + case StarTrackerSettings::WATTS_M_HZ: + ui->solarFlux->setText(QString("%1 Wm^-2Hz^-1").arg(Units::solarFluxUnitsToWattsPerMetrePerHertz(m_solarFlux))); + break; + } + ui->solarFlux->setCursorPosition(0); + } +} + +void StarTrackerGUI::networkManagerFinished(QNetworkReply *reply) +{ + ui->solarFlux->setText(""); // Don't show obsolete data + QNetworkReply::NetworkError replyError = reply->error(); + + if (replyError) + { + qWarning() << "StarTrackerGUI::networkManagerFinished:" + << " error(" << (int) replyError + << "): " << replyError + << ": " << reply->errorString(); + } + else + { + QString answer = reply->readAll(); + QRegExp re("\\Observed Flux Density\\<\\/th\\>\\([0-9]+(\\.[0-9]+)?)\\<\\/td\\>"); + if (re.indexIn(answer) != -1) + { + m_solarFlux = re.capturedTexts()[1].toDouble(); + displaySolarFlux(); + } + else + qDebug() << "No Solar flux found: " << answer; + } + + reply->deleteLater(); +} diff --git a/plugins/feature/startracker/startrackergui.h b/plugins/feature/startracker/startrackergui.h index ced54e3e2..336874e81 100644 --- a/plugins/feature/startracker/startrackergui.h +++ b/plugins/feature/startracker/startrackergui.h @@ -21,6 +21,7 @@ #include #include +#include #include "feature/featuregui.h" #include "util/messagequeue.h" @@ -29,6 +30,8 @@ class PluginAPI; class FeatureUISet; class StarTracker; +class QNetworkAccessManager; +class QNetworkReply; namespace Ui { class StarTrackerGUI; @@ -57,12 +60,17 @@ private: StarTracker* m_starTracker; MessageQueue m_inputMessageQueue; QTimer m_statusTimer; + QTimer m_solarFluxTimer; int m_lastFeatureState; QChart m_chart; QDateTimeAxis m_chartXAxis; QValueAxis m_chartYAxis; + QNetworkAccessManager *m_networkManager; + QNetworkRequest m_networkRequest; + double m_solarFlux; + explicit StarTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent = nullptr); virtual ~StarTrackerGUI(); @@ -74,6 +82,7 @@ private: bool handleMessage(const Message& message); void updateLST(); void plotChart(); + void displaySolarFlux(); void leaveEvent(QEvent*); void enterEvent(QEvent*); @@ -94,6 +103,8 @@ private slots: void on_dateTime_dateTimeChanged(const QDateTime &datetime); void updateStatus(); void on_viewOnMap_clicked(); + void updateSolarFlux(); + void networkManagerFinished(QNetworkReply *reply); }; diff --git a/plugins/feature/startracker/startrackergui.ui b/plugins/feature/startracker/startrackergui.ui index 9e859b468..c45a56d08 100644 --- a/plugins/feature/startracker/startrackergui.ui +++ b/plugins/feature/startracker/startrackergui.ui @@ -409,6 +409,23 @@ This can be specified as a decimal (E.g. 34.23) or in degrees, minutes and secon + + + + Solar Flux + + + + + + + Displays the solar flux at 10.7cm + + + true + + + @@ -486,15 +503,21 @@ This can be specified as a decimal (E.g. 34.23) or in degrees, minutes and secon startStop + viewOnMap useMyPosition displaySettings latitude longitude + dateTimeSelect + dateTime + lst + solarFlux target rightAscension declination azimuth elevation + elevationChart diff --git a/plugins/feature/startracker/startrackersettings.cpp b/plugins/feature/startracker/startrackersettings.cpp index 2585a4759..e363c1871 100644 --- a/plugins/feature/startracker/startrackersettings.cpp +++ b/plugins/feature/startracker/startrackersettings.cpp @@ -46,6 +46,7 @@ void StarTrackerSettings::resetToDefaults() m_enableServer = true; m_serverPort = 10001; m_azElUnits = DM; + m_solarFluxUnits = SFU; m_updatePeriod = 1.0; m_jnow = false; m_drawSunOnMap = true; @@ -92,6 +93,7 @@ QByteArray StarTrackerSettings::serialize() const s.writeU32(26, m_reverseAPIPort); s.writeU32(27, m_reverseAPIFeatureSetIndex); s.writeU32(28, m_reverseAPIFeatureIndex); + s.writeU32(29, m_solarFluxUnits); return s.final(); } @@ -156,6 +158,8 @@ bool StarTrackerSettings::deserialize(const QByteArray& data) d.readU32(28, &utmp, 0); m_reverseAPIFeatureIndex = utmp > 99 ? 99 : utmp; + d.readU32(29, (quint32 *)&m_solarFluxUnits, SFU); + return true; } else diff --git a/plugins/feature/startracker/startrackersettings.h b/plugins/feature/startracker/startrackersettings.h index 17290f603..3fec6fd6c 100644 --- a/plugins/feature/startracker/startrackersettings.h +++ b/plugins/feature/startracker/startrackersettings.h @@ -44,6 +44,7 @@ struct StarTrackerSettings uint16_t m_serverPort; bool m_enableServer; // Enable Stellarium server enum AzElUnits {DMS, DM, D, Decimal} m_azElUnits; + enum SolarFluxUnits {SFU, JANSKY, WATTS_M_HZ} m_solarFluxUnits; float m_updatePeriod; bool m_jnow; // Use JNOW epoch rather than J2000 bool m_drawSunOnMap; diff --git a/plugins/feature/startracker/startrackersettingsdialog.cpp b/plugins/feature/startracker/startrackersettingsdialog.cpp index f5dd6cbcd..c21abcf36 100644 --- a/plugins/feature/startracker/startrackersettingsdialog.cpp +++ b/plugins/feature/startracker/startrackersettingsdialog.cpp @@ -37,6 +37,7 @@ StarTrackerSettingsDialog::StarTrackerSettingsDialog(StarTrackerSettings *settin ui->height->setValue(settings->m_heightAboveSeaLevel); ui->temperatureLapseRate->setValue(settings->m_temperatureLapseRate); ui->frequency->setValue(settings->m_frequency/1000000.0); + ui->solarFluxUnits->setCurrentIndex((int)settings->m_solarFluxUnits); ui->drawSunOnMap->setChecked(settings->m_drawSunOnMap); ui->drawMoonOnMap->setChecked(settings->m_drawMoonOnMap); ui->drawStarOnMap->setChecked(settings->m_drawStarOnMap); @@ -61,6 +62,7 @@ void StarTrackerSettingsDialog::accept() m_settings->m_heightAboveSeaLevel = ui->height->value(); m_settings->m_temperatureLapseRate = ui->temperatureLapseRate->value(); m_settings->m_frequency = ui->frequency->value() * 1000000.0; + m_settings->m_solarFluxUnits = (StarTrackerSettings::SolarFluxUnits)ui->solarFluxUnits->currentIndex(); m_settings->m_drawSunOnMap = ui->drawSunOnMap->isChecked(); m_settings->m_drawMoonOnMap = ui->drawMoonOnMap->isChecked(); m_settings->m_drawStarOnMap = ui->drawStarOnMap->isChecked(); diff --git a/plugins/feature/startracker/startrackersettingsdialog.ui b/plugins/feature/startracker/startrackersettingsdialog.ui index 8c1c15a72..bd40dbfba 100644 --- a/plugins/feature/startracker/startrackersettingsdialog.ui +++ b/plugins/feature/startracker/startrackersettingsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 351 - 468 + 393 + 485 @@ -23,73 +23,10 @@ - - + + - Height above sea level (m) - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Draw target star on map - - - - - - - Air temperature (C) - - - - - - - Refraction correction - - - - - - - Stellarium telescope server IP port number - - - 1024 - - - 65535 - - - 10001 - - - - - - - Radio frequency being observed - - - 1000000000 - - - 435 + Update period (s) @@ -100,113 +37,17 @@ - - - - Air pressure in millibars, for use in atmospheric refraction correction - - - 2000.000000000000000 - - - 1.000000000000000 - - - 1010.000000000000000 - - - - - + + - Epoch for RA & Dec + Azimuth and elevation units - - - - Air temperature in degrees Celsius, for use in atmospheric refraction correction - - - -100 - - - 100 - - - 10 - - - - - + + - Draw Sun on map - - - - - - - Draw Moon on map - - - - - - - Relative humidity in % - - - 100 - - - 80 - - - - - - - Stellarium server port - - - - - - - Update period (s) - - - - - - - Humidity (%) - - - - - - - Enter the time in seconds between each calculation of the target's position - - - 1.000000000000000 - - - - - - - Height of observation/antenna location above sea level in metres - - - -1000 - - - 20000 + Refraction correction @@ -217,30 +58,6 @@ - - - - Epoch for custom right ascension and declination - - - - J2000 - - - - - JNOW - - - - - - - - Azimuth and elevation units - - - @@ -266,7 +83,7 @@ - + Enable Stellarium server which allows RA and Dec to be sent to and from Stellarium @@ -276,6 +93,46 @@ + + + + Height of observation/antenna location above sea level in metres + + + -1000 + + + 20000 + + + + + + + Radio frequency being observed + + + 1000000000 + + + 435 + + + + + + + Epoch for RA & Dec + + + + + + + Air temperature (C) + + + @@ -306,13 +163,41 @@ - - - - Temperature lapse rate (K/m) - + + - Temperature lapse rate (K/km) + Draw Sun on map + + + + + + + Height above sea level (m) + + + + + + + Epoch for custom right ascension and declination + + + + J2000 + + + + + JNOW + + + + + + + + Humidity (%) @@ -329,6 +214,150 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Draw Moon on map + + + + + + + Air pressure in millibars, for use in atmospheric refraction correction + + + 2000.000000000000000 + + + 1.000000000000000 + + + 1010.000000000000000 + + + + + + + Temperature lapse rate (K/m) + + + Temperature lapse rate (K/km) + + + + + + + Relative humidity in % + + + 100 + + + 80 + + + + + + + Stellarium telescope server IP port number + + + 1024 + + + 65535 + + + 10001 + + + + + + + Air temperature in degrees Celsius, for use in atmospheric refraction correction + + + -100 + + + 100 + + + 10 + + + + + + + Enter the time in seconds between each calculation of the target's position + + + 1.000000000000000 + + + + + + + Stellarium server port + + + + + + + Draw target star on map + + + + + + + Solar flux units + + + + + + + Units to use for the display of the Solar flux + + + + Solar flux units (sfu) + + + + + Jansky (Jy) + + + + + Watts per square metre per hertz (W m^-2 Hz-1) + + + + @@ -344,6 +373,24 @@ + + epoch + azElUnits + refraction + pressure + temperature + humidity + height + temperatureLapseRate + frequency + solarFluxUnits + updatePeriod + serverPort + enableServer + drawSunOnMap + drawMoonOnMap + drawStarOnMap + diff --git a/sdrbase/util/units.h b/sdrbase/util/units.h index 8faecc1fa..706da3851 100644 --- a/sdrbase/util/units.h +++ b/sdrbase/util/units.h @@ -213,6 +213,16 @@ public: return false; } + static float solarFluxUnitsToJansky(float sfu) + { + return sfu * 10000.0f; + } + + static float solarFluxUnitsToWattsPerMetrePerHertz(float sfu) + { + return sfu * 1e-22f; + } + }; #endif // INCLUDE_UNITS_H