Skip to content

Commit

Permalink
Merge pull request #1658 from srcejon/fix_1641
Browse files Browse the repository at this point in the history
Sat & Star tracker: Plot target on Az/El chart.
  • Loading branch information
f4exb committed Apr 14, 2023
2 parents 3ad4467 + 0581b4c commit 32d5a2c
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 14 deletions.
31 changes: 26 additions & 5 deletions plugins/feature/satellitetracker/satellitetrackergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ bool SatelliteTrackerGUI::handleMessage(const Message& message)

ui->azimuth->setText(convertDegreesToText(satState->m_azimuth));
ui->elevation->setText(convertDegreesToText(satState->m_elevation));
plotChart();

if (satState->m_passes.size() > 0)
{
Expand All @@ -143,7 +144,6 @@ bool SatelliteTrackerGUI::handleMessage(const Message& message)
m_nextTargetAOS = pass.m_aos;
m_nextTargetLOS = pass.m_los;
m_geostationarySatVisible = geostationary;
plotChart();
updateTimeToAOS();
}
}
Expand Down Expand Up @@ -1084,14 +1084,11 @@ void SatelliteTrackerGUI::plotPolarChart()
m_polarChart->addSeries(nowSeries);
nowSeries->attachAxis(angularAxis);
nowSeries->attachAxis(radialAxis);
if (!redrawTime) {
redrawTime = 5000;
}
}

if (redrawTime > 0)
{
// Redraw to show updated satellite position or rotator position
// Redraw to show updated rotator position
m_redrawTimer.setSingleShot(true);
m_redrawTimer.start(redrawTime);
}
Expand Down Expand Up @@ -1239,6 +1236,30 @@ void SatelliteTrackerGUI::plotAzElChart()
azSeriesList[i]->attachAxis(yRightAxis);
}

// Plot current target on elevation series
if (m_targetSatState && (m_targetSatState->m_elevation > 0.0))
{
QDateTime currentTime;

if (m_settings.m_dateTime == "") {
currentTime = m_satelliteTracker->currentDateTimeUtc();
} else if (m_settings.m_utc) {
currentTime = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
} else {
currentTime = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs).toUTC();
}

QScatterSeries *posSeries = new QScatterSeries();
posSeries->setMarkerSize(3);
posSeries->append(currentTime.toMSecsSinceEpoch(), m_targetSatState->m_elevation);
posSeries->setPointLabelsVisible(true);
posSeries->setPointLabelsFormat(m_settings.m_target);
posSeries->setPointLabelsClipping(false);
m_lineChart->addSeries(posSeries);
posSeries->attachAxis(xAxis);
posSeries->attachAxis(yLeftAxis);
}

xAxis->setRange(pass.m_aos, pass.m_los);
xAxis->setFormat("hh:mm");
yLeftAxis->setRange(0.0, 90.0);
Expand Down
9 changes: 5 additions & 4 deletions plugins/feature/satellitetracker/satellitetrackersgp4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ void getSatelliteState(QDateTime dateTime,
QTime passStartTime, QTime passFinishTime, bool utc,
int noOfPasses, int groundTrackSteps, SatelliteState *satState)
{
try {
try
{
Tle tle = Tle(tle0.toStdString(), tle1.toStdString(), tle2.toStdString());
SGP4 sgp4(tle);
Observer obs(latitude, longitude, altitude);
Expand Down Expand Up @@ -522,14 +523,14 @@ void getSatelliteState(QDateTime dateTime,
}
catch (SatelliteException& se)
{
qDebug() << "getSatelliteState: " << satState->m_name << ": " << se.what();
qDebug() << "getSatelliteState:SatelliteException " << satState->m_name << ": " << se.what();
}
catch (DecayedException& de)
{
qDebug() << "getSatelliteState: " << satState->m_name << ": " << de.what();
qDebug() << "getSatelliteState:DecayedException " << satState->m_name << ": " << de.what();
}
catch (TleException& tlee)
{
qDebug() << "getSatelliteState: " << satState->m_name << ": " << tlee.what();
qDebug() << "getSatelliteState:TleException " << satState->m_name << ": " << tlee.what() << "\n" << tle0 << "\n" << tle1 << "\n" << tle2;
}
}
57 changes: 52 additions & 5 deletions plugins/feature/startracker/startrackergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,12 +1540,14 @@ void StarTrackerGUI::plotElevationLineChart()
azSeries->setPen(pen);

QDateTime dt;
QDateTime currentTime;

if (m_settings.m_dateTime.isEmpty()) {
dt = QDateTime::currentDateTime();
currentTime = QDateTime::currentDateTime();
} else {
dt = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
currentTime = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
}
dt = currentTime;

dt.setTime(QTime(0,0));
QDateTime startTime = dt;
Expand Down Expand Up @@ -1635,6 +1637,28 @@ void StarTrackerGUI::plotElevationLineChart()
azSeriesList[i]->attachAxis(yRightAxis);
}

// Plot current target on elevation series
if (ui->azimuth->hasValue() && ui->elevation->hasValue() && (ui->elevation->value() > 0.0))
{
QScatterSeries *posSeries = new QScatterSeries();
posSeries->setMarkerSize(3);
posSeries->append(currentTime.toMSecsSinceEpoch(), ui->elevation->value());
if (m_settings.m_target.startsWith("Custom"))
{
posSeries->setPointLabelsVisible(false);
posSeries->setPointLabelsFormat("");
}
else
{
posSeries->setPointLabelsVisible(true);
posSeries->setPointLabelsFormat(m_settings.m_target);
}
posSeries->setPointLabelsClipping(false);
m_azElLineChart->addSeries(posSeries);
posSeries->attachAxis(xAxis);
posSeries->attachAxis(yLeftAxis);
}

elSeries->attachAxis(xAxis);
elSeries->attachAxis(yLeftAxis);
xAxis->setTitleText(QString("%1 %2").arg(startTime.date().toString()).arg(startTime.timeZoneAbbreviation()));
Expand Down Expand Up @@ -1719,14 +1743,15 @@ void StarTrackerGUI::plotElevationPolarChart()
double maxElevation = -90.0;

QLineSeries *polarSeries = new QLineSeries();
QDateTime currentTime;
QDateTime dt;

if (m_settings.m_dateTime.isEmpty()) {
dt = QDateTime::currentDateTime();
currentTime = QDateTime::currentDateTime();
} else {
dt = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
currentTime = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
}

dt = currentTime;
dt.setTime(QTime(0,0));
QDateTime startTime = dt;
QDateTime endTime = dt;
Expand Down Expand Up @@ -1978,6 +2003,28 @@ void StarTrackerGUI::plotElevationPolarChart()
setSeries->attachAxis(radialAxis);
}

// Plot target current position
if (ui->azimuth->hasValue() && ui->elevation->hasValue() && (ui->elevation->value() > 0.0))
{
QScatterSeries *posSeries = new QScatterSeries();
posSeries->setMarkerSize(3);
posSeries->append(ui->azimuth->value(), 90 - ui->elevation->value());
if (m_settings.m_target.startsWith("Custom"))
{
posSeries->setPointLabelsVisible(false);
posSeries->setPointLabelsFormat("");
}
else
{
posSeries->setPointLabelsVisible(true);
posSeries->setPointLabelsFormat(m_settings.m_target);
}
posSeries->setPointLabelsClipping(false);
m_azElPolarChart->addSeries(posSeries);
posSeries->attachAxis(angularAxis);
posSeries->attachAxis(radialAxis);
}

if (maxElevation < 0) {
m_azElPolarChart->setTitle("Not visible from this latitude");
} else {
Expand Down

0 comments on commit 32d5a2c

Please sign in to comment.