1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Merge pull request #1449 from srcejon/fix_1445

Satellite Tracker: Fix for #1445.
This commit is contained in:
Edouard Griffiths 2022-09-26 19:41:14 +02:00 committed by GitHub
commit 1ff4249202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 40 deletions

View File

@ -1168,6 +1168,10 @@ QDateTime SatelliteTracker::currentDateTimeUtc()
return QDateTime::currentDateTimeUtc();
}
}
else if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::CUSTOM)
{
return QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
}
else if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::FROM_MAP)
{
QString dateTimeStr;

View File

@ -289,11 +289,6 @@ SatelliteTrackerGUI::SatelliteTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *fea
ui->dateTime->setDateTime(m_satelliteTracker->currentDateTime());
ui->deviceFeatureSelect->setVisible(false);
// Use My Position from preferences, if none set
if ((m_settings.m_latitude == 0.0) && (m_settings.m_longitude == 0.0)) {
on_useMyPosition_clicked();
}
resizeTable();
// Allow user to reorder columns
ui->satTable->horizontalHeader()->setSectionsMovable(true);
@ -322,6 +317,11 @@ SatelliteTrackerGUI::SatelliteTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *fea
// Get initial list of satellites
on_updateSatData_clicked();
// Use My Position from preferences, if none set
if ((m_settings.m_latitude == 0.0) && (m_settings.m_longitude == 0.0)) {
on_useMyPosition_clicked();
}
}
SatelliteTrackerGUI::~SatelliteTrackerGUI()
@ -399,6 +399,8 @@ void SatelliteTrackerGUI::onMenuDialogCalled(const QPoint &p)
void SatelliteTrackerGUI::aos(const QString& name, int duration, int maxElevation)
{
// Call plotChart() to start the periodic updates with sat position in polar chart
plotChart();
// Give speech notification of pass
QString speech = m_settings.m_aosSpeech.trimmed();
if (!speech.isEmpty())

View File

@ -306,6 +306,8 @@ void SatelliteTrackerWorker::update()
else
qdt = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs).toUTC();
bool timeReversed = m_lastUpdateDateTime > qdt;
QHashIterator<QString, SatWorkerState *> itr(m_workerState);
while (itr.hasNext())
{
@ -320,7 +322,7 @@ void SatelliteTrackerWorker::update()
// Calculate position, AOS/LOS and other details for satellite
int noOfPasses;
bool recalcAsPastLOS = (satWorkerState->m_satState.m_passes.size() > 0) && (satWorkerState->m_satState.m_passes[0].m_los < qdt);
if (m_recalculatePasses || recalcAsPastLOS)
if (m_recalculatePasses || recalcAsPastLOS || timeReversed)
noOfPasses = (name == m_settings.m_target) ? 99 : 1;
else
noOfPasses = 0;
@ -330,48 +332,73 @@ void SatelliteTrackerWorker::update()
m_settings.m_passStartTime, m_settings.m_passFinishTime, m_settings.m_utc,
noOfPasses, m_settings.m_groundTrackPoints, &satWorkerState->m_satState);
// Update AOS/LOS (only set timers if using real time)
if ((m_settings.m_dateTime == "") && (satWorkerState->m_satState.m_passes.size() > 0))
// Update AOS/LOS
if (satWorkerState->m_satState.m_passes.size() > 0)
{
// Do we have a new AOS?
if ((satWorkerState->m_aos != satWorkerState->m_satState.m_passes[0].m_aos) || (satWorkerState->m_los != satWorkerState->m_satState.m_passes[0].m_los))
// Only use timers if using real time
if (m_settings.m_dateTimeSelect == SatelliteTrackerSettings::NOW)
{
qDebug() << "SatelliteTrackerWorker: Current time: " << qdt.toString(Qt::ISODateWithMs);
qDebug() << "SatelliteTrackerWorker: New AOS: " << name << " new: " << satWorkerState->m_satState.m_passes[0].m_aos << " old: " << satWorkerState->m_aos;
qDebug() << "SatelliteTrackerWorker: New LOS: " << name << " new: " << satWorkerState->m_satState.m_passes[0].m_los << " old: " << satWorkerState->m_los;
satWorkerState->m_aos = satWorkerState->m_satState.m_passes[0].m_aos;
satWorkerState->m_los = satWorkerState->m_satState.m_passes[0].m_los;
if (satWorkerState->m_aos.isValid())
// Do we have a new pass?
if ((satWorkerState->m_aos != satWorkerState->m_satState.m_passes[0].m_aos) || (satWorkerState->m_los != satWorkerState->m_satState.m_passes[0].m_los))
{
if (satWorkerState->m_aos > qdt)
qDebug() << "SatelliteTrackerWorker: Current time: " << qdt.toString(Qt::ISODateWithMs);
qDebug() << "SatelliteTrackerWorker: New AOS: " << name << " new: " << satWorkerState->m_satState.m_passes[0].m_aos << " old: " << satWorkerState->m_aos;
qDebug() << "SatelliteTrackerWorker: New LOS: " << name << " new: " << satWorkerState->m_satState.m_passes[0].m_los << " old: " << satWorkerState->m_los;
satWorkerState->m_aos = satWorkerState->m_satState.m_passes[0].m_aos;
satWorkerState->m_los = satWorkerState->m_satState.m_passes[0].m_los;
satWorkerState->m_hasSignalledAOS = false;
if (satWorkerState->m_aos.isValid())
{
satWorkerState->m_aosTimer.setInterval(satWorkerState->m_aos.toMSecsSinceEpoch() - qdt.toMSecsSinceEpoch());
satWorkerState->m_aosTimer.setSingleShot(true);
satWorkerState->m_aosTimer.start();
}
else if (qdt < satWorkerState->m_los)
aos(satWorkerState);
if (satWorkerState->m_aos > qdt)
{
satWorkerState->m_aosTimer.setInterval(satWorkerState->m_aos.toMSecsSinceEpoch() - qdt.toMSecsSinceEpoch());
satWorkerState->m_aosTimer.setSingleShot(true);
satWorkerState->m_aosTimer.start();
}
else if (qdt < satWorkerState->m_los)
aos(satWorkerState);
if (satWorkerState->m_los.isValid() && (m_settings.m_target == satWorkerState->m_name))
calculateRotation(satWorkerState);
}
if (satWorkerState->m_los.isValid() && (satWorkerState->m_los > qdt))
{
if (satWorkerState->m_losTimer.isActive()) {
qDebug() << "SatelliteTrackerWorker::update m_losTimer.remainingTime: " << satWorkerState->m_losTimer.remainingTime();
if (satWorkerState->m_los.isValid() && (m_settings.m_target == satWorkerState->m_name))
calculateRotation(satWorkerState);
}
// We can detect a new AOS for a satellite, a little bit before the LOS has occured
// Allow for 5s here (1s doesn't appear to be enough in some cases)
if (satWorkerState->m_losTimer.isActive() && (satWorkerState->m_losTimer.remainingTime() <= 5000))
if (satWorkerState->m_los.isValid() && (satWorkerState->m_los > qdt))
{
satWorkerState->m_losTimer.stop();
// LOS hasn't been called yet - do so, before we reset timer
los(satWorkerState);
if (satWorkerState->m_losTimer.isActive()) {
qDebug() << "SatelliteTrackerWorker::update m_losTimer.remainingTime: " << satWorkerState->m_losTimer.remainingTime();
}
// We can detect a new AOS for a satellite, a little bit before the LOS has occured
// Allow for 5s here (1s doesn't appear to be enough in some cases)
if (satWorkerState->m_losTimer.isActive() && (satWorkerState->m_losTimer.remainingTime() <= 5000))
{
satWorkerState->m_losTimer.stop();
// LOS hasn't been called yet - do so, before we reset timer
los(satWorkerState);
}
qDebug() << "SatelliteTrackerWorker:: Interval to LOS " << (satWorkerState->m_los.toMSecsSinceEpoch() - qdt.toMSecsSinceEpoch());
satWorkerState->m_losTimer.setInterval(satWorkerState->m_los.toMSecsSinceEpoch() - qdt.toMSecsSinceEpoch());
satWorkerState->m_losTimer.setSingleShot(true);
satWorkerState->m_losTimer.start();
}
qDebug() << "SatelliteTrackerWorker:: Interval to LOS " << (satWorkerState->m_los.toMSecsSinceEpoch() - qdt.toMSecsSinceEpoch());
satWorkerState->m_losTimer.setInterval(satWorkerState->m_los.toMSecsSinceEpoch() - qdt.toMSecsSinceEpoch());
satWorkerState->m_losTimer.setSingleShot(true);
satWorkerState->m_losTimer.start();
}
}
else
{
// Do we need to signal LOS?
if (satWorkerState->m_hasSignalledAOS && !satWorkerState->hasAOS(qdt))
{
los(satWorkerState);
satWorkerState->m_hasSignalledAOS = false;
}
// Do we have a new pass?
if ((satWorkerState->m_aos != satWorkerState->m_satState.m_passes[0].m_aos) || (satWorkerState->m_los != satWorkerState->m_satState.m_passes[0].m_los))
{
satWorkerState->m_aos = satWorkerState->m_satState.m_passes[0].m_aos;
satWorkerState->m_los = satWorkerState->m_satState.m_passes[0].m_los;
satWorkerState->m_hasSignalledAOS = false;
}
// Check if we need to signal AOS
if (!satWorkerState->m_hasSignalledAOS && satWorkerState->m_aos.isValid() && satWorkerState->hasAOS(qdt)) {
aos(satWorkerState);
}
}
}
@ -505,6 +532,7 @@ void SatelliteTrackerWorker::update()
qDebug() << "SatelliteTrackerWorker::update: No TLE for " << sat->m_name << ". Can't compute position.";
}
}
m_lastUpdateDateTime = qdt;
m_recalculatePasses = false;
}
@ -512,6 +540,8 @@ void SatelliteTrackerWorker::aos(SatWorkerState *satWorkerState)
{
qDebug() << "SatelliteTrackerWorker::aos " << satWorkerState->m_name;
satWorkerState->m_hasSignalledAOS = true;
// Indicate AOS to GUI
if (getMessageQueueToGUI())
{

View File

@ -47,6 +47,7 @@ public:
m_name(name)
{
m_satState.m_name = name;
m_hasSignalledAOS = false;
}
bool hasAOS(const QDateTime& currentTime);
@ -60,6 +61,7 @@ protected:
QTimer m_dopplerTimer;
QList<int> m_initFrequencyOffset;
SatelliteState m_satState;
bool m_hasSignalledAOS; // For pass specified by m_aos and m_los
friend SatelliteTrackerWorker;
};
@ -114,6 +116,7 @@ private:
bool m_recalculatePasses; //!< Recalculate passes as something has changed
bool m_flipRotation; //!< Use 180 elevation to avoid 360/0 degree discontinutiy
bool m_extendedAzRotation; //!< Use 450+ degree azimuth to avoid 360/0 degree discontinuity
QDateTime m_lastUpdateDateTime;
bool handleMessage(const Message& cmd);
void applySettings(const SatelliteTrackerSettings& settings, bool force = false);