Skip to content

Commit

Permalink
Merge pull request #1696 from srcejon/fix_doppler_and_track_sats
Browse files Browse the repository at this point in the history
Fix Sat Tracker crash
  • Loading branch information
f4exb authored May 24, 2023
2 parents 8260721 + 5ff0a5d commit 6c6b9a1
Show file tree
Hide file tree
Showing 15 changed files with 294 additions and 43 deletions.
38 changes: 36 additions & 2 deletions plugins/channelrx/radioastronomy/radioastronomygui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2596,9 +2596,13 @@ void RadioAstronomyGUI::updateRotatorList(const QList<RadioAstronomySettings::Av
// if the chosen rotator appears
int rotatorIndex = ui->rotator->findText(m_settings.m_rotator);

if (rotatorIndex >= 0) {
if (rotatorIndex >= 0)
{
ui->rotator->setCurrentIndex(rotatorIndex);
} else {
setColumnPrecisionFromRotator();
}
else
{
ui->rotator->setCurrentIndex(0); // return to None
}

Expand Down Expand Up @@ -2709,6 +2713,36 @@ void RadioAstronomyGUI::on_rotator_currentTextChanged(const QString& text)
{
m_settings.m_rotator = text;
applySettings();
setColumnPrecisionFromRotator();
}

void RadioAstronomyGUI::setColumnPrecisionFromRotator()
{
// Match rotator precision
const QRegExp re("F([0-9]+):([0-9]+)");
if (re.indexIn(m_settings.m_rotator) >= 0)
{
int featureSetIndex = re.capturedTexts()[1].toInt();
int featureIndex = re.capturedTexts()[2].toInt();

int precision = 0;
if (ChannelWebAPIUtils::getFeatureSetting(featureSetIndex, featureIndex, "precision", precision))
{
int old = ((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_GAL_LAT))->getPrecision();
((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_GAL_LAT))->setPrecision(precision);
((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_GAL_LON))->setPrecision(precision);
((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_AZ))->setPrecision(precision);
((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_EL))->setPrecision(precision);
if (precision > old)
{
ui->powerTable->resizeColumnToContents(POWER_COL_GAL_LAT);
ui->powerTable->resizeColumnToContents(POWER_COL_GAL_LON);
ui->powerTable->resizeColumnToContents(POWER_COL_AZ);
ui->powerTable->resizeColumnToContents(POWER_COL_EL);
}
ui->powerTable->viewport()->update();
}
}
}

void RadioAstronomyGUI::on_showSensors_clicked()
Expand Down
1 change: 1 addition & 0 deletions plugins/channelrx/radioastronomy/radioastronomygui.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ public slots:
void calcPowerChartTickCount(int width);
void calcSpectrumChartTickCount(QValueAxis *axis, int width);
int powerYUnitsToIndex(RadioAstronomySettings::PowerYUnits units);
void setColumnPrecisionFromRotator();

void leaveEvent(QEvent*);
void enterEvent(EnterEventType*);
Expand Down
3 changes: 3 additions & 0 deletions plugins/feature/gs232controller/gs232controllergui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="azimuthMin">
<property name="minimum">
<number>-180</number>
</property>
<property name="maximum">
<number>450</number>
</property>
Expand Down
6 changes: 3 additions & 3 deletions plugins/feature/gs232controller/rotctrldprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void RotCtrlDProtocol::readData()
int rprt = matchRprt.captured(1).toInt();
if (rprt != 0)
{
qWarning() << "GS232ControllerWorker::readData - rotctld error: " << errors[-rprt];
qWarning() << "RotCtrlDProtocol::readData - rotctld error: " << errors[-rprt];
// Seem to get a lot of EPROTO errors from rotctld due to extra 00 char in response to GS232 C2 command
// E.g: ./rotctld.exe -m 603 -r com7 -vvvvv
// read_string(): RX 16 characters
Expand All @@ -97,12 +97,12 @@ void RotCtrlDProtocol::readData()
QString az = m_rotCtlDAz;
QString el = response;
m_rotCtlDReadAz = false;
//qDebug() << "GS232ControllerWorker::readData read Az " << az << " El " << el;
//qDebug() << "RotCtrlDProtocol::readData read Az " << az << " El " << el;
reportAzEl(az.toFloat(), el.toFloat());
}
else
{
qWarning() << "GS232ControllerWorker::readData - Unexpected rotctld response \"" << response << "\"";
qWarning() << "RotCtrlDProtocol::readData - Unexpected rotctld response \"" << response << "\"";
reportError(QString("Unexpected rotctld response: %1").arg(response));
}
}
Expand Down
40 changes: 21 additions & 19 deletions plugins/feature/satellitetracker/satellitetrackerworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,28 +811,30 @@ void SatelliteTrackerWorker::applyDeviceAOSSettings(const QString& name)
void SatelliteTrackerWorker::enableDoppler(SatWorkerState *satWorkerState)
{
QList<SatelliteTrackerSettings::SatelliteDeviceSettings *> *m_deviceSettingsList = m_settings.m_deviceSettings.value(satWorkerState->m_name);

satWorkerState->m_doppler.clear();
bool requiresDoppler = false;
for (int i = 0; i < m_deviceSettingsList->size(); i++)
if (m_deviceSettingsList)
{
SatelliteTrackerSettings::SatelliteDeviceSettings *devSettings = m_deviceSettingsList->at(i);
if (devSettings->m_doppler.size() > 0)
satWorkerState->m_doppler.clear();
bool requiresDoppler = false;
for (int i = 0; i < m_deviceSettingsList->size(); i++)
{
requiresDoppler = true;
for (int j = 0; j < devSettings->m_doppler.size(); j++) {
satWorkerState->m_doppler.append(0);
SatelliteTrackerSettings::SatelliteDeviceSettings *devSettings = m_deviceSettingsList->at(i);
if (devSettings->m_doppler.size() > 0)
{
requiresDoppler = true;
for (int j = 0; j < devSettings->m_doppler.size(); j++) {
satWorkerState->m_doppler.append(0);
}
}
}
}
if (requiresDoppler)
{
qDebug() << "SatelliteTrackerWorker::applyDeviceAOSSettings: Enabling doppler for " << satWorkerState->m_name;
satWorkerState->m_dopplerTimer.setInterval(m_settings.m_dopplerPeriod * 1000);
satWorkerState->m_dopplerTimer.start();
connect(&satWorkerState->m_dopplerTimer, &QTimer::timeout, [this, satWorkerState]() {
doppler(satWorkerState);
});
if (requiresDoppler)
{
qDebug() << "SatelliteTrackerWorker::applyDeviceAOSSettings: Enabling doppler for " << satWorkerState->m_name;
satWorkerState->m_dopplerTimer.setInterval(m_settings.m_dopplerPeriod * 1000);
satWorkerState->m_dopplerTimer.start();
connect(&satWorkerState->m_dopplerTimer, &QTimer::timeout, [this, satWorkerState]() {
doppler(satWorkerState);
});
}
}
}

Expand Down Expand Up @@ -874,7 +876,7 @@ void SatelliteTrackerWorker::doppler(SatWorkerState *satWorkerState)
qDebug() << "SatelliteTrackerWorker::doppler " << satWorkerState->m_name;

QList<SatelliteTrackerSettings::SatelliteDeviceSettings *> *m_deviceSettingsList = m_settings.m_deviceSettings.value(satWorkerState->m_name);
if (m_deviceSettingsList != nullptr)
if (m_deviceSettingsList)
{
for (int i = 0; i < m_deviceSettingsList->size(); i++)
{
Expand Down
4 changes: 4 additions & 0 deletions plugins/feature/startracker/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ To allow Stellarium to set the RA and Dec, select Custom RA/Dec, and ensure the
| S7 | HI | IAU secondary calibration region (l=132,b=-1) | Tb=100 peak |
| S8 | HI | IAU primary calibration region (l=207,b=-15) | Tb=72 peak |
| S9 | HI | IAU secondary calibration region (l=356,b=-4) | Tb=85 peak |
| SatelliteTracker | | Gets target Az/El from Satellite Tracker | |

References:

Expand Down Expand Up @@ -173,6 +174,9 @@ In order to assist in determining whether and when observations of the target ob
This can be plotted on Cartesian or polar axis.
Some objects may not be visible from a particular latitude for the specified time, in which case, the graph title will indicate the object is not visible on that particular date.

When the target is set to a Satellite Tracker, this chart is plotted based on the Satellite's current position only. It does not take in to consideration the satellite's movement. For that,
use the chart in the Satellite Tracker.

<h3>Solar flux vs frequency</h3>

![Star Tracker Solar Flux](../../../doc/img/StarTracker_solarflux.png)
Expand Down
66 changes: 66 additions & 0 deletions plugins/feature/startracker/startracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "device/deviceset.h"
#include "dsp/dspengine.h"
#include "feature/featureset.h"
#include "util/weather.h"
#include "util/units.h"
#include "settings/serializable.h"
Expand All @@ -41,6 +42,7 @@
MESSAGE_CLASS_DEFINITION(StarTracker::MsgConfigureStarTracker, Message)
MESSAGE_CLASS_DEFINITION(StarTracker::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(StarTracker::MsgSetSolarFlux, Message)
MESSAGE_CLASS_DEFINITION(StarTracker::MsgReportAvailableSatelliteTrackers, Message)

const char* const StarTracker::m_featureIdURI = "sdrangel.feature.startracker";
const char* const StarTracker::m_featureId = "StarTracker";
Expand Down Expand Up @@ -69,12 +71,25 @@ StarTracker::StarTracker(WebAPIAdapterInterface *webAPIAdapterInterface) :
m_temps.append(new FITS(":/startracker/startracker/1420mhz_ra_dec.fits"));
m_spectralIndex = new FITS(":/startracker/startracker/408mhz_ra_dec_spectral_index.fits");
scanAvailableChannels();
scanAvailableFeatures();
QObject::connect(
MainCore::instance(),
&MainCore::channelAdded,
this,
&StarTracker::handleChannelAdded
);
QObject::connect(
MainCore::instance(),
&MainCore::featureAdded,
this,
&StarTracker::handleFeatureAdded
);
QObject::connect(
MainCore::instance(),
&MainCore::featureRemoved,
this,
&StarTracker::handleFeatureRemoved
);
}

StarTracker::~StarTracker()
Expand Down Expand Up @@ -908,6 +923,57 @@ void StarTracker::handleMessagePipeToBeDeleted(int reason, QObject* object)
}
}

void StarTracker::scanAvailableFeatures()
{
qDebug("StarTracker::scanAvailableFeatures");
MainCore *mainCore = MainCore::instance();
std::vector<FeatureSet*>& featureSets = mainCore->getFeatureeSets();
m_satelliteTrackers.clear();

for (const auto& featureSet : featureSets)
{
for (int fei = 0; fei < featureSet->getNumberOfFeatures(); fei++)
{
Feature *feature = featureSet->getFeatureAt(fei);

if (feature->getURI() == "sdrangel.feature.satellitetracker")
{
StarTrackerSettings::AvailableFeature satelliteTracker =
StarTrackerSettings::AvailableFeature{featureSet->getIndex(), fei, feature->getIdentifier()};
m_satelliteTrackers[feature] = satelliteTracker;
}
}
}

notifyUpdateSatelliteTrackers();
}

void StarTracker::handleFeatureAdded(int featureSetIndex, Feature *feature)
{
(void) featureSetIndex;
(void) feature;

scanAvailableFeatures();
}

void StarTracker::handleFeatureRemoved(int featureSetIndex, Feature *feature)
{
(void) featureSetIndex;
(void) feature;

scanAvailableFeatures();
}

void StarTracker::notifyUpdateSatelliteTrackers()
{
if (getMessageQueueToGUI())
{
MsgReportAvailableSatelliteTrackers *msg = MsgReportAvailableSatelliteTrackers::create();
msg->getFeatures() = m_satelliteTrackers.values();
getMessageQueueToGUI()->push(msg);
}
}

void StarTracker::handleChannelMessageQueue(MessageQueue* messageQueue)
{
Message* message;
Expand Down
23 changes: 23 additions & 0 deletions plugins/feature/startracker/startracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ class StarTracker : public Feature
{ }
};

class MsgReportAvailableSatelliteTrackers : public Message {
MESSAGE_CLASS_DECLARATION

public:
QList<StarTrackerSettings::AvailableFeature>& getFeatures() { return m_availableFeatures; }

static MsgReportAvailableSatelliteTrackers* create() {
return new MsgReportAvailableSatelliteTrackers();
}

private:
QList<StarTrackerSettings::AvailableFeature> m_availableFeatures;

MsgReportAvailableSatelliteTrackers() :
Message()
{}
};

StarTracker(WebAPIAdapterInterface *webAPIAdapterInterface);
virtual ~StarTracker();
virtual void destroy() { delete this; }
Expand Down Expand Up @@ -165,6 +183,7 @@ class StarTracker : public Feature
QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest;
QSet<ChannelAPI*> m_availableChannels;
QHash<Feature*, StarTrackerSettings::AvailableFeature> m_satelliteTrackers;
Weather *m_weather;
float m_solarFlux;

Expand All @@ -178,12 +197,16 @@ class StarTracker : public Feature
void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response);
double applyBeam(const FITS *fits, double beamwidth, double ra, double dec, int& imgX, int& imgY) const;
void scanAvailableChannels();
void scanAvailableFeatures();
void notifyUpdateSatelliteTrackers();

private slots:
void networkManagerFinished(QNetworkReply *reply);
void weatherUpdated(float temperature, float pressure, float humidity);
void handleChannelAdded(int deviceSetIndex, ChannelAPI *channel);
void handleMessagePipeToBeDeleted(int reason, QObject* object);
void handleFeatureAdded(int featureSetIndex, Feature *feature);
void handleFeatureRemoved(int featureSetIndex, Feature *feature);
void handleChannelMessageQueue(MessageQueue* messageQueue);
};

Expand Down
Loading

0 comments on commit 6c6b9a1

Please sign in to comment.