Files
location_plotter/src/MainWindow.h
T
Onur Cayan 498757b502
Ubuntu build / build-and-test (ubuntu-22.04) (push) Has been cancelled
Ubuntu build / build-and-test (ubuntu-24.04) (push) Has been cancelled
Add source-aware UART log replay
2026-08-12 13:54:11 +03:00

129 lines
3.9 KiB
C++

#pragma once
#include "TelemetryPoint.h"
#include <QMainWindow>
#include <QStringList>
#include <QSet>
#include <QVector>
#include <optional>
class QLabel;
class QCheckBox;
class QComboBox;
class QLineEdit;
class QPlainTextEdit;
class QPushButton;
class QSpinBox;
class QTableView;
class QTimer;
class QCloseEvent;
class QFile;
class MapWidget;
class GlobeWidget;
class RinexNavigation;
class SerialReader;
class TelemetryTableModel;
class UartReplay;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
bool loadTelemetryLog(const QString &filePath);
bool startUartReplay(const QString &filePath, int gpsIntervalMs = 200,
int sensorIntervalMs = 50);
protected:
void closeEvent(QCloseEvent *event) override;
private slots:
void toggleSerial();
void clearPoints();
void handleSerialLine(const QString &line);
void handleSerialStatus(const QString &status);
void handleSerialError(const QString &message);
void handleLocationTimeout();
void trimToMaxPoints();
void updateReferenceLocation();
void flushUiUpdates();
void openTelemetryLog();
void openUartReplay();
void stopUartReplay();
void refreshSerialPorts();
bool startUartLogging(const QString &port, int baudRate);
void stopUartLogging();
private:
void buildUi();
void updateConnectionControls();
void addTelemetryPoint(const ParsedTelemetry &telemetry);
void refreshTable();
void updateSummaryLabels();
void updateDopLabels();
void updateAnalysis();
void appendLogLine(const QString &line, bool parsed);
void mergePendingTelemetry(const ParsedTelemetry &telemetry);
void commitPendingTelemetry();
void resetTelemetryState();
void scheduleTelemetryRefresh();
void refreshTelemetryViews();
void flushPendingLogLines();
void appendUartLogLine(const QString &line);
int selectedBaudRate() const;
SerialReader *m_serial = nullptr;
UartReplay *m_replay = nullptr;
MapWidget *m_map = nullptr;
GlobeWidget *m_globe = nullptr;
RinexNavigation *m_rinex = nullptr;
QComboBox *m_portCombo = nullptr;
QComboBox *m_baudCombo = nullptr;
QSpinBox *m_maxPointsSpin = nullptr;
QLineEdit *m_referenceLatEdit = nullptr;
QLineEdit *m_referenceLonEdit = nullptr;
QPushButton *m_connectButton = nullptr;
QPushButton *m_clearButton = nullptr;
QPushButton *m_openLogButton = nullptr;
QPushButton *m_replayButton = nullptr;
QPushButton *m_refreshRinexButton = nullptr;
QCheckBox *m_autoFollowCheck = nullptr;
QCheckBox *m_showTelemetryCheck = nullptr;
QCheckBox *m_showRecentPointsCheck = nullptr;
QLabel *m_statusLabel = nullptr;
QLabel *m_satelliteLabel = nullptr;
QLabel *m_satelliteQualityLabel = nullptr;
QLabel *m_gdopLabel = nullptr;
QLabel *m_hdopLabel = nullptr;
QLabel *m_vdopLabel = nullptr;
QLabel *m_tdopLabel = nullptr;
QLabel *m_countLabel = nullptr;
QLabel *m_meanLocationLabel = nullptr;
QLabel *m_lastDeviationLabel = nullptr;
QLabel *m_meanDeviationLabel = nullptr;
QLabel *m_rmsScatterLabel = nullptr;
QLabel *m_maxScatterLabel = nullptr;
QLabel *m_cepLabel = nullptr;
QCheckBox *m_showAverageCheck = nullptr;
QTableView *m_table = nullptr;
TelemetryTableModel *m_tableModel = nullptr;
QPlainTextEdit *m_log = nullptr;
QTimer *m_locationTimeoutTimer = nullptr;
QTimer *m_uiRefreshTimer = nullptr;
QFile *m_uartLogFile = nullptr;
QString m_uartLogPath;
QVector<TelemetryPoint> m_points;
QStringList m_pendingLogLines;
std::optional<int> m_lastSatelliteCount;
QSet<QString> m_observedPrns;
std::optional<double> m_referenceLatitude;
std::optional<double> m_referenceLongitude;
DopValues m_lastDop;
ParsedTelemetry m_pendingTelemetry;
bool m_telemetryRefreshPending = false;
};