75 lines
2.3 KiB
C++
75 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include "SatelliteData.h"
|
|
|
|
#include <QDateTime>
|
|
#include <QNetworkAccessManager>
|
|
#include <QObject>
|
|
#include <QVector>
|
|
#include <QTimer>
|
|
|
|
class RinexNavigation : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit RinexNavigation(QObject *parent = nullptr);
|
|
|
|
void refresh();
|
|
[[nodiscard]] bool isLoading() const { return m_loading; }
|
|
|
|
static QVector<SatellitePosition> parseGpsNavigation(
|
|
const QByteArray &rinex, const QDateTime &whenUtc, QString *error = nullptr);
|
|
|
|
signals:
|
|
void satellitesUpdated(const QVector<SatellitePosition> &satellites);
|
|
void satelliteMotionUpdated(const QVector<SatellitePosition> ¤t,
|
|
const QVector<SatellitePosition> &next,
|
|
int durationMs);
|
|
void statusChanged(const QString &status, bool error);
|
|
void loadingChanged(bool loading);
|
|
|
|
private:
|
|
struct Ephemeris {
|
|
QString prn;
|
|
QDateTime toc;
|
|
double crs = 0.0;
|
|
double deltaN = 0.0;
|
|
double m0 = 0.0;
|
|
double cuc = 0.0;
|
|
double eccentricity = 0.0;
|
|
double cus = 0.0;
|
|
double sqrtA = 0.0;
|
|
double toe = 0.0;
|
|
double cic = 0.0;
|
|
double omega0 = 0.0;
|
|
double cis = 0.0;
|
|
double i0 = 0.0;
|
|
double crc = 0.0;
|
|
double omega = 0.0;
|
|
double omegaDot = 0.0;
|
|
double idot = 0.0;
|
|
int gpsWeek = 0;
|
|
bool healthy = true;
|
|
};
|
|
|
|
void requestDay(const QDate &date, int fallbackIndex);
|
|
void handleDownload(const QByteArray &compressed, const QDate &date, int fallbackIndex);
|
|
bool loadCache();
|
|
QString cachePath() const;
|
|
void updateCurrentPositions();
|
|
void publishCurrentMotion();
|
|
void setLoading(bool loading);
|
|
static QVector<Ephemeris> parseEphemerides(
|
|
const QByteArray &rinex, QString *error = nullptr);
|
|
static QVector<Ephemeris> selectEphemerides(
|
|
const QVector<Ephemeris> &ephemerides, const QDateTime &whenUtc);
|
|
static QVector<SatellitePosition> propagateEphemerides(
|
|
const QVector<Ephemeris> &ephemerides, const QDateTime &whenUtc);
|
|
static SatellitePosition propagate(const Ephemeris &eph, const QDateTime &whenUtc);
|
|
|
|
QNetworkAccessManager m_network;
|
|
QTimer m_positionTimer;
|
|
QVector<Ephemeris> m_ephemerides;
|
|
bool m_loading = false;
|
|
};
|