Browse Source

Add Aircraft feature

chirpmodem-v8.1.0
Jon Beniston 3 months ago
parent
commit
068cfca547
  1. 1
      CMakeLists.txt
  2. 90
      plugins/feature/aircraft/CMakeLists.txt
  3. 167
      plugins/feature/aircraft/aircraft.cpp
  4. 99
      plugins/feature/aircraft/aircraft.h
  5. 1282
      plugins/feature/aircraft/aircraftdb.cpp
  6. 1979
      plugins/feature/aircraft/aircraftgui.cpp
  7. 250
      plugins/feature/aircraft/aircraftgui.h
  8. 1042
      plugins/feature/aircraft/aircraftgui.ui
  9. 6
      plugins/feature/aircraft/aircrafticons.qrc
  10. 126
      plugins/feature/aircraft/aircraftnotificationdialog.cpp
  11. 53
      plugins/feature/aircraft/aircraftnotificationdialog.h
  12. 166
      plugins/feature/aircraft/aircraftnotificationdialog.ui
  13. 79
      plugins/feature/aircraft/aircraftplugin.cpp
  14. 47
      plugins/feature/aircraft/aircraftplugin.h
  15. 421
      plugins/feature/aircraft/aircraftsettings.cpp
  16. 126
      plugins/feature/aircraft/aircraftsettings.h
  17. 143
      plugins/feature/aircraft/aircraftsettingsdialog.cpp
  18. 50
      plugins/feature/aircraft/aircraftsettingsdialog.h
  19. 239
      plugins/feature/aircraft/aircraftsettingsdialog.ui
  20. 441
      plugins/feature/aircraft/aircrafttablemodels.cpp
  21. 206
      plugins/feature/aircraft/aircrafttablemodels.h
  22. 3621
      plugins/feature/aircraft/aircrafttracker.cpp
  23. 770
      plugins/feature/aircraft/aircrafttracker.h
  24. 49
      plugins/feature/aircraft/aircraftwebapiadapter.cpp
  25. 50
      plugins/feature/aircraft/aircraftwebapiadapter.h
  26. BIN
      plugins/feature/aircraft/icons/chart.png
  27. BIN
      plugins/feature/aircraft/icons/stats.png
  28. 354
      plugins/feature/aircraft/readme.md
  29. 230517
      plugins/feature/aircraft/sqlite/sqlite3.c
  30. 12174
      plugins/feature/aircraft/sqlite/sqlite3.h
  31. 126
      swagger/sdrangel/api/swagger/include/Aircraft.yaml
  32. 2
      swagger/sdrangel/api/swagger/include/FeatureActions.yaml
  33. 2
      swagger/sdrangel/api/swagger/include/FeatureReport.yaml
  34. 2
      swagger/sdrangel/api/swagger/include/FeatureSettings.yaml

1
CMakeLists.txt

@ -216,6 +216,7 @@ option(ENABLE_FEATURE_SATELLITETRACKER "Enable feature satellitetracker plugin" @@ -216,6 +216,7 @@ option(ENABLE_FEATURE_SATELLITETRACKER "Enable feature satellitetracker plugin"
option(ENABLE_FEATURE_APRS "Enable feature aprs plugin" ON)
option(ENABLE_FEATURE_DEMODANALYZER "Enable feature demodanalyzer plugin" ON)
option(ENABLE_FEATURE_AMBE "Enable feature ambe plugin" ON)
option(ENABLE_FEATURE_AIRCRAFT "Enable feature aircraft plugin" ON)
option(ENABLE_FEATURE_AIS "Enable feature ais plugin" ON)
option(ENABLE_FEATURE_AFC "Enable feature afc plugin" ON)
option(ENABLE_FEATURE_STARTRACKER "Enable feature startracker plugin" ON)

90
plugins/feature/aircraft/CMakeLists.txt

@ -0,0 +1,90 @@ @@ -0,0 +1,90 @@
project(aircraft)
set(aircraft_SOURCES
aircraft.cpp
aircraftsettings.cpp
aircraftplugin.cpp
aircrafttracker.cpp
aircraftdb.cpp
aircraftwebapiadapter.cpp
sqlite/sqlite3.c
)
set(aircraft_HEADERS
aircraft.h
aircraftsettings.h
aircraftplugin.h
aircrafttracker.h
aircraftwebapiadapter.h
sqlite/sqlite3.h
)
# Vendored SQLite amalgamation (public domain) for session persistence.
# Only used from the tracker thread, so thread safety is not needed.
set_source_files_properties(sqlite/sqlite3.c PROPERTIES
COMPILE_DEFINITIONS "SQLITE_THREADSAFE=0;SQLITE_OMIT_LOAD_EXTENSION;SQLITE_OMIT_DEPRECATED"
SKIP_AUTOGEN ON
)
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
)
if(NOT SERVER_MODE)
set(aircraft_SOURCES
${aircraft_SOURCES}
aircraftgui.cpp
aircraftgui.ui
aircrafticons.qrc
aircrafttablemodels.cpp
aircraftnotificationdialog.cpp
aircraftnotificationdialog.ui
aircraftsettingsdialog.cpp
aircraftsettingsdialog.ui
)
set(aircraft_HEADERS
${aircraft_HEADERS}
aircraftgui.h
aircrafttablemodels.h
aircraftnotificationdialog.h
aircraftsettingsdialog.h
)
set(TARGET_NAME ${PLUGINS_PREFIX}featureaircraft)
set(TARGET_LIB Qt::Widgets Qt::Positioning Qt::Charts)
if(Qt${QT_DEFAULT_MAJOR_VERSION}TextToSpeech_FOUND)
list(APPEND TARGET_LIB Qt::TextToSpeech)
endif()
set(TARGET_LIB_GUI "sdrgui")
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
else()
set(TARGET_NAME ${PLUGINSSRV_PREFIX}featureaircraftsrv)
set(TARGET_LIB Qt::Positioning)
set(TARGET_LIB_GUI "")
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
endif()
if(NOT Qt6_FOUND)
add_library(${TARGET_NAME} ${aircraft_SOURCES})
else()
qt_add_plugin(${TARGET_NAME} CLASS_NAME AircraftPlugin)
target_sources(${TARGET_NAME} PRIVATE ${aircraft_SOURCES})
endif()
if(NOT BUILD_SHARED_LIBS)
set_property(GLOBAL APPEND PROPERTY STATIC_PLUGINS_PROPERTY ${TARGET_NAME})
endif()
target_link_libraries(${TARGET_NAME} PRIVATE
Qt::Core
${TARGET_LIB}
sdrbase
${TARGET_LIB_GUI}
)
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
# Install debug symbols
if (WIN32)
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}> CONFIGURATIONS Debug RelWithDebInfo DESTINATION ${INSTALL_FOLDER} )
endif()

167
plugins/feature/aircraft/aircraft.cpp

@ -0,0 +1,167 @@ @@ -0,0 +1,167 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QThread>
#include "SWGMapItem.h"
#include "maincore.h"
#include "channel/channelapi.h"
#include "aircraft.h"
MESSAGE_CLASS_DEFINITION(Aircraft::MsgConfigureAircraft, Message)
const char* const Aircraft::m_featureIdURI = "sdrangel.feature.aircraft";
const char* const Aircraft::m_featureId = "Aircraft";
Aircraft::Aircraft(WebAPIAdapterInterface *webAPIAdapterInterface) :
Feature(m_featureIdURI, webAPIAdapterInterface),
m_availableChannelHandler({"sdrangel.channel.adsbdemod", "sdrangel.channel.acarsdemod"}, QStringList{"aircraftreport"})
{
qDebug("Aircraft::Aircraft: webAPIAdapterInterface: %p", webAPIAdapterInterface);
setObjectName(m_featureId);
m_state = StIdle;
m_errorMessage = "Aircraft error";
QObject::connect(
&m_availableChannelHandler,
&AvailableChannelOrFeatureHandler::messageEnqueued,
this,
&Aircraft::handleChannelMessageQueue);
// All processing runs on the tracker's thread, for the feature's lifetime,
// so it works the same with or without a GUI
m_thread = new QThread();
m_tracker = new AircraftTracker(this);
m_tracker->moveToThread(m_thread);
QObject::connect(m_thread, &QThread::started, m_tracker, &AircraftTracker::startWork);
QObject::connect(m_thread, &QThread::finished, m_tracker, &QObject::deleteLater);
QObject::connect(m_thread, &QThread::finished, m_thread, &QThread::deleteLater);
m_thread->start();
}
Aircraft::~Aircraft()
{
QObject::disconnect(
&m_availableChannelHandler,
&AvailableChannelOrFeatureHandler::messageEnqueued,
this,
&Aircraft::handleChannelMessageQueue);
m_thread->quit();
m_thread->wait();
m_tracker = nullptr;
m_thread = nullptr;
}
void Aircraft::start()
{
qDebug("Aircraft::start");
m_state = StRunning;
}
void Aircraft::stop()
{
qDebug("Aircraft::stop");
m_state = StIdle;
}
bool Aircraft::handleMessage(const Message& cmd)
{
if (MsgConfigureAircraft::match(cmd))
{
MsgConfigureAircraft& cfg = (MsgConfigureAircraft&) cmd;
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
return true;
}
else if (MainCore::MsgAircraftReport::match(cmd))
{
// All processing happens on the tracker's thread
MainCore::MsgAircraftReport& report = (MainCore::MsgAircraftReport&) cmd;
// The user can turn individual demodulators off
bool wanted = true;
if (!m_settings.m_disabledSources.isEmpty())
{
const ChannelAPI *channel = qobject_cast<const ChannelAPI *>(report.getPipeSource());
if (channel && m_settings.m_disabledSources.contains(channel->getURI())) {
wanted = false;
}
}
if (m_tracker && wanted)
{
m_tracker->getInputMessageQueue()->push(AircraftTracker::MsgReport::create(report.getReport()));
report.getReport().m_mapItem = nullptr; // Ownership moved with the copy
}
else if (report.getReport().m_mapItem)
{
delete report.getReport().m_mapItem;
report.getReport().m_mapItem = nullptr;
}
return true;
}
else
{
return false;
}
}
QByteArray Aircraft::serialize() const
{
return m_settings.serialize();
}
bool Aircraft::deserialize(const QByteArray& data)
{
bool ok = m_settings.deserialize(data);
if (!ok) {
m_settings.resetToDefaults();
}
MsgConfigureAircraft *msg = MsgConfigureAircraft::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(msg);
return ok;
}
void Aircraft::applySettings(const AircraftSettings& settings, const QList<QString>& settingsKeys, bool force)
{
qDebug() << "Aircraft::applySettings:" << settings.getDebugString(settingsKeys, force) << force;
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
if (m_tracker) {
m_tracker->getInputMessageQueue()->push(AircraftTracker::MsgConfigureTracker::create(settings, settingsKeys, force));
}
}
void Aircraft::handleChannelMessageQueue(MessageQueue* messageQueue)
{
Message* message;
while ((message = messageQueue->pop()) != nullptr)
{
if (handleMessage(*message)) {
delete message;
}
}
}

99
plugins/feature/aircraft/aircraft.h

@ -0,0 +1,99 @@ @@ -0,0 +1,99 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_FEATURE_AIRCRAFT_H_
#define INCLUDE_FEATURE_AIRCRAFT_H_
#include "feature/feature.h"
#include "util/message.h"
#include "availablechannelorfeaturehandler.h"
#include "aircraftsettings.h"
#include "aircrafttracker.h"
class WebAPIAdapterInterface;
class QThread;
// Collates aircraft data from the ADS-B and ACARS (VHF/VDL-2/HFDL/Aero) demodulators
// into a combined aircraft/flight model, and is the source of aircraft items for
// the Map feature. Demodulators send MainCore::MsgAircraftReport over the
// "aircraftreport" message pipe; the model itself lives in the GUI (like the AIS
// feature, decode-side data currently originates in the demodulator GUIs).
class Aircraft : public Feature
{
Q_OBJECT
public:
class MsgConfigureAircraft : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AircraftSettings& getSettings() const { return m_settings; }
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; }
static MsgConfigureAircraft* create(const AircraftSettings& settings, const QList<QString>& settingsKeys, bool force) {
return new MsgConfigureAircraft(settings, settingsKeys, force);
}
private:
AircraftSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force;
MsgConfigureAircraft(const AircraftSettings& settings, const QList<QString>& settingsKeys, bool force) :
Message(),
m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force)
{ }
};
Aircraft(WebAPIAdapterInterface *webAPIAdapterInterface);
virtual ~Aircraft();
virtual void destroy() { delete this; }
virtual bool handleMessage(const Message& cmd);
// The tracker runs on its own thread for the feature's lifetime; the GUI
// connects to its signals and sends it messages
AircraftTracker *getTracker() { return m_tracker; }
virtual void getIdentifier(QString& id) const { id = objectName(); }
virtual QString getIdentifier() const { return objectName(); }
virtual void getTitle(QString& title) const { title = m_settings.m_title; }
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
static const char* const m_featureIdURI;
static const char* const m_featureId;
private:
AircraftSettings m_settings;
AvailableChannelOrFeatureHandler m_availableChannelHandler;
QThread *m_thread;
AircraftTracker *m_tracker;
void start();
void stop();
void applySettings(const AircraftSettings& settings, const QList<QString>& settingsKeys, bool force = false);
private slots:
void handleChannelMessageQueue(MessageQueue* messageQueue);
};
#endif // INCLUDE_FEATURE_AIRCRAFT_H_

1282
plugins/feature/aircraft/aircraftdb.cpp

File diff suppressed because it is too large Load Diff

1979
plugins/feature/aircraft/aircraftgui.cpp

File diff suppressed because it is too large Load Diff

250
plugins/feature/aircraft/aircraftgui.h

@ -0,0 +1,250 @@ @@ -0,0 +1,250 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_FEATURE_AIRCRAFTGUI_H_
#define INCLUDE_FEATURE_AIRCRAFTGUI_H_
#include <QTimer>
#include <QMenu>
#include <QDateTime>
#include <QtCharts>
#include "feature/featuregui.h"
#include "util/messagequeue.h"
#include "util/planespotters.h"
#include "settings/rollupstate.h"
#include "aircraftsettings.h"
#include "aircrafttracker.h"
#include "aircrafttablemodels.h"
class PluginAPI;
class FeatureUISet;
class Aircraft;
class QTableWidget;
class QTableWidgetItem;
class QTextToSpeech;
class QSortFilterProxyModel;
namespace Ui {
class AircraftGUI;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
using namespace QtCharts;
#endif
// View onto the AircraftTracker, which runs on its own thread inside the
// feature and does all the processing; this GUI just displays the snapshots
// the tracker sends it and forwards user actions back
class AircraftGUI : public FeatureGUI {
Q_OBJECT
public:
static AircraftGUI* create(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature);
virtual void destroy();
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual void setWorkspaceIndex(int index);
virtual int getWorkspaceIndex() const { return m_settings.m_workspaceIndex; }
virtual void setGeometryBytes(const QByteArray& blob) { m_settings.m_geometryBytes = blob; }
virtual QByteArray getGeometryBytes() const { return m_settings.m_geometryBytes; }
private:
Ui::AircraftGUI* ui;
PluginAPI* m_pluginAPI;
FeatureUISet* m_featureUISet;
AircraftSettings m_settings;
// The statistics records, serialised by the tracker and held ready for serialize(),
// which is const and cannot go and ask for them
QByteArray m_statisticsBlob;
// All three splitters in one blob - see AircraftSettings::m_splitterStates
QByteArray saveSplitters() const;
void restoreSplitters(const QByteArray& data);
QString m_selectedFlightNumber; // Drives the Past Aircraft tab
// updateHistoryTables() replaces the rows, and clearing them emits a selection
// change with nothing selected, which would otherwise stop watching the flight
// the selection that triggered the rebuild had just chosen
bool m_updatingHistoryTables = false;
// Which column Find looks in, in the order the combo lists them
enum FindColumn { FindAll = 0, FindIcao, FindReg, FindType, FindFlight };
// Where the last match was, so Enter steps on to the next one rather than finding
// the same row again
int m_findRow = -1;
// Typing searches, but not on every keystroke: each match selects a row, and a
// selection change reloads the message tables, the profile chart and the aircraft
// photograph - the last of which can go to the network
QTimer m_findTimer;
QList<QString> m_settingsKeys;
RollupState m_rollupState;
bool m_doApplySettings;
Aircraft* m_aircraft;
MessageQueue m_inputMessageQueue;
// One model each for aircraft and flights, shown through two views apiece: what we
// are hearing now, and the archive of everything else
AircraftTableModel *m_aircraftModel;
ActiveFilterProxy *m_aircraftProxy;
ActiveFilterProxy *m_oldAircraftProxy;
FlightTableModel *m_flightModel;
ActiveFilterProxy *m_flightProxy;
ActiveFilterProxy *m_oldFlightProxy;
QMenu *m_columnMenu;
QMenu *m_flightColumnMenu;
// Selection driving the Documents/ATC filter, the photo and the profile
quint64 m_selectedAircraftId = 0;
QString m_selectedRegistration;
quint32 m_selectedIcao = 0;
quint64 m_selectedFlightId = 0;
// Message rate chart, driven by the tracker's rate samples
static const int CHART_SERIES = AircraftReport::ProtocolCount + 1;
QChart *m_chart = nullptr;
QDateTimeAxis *m_chartXAxis = nullptr;
QValueAxis *m_chartYAxis = nullptr;
QLineSeries *m_chartSeries[CHART_SERIES];
// Flight profile chart, from the tracker's profile snapshots
QChart *m_profileChart = nullptr;
quint64 m_profileFlightId = 0;
QString m_profileTitle;
QList<qint64> m_profileTimes;
QList<float> m_profileAltFt;
QList<float> m_profileSpeedKts;
QTextToSpeech *m_speech = nullptr;
// Aircraft photos from planespotters.net for the selected aircraft
PlaneSpotters m_planeSpotters;
QString m_photoLink;
QString m_photoKey; // Registration/ICAO the current request is for
explicit AircraftGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent = nullptr);
virtual ~AircraftGUI();
void blockApplySettings(bool block);
void applySettings(bool force = false);
void displaySettings();
bool handleMessage(const Message& message);
void makeUIConnections();
AircraftTracker *tracker() const;
void setDefaultColumnWidths();
void showRowNumbers(QTableView *table);
void trackerStatistics(const AircraftStatistics& statistics);
bool messageRowVisible(const QTableWidgetItem *firstItem) const;
void applyMessageFilter();
void tableContextMenu(QTableWidget *table, QPoint pos);
void viewContextMenu(QTableView *view, bool aircraftView, QPoint pos);
void showContextMenu(QWidget *parent, const QString& cellText, const QString& mapName,
QPoint globalPos, const QString& showFlight = QString(),
quint64 showAircraftId = 0);
void selectFlight(const QString& flight);
void selectAircraft(quint64 aircraftId);
void plotChart();
void plotProfileChart();
void watchFlight(quint64 flightId, const QString& title);
void updatePhoto(const QString& registration, quint32 icao);
void updateAircraftInfo(const QString& registration, quint32 icao);
bool showingArchive() const;
void updatePhotoText(const QString& registration, quint32 icao);
QAction *createCheckableItem(QString& text, int idx, bool checked, const char *slot);
private slots:
void onMenuDialogCalled(const QPoint &p);
void onWidgetRolled(QWidget* widget, bool rollDown);
void handleInputMessages();
void on_deleteAircraft_clicked();
void on_settings_clicked();
void on_notifications_clicked();
void on_atcLabels_clicked(bool checked);
void on_stats_clicked(bool checked);
void statsContextMenu(const QPoint& pos);
void updateHistoryTables();
void trackerWeatherReports(const QList<WeatherEvent>& reports);
void weatherSelectionChanged();
void on_find_returnPressed();
void on_find_textChanged(const QString& text);
bool findFrom(int startRow, const QString& text);
void pastFlightSelectionChanged();
void chartContextMenu(const QPoint& pos);
void on_displayChart_clicked(bool checked);
void documentSelectionChanged();
void aircraftSelectionChanged();
void flightSelectionChanged();
void aircraft_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
void flights_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
void flights_sectionResized(int logicalIndex, int oldSize, int newSize);
void flightColumnSelectMenu(QPoint pos);
void flightColumnSelectMenuChecked(bool checked = false);
void aircraft_sectionResized(int logicalIndex, int oldSize, int newSize);
void aircraftColumnSelectMenu(QPoint pos);
void aircraftColumnSelectMenuChecked(bool checked = false);
void legendMarkerClicked();
void aircraftPhoto(const PlaneSpottersPhoto *photo);
void photoClicked();
// From the tracker
void trackerAircraftUpdated(const QList<AircraftDisplay>& aircraft);
void trackerAircraftRemoved(const QList<quint64>& ids);
void trackerFlightsUpdated(const QList<FlightDisplay>& flights);
void trackerFlightsRemoved(const QList<quint64>& ids);
void trackerDocumentsAdded(const QList<DocumentEvent>& documents);
void trackerAtcMessages(const QList<AtcEvent>& messages);
void trackerProfileUpdated(quint64 flightId, const QList<qint64>& times, const QList<float>& altitudeFt, const QList<float>& speedKts);
void trackerMessageRates(const QList<float>& rates);
void trackerSpeechNotification(const QString& speech);
void trackerAllCleared();
void trackerDatabaseFilenameReverted(const QString& filename);
// Column enums for the Documents and ATC tables (still QTableWidgets)
private:
enum DocumentCol {
DOCUMENT_COL_TIME,
DOCUMENT_COL_FLIGHT,
DOCUMENT_COL_REG,
DOCUMENT_COL_TYPE,
DOCUMENT_COL_TITLE
};
enum WeatherCol {
WEATHER_COL_TIME,
WEATHER_COL_AIRPORT,
WEATHER_COL_TYPE,
WEATHER_COL_VIA,
WEATHER_COL_REPORT
};
enum AtcCol {
ATC_COL_TIME,
ATC_COL_PROTOCOL,
ATC_COL_DIR,
ATC_COL_FROM,
ATC_COL_TO,
ATC_COL_MESSAGE
};
};
#endif // INCLUDE_FEATURE_AIRCRAFTGUI_H_

1042
plugins/feature/aircraft/aircraftgui.ui

File diff suppressed because it is too large Load Diff

6
plugins/feature/aircraft/aircrafticons.qrc

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icons/stats.png</file>
<file>icons/chart.png</file>
</qresource>
</RCC>

126
plugins/feature/aircraft/aircraftnotificationdialog.cpp

@ -0,0 +1,126 @@ @@ -0,0 +1,126 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QComboBox>
#include "aircraftnotificationdialog.h"
AircraftNotificationDialog::AircraftNotificationDialog(AircraftSettings *settings,
QWidget* parent) :
QDialog(parent),
ui(new Ui::AircraftNotificationDialog),
m_settings(settings)
{
ui->setupUi(this);
resizeTable();
for (int i = 0; i < m_settings->m_notificationSettings.size(); i++) {
addRow(m_settings->m_notificationSettings[i].data());
}
}
AircraftNotificationDialog::~AircraftNotificationDialog()
{
delete ui;
}
void AircraftNotificationDialog::accept()
{
m_settings->m_notificationSettings.clear();
for (int i = 0; i < ui->table->rowCount(); i++)
{
QSharedPointer<AircraftSettings::NotificationSettings> notificationSettings = QSharedPointer<AircraftSettings::NotificationSettings>::create();
notificationSettings->m_matchColumn = ((QComboBox *)ui->table->cellWidget(i, NOTIFICATION_COL_MATCH))->currentIndex();
notificationSettings->m_regExp = ui->table->item(i, NOTIFICATION_COL_REG_EXP)->data(Qt::DisplayRole).toString().trimmed();
notificationSettings->m_speech = ui->table->item(i, NOTIFICATION_COL_SPEECH)->data(Qt::DisplayRole).toString().trimmed();
notificationSettings->m_command = ui->table->item(i, NOTIFICATION_COL_COMMAND)->data(Qt::DisplayRole).toString().trimmed();
notificationSettings->updateRegularExpression();
m_settings->m_notificationSettings.append(notificationSettings);
}
QDialog::accept();
}
void AircraftNotificationDialog::resizeTable()
{
AircraftSettings::NotificationSettings dummy;
dummy.m_matchColumn = AircraftSettings::MATCH_FLIGHT;
dummy.m_regExp = "A regular expression";
dummy.m_speech = "${flight} ${type} detected on ${protocol}";
dummy.m_command = "/usr/home/sdrangel/myscript ${flight}";
addRow(&dummy);
ui->table->resizeColumnsToContents();
ui->table->selectRow(0);
on_remove_clicked();
ui->table->selectRow(-1);
}
void AircraftNotificationDialog::on_add_clicked()
{
addRow();
}
// Remove selected row
void AircraftNotificationDialog::on_remove_clicked()
{
// Selection mode is single, so only a single row should be returned
QModelIndexList indexList = ui->table->selectionModel()->selectedRows();
if (!indexList.isEmpty())
{
int row = indexList.at(0).row();
ui->table->removeRow(row);
}
}
void AircraftNotificationDialog::addRow(AircraftSettings::NotificationSettings *settings)
{
QComboBox *match = new QComboBox();
// In the same order as enum NotificationMatch
match->addItem("ICAO ID");
match->addItem("Reg");
match->addItem("Flight");
match->addItem("Type");
QTableWidgetItem *regExpItem = new QTableWidgetItem();
QTableWidgetItem *speechItem = new QTableWidgetItem();
QTableWidgetItem *commandItem = new QTableWidgetItem();
if (settings != nullptr)
{
match->setCurrentIndex(settings->m_matchColumn);
regExpItem->setData(Qt::DisplayRole, settings->m_regExp);
speechItem->setData(Qt::DisplayRole, settings->m_speech);
commandItem->setData(Qt::DisplayRole, settings->m_command);
}
else
{
match->setCurrentIndex(AircraftSettings::MATCH_FLIGHT);
regExpItem->setData(Qt::DisplayRole, ".*");
speechItem->setData(Qt::DisplayRole, "${flight} detected");
}
ui->table->setSortingEnabled(false);
int row = ui->table->rowCount();
ui->table->setRowCount(row + 1);
ui->table->setCellWidget(row, NOTIFICATION_COL_MATCH, match);
ui->table->setItem(row, NOTIFICATION_COL_REG_EXP, regExpItem);
ui->table->setItem(row, NOTIFICATION_COL_SPEECH, speechItem);
ui->table->setItem(row, NOTIFICATION_COL_COMMAND, commandItem);
ui->table->setSortingEnabled(true);
}

53
plugins/feature/aircraft/aircraftnotificationdialog.h

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AIRCRAFTNOTIFICATIONDIALOG_H
#define INCLUDE_AIRCRAFTNOTIFICATIONDIALOG_H
#include "ui_aircraftnotificationdialog.h"
#include "aircraftsettings.h"
class AircraftNotificationDialog : public QDialog {
Q_OBJECT
public:
explicit AircraftNotificationDialog(AircraftSettings* settings, QWidget* parent = 0);
~AircraftNotificationDialog();
private:
void resizeTable();
private slots:
void accept();
void on_add_clicked();
void on_remove_clicked();
void addRow(AircraftSettings::NotificationSettings *settings=nullptr);
private:
Ui::AircraftNotificationDialog* ui;
AircraftSettings *m_settings;
enum NotificationCol {
NOTIFICATION_COL_MATCH,
NOTIFICATION_COL_REG_EXP,
NOTIFICATION_COL_SPEECH,
NOTIFICATION_COL_COMMAND
};
};
#endif // INCLUDE_AIRCRAFTNOTIFICATIONDIALOG_H

166
plugins/feature/aircraft/aircraftnotificationdialog.ui

@ -0,0 +1,166 @@ @@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AircraftNotificationDialog</class>
<widget class="QDialog" name="AircraftNotificationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>855</width>
<height>400</height>
</rect>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::PreventContextMenu</enum>
</property>
<property name="windowTitle">
<string>Notifications</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Speech and command notifications. Substitutions: ${icao} ${reg} ${flight} ${type} ${protocol}</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<widget class="QTableWidget" name="table">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<column>
<property name="text">
<string>Match</string>
</property>
<property name="toolTip">
<string>Aircraft data to match</string>
</property>
</column>
<column>
<property name="text">
<string>Reg Exp</string>
</property>
<property name="toolTip">
<string>Regular expression to match with</string>
</property>
</column>
<column>
<property name="text">
<string>Speech</string>
</property>
<property name="toolTip">
<string>Speech for the computer to read when a match is made</string>
</property>
</column>
<column>
<property name="text">
<string>Command</string>
</property>
<property name="toolTip">
<string>Command/script to execute when a match is made</string>
</property>
</column>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="buttonsHorizontalLayout">
<item>
<widget class="QPushButton" name="add">
<property name="toolTip">
<string>Add a notification rule</string>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="remove">
<property name="toolTip">
<string>Remove selected notification rule</string>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<spacer name="buttonsHorizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>table</tabstop>
<tabstop>add</tabstop>
<tabstop>remove</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AircraftNotificationDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AircraftNotificationDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

79
plugins/feature/aircraft/aircraftplugin.cpp

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QtPlugin>
#include "plugin/pluginapi.h"
#ifndef SERVER_MODE
#include "aircraftgui.h"
#endif
#include "aircraft.h"
#include "aircraftplugin.h"
#include "aircraftwebapiadapter.h"
const PluginDescriptor AircraftPlugin::m_pluginDescriptor = {
Aircraft::m_featureId,
QStringLiteral("Aircraft"),
QStringLiteral("7.28.0"),
QStringLiteral("(c) Jon Beniston, M7RCE"),
QStringLiteral("https://github.com/f4exb/sdrangel"),
true,
QStringLiteral("https://github.com/f4exb/sdrangel")
};
AircraftPlugin::AircraftPlugin(QObject* parent) :
QObject(parent),
m_pluginAPI(nullptr)
{
}
const PluginDescriptor& AircraftPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void AircraftPlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
m_pluginAPI->registerFeature(Aircraft::m_featureIdURI, Aircraft::m_featureId, this);
}
#ifdef SERVER_MODE
FeatureGUI* AircraftPlugin::createFeatureGUI(FeatureUISet *featureUISet, Feature *feature) const
{
(void) featureUISet;
(void) feature;
return nullptr;
}
#else
FeatureGUI* AircraftPlugin::createFeatureGUI(FeatureUISet *featureUISet, Feature *feature) const
{
return AircraftGUI::create(m_pluginAPI, featureUISet, feature);
}
#endif
Feature* AircraftPlugin::createFeature(WebAPIAdapterInterface* webAPIAdapterInterface) const
{
return new Aircraft(webAPIAdapterInterface);
}
FeatureWebAPIAdapter* AircraftPlugin::createFeatureWebAPIAdapter() const
{
return new AircraftWebAPIAdapter();
}

47
plugins/feature/aircraft/aircraftplugin.h

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_FEATURE_AIRCRAFTPLUGIN_H
#define INCLUDE_FEATURE_AIRCRAFTPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class FeatureGUI;
class WebAPIAdapterInterface;
class AircraftPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "sdrangel.feature.aircraft")
public:
explicit AircraftPlugin(QObject* parent = nullptr);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
virtual FeatureGUI* createFeatureGUI(FeatureUISet *featureUISet, Feature *feature) const;
virtual Feature* createFeature(WebAPIAdapterInterface *webAPIAdapterInterface) const;
virtual FeatureWebAPIAdapter* createFeatureWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
};
#endif // INCLUDE_FEATURE_AIRCRAFTPLUGIN_H

421
plugins/feature/aircraft/aircraftsettings.cpp

@ -0,0 +1,421 @@ @@ -0,0 +1,421 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QColor>
#include <QDataStream>
#include <QDebug>
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include <QStandardPaths>
#include "aircraftsettings.h"
AircraftSettings::AircraftSettings() :
m_rollupState(nullptr)
{
resetToDefaults();
}
// The demodulators that report aircraft to this feature. Anything listed is accepted
// unless the user turns it off, so a demodulator added later is included by default.
const QStringList& AircraftSettings::sourceURIs()
{
static const QStringList uris = {
"sdrangel.channel.adsbdemod",
"sdrangel.channel.acarsdemod"
};
return uris;
}
QString AircraftSettings::sourceName(const QString& uri)
{
if (uri == "sdrangel.channel.adsbdemod") {
return "ADS-B Demodulator";
} else if (uri == "sdrangel.channel.acarsdemod") {
return "ACARS Demodulator";
}
return uri;
}
QString AircraftSettings::defaultDatabaseFilename()
{
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
return locations[0] + "/aircraft.db";
}
void AircraftSettings::resetToDefaults()
{
m_title = "Aircraft";
m_rgbColor = QColor(0, 105, 105).rgb();
m_useReverseAPI = false;
m_reverseAPIAddress = "127.0.0.1";
m_reverseAPIPort = 8888;
m_reverseAPIFeatureSetIndex = 0;
m_reverseAPIFeatureIndex = 0;
m_workspaceIndex = 0;
// HFDL reporting can be very sparse, so aircraft linger well beyond the
// ADS-B style timeout - they may reappear on HF a long way away
m_removalMins = 180;
m_adsbPositionMins = 1;
m_acarsPositionMins = 10;
m_retentionDays = 0; // Keep everything until the user chooses a limit
m_atcLabels = true;
m_displayMaxRangeOnMap = false;
m_atcCallsigns = false;
m_statistics = QByteArray();
m_splitterStates = QByteArray();
m_displayStatistics = true;
m_displayChart = false;
m_favourLivery = true;
m_useLiveryIcons = false;
m_databaseFilename = "";
m_disabledSources.clear();
// Rules that speak and run commands are exactly the kind of thing a reset is asked
// for to be rid of, and leaving them behind means the reset does not do what it says
m_notificationSettings.clear();
for (int i = 0; i < FLIGHT_COLUMNS; i++)
{
m_flightColumnIndexes[i] = i;
m_flightColumnSizes[i] = -1; // Autosize
}
for (int i = 0; i < AIRCRAFT_COLUMNS; i++)
{
m_columnIndexes[i] = i;
m_columnSizes[i] = -1; // Autosize
}
}
QByteArray AircraftSettings::serialize() const
{
SimpleSerializer s(1);
s.writeString(20, m_title);
s.writeU32(21, m_rgbColor);
s.writeBool(22, m_useReverseAPI);
s.writeString(23, m_reverseAPIAddress);
s.writeU32(24, m_reverseAPIPort);
s.writeU32(25, m_reverseAPIFeatureSetIndex);
s.writeU32(26, m_reverseAPIFeatureIndex);
if (m_rollupState) {
s.writeBlob(27, m_rollupState->serialize());
}
s.writeS32(28, m_workspaceIndex);
s.writeBlob(29, m_geometryBytes);
s.writeS32(30, m_removalMins);
s.writeS32(41, m_adsbPositionMins);
s.writeS32(42, m_acarsPositionMins);
s.writeBlob(31, serializeNotificationSettings(m_notificationSettings));
// Key 31 used to carry this as well, underneath the blob above, so it never survived
// a restart - readS32() was being handed a blob and falling back to the default
s.writeS32(36, m_retentionDays);
s.writeBool(32, m_atcLabels);
s.writeBool(44, m_displayMaxRangeOnMap);
s.writeBool(33, m_atcCallsigns);
s.writeString(34, m_databaseFilename);
s.writeList(35, m_disabledSources);
s.writeBlob(37, m_statistics);
s.writeBool(38, m_displayStatistics);
s.writeBool(39, m_displayChart);
s.writeBlob(43, m_splitterStates);
s.writeBool(40, m_favourLivery);
s.writeBool(45, m_useLiveryIcons);
for (int i = 0; i < AIRCRAFT_COLUMNS; i++) {
s.writeS32(300 + i, m_columnIndexes[i]);
}
for (int i = 0; i < FLIGHT_COLUMNS; i++) {
s.writeS32(500 + i, m_flightColumnIndexes[i]);
}
for (int i = 0; i < FLIGHT_COLUMNS; i++) {
s.writeS32(600 + i, m_flightColumnSizes[i]);
}
for (int i = 0; i < AIRCRAFT_COLUMNS; i++) {
s.writeS32(400 + i, m_columnSizes[i]);
}
return s.final();
}
bool AircraftSettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if (!d.isValid())
{
resetToDefaults();
return false;
}
if (d.getVersion() == 1)
{
QByteArray bytetmp;
uint32_t utmp;
d.readString(20, &m_title, "Aircraft");
d.readU32(21, &m_rgbColor, QColor(0, 105, 105).rgb());
d.readBool(22, &m_useReverseAPI, false);
d.readString(23, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(24, &utmp, 0);
if ((utmp > 1023) && (utmp <= 65535)) {
m_reverseAPIPort = utmp;
} else {
m_reverseAPIPort = 8888;
}
d.readU32(25, &utmp, 0);
m_reverseAPIFeatureSetIndex = utmp > 99 ? 99 : utmp;
d.readU32(26, &utmp, 0);
m_reverseAPIFeatureIndex = utmp > 99 ? 99 : utmp;
if (m_rollupState)
{
d.readBlob(27, &bytetmp);
m_rollupState->deserialize(bytetmp);
}
d.readS32(28, &m_workspaceIndex, 0);
d.readBlob(29, &m_geometryBytes);
d.readS32(30, &m_removalMins, 180);
d.readS32(41, &m_adsbPositionMins, 1);
d.readS32(42, &m_acarsPositionMins, 10);
d.readS32(36, &m_retentionDays, 0);
d.readBlob(31, &bytetmp);
deserializeNotificationSettings(bytetmp, m_notificationSettings);
d.readBool(32, &m_atcLabels, true);
d.readBool(44, &m_displayMaxRangeOnMap, false);
d.readBool(33, &m_atcCallsigns, false);
d.readString(34, &m_databaseFilename, "");
d.readList(35, &m_disabledSources);
d.readBlob(37, &m_statistics);
d.readBool(38, &m_displayStatistics, true);
d.readBool(39, &m_displayChart, false);
d.readBlob(43, &m_splitterStates);
d.readBool(40, &m_favourLivery, true);
d.readBool(45, &m_useLiveryIcons, false);
for (int i = 0; i < FLIGHT_COLUMNS; i++) {
d.readS32(500 + i, &m_flightColumnIndexes[i], i);
}
for (int i = 0; i < FLIGHT_COLUMNS; i++) {
d.readS32(600 + i, &m_flightColumnSizes[i], -1);
}
for (int i = 0; i < AIRCRAFT_COLUMNS; i++) {
d.readS32(300 + i, &m_columnIndexes[i], i);
}
for (int i = 0; i < AIRCRAFT_COLUMNS; i++) {
d.readS32(400 + i, &m_columnSizes[i], -1);
}
return true;
}
else
{
resetToDefaults();
return false;
}
}
void AircraftSettings::applySettings(const QStringList& settingsKeys, const AircraftSettings& settings)
{
if (settingsKeys.contains("title")) {
m_title = settings.m_title;
}
if (settingsKeys.contains("rgbColor")) {
m_rgbColor = settings.m_rgbColor;
}
if (settingsKeys.contains("useReverseAPI")) {
m_useReverseAPI = settings.m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress")) {
m_reverseAPIAddress = settings.m_reverseAPIAddress;
}
if (settingsKeys.contains("reverseAPIPort")) {
m_reverseAPIPort = settings.m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIFeatureSetIndex")) {
m_reverseAPIFeatureSetIndex = settings.m_reverseAPIFeatureSetIndex;
}
if (settingsKeys.contains("reverseAPIFeatureIndex")) {
m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex;
}
if (settingsKeys.contains("workspaceIndex")) {
m_workspaceIndex = settings.m_workspaceIndex;
}
if (settingsKeys.contains("removalMins")) {
m_removalMins = settings.m_removalMins;
}
if (settingsKeys.contains("adsbPositionMins")) {
m_adsbPositionMins = settings.m_adsbPositionMins;
}
if (settingsKeys.contains("acarsPositionMins")) {
m_acarsPositionMins = settings.m_acarsPositionMins;
}
if (settingsKeys.contains("retentionDays")) {
m_retentionDays = settings.m_retentionDays;
}
if (settingsKeys.contains("notificationSettings")) {
m_notificationSettings = settings.m_notificationSettings;
}
if (settingsKeys.contains("atcLabels")) {
m_atcLabels = settings.m_atcLabels;
}
if (settingsKeys.contains("displayMaxRangeOnMap")) {
m_displayMaxRangeOnMap = settings.m_displayMaxRangeOnMap;
}
if (settingsKeys.contains("displayStatistics")) {
m_displayStatistics = settings.m_displayStatistics;
}
if (settingsKeys.contains("displayChart")) {
m_displayChart = settings.m_displayChart;
}
if (settingsKeys.contains("favourLivery")) {
m_favourLivery = settings.m_favourLivery;
}
if (settingsKeys.contains("useLiveryIcons")) {
m_useLiveryIcons = settings.m_useLiveryIcons;
}
if (settingsKeys.contains("statistics")) {
m_statistics = settings.m_statistics;
}
if (settingsKeys.contains("atcCallsigns")) {
m_atcCallsigns = settings.m_atcCallsigns;
}
if (settingsKeys.contains("databaseFilename")) {
m_databaseFilename = settings.m_databaseFilename;
}
if (settingsKeys.contains("disabledSources")) {
m_disabledSources = settings.m_disabledSources;
}
if (settingsKeys.contains("flightColumnIndexes"))
{
for (int i = 0; i < FLIGHT_COLUMNS; i++) {
m_flightColumnIndexes[i] = settings.m_flightColumnIndexes[i];
}
}
if (settingsKeys.contains("flightColumnSizes"))
{
for (int i = 0; i < FLIGHT_COLUMNS; i++) {
m_flightColumnSizes[i] = settings.m_flightColumnSizes[i];
}
}
if (settingsKeys.contains("columnIndexes"))
{
for (int i = 0; i < AIRCRAFT_COLUMNS; i++) {
m_columnIndexes[i] = settings.m_columnIndexes[i];
}
}
if (settingsKeys.contains("columnSizes"))
{
for (int i = 0; i < AIRCRAFT_COLUMNS; i++) {
m_columnSizes[i] = settings.m_columnSizes[i];
}
}
}
QDataStream& operator<<(QDataStream& out, const QSharedPointer<AircraftSettings::NotificationSettings>& settings)
{
out << settings->m_matchColumn;
out << settings->m_regExp;
out << settings->m_speech;
out << settings->m_command;
return out;
}
QDataStream& operator>>(QDataStream& in, QSharedPointer<AircraftSettings::NotificationSettings>& settings)
{
settings = QSharedPointer<AircraftSettings::NotificationSettings>::create();
in >> settings->m_matchColumn;
in >> settings->m_regExp;
in >> settings->m_speech;
in >> settings->m_command;
settings->updateRegularExpression();
return in;
}
QByteArray AircraftSettings::serializeNotificationSettings(const QList<QSharedPointer<NotificationSettings>>& notificationSettings) const
{
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
stream << notificationSettings;
return data;
}
void AircraftSettings::deserializeNotificationSettings(const QByteArray& data, QList<QSharedPointer<NotificationSettings>>& notificationSettings)
{
QDataStream stream(data);
stream >> notificationSettings;
}
AircraftSettings::NotificationSettings::NotificationSettings() :
m_matchColumn(MATCH_REG)
{
}
void AircraftSettings::NotificationSettings::updateRegularExpression()
{
m_regularExpression.setPattern(m_regExp);
m_regularExpression.optimize();
if (!m_regularExpression.isValid()) {
qDebug() << "Aircraft: Regular expression is not valid: " << m_regExp;
}
}
QString AircraftSettings::getDebugString(const QStringList& settingsKeys, bool force) const
{
std::ostringstream ostr;
if (settingsKeys.contains("title") || force) {
ostr << " m_title: " << m_title.toStdString();
}
if (settingsKeys.contains("rgbColor") || force) {
ostr << " m_rgbColor: " << m_rgbColor;
}
if (settingsKeys.contains("removalMins") || force) {
ostr << " m_removalMins: " << m_removalMins;
}
if (settingsKeys.contains("adsbPositionMins") || force) {
ostr << " m_adsbPositionMins: " << m_adsbPositionMins;
}
if (settingsKeys.contains("acarsPositionMins") || force) {
ostr << " m_acarsPositionMins: " << m_acarsPositionMins;
}
if (settingsKeys.contains("retentionDays") || force) {
ostr << " m_retentionDays: " << m_retentionDays;
}
if (settingsKeys.contains("atcCallsigns") || force) {
ostr << " m_atcCallsigns: " << m_atcCallsigns;
}
if (settingsKeys.contains("databaseFilename") || force) {
ostr << " m_databaseFilename: " << m_databaseFilename.toStdString();
}
if (settingsKeys.contains("disabledSources") || force) {
ostr << " m_disabledSources: " << m_disabledSources.join(",").toStdString();
}
return QString(ostr.str().c_str());
}

126
plugins/feature/aircraft/aircraftsettings.h

@ -0,0 +1,126 @@ @@ -0,0 +1,126 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_FEATURE_AIRCRAFTSETTINGS_H_
#define INCLUDE_FEATURE_AIRCRAFTSETTINGS_H_
#include <QByteArray>
#include <QString>
#include <QList>
#include <QSharedPointer>
#include <QRegularExpression>
class Serializable;
// Number of columns in the tables. These size the saved width and order arrays, and
// the header's own sectionMoved/sectionResized hand back a logical index straight out of
// the model - so a column added to a model without changing the count here writes off
// the end of the array. aircrafttablemodels.cpp asserts the two agree at compile time.
#define AIRCRAFT_COLUMNS 16
// Flight, Reg, From, To, Out, Off, On, In, First seen, Last seen, LS, OC, FP, Docs,
// Protocols
#define FLIGHT_COLUMNS 15
struct AircraftSettings
{
// What a notification rule matches against
enum NotificationMatch {
MATCH_ICAO,
MATCH_REG,
MATCH_FLIGHT,
MATCH_TYPE
};
struct NotificationSettings {
int m_matchColumn; // One of enum NotificationMatch
QString m_regExp;
QString m_speech;
QString m_command;
QRegularExpression m_regularExpression;
NotificationSettings();
void updateRegularExpression();
};
QString m_title;
quint32 m_rgbColor;
bool m_useReverseAPI;
QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort;
uint16_t m_reverseAPIFeatureSetIndex;
uint16_t m_reverseAPIFeatureIndex;
Serializable *m_rollupState;
int m_workspaceIndex;
QByteArray m_geometryBytes;
int m_removalMins; // Archive an aircraft after this many minutes without a report
// How long a position stays believable, and so how long the aircraft stays on the
// Map. Separate figures because the protocols report at wildly different rates: ADS-B
// is about once a second, while an ACARS, VDL-2 or HFDL position can be the only one
// for many minutes. Applies to the 2D and 3D maps alike.
int m_adsbPositionMins;
int m_acarsPositionMins;
int m_retentionDays; // Discard archived aircraft after this many days; 0 keeps them
bool m_atcLabels; // Display route, altitude and speed in Map labels
bool m_atcCallsigns; // Map labels use the airline's callsign (SPEEDBIRD) not its code (BAW)
// Keep the furthest aircraft ever heard on the Map, at the position it was in when
// it set the record. Serialised at key 44.
bool m_displayMaxRangeOnMap;
// The Statistics tab's records - furthest, fastest, highest - serialised by the
// tracker. Kept opaque here so a new statistic does not need a new settings key.
QByteArray m_statistics;
//!< How the splitters divide the space. One blob for all of them, so that adding
//!< another splitter later does not need another settings key.
//!< Serialised at key 43: SimpleDeserializer REJECTS THE WHOLE BLOB if an id appears
//!< twice, so a clashing key does not lose one setting, it loses every setting the
//!< feature has. This was first written at 41, which m_adsbPositionMins already had.
QByteArray m_splitterStates;
bool m_displayStatistics; // Statistics table shown in the splitter
bool m_displayChart; // Message rate chart shown in the splitter
// Prefer a model in the right airline livery over a model of exactly the right type
bool m_favourLivery;
bool m_useLiveryIcons; // Use aircraft icons with airline liveries on 2D map, instead of black icons
QString m_databaseFilename; // Where the session is kept; empty means the default location
QStringList m_disabledSources; // Channel URIs not to accept reports from; empty accepts all
// The demodulators that can feed this feature, and what to call them
static const QStringList& sourceURIs();
static QString sourceName(const QString& uri);
static QString defaultDatabaseFilename();
QList<QSharedPointer<NotificationSettings>> m_notificationSettings;
int m_columnIndexes[AIRCRAFT_COLUMNS];
int m_columnSizes[AIRCRAFT_COLUMNS];
int m_flightColumnIndexes[FLIGHT_COLUMNS];
int m_flightColumnSizes[FLIGHT_COLUMNS];
AircraftSettings();
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
void applySettings(const QStringList& settingsKeys, const AircraftSettings& settings);
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
QByteArray serializeNotificationSettings(const QList<QSharedPointer<NotificationSettings>>& notificationSettings) const;
static void deserializeNotificationSettings(const QByteArray& data, QList<QSharedPointer<NotificationSettings>>& notificationSettings);
};
QDataStream& operator<<(QDataStream& out, const QSharedPointer<AircraftSettings::NotificationSettings>& settings);
QDataStream& operator>>(QDataStream& in, QSharedPointer<AircraftSettings::NotificationSettings>& settings);
#endif // INCLUDE_FEATURE_AIRCRAFTSETTINGS_H_

143
plugins/feature/aircraft/aircraftsettingsdialog.cpp

@ -0,0 +1,143 @@ @@ -0,0 +1,143 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QFileDialog>
#include <QFileInfo>
#include <QListWidgetItem>
#include "aircraftsettingsdialog.h"
AircraftSettingsDialog::AircraftSettingsDialog(AircraftSettings *settings, QWidget *parent) :
QDialog(parent),
ui(new Ui::AircraftSettingsDialog),
m_settings(settings)
{
ui->setupUi(this);
ui->removal->setValue(m_settings->m_removalMins);
ui->retention->setValue(m_settings->m_retentionDays);
ui->adsbPosition->setValue(m_settings->m_adsbPositionMins);
ui->acarsPosition->setValue(m_settings->m_acarsPositionMins);
ui->atcCallsigns->setChecked(m_settings->m_atcCallsigns);
ui->favourLivery->setChecked(m_settings->m_favourLivery);
ui->useLiveryIcons->setChecked(m_settings->m_useLiveryIcons);
ui->maxRangeOnMap->setChecked(m_settings->m_displayMaxRangeOnMap);
ui->database->setText(m_settings->m_databaseFilename.isEmpty()
? AircraftSettings::defaultDatabaseFilename()
: m_settings->m_databaseFilename);
// Every demodulator that can feed us, ticked unless it has been turned off
for (const QString& uri : AircraftSettings::sourceURIs())
{
QListWidgetItem *item = new QListWidgetItem(AircraftSettings::sourceName(uri));
item->setData(Qt::UserRole, uri);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(m_settings->m_disabledSources.contains(uri) ? Qt::Unchecked : Qt::Checked);
ui->sources->addItem(item);
}
}
AircraftSettingsDialog::~AircraftSettingsDialog()
{
delete ui;
}
void AircraftSettingsDialog::on_browse_clicked()
{
QString current = ui->database->text().isEmpty()
? AircraftSettings::defaultDatabaseFilename()
: ui->database->text();
QString filename = QFileDialog::getSaveFileName(this, "Aircraft session database", current,
"Database files (*.db);;All files (*)", nullptr, QFileDialog::DontConfirmOverwrite);
if (!filename.isEmpty()) {
ui->database->setText(filename);
}
}
void AircraftSettingsDialog::accept()
{
if (ui->removal->value() != m_settings->m_removalMins)
{
m_settings->m_removalMins = ui->removal->value();
m_changed.append("removalMins");
}
if (ui->retention->value() != m_settings->m_retentionDays)
{
m_settings->m_retentionDays = ui->retention->value();
m_changed.append("retentionDays");
}
if (ui->adsbPosition->value() != m_settings->m_adsbPositionMins)
{
m_settings->m_adsbPositionMins = ui->adsbPosition->value();
m_changed.append("adsbPositionMins");
}
if (ui->acarsPosition->value() != m_settings->m_acarsPositionMins)
{
m_settings->m_acarsPositionMins = ui->acarsPosition->value();
m_changed.append("acarsPositionMins");
}
if (ui->maxRangeOnMap->isChecked() != m_settings->m_displayMaxRangeOnMap)
{
m_settings->m_displayMaxRangeOnMap = ui->maxRangeOnMap->isChecked();
m_changed.append("displayMaxRangeOnMap");
}
if (ui->favourLivery->isChecked() != m_settings->m_favourLivery)
{
m_settings->m_favourLivery = ui->favourLivery->isChecked();
m_changed.append("favourLivery");
}
if (ui->useLiveryIcons->isChecked() != m_settings->m_useLiveryIcons)
{
m_settings->m_useLiveryIcons = ui->useLiveryIcons->isChecked();
m_changed.append("useLiveryIcons");
}
if (ui->atcCallsigns->isChecked() != m_settings->m_atcCallsigns)
{
m_settings->m_atcCallsigns = ui->atcCallsigns->isChecked();
m_changed.append("atcCallsigns");
}
// An empty setting means "wherever the default is", so don't store the default path
QString database = ui->database->text().trimmed();
if (database == AircraftSettings::defaultDatabaseFilename()) {
database = "";
}
if (database != m_settings->m_databaseFilename)
{
m_settings->m_databaseFilename = database;
m_changed.append("databaseFilename");
}
QStringList disabled;
for (int i = 0; i < ui->sources->count(); i++)
{
QListWidgetItem *item = ui->sources->item(i);
if (item->checkState() != Qt::Checked) {
disabled.append(item->data(Qt::UserRole).toString());
}
}
if (disabled != m_settings->m_disabledSources)
{
m_settings->m_disabledSources = disabled;
m_changed.append("disabledSources");
}
QDialog::accept();
}

50
plugins/feature/aircraft/aircraftsettingsdialog.h

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AIRCRAFTSETTINGSDIALOG_H
#define INCLUDE_AIRCRAFTSETTINGSDIALOG_H
#include <QDialog>
#include <QStringList>
#include "ui_aircraftsettingsdialog.h"
#include "aircraftsettings.h"
// Settings that are set once and then left alone: how long aircraft are kept, where
// the session is stored, which demodulators to listen to and how aircraft are labelled
class AircraftSettingsDialog : public QDialog {
Q_OBJECT
public:
explicit AircraftSettingsDialog(AircraftSettings *settings, QWidget *parent = nullptr);
~AircraftSettingsDialog();
// Which settings the user actually changed, for applySettings
const QStringList& changedSettings() const { return m_changed; }
private slots:
void accept();
void on_browse_clicked();
private:
Ui::AircraftSettingsDialog *ui;
AircraftSettings *m_settings;
QStringList m_changed;
};
#endif // INCLUDE_AIRCRAFTSETTINGSDIALOG_H

239
plugins/feature/aircraft/aircraftsettingsdialog.ui

@ -0,0 +1,239 @@ @@ -0,0 +1,239 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AircraftSettingsDialog</class>
<widget class="QDialog" name="AircraftSettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<height>380</height>
</rect>
</property>
<property name="windowTitle">
<string>Aircraft Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="timeoutsGroup">
<property name="title">
<string>Timeouts</string>
</property>
<layout class="QFormLayout" name="timeoutsLayout">
<item row="0" column="0">
<widget class="QLabel" name="removalLabel">
<property name="text">
<string>Archive after (mins)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="removal">
<property name="toolTip">
<string>Move an aircraft to the Old Aircraft table, and off the Map, after this many minutes without a report</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10080</number>
</property>
<property name="value">
<number>180</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="retentionLabel">
<property name="text">
<string>Keep for (days)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="retention">
<property name="toolTip">
<string>Discard archived aircraft and their flights after this many days without a report. Zero keeps them indefinitely, but the session database will grow.</string>
</property>
<property name="specialValueText">
<string>Forever</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>3650</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="adsbPositionLabel">
<property name="text">
<string>ADS-B position for (mins)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="adsbPosition">
<property name="toolTip">
<string>Keep an aircraft on the Map for this many minutes after its last ADS-B position. ADS-B reports about once a second, so a short time here means the Map only shows aircraft that are actually being heard</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1440</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="acarsPositionLabel">
<property name="text">
<string>ACARS position for (mins)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="acarsPosition">
<property name="toolTip">
<string>Keep an aircraft on the Map for this many minutes after its last position from ACARS, VDL-2, HFDL or Aero. These report far less often than ADS-B, so expiring them as quickly would leave the aircraft off the Map most of the time</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1440</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="databaseGroup">
<property name="title">
<string>Session database</string>
</property>
<layout class="QHBoxLayout" name="databaseLayout">
<item>
<widget class="QLineEdit" name="database">
<property name="toolTip">
<string>File the aircraft, flights and messages seen are saved in, so they survive a restart</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="browse">
<property name="toolTip">
<string>Choose where the session database is kept</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="sourcesGroup">
<property name="title">
<string>Receive aircraft data from</string>
</property>
<layout class="QVBoxLayout" name="sourcesLayout">
<item>
<widget class="QListWidget" name="sources">
<property name="toolTip">
<string>Demodulators to accept aircraft reports from. Unticked demodulators are ignored.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="mapGroup">
<property name="title">
<string>Map</string>
</property>
<layout class="QVBoxLayout" name="mapLayout">
<item>
<widget class="QCheckBox" name="atcCallsigns">
<property name="toolTip">
<string>Label aircraft with the airline's radio callsign (SPEEDBIRD 123) rather than its code (BAW123)</string>
</property>
<property name="text">
<string>Use airline callsigns in Map labels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="maxRangeOnMap">
<property name="toolTip">
<string>Keep the aircraft that set the all time maximum range record on the Map, drawn at the position it was in when it set it. It stays there until the record is beaten or the records are reset.</string>
</property>
<property name="text">
<string>Show the maximum range record on the Map</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="favourLivery">
<property name="toolTip">
<string>On the 3D map, prefer a similar aircraft in the correct airline livery over an exact aircraft type in the wrong one. Only applies where no model of the right type in the right livery exists.</string>
</property>
<property name="text">
<string>Favour airline livery over aircraft type (3D map)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useLiveryIcons">
<property name="toolTip">
<string>On the 2D map, display aircraft using icons showing their airline's livery, matched from the aircraft type and operator, instead of black icons</string>
</property>
<property name="text">
<string>Livery aircraft icons (2D map)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AircraftSettingsDialog</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AircraftSettingsDialog</receiver>
<slot>reject()</slot>
</connection>
</connections>
</ui>

441
plugins/feature/aircraft/aircrafttablemodels.cpp

@ -0,0 +1,441 @@ @@ -0,0 +1,441 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <cmath>
#include "util/airlines.h"
#include "util/osndb.h"
#include "aircrafttablemodels.h"
#include "aircraftsettings.h"
// The saved column width and order arrays are sized by these, and a header signal
// indexes them with a logical column straight from the model. Adding a column to a
// model without growing the array would write past the end of it.
static_assert(AircraftTableModel::COL_COUNT == AIRCRAFT_COLUMNS,
"AIRCRAFT_COLUMNS must match AircraftTableModel::COL_COUNT");
static_assert(FlightTableModel::COL_COUNT == FLIGHT_COLUMNS,
"FLIGHT_COLUMNS must match FlightTableModel::COL_COUNT");
AircraftTableModel::AircraftTableModel(QObject *parent) :
QAbstractTableModel(parent)
{
}
int AircraftTableModel::rowCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : m_rows.size();
}
int AircraftTableModel::columnCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : COL_COUNT;
}
QVariant AircraftTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if ((orientation != Qt::Horizontal) || (role != Qt::DisplayRole)) {
return QVariant();
}
switch (section)
{
case COL_ICAO: return "ICAO";
case COL_REG: return "Reg";
case COL_TYPE: return "Type";
case COL_FLIGHT: return "Flight";
case COL_AIRLINE: return "Airline";
case COL_SIDEVIEW: return "Sideview";
case COL_COUNTRY: return "Country";
case COL_LATITUDE: return "Lat (°)";
case COL_LONGITUDE: return "Lon (°)";
case COL_DISTANCE: return "Dist (km)";
case COL_ALTITUDE: return "Alt (ft)";
case COL_HEADING: return "Hdg (°)";
case COL_SPEED: return "Spd (kn)";
case COL_PROTOCOLS: return "Protocols";
case COL_MESSAGES: return "Msgs";
case COL_LAST_SEEN: return "Last seen";
default: return QVariant();
}
}
// Country flag, airline logo and sideview silhouette, as in the ADS-B
// demodulator's table, resolved once per aircraft
void AircraftTableModel::resolveIcons(Row& row) const
{
row.m_iconsResolved = true;
row.m_country = QIcon();
row.m_airline = QIcon();
row.m_airlineText.clear();
row.m_sideview = QIcon();
row.m_type.clear();
QSharedPointer<const QHash<QString, AircraftInformation *>> aircraftInfo = OsnDB::getAircraftInformationByReg();
const AircraftInformation *info = nullptr;
if (aircraftInfo && aircraftInfo->contains(row.m_display.m_registration)) {
info = aircraftInfo->value(row.m_display.m_registration);
}
if (info)
{
row.m_type = info->m_type;
QIcon *icon = nullptr;
if (!info->m_operatorICAO.isEmpty()) {
icon = AircraftInformation::getAirlineIcon(info->m_operatorICAO);
}
if (icon) {
row.m_airline = *icon;
} else if (!info->m_operator.isEmpty()) {
row.m_airlineText = info->m_operator;
} else {
row.m_airlineText = info->m_owner;
}
icon = AircraftInformation::getSideviewIcon(info->m_registration, info->m_operatorICAO, info->m_type);
if (icon) {
row.m_sideview = *icon;
}
QString flag = info->getFlag();
if (!flag.isEmpty())
{
icon = AircraftInformation::getFlagIcon(flag);
if (icon) {
row.m_country = *icon;
}
}
}
else if (!row.m_display.m_flight.isEmpty())
{
// No database entry: airline logo and country from the flight's
// airline designator
const Airline *airline = Airline::getByICAO(row.m_display.m_flight.left(3));
if (airline)
{
QIcon *icon = AircraftInformation::getAirlineIcon(airline->m_icao);
if (icon) {
row.m_airline = *icon;
} else {
row.m_airlineText = airline->m_name;
}
QString flag = airline->m_country.toLower().replace(" ", "_");
icon = AircraftInformation::getFlagIcon(flag);
if (icon) {
row.m_country = *icon;
}
}
}
}
QVariant AircraftTableModel::data(const QModelIndex& index, int role) const
{
if (role == ActiveRole)
{
const int r = index.row();
return ((r >= 0) && (r < m_rows.size())) ? m_rows[r].m_display.m_active : false;
}
if (!index.isValid() || (index.row() >= m_rows.size())) {
return QVariant();
}
const Row& row = m_rows[index.row()];
const AircraftDisplay& d = row.m_display;
if ((role == Qt::DecorationRole) || ((role == Qt::DisplayRole) && ((index.column() == COL_TYPE) || (index.column() == COL_AIRLINE))))
{
if (!row.m_iconsResolved) {
resolveIcons(const_cast<Row&>(row));
}
}
if (role == Qt::DecorationRole)
{
switch (index.column())
{
case COL_COUNTRY: return row.m_country.isNull() ? QVariant() : row.m_country;
case COL_AIRLINE: return row.m_airline.isNull() ? QVariant() : row.m_airline;
case COL_SIDEVIEW: return row.m_sideview.isNull() ? QVariant() : row.m_sideview;
default: return QVariant();
}
}
if (role != Qt::DisplayRole) {
return QVariant();
}
switch (index.column())
{
case COL_ICAO:
return d.m_icao ? QString("%1").arg(d.m_icao, 6, 16, QChar('0')).toUpper() : QVariant();
case COL_REG: return d.m_registration;
case COL_TYPE: return row.m_type;
case COL_FLIGHT: return d.m_flight;
case COL_AIRLINE: return row.m_airline.isNull() ? QVariant(row.m_airlineText) : QVariant();
case COL_LATITUDE: return d.m_positionValid ? QVariant((double) d.m_latitude) : QVariant();
case COL_LONGITUDE: return d.m_positionValid ? QVariant((double) d.m_longitude) : QVariant();
// Rounded to 100 m but still a number, so the column sorts by magnitude rather
// than by the leading character of a formatted string
case COL_DISTANCE: return d.m_distanceValid
? QVariant(std::round((double) d.m_distanceKm * 10.0) / 10.0) : QVariant();
// Altitude alone, not altitude and a position. The tracker deliberately accepts an
// altitude from a report that carried no position - a Mode S altitude reply has one
// and not the other - so requiring both hid a figure it had gone to the trouble of
// keeping.
case COL_ALTITUDE: return d.m_altitudeValid ? QVariant((int) d.m_altitudeFt) : QVariant();
case COL_HEADING: return d.m_headingValid ? QVariant((int) d.m_heading) : QVariant();
case COL_SPEED: return d.m_speedValid ? QVariant((int) d.m_speedKts) : QVariant();
case COL_PROTOCOLS: return d.m_protocols;
case COL_MESSAGES: return d.m_messages;
case COL_LAST_SEEN: return d.m_lastSeen;
default: return QVariant();
}
}
void AircraftTableModel::upsert(const QList<AircraftDisplay>& aircraft)
{
for (const AircraftDisplay& d : aircraft)
{
int row = m_rowById.value(d.m_id, -1);
if (row >= 0)
{
// Re-resolve icons if the identity changed
if ((m_rows[row].m_display.m_registration != d.m_registration)
|| (m_rows[row].m_display.m_flight != d.m_flight)) {
m_rows[row].m_iconsResolved = false;
}
m_rows[row].m_display = d;
emit dataChanged(index(row, 0), index(row, COL_COUNT - 1));
}
else
{
beginInsertRows(QModelIndex(), m_rows.size(), m_rows.size());
Row newRow;
newRow.m_display = d;
m_rowById.insert(d.m_id, m_rows.size());
m_rows.append(newRow);
endInsertRows();
}
}
}
void AircraftTableModel::remove(const QList<quint64>& ids)
{
for (quint64 id : ids)
{
int row = m_rowById.value(id, -1);
if (row >= 0)
{
beginRemoveRows(QModelIndex(), row, row);
m_rows.removeAt(row);
m_rowById.remove(id);
reindex(row);
endRemoveRows();
}
}
}
void AircraftTableModel::reindex(int from)
{
for (int i = from; i < m_rows.size(); i++) {
m_rowById.insert(m_rows[i].m_display.m_id, i);
}
}
void AircraftTableModel::clear()
{
beginResetModel();
m_rows.clear();
m_rowById.clear();
endResetModel();
}
const AircraftDisplay *AircraftTableModel::aircraftAt(int row) const
{
return ((row >= 0) && (row < m_rows.size())) ? &m_rows[row].m_display : nullptr;
}
FlightTableModel::FlightTableModel(QObject *parent) :
QAbstractTableModel(parent)
{
}
int FlightTableModel::rowCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : m_rows.size();
}
int FlightTableModel::columnCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : COL_COUNT;
}
QVariant FlightTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if ((orientation != Qt::Horizontal) || (role != Qt::DisplayRole)) {
return QVariant();
}
switch (section)
{
case COL_FLIGHT: return "Flight";
case COL_REG: return "Reg";
case COL_FROM: return "From";
case COL_TO: return "To";
case COL_OUT: return "Out";
case COL_OFF: return "Off";
case COL_ON: return "On";
case COL_IN: return "In";
case COL_FIRST_SEEN: return "First seen";
case COL_LAST_SEEN: return "Last seen";
case COL_LS: return "LS";
case COL_OC: return "OC";
case COL_FP: return "FP";
case COL_DOCS: return "Docs";
case COL_PROTOCOLS: return "Protocols";
default: return QVariant();
}
}
QVariant FlightTableModel::data(const QModelIndex& index, int role) const
{
if (role == ActiveRole)
{
const int r = index.row();
return ((r >= 0) && (r < m_rows.size())) ? m_rows[r].m_active : false;
}
if (!index.isValid() || (index.row() >= m_rows.size())) {
return QVariant();
}
const FlightDisplay& d = m_rows[index.row()];
// OOOI columns show the time and sort on the instant. Qt sorts on the display role
// by default, so the full value goes out as the sort role and the short form as the
// display - otherwise a flight that went out at 23:55 sorts after one at 00:10.
if ((index.column() >= COL_OUT) && (index.column() <= COL_IN))
{
const QDateTime *when = (index.column() == COL_OUT) ? &d.m_out
: (index.column() == COL_OFF) ? &d.m_off
: (index.column() == COL_ON) ? &d.m_on : &d.m_in;
if (role == Qt::DisplayRole) {
return when->isValid() ? when->toUTC().toString("hh:mm") : QString();
}
if (role == Qt::ToolTipRole) {
return when->isValid() ? when->toUTC().toString("yyyy-MM-dd hh:mm:ss' UTC'") : QString();
}
if (role == SortRole) {
return *when;
}
}
if (role == Qt::ToolTipRole)
{
if ((index.column() == COL_FLIGHT) && !d.m_aliases.isEmpty()) {
return QString("Also known as: %1").arg(d.m_aliases);
}
if ((index.column() == COL_FROM) && !d.m_route.isEmpty()) {
return QString("Route: %1").arg(d.m_route);
}
return QVariant();
}
if (role != Qt::DisplayRole) {
return QVariant();
}
switch (index.column())
{
case COL_FLIGHT: return d.m_flight;
case COL_REG: return d.m_reg;
case COL_FROM: return d.m_departure;
case COL_TO: return d.m_arrival;
// Displayed as the time alone - these are all within a few hours of each other and
// the date is noise - but returned as a QDateTime so sorting still works across
// midnight, which a bare "23:55" against "00:10" would not
case COL_OUT: return d.m_out;
case COL_OFF: return d.m_off;
case COL_ON: return d.m_on;
case COL_IN: return d.m_in;
case COL_FIRST_SEEN: return d.m_firstSeen;
case COL_LAST_SEEN: return d.m_lastSeen;
// Sorted and displayed on the same value, so sorting groups the flights that have
// one against those that do not
// A tick where the flight has one, and nothing where it does not. A column of
// crosses is as loud as a column of ticks, which makes the ticks - the thing worth
// spotting - harder to pick out than an empty cell does.
case COL_LS: return d.m_hasLoadsheet ? QString(QChar(0x2713)) : QString();
case COL_OC: return d.m_hasClearance ? QString(QChar(0x2713)) : QString();
case COL_FP: return d.m_hasFlightPlan ? QString(QChar(0x2713)) : QString();
case COL_DOCS: return d.m_documents;
// What THIS flight has been heard on. The aircraft table's column of the same
// name is the airframe's, over every flight it has ever made.
case COL_PROTOCOLS: return d.m_protocols;
default: return QVariant();
}
}
void FlightTableModel::upsert(const QList<FlightDisplay>& flights)
{
for (const FlightDisplay& d : flights)
{
int row = m_rowById.value(d.m_id, -1);
if (row >= 0)
{
m_rows[row] = d;
emit dataChanged(index(row, 0), index(row, COL_COUNT - 1));
}
else
{
beginInsertRows(QModelIndex(), m_rows.size(), m_rows.size());
m_rowById.insert(d.m_id, m_rows.size());
m_rows.append(d);
endInsertRows();
}
}
}
void FlightTableModel::remove(const QList<quint64>& ids)
{
for (quint64 id : ids)
{
int row = m_rowById.value(id, -1);
if (row >= 0)
{
beginRemoveRows(QModelIndex(), row, row);
m_rows.removeAt(row);
m_rowById.remove(id);
reindex(row);
endRemoveRows();
}
}
}
void FlightTableModel::reindex(int from)
{
for (int i = from; i < m_rows.size(); i++) {
m_rowById.insert(m_rows[i].m_id, i);
}
}
void FlightTableModel::clear()
{
beginResetModel();
m_rows.clear();
m_rowById.clear();
endResetModel();
}
const FlightDisplay *FlightTableModel::flightAt(int row) const
{
return ((row >= 0) && (row < m_rows.size())) ? &m_rows[row] : nullptr;
}

206
plugins/feature/aircraft/aircrafttablemodels.h

@ -0,0 +1,206 @@ @@ -0,0 +1,206 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_FEATURE_AIRCRAFTTABLEMODELS_H_
#define INCLUDE_FEATURE_AIRCRAFTTABLEMODELS_H_
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include <QIcon>
#include <QHash>
#include "aircrafttracker.h"
// True while data is arriving for the aircraft or flight in this row
static const int ActiveRole = Qt::UserRole + 100;
// Columns whose display value does not sort the way the underlying value does - the OOOI
// times show "hh:mm" but must order across midnight - publish the real value here
static const int SortRole = Qt::UserRole + 101;
// Model/view for the aircraft table: rows are display snapshots from the
// tracker; icons are resolved lazily on the GUI side
// Filters a table down to the rows we are currently receiving data for, or to those we
// are not - the same model feeds both the live and the archive views
class ActiveFilterProxy : public QSortFilterProxyModel {
Q_OBJECT
public:
protected:
// Sorting is on the display role, so a column showing a shortened value would sort
// by its text. One that publishes SortRole is ordered by that instead.
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
{
const QVariant l = left.data(SortRole);
if (l.isValid()) {
return l.toDateTime() < right.data(SortRole).toDateTime();
}
return QSortFilterProxyModel::lessThan(left, right);
}
public:
ActiveFilterProxy(bool wantActive, QObject *parent = nullptr) :
QSortFilterProxyModel(parent),
m_wantActive(wantActive)
{
// A row number is a position, so every row below an insertion, a removal or a
// re-sort is now numbered differently and the whole column has to be repainted.
// Without this the numbers only refresh where the view happens to redraw.
auto renumber = [this]()
{
if (rowCount() > 0) {
emit headerDataChanged(Qt::Vertical, 0, rowCount() - 1);
}
};
connect(this, &QAbstractItemModel::rowsInserted, this, renumber);
connect(this, &QAbstractItemModel::rowsRemoved, this, renumber);
connect(this, &QAbstractItemModel::layoutChanged, this, renumber);
connect(this, &QAbstractItemModel::modelReset, this, renumber);
}
// Row numbers down the side, counting what is DISPLAYED rather than the underlying
// rows. It has to be done here rather than by just showing the vertical header: the
// source models return nothing for a vertical section, so the header would be blank,
// and QSortFilterProxyModel's own implementation maps the section back to its SOURCE
// row, so the numbers would jump about as soon as the table was sorted. Numbering the
// view position means the top row is always 1, whatever the sort order.
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override
{
if (orientation == Qt::Vertical)
{
if (role == Qt::DisplayRole) {
return section + 1;
}
return QVariant();
}
return QSortFilterProxyModel::headerData(section, orientation, role);
}
protected:
bool filterAcceptsRow(int row, const QModelIndex& parent) const override
{
const QModelIndex index = sourceModel()->index(row, 0, parent);
return sourceModel()->data(index, ActiveRole).toBool() == m_wantActive;
}
private:
bool m_wantActive;
};
class AircraftTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum Col {
COL_ICAO,
COL_REG,
COL_TYPE,
COL_FLIGHT,
COL_AIRLINE,
COL_SIDEVIEW,
COL_COUNTRY,
COL_LATITUDE,
COL_LONGITUDE,
COL_DISTANCE,
COL_ALTITUDE,
COL_HEADING,
COL_SPEED,
COL_PROTOCOLS,
COL_MESSAGES,
COL_LAST_SEEN,
COL_COUNT
};
explicit AircraftTableModel(QObject *parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
void upsert(const QList<AircraftDisplay>& aircraft);
void remove(const QList<quint64>& ids);
void clear();
const AircraftDisplay *aircraftAt(int row) const;
private:
struct Row {
AircraftDisplay m_display;
bool m_iconsResolved = false;
QIcon m_country;
QIcon m_airline;
QString m_airlineText;
QIcon m_sideview;
QString m_type;
};
QList<Row> m_rows;
QHash<quint64, int> m_rowById;
void resolveIcons(Row& row) const;
void reindex(int from);
};
// Model/view for the flights table
class FlightTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum Col {
COL_FLIGHT,
COL_REG,
COL_FROM,
COL_TO,
COL_OUT, // OOOI: off the gate
COL_OFF, // airborne
COL_ON, // landed
COL_IN, // on the gate
COL_FIRST_SEEN,
COL_LAST_SEEN,
COL_LS, // Loadsheet
COL_OC, // Oceanic clearance
COL_FP, // Flight plan
COL_DOCS,
// Appended rather than placed beside Messages where it belongs: the saved
// column widths and order are stored by index, so inserting in the middle
// would shift every one of them. Drag it where you want it.
COL_PROTOCOLS,
COL_COUNT
};
explicit FlightTableModel(QObject *parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
void upsert(const QList<FlightDisplay>& flights);
void remove(const QList<quint64>& ids);
void clear();
const FlightDisplay *flightAt(int row) const;
private:
QList<FlightDisplay> m_rows;
QHash<quint64, int> m_rowById;
void reindex(int from);
};
#endif // INCLUDE_FEATURE_AIRCRAFTTABLEMODELS_H_

3621
plugins/feature/aircraft/aircrafttracker.cpp

File diff suppressed because it is too large Load Diff

770
plugins/feature/aircraft/aircrafttracker.h

@ -0,0 +1,770 @@ @@ -0,0 +1,770 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_FEATURE_AIRCRAFTTRACKER_H_
#define INCLUDE_FEATURE_AIRCRAFTTRACKER_H_
#include <QObject>
#include <QTimer>
#include <QDateTime>
#include <QHash>
#include <QSet>
#include <QGeoCoordinate>
#include <QMetaType>
#include "util/message.h"
#include "util/messagequeue.h"
#include "util/aircraftreport.h"
#include "util/osndb.h"
// For the tables a filed route is resolved against - see resolveRoute()
#include "util/openaip.h"
#include "util/ourairportsdb.h"
#include "util/waypoints.h"
#include "aircraftsettings.h"
class Feature;
struct sqlite3;
namespace SWGSDRangel {
class SWGMapItem;
class SWGMapCoordinate;
}
// Snapshots of the tracker's state, sent to the GUI over queued signals so the
// GUI never touches the tracker thread's data
struct AircraftDisplay {
quint64 m_id = 0;
quint32 m_icao = 0;
QString m_registration;
QString m_flight;
bool m_positionValid = false;
// Distance from the antenna that heard the aircraft, in km - see TrackedAircraft
bool m_distanceValid = false;
float m_distanceKm = 0.0f;
float m_latitude = 0.0f;
float m_longitude = 0.0f;
bool m_altitudeValid = false;
float m_altitudeFt = 0.0f;
bool m_headingValid = false;
float m_heading = 0.0f;
bool m_speedValid = false;
float m_speedKts = 0.0f;
QString m_protocols;
int m_messages = 0;
QDateTime m_lastSeen;
QString m_mapName;
quint64 m_currentFlightId = 0;
bool m_active = false; // Data is arriving for this aircraft
};
struct FlightDisplay {
quint64 m_id = 0;
quint64 m_aircraftId = 0;
QString m_flight;
QString m_aliases;
QString m_reg;
QString m_departure;
QString m_arrival;
QString m_route;
QDateTime m_firstSeen;
QDateTime m_lastSeen;
int m_documents = 0;
int m_messages = 0;
QString m_protocols; // Protocols and frequencies THIS flight was heard on
QDateTime m_out;
QDateTime m_off;
QDateTime m_on;
QDateTime m_in;
// Whether the flight has produced each of the documents worth knowing about at a
// glance, so the table can say so without opening the flight
bool m_hasLoadsheet = false;
bool m_hasClearance = false;
bool m_hasFlightPlan = false;
bool m_active = false; // The flight an active aircraft is currently flying
};
struct DocumentEvent {
quint64 m_aircraftId = 0;
quint64 m_flightId = 0;
QDateTime m_received;
QString m_flight;
QString m_reg;
QString m_kind;
QString m_title;
QString m_text;
QString m_mapName;
};
struct AtcEvent {
quint64 m_aircraftId = 0;
quint64 m_flightId = 0;
QDateTime m_received;
QString m_protocol;
bool m_uplink = false;
QString m_from;
QString m_to;
QString m_message;
QString m_tooltip;
QString m_mapName;
};
Q_DECLARE_METATYPE(AircraftDisplay)
Q_DECLARE_METATYPE(FlightDisplay)
Q_DECLARE_METATYPE(DocumentEvent)
// A weather report is about an AIRPORT, not about the aircraft that happened to ask
// for it - so it outlives that aircraft and is kept in its own log
struct WeatherEvent {
QDateTime m_received;
QString m_airport; // ICAO code, empty if the report did not name one
QString m_kind; // METAR, TAF, ATIS, TWIP, NOTAM, PIREP, SIGMET
QString m_summary; // First line, for the table
QString m_text; // The report as sent
QString m_from; // Aircraft that carried it, for provenance
};
Q_DECLARE_METATYPE(AtcEvent)
Q_DECLARE_METATYPE(WeatherEvent)
// Collates aircraft reports from the demodulators into aircraft, flights and
// documents, drives the Map and persists the session, all off the GUI thread.
// Runs on its own thread inside the Aircraft feature, in both GUI and server
// builds; the GUI, when there is one, is a view driven by this class's signals.
// Session and lifetime statistics shown on the Statistics tab.
//
// Every figure is kept twice: once for this session and once for all time. The two
// answer different questions - "is the aerial working as well as it did yesterday"
// wants the session, "how far have we ever heard" wants all time - and neither is
// recoverable from the other, so both are counted as reports arrive.
//
// The all time side persists. Most of it travels in the settings blob, as the records
// always have. The one exception is the aircraft count, which cannot be a running
// total: the same airframe heard on two days must count once, so it needs the set of
// who has been heard, not a number. That set is the database's "seen" table, which is
// also the only part of this that survives the retention period pruning the rest.
struct AircraftStatistics {
// A record holder: the value, who set it, when, and where they were at the time.
// The position is what lets the max range record be drawn on the Map at the point
// it was actually achieved rather than wherever the aircraft is now - which for an
// all time record is very probably nowhere, the aircraft having long since landed.
struct Record {
bool m_valid = false;
float m_value = 0.0f;
QString m_aircraft; // Registration, else flight, else ICAO address
QDateTime m_when;
bool m_positionValid = false;
float m_latitude = 0.0f;
float m_longitude = 0.0f;
bool m_altitudeValid = false;
float m_altitudeFt = 0.0f;
// Returns true if this beat the record
bool update(float value, const QString& aircraft, const QDateTime& when,
bool positionValid, float latitude, float longitude,
bool altitudeValid, float altitudeFt)
{
if (m_valid && (value <= m_value)) {
return false;
}
m_valid = true;
m_value = value;
m_aircraft = aircraft;
m_when = when;
m_positionValid = positionValid;
m_latitude = latitude;
m_longitude = longitude;
m_altitudeValid = altitudeValid;
m_altitudeFt = altitudeFt;
return true;
}
};
// One complete set of figures, over whatever period the holder covers
struct Scope {
// Furthest heard on each protocol, indexed by AircraftReport::Protocol. Per
// protocol rather than one overall figure because the whole point of comparing
// them is that they are so different - line of sight VHF against HF skywave
// against a satellite.
Record m_maxRange[AircraftReport::ProtocolCount];
Record m_fastest; // Ground speed, knots
Record m_highest; // Altitude, feet
quint64 m_totalMessages = 0; // Reports of any kind
quint64 m_messagesByProtocol[AircraftReport::ProtocolCount] = {};
int m_distinctAircraft = 0; // Different aircraft heard
int m_maxConcurrent = 0; // Most aircraft heard within any 15 minute window
QDateTime m_maxConcurrentWhen;
qint64 m_seconds = 0; // Time spent listening, filled in as it is emitted
// Applies a report to every record this scope keeps
void update(int protocol, bool rangeValid, float rangeKm, bool speedValid,
float speedKts, bool altitudeValid, float altitudeFt,
const QString& who, const QDateTime& when,
bool positionValid, float latitude, float longitude)
{
m_totalMessages++;
if ((protocol >= 0) && (protocol < AircraftReport::ProtocolCount))
{
m_messagesByProtocol[protocol]++;
if (rangeValid) {
m_maxRange[protocol].update(rangeKm, who, when, positionValid,
latitude, longitude, altitudeValid, altitudeFt);
}
}
if (speedValid) {
m_fastest.update(speedKts, who, when, positionValid, latitude, longitude,
altitudeValid, altitudeFt);
}
if (altitudeValid) {
m_highest.update(altitudeFt, who, when, positionValid, latitude, longitude,
altitudeValid, altitudeFt);
}
}
};
Scope m_session;
Scope m_allTime;
QDateTime m_sessionStart;
QDateTime m_firstStart; // When the all time figures began
static const int ConcurrentWindowMins = 15;
};
Q_DECLARE_METATYPE(AircraftStatistics)
class AircraftTracker : public QObject
{
Q_OBJECT
public:
class MsgConfigureTracker : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AircraftSettings& getSettings() const { return m_settings; }
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; }
static MsgConfigureTracker* create(const AircraftSettings& settings, const QList<QString>& settingsKeys, bool force) {
return new MsgConfigureTracker(settings, settingsKeys, force);
}
private:
AircraftSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force;
MsgConfigureTracker(const AircraftSettings& settings, const QList<QString>& settingsKeys, bool force) :
Message(), m_settings(settings), m_settingsKeys(settingsKeys), m_force(force)
{}
};
class MsgReport : public Message {
MESSAGE_CLASS_DECLARATION
public:
AircraftReport& getReport() { return m_report; }
static MsgReport* create(const AircraftReport& report) { return new MsgReport(report); }
~MsgReport(); // Owns m_report.m_mapItem until processing transfers it
private:
AircraftReport m_report;
MsgReport(const AircraftReport& report) : Message(), m_report(report) {}
};
class MsgDeleteAll : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgDeleteAll* create() { return new MsgDeleteAll(); }
private:
MsgDeleteAll() : Message() {}
};
// Zero one half of the statistics. The all time half also clears the record of
// which airframes have been heard, which is the only way its aircraft count can go
// back to nothing
class MsgResetStatistics : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getAllTime() const { return m_allTime; }
static MsgResetStatistics* create(bool allTime) { return new MsgResetStatistics(allTime); }
private:
bool m_allTime;
MsgResetStatistics(bool allTime) : Message(), m_allTime(allTime) {}
};
// GUI (re)connected: resend the complete state
class MsgResync : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgResync* create() { return new MsgResync(); }
private:
MsgResync() : Message() {}
};
// Which flight's profile the GUI is charting; 0 for none
class MsgWatchFlight : public Message {
MESSAGE_CLASS_DECLARATION
public:
quint64 getFlightId() const { return m_flightId; }
static MsgWatchFlight* create(quint64 flightId) { return new MsgWatchFlight(flightId); }
private:
quint64 m_flightId;
MsgWatchFlight(quint64 flightId) : Message(), m_flightId(flightId) {}
};
explicit AircraftTracker(Feature *feature);
~AircraftTracker();
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
public:
// Used by the GUI, which owns persistence: it holds the blob ready for serialize()
static QByteArray serializeStatistics(const AircraftStatistics& statistics);
static AircraftStatistics deserializeStatistics(const QByteArray& data);
public slots:
void startWork();
signals:
void aircraftUpdated(const QList<AircraftDisplay>& aircraft);
void aircraftRemoved(const QList<quint64>& ids);
void flightsUpdated(const QList<FlightDisplay>& flights);
void flightsRemoved(const QList<quint64>& ids);
void documentsAdded(const QList<DocumentEvent>& documents);
void atcMessages(const QList<AtcEvent>& messages);
void weatherReports(const QList<WeatherEvent>& reports);
void profileUpdated(quint64 flightId, const QList<qint64>& times, const QList<float>& altitudeFt, const QList<float>& speedKts);
void messageRates(const QList<float>& ratesPerProtocolThenTotal);
void statisticsUpdated(const AircraftStatistics& statistics);
void speechNotification(const QString& speech);
void allCleared();
//!< The database could not be changed, so the setting has been put back to the file
//!< actually in use. The GUI holds the settings that get serialised, so it has to
//!< hear about it or it would keep - and save - a path nothing is writing to.
void databaseFilenameReverted(const QString& filename);
private:
struct TrackedAircraft;
struct TrackedDocument {
int m_kind;
QString m_title;
QString m_text;
QDateTime m_received;
};
struct TrackedFlight {
quint64 m_id = 0;
QString m_flight;
QStringList m_aliases;
TrackedAircraft *m_aircraft = nullptr;
QDateTime m_firstSeen;
QDateTime m_lastSeen;
QString m_departure;
QString m_arrival;
QString m_route;
//!< When the message that revealed m_departure, m_arrival and m_route was
//!< received, so a delayed one cannot put back what a newer one has replaced.
//!< Invalid where the facts came from the callsign to route database, which is a
//!< standing guess rather than something the aircraft said.
QDateTime m_routeFiled;
// A route the aircraft has been given, drawn on the Map. Kept apart from
// m_route because the callsign to route database also fills that in, with the
// airport pair rather than a list of waypoints, and only a real waypoint list
// can be drawn.
struct FiledRoute {
QString m_waypoints; //!< The route as filed, names separated by spaces
//!< Where the message put those waypoints, when it said. Same order and
//!< length as m_waypoints, or empty when it named them without placing them.
QList<AircraftReport::RouteWaypoint> m_points;
QString m_text; //!< The message that filed it, for the popup
QDateTime m_filed; //!< When, so a merge can tell two routes apart
QString m_drawn; //!< What was last sent, so it is only sent once
//!< Held back for want of a Map to send it to or a name to key it on -
//!< neither of which the flight is told about when it changes
bool m_pending = false;
//!< The Map item names last emitted, so that anything which will not be
//!< drawn again can be taken off. The Map keys on the name, so a route that
//!< has been renamed would otherwise be drawn twice over.
QString m_drawnLine;
QStringList m_drawnWaypoints;
};
FiledRoute m_flightPlan; //!< An FPN plan, or a position report's route insert
FiledRoute m_clearance; //!< An oceanic clearance or its readback
//!< Protocols and frequencies THIS flight has been heard on, the same tally the
//!< airframe keeps but bounded to one flight. The Map shows this one: an
//!< airframe heard on HFDL over the Atlantic last month is not being heard on
//!< HFDL now, so naming it beside the aircraft on the Map is simply wrong.
QHash<QPair<int, qint64>, int> m_sources;
QList<TrackedDocument *> m_documents;
QList<qint64> m_profileTimes;
QList<float> m_profileAltFt;
QList<float> m_profileSpeedKts;
// The ground track belongs to the FLIGHT, not to the airframe. An aircraft is
// heard again days later on a different route, and drawing every track it has
// ever flown puts unrelated lines across the map
// How many of the points below are already in the database. The track and the
// profile only ever grow, so a save writes the tail rather than rewriting the
// whole history - see saveDatabase(). Reset to zero, and the flight added to
// m_flightsToRewrite, whenever the arrays are rebuilt rather than appended to.
int m_trackSaved = 0;
int m_profileSaved = 0;
QList<QGeoCoordinate> m_track;
QList<QDateTime> m_trackTimes;
int m_messages = 0; // Reports of any kind attributed to this flight
// The OOOI times, as the flight reported them. Out of gate, take off, landing,
// on gate - the four instants that describe a flight from the ground's point of
// view, and the ones an airline's own systems run on.
QDateTime m_out;
QDateTime m_off;
QDateTime m_on;
QDateTime m_in;
// The ground track belongs to the FLIGHT, not to the airframe. An aircraft is
// heard again days later on a different route, and drawing every track it has
// ever flown puts unrelated lines across the map
~TrackedFlight() { qDeleteAll(m_documents); }
};
// How much a position can be trusted, best first. A VDL-2 XID link management frame
// carries an aircraft location parameter with 0.1 degree resolution - about 11 km -
// which is enough for a ground station to decide a handoff, but drags an ADS-B track
// sideways every time one arrives
enum PositionRank {
PositionAdsb = 0, // ADS-B: metres, about once a second
PositionReported = 1, // A real position report, whatever protocol carried it
PositionCoarse = 2, // A location parameter from a link management frame
PositionRanks = 3
};
static int positionRank(const AircraftReport& report);
// Altitude is ranked separately from position, and for a different reason. An XID
// location parameter carries an altitude as a single octet of thousands of feet, and
// a minority of aircraft - overwhelmingly Boeing 737NGs - fill it with nonsense:
// 59000, 65000, 90000, 123000 ft have all been observed off air, from aircraft whose
// ADS-B put them at a normal cruise at the same moment. The value is not merely
// coarse, it is sometimes wrong, so it must not set a record and must not displace a
// real altitude. See the note above AcarsVdl2Atn's altitude handling for the
// measurements behind that.
enum AltitudeRank {
AltitudeAdsb = 0, // ADS-B: 25 ft, about once a second
AltitudeReported = 1, // A real position or performance report
AltitudeCoarse = 2, // A link management frame's location parameter
AltitudeRanks = 3
};
static int altitudeRank(const AircraftReport& report);
// A less accurate source is only used once the better ones have gone quiet for this long
static const int m_positionRankTimeoutSecs = 60;
// How long a flight number may still stand in for an identity. Long enough to cover
// a flight heard intermittently, far short of the same number returning tomorrow.
static const int m_flightKeyValidSecs = 12*60*60;
// Positions that would need a faster aircraft than this to reach are stale or wrong
static const int m_maxGroundSpeedKn = 700;
static constexpr double m_positionToleranceKm = 5.0;
struct TrackedAircraft {
quint64 m_id = 0;
quint32 m_icao = 0;
QString m_registration;
QString m_flight;
bool m_positionValid = false;
float m_latitude = 0.0f;
float m_longitude = 0.0f;
float m_altitudeFt = 0.0f;
bool m_altitudeValid = false;
// The two most recent altitude observations, so an altitude can be worked out
// for the moment a position was measured rather than assuming they coincide
QDateTime m_altitudeDateTime;
float m_prevAltitudeFt = 0.0f;
QDateTime m_prevAltitudeDateTime;
float m_heading = 0.0f;
bool m_headingValid = false;
float m_speedKts = 0.0f;
bool m_speedValid = false;
//!< When each was observed. Neither is timestamped in its own right - a velocity
//!< message says what the aircraft is doing now, not when - so this is the
//!< report's reception time, which is enough to stop a delayed report putting
//!< back a heading or speed the aircraft has already left behind.
QDateTime m_headingDateTime;
QDateTime m_speedDateTime;
// Great circle distance from the receiver to the aircraft, in km. Measured from
// the position of the DEVICE the report arrived on where it has one - a remote
// SDR reports where it is - and from My Position otherwise, so a distance always
// means "from the antenna that heard it" rather than "from here".
bool m_distanceValid = false;
float m_distanceKm = 0.0f;
QDateTime m_positionDateTime;
QDateTime m_positionRankTimes[PositionRanks]; // When a position of each rank last arrived
int m_positionRank = PositionRanks; // Rank of the position we are holding
QDateTime m_altitudeRankTimes[AltitudeRanks]; // When an altitude of each rank last arrived
QDateTime m_lastSeen;
QString m_departure;
QString m_arrival;
QString m_route;
QString m_lastDocumentText;
// Every protocol and frequency this airframe has EVER been heard on, kept for
// as long as the airframe is. The flight has its own, which is what the Map
// shows: an airframe heard on HFDL over the Atlantic last month is not being
// heard on HFDL now, and saying so on the Map is simply wrong.
QHash<QPair<int, qint64>, int> m_sources;
int m_messages = 0;
QString m_mapName;
QDateTime m_lastMapItemTime;
QString m_model3D;
float m_modelAltitudeOffset = 0.0f; // So the undercarriage is not underground
float m_labelAltitudeOffset = 0.0f;
// Whether we chose the model or the ADS-B pass-through brought one. Only ours may
// be thrown away and chosen again when the livery preference changes - replacing
// a pass-through model with our own would fight the demodulator for it.
bool m_modelIsOurs = false;
bool m_mapModelForm = false;
bool m_mapTrackChanged = true;
//!< Owed to a Map that has just appeared, and still owed until something has
//!< actually been sent - see checkMapConsumers()
bool m_mapResync = false;
QList<TrackedFlight *> m_flights;
TrackedFlight *m_currentFlight = nullptr;
// Set when a report arrives, cleared when the aircraft goes quiet. Aircraft
// restored from the session database start inactive, so a new session begins
// with empty active tables
bool m_active = false;
QSet<int> m_notifiedRules;
~TrackedAircraft() { qDeleteAll(m_flights); }
};
Feature *m_feature; // Pipe source for the Map
AircraftSettings m_settings;
MessageQueue m_inputMessageQueue;
QList<TrackedAircraft *> m_aircraft;
QHash<QString, TrackedAircraft *> m_byKey;
quint64 m_nextId = 1;
QSharedPointer<const QHash<QString, AircraftInformation *>> m_aircraftInfo;
QSharedPointer<const QHash<int, AircraftInformation *>> m_aircraftInfoByIcao;
QSharedPointer<const QHash<QString, AircraftRouteInformation *>> m_routeInfo;
// Used to turn the named waypoints of a filed route into coordinates. All three are
// process wide caches shared with the Map and the ACARS demodulator, so holding them
// here costs a pointer rather than another copy of the data.
QSharedPointer<const QList<NavAid *>> m_navAids;
QSharedPointer<const QHash<QString, AirportInformation *>> m_airports;
QSharedPointer<const QMultiHash<QString, Waypoint *>> m_waypoints;
QList<AtcEvent> m_atcLog; // Self-contained, outlives its aircraft
QList<WeatherEvent> m_weatherLog; // Likewise, and keyed on airports not aircraft
// Which reports are already in the log, so a repeat is recognised without comparing
// it against every entry ever logged. Maps a hash of the report to its position; the
// full comparison still happens on a hash match, so a collision costs one comparison
// rather than silently dropping a report that was not really a duplicate. The log is
// only ever appended to, so the positions never move.
QMultiHash<size_t, int> m_weatherIndex;
// Batched GUI notifications
QSet<TrackedAircraft *> m_dirtyAircraft;
QSet<TrackedFlight *> m_dirtyFlights;
QList<DocumentEvent> m_pendingDocuments;
QList<AtcEvent> m_pendingAtc;
QList<WeatherEvent> m_pendingWeather;
QTimer *m_flushTimer = nullptr;
QTimer *m_removalTimer = nullptr;
QTimer *m_chartTimer = nullptr;
// One counter per protocol plus a total
static const int CHART_COUNTS = AircraftReport::ProtocolCount + 1;
int m_chartCounts[CHART_COUNTS];
QDateTime m_chartRateTime;
quint64 m_watchedFlight = 0; // Flight whose profile the GUI charts
bool m_watchedFlightChanged = false;
sqlite3 *m_db = nullptr;
// Flights whose stored track and profile no longer match what is in memory. Deleted
// flights have to be named, because the save no longer empties those tables and so
// would otherwise leave their rows behind for ever.
QSet<quint64> m_flightsToDelete;
QSet<quint64> m_flightsToRewrite;
bool m_dbTrackWipe = false; //!< Everything in track and profile is stale
bool m_dbDirty = false;
bool m_loadingDatabase = false;
bool handleMessage(const Message& message);
void processReport(AircraftReport& report);
TrackedAircraft *findOrCreateAircraft(const AircraftReport& report);
void absorbAircraft(TrackedAircraft *item, TrackedAircraft *weak);
TrackedFlight *updateFlight(TrackedAircraft *item, const AircraftReport& report);
void mergeFlightInto(TrackedAircraft *item, TrackedFlight *dst, TrackedFlight *src);
void mergeLoadedFlights(TrackedAircraft *item);
static bool splitFlightName(const QString& flight, QString& airline, QString& number);
static bool sameFlightNumber(const QString& a, const QString& b);
static bool flightMatches(const TrackedFlight *flight, const QString& name);
//!< When this aircraft was last heard flying this callsign, which is not when it was
//!< last heard: it is very likely flying something else by now
static QDateTime flightLastSeen(const TrackedAircraft *item, const QString& flight);
//!< Whether two of one airframe's flights are one operation rather than the same
//!< callsign flown again on another day
bool sameOperation(const TrackedFlight *a, const TrackedFlight *b) const;
void addFlightAlias(TrackedAircraft *item, TrackedFlight *flight, const QString& name);
void addDocument(TrackedAircraft *item, TrackedFlight *flight, const AircraftReport& report);
void addAtcMessage(TrackedAircraft *item, TrackedFlight *flight, const AircraftReport& report);
void addWeatherReport(TrackedAircraft *item, const AircraftReport& report);
static QString weatherKindName(int kind);
QString documentKindName(int kind) const;
QString protocolName(int protocol) const;
static QString notificationSignature(const AircraftSettings& settings);
void claimKey(TrackedAircraft *item, const QString& key);
void updateRecordMapItem();
static const char *RecordMapItemName;
void resolveRoute(QList<AircraftReport::RouteWaypoint>& points,
QList<QGeoCoordinate>& coords) const;
void sendRouteToMap(TrackedFlight *flight, TrackedFlight::FiledRoute& route,
const QString& kind);
void removeDrawnRoute(TrackedFlight::FiledRoute& route);
// What updateRecordMapItem() last put on the Map, so an unchanged record is not
// re-sent 3 times a second, and so it can be taken off again when the option is
// turned off or the record is reset
QString m_recordMapKey;
bool m_recordOnMap = false;
bool m_recordUnplaceableWarned = false;
// Flights with a route that could not be delivered. Held by id rather than by
// pointer, so a flight deleted or merged away in the meantime simply fails to
// resolve rather than leaving this dangling.
QSet<quint64> m_routesPending;
void retryRoutes();
// WHICH Map features were listening last time anything was sent, by pipe id rather
// than by count: closing one Map and opening another between flushes leaves the count
// where it was, and the replacement would never be caught up. Delivery is remembered
// per item rather than per Map - what has been drawn, what track was last sent - so a
// Map opened after the fact is given later positions but none of what went out before
// it existed. Saying it all again to everyone is the cheap answer; per consumer state
// would be the thorough one.
QSet<unsigned int> m_mapConsumers;
// Aircraft owed to a Map that has just opened but not sendable yet: a basic item
// would replace a richer pass-through one for a minute after the last of those
// arrived. Kept here rather than in m_dirtyAircraft, which flush() empties every
// pass and which drives a GUI update for everything in it.
QSet<TrackedAircraft *> m_mapResyncPending;
void checkMapConsumers();
// Statistics
void updateStatistics(const AircraftReport& report, TrackedAircraft *item,
bool rangeValid, float rangeKm,
bool altitudeValid, float altitudeFt);
void updateConcurrent(const QDateTime& now);
QGeoCoordinate receiverPosition(int deviceSetIndex);
void update3DModel(TrackedAircraft *item);
AircraftStatistics m_statistics;
bool m_statisticsDirty = false;
bool m_statisticsLoaded = false;
// Seconds carried in from previous sessions, so the all time clock can be reported
// as a live total rather than only advancing when the app is restarted
qint64 m_allTimeSecondsBase = 0;
// What m_allTimeSecondsBase is measured from. Normally the start of the session, but
// an all time reset moves it to the moment of the reset - otherwise the all time
// clock would restart at however long this session had already been running
QDateTime m_allTimeSince;
// Aircraft heard this session. The tracked list is restored from the database at
// startup, so "a TrackedAircraft was allocated" counts only aircraft that fell out
// of the retention period - which under-reported the session badly
QSet<quint64> m_sessionHeard;
// Those of them already written to the all time table. Separate from the above
// because an aircraft can be heard before it is identified - an ACARS report can
// arrive with only a flight number and gain its registration later - and it must be
// counted under the identity it will keep, not the first one it happened to show
QSet<quint64> m_sessionRecorded;
// Drives a statistics update once a minute so both elapsed clocks tick even when
// nothing is being received
qint64 m_statisticsMinute = -1;
// Receiver positions, cached by device set index: getDevicePosition() builds a whole
// device report and parses it as JSON, which is far too heavy to do per message
QHash<int, QGeoCoordinate> m_devicePositions;
QDateTime m_devicePositionsRefreshed;
// Taking the tally rather than its owner, because both the airframe and the
// flight it is on keep one
QStringList sourcesList(const QHash<QPair<int, qint64>, int>& sources) const;
QString sourcesText(const QHash<QPair<int, qint64>, int>& sources) const;
QString mapItemName(const TrackedAircraft *item) const;
QString flightLabel(const QString& flight) const;
QString atcLabel(const TrackedAircraft *item) const;
QString aircraftImage(const TrackedAircraft *item) const;
//!< The same choice for an aircraft that is no longer tracked - all the record
//!< marker has is the name and, where the airframe is still known, its 3D model
QString aircraftImage(const QString& registration, const QString& model3D) const;
QList<SWGSDRangel::SWGMapCoordinate *> *buildTrack(const TrackedFlight *flight) const;
QDateTime mapAvailableUntil(const TrackedAircraft *item) const;
int positionTimeoutSecs(const TrackedAircraft *item) const;
bool positionStale(const TrackedAircraft *item, const QDateTime& now) const;
static float altitudeAt(const TrackedAircraft *item, const QDateTime& when, float fallbackFt);
// Which of an aircraft's flights the map should draw the track of - the one it is
// flying now, unless the GUI is looking at one of its past flights
const TrackedFlight *trackFlight(const TrackedAircraft *item) const;
void sendToMap(TrackedAircraft *item);
void forwardMapItem(TrackedAircraft *item, SWGSDRangel::SWGMapItem *swgMapItem);
void removeFromMap(const QString& name);
void checkNotifications(TrackedAircraft *item, const AircraftReport& report);
QString subAircraftString(TrackedAircraft *item, const AircraftReport& report, const QString& string) const;
void commandNotification(const QString& command);
void deleteAll();
void resync();
void applySettings(const AircraftSettings& settings, const QList<QString>& settingsKeys, bool force);
AircraftDisplay displayFor(const TrackedAircraft *item) const;
FlightDisplay displayFor(const TrackedFlight *flight) const;
DocumentEvent documentEvent(const TrackedAircraft *item, const TrackedFlight *flight, const TrackedDocument *doc) const;
void emitProfile(const TrackedFlight *flight);
TrackedFlight *flightById(quint64 id) const;
QString regFor(const TrackedAircraft *item) const;
// Implemented in aircraftdb.cpp
bool openDatabase();
// Remembers that this airframe has been heard at all, for the all time aircraft
// count. Returns 1 if it had not been heard before, 0 if it had, and -1 if it cannot
// be identified yet - in which case the caller should try again on the next report
//!< Writes this airframe into the all time "seen" table, folding away a row left
//!< under an identity it has since outgrown. Returns 1 when the table was written,
//!< -1 when it could not be and the caller should ask again, and sets countDelta to
//!< the change in the number of distinct airframes the table holds: +1 for one not
//!< seen before, -1 where two rows turned out to be one airframe, 0 otherwise.
int recordSeen(TrackedAircraft *item, int& countDelta);
int seenCount();
void resetSeen();
void closeDatabase();
//!< Returns false when nothing was written - the transaction rolled back, or there
//!< is no database. The session is then still only in memory, which is what makes it
//!< unsafe to switch databases: see changeDatabase().
bool saveDatabase();
void revertDatabaseFilename(const QString& path);
// The stored track and profile no longer relate to what is in memory at all
void forgetSavedTracks();
void loadDatabase();
private slots:
void handleInputMessages();
void flush();
void removeOldAircraft();
void setActive(TrackedAircraft *item, bool active);
void discardOldAircraft();
void changeDatabase(const QString& oldPath);
static QString databasePath(const AircraftSettings& settings);
void updateChartCounts();
};
#endif // INCLUDE_FEATURE_AIRCRAFTTRACKER_H_

49
plugins/feature/aircraft/aircraftwebapiadapter.cpp

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "aircraftwebapiadapter.h"
AircraftWebAPIAdapter::AircraftWebAPIAdapter()
{
}
AircraftWebAPIAdapter::~AircraftWebAPIAdapter()
{
}
int AircraftWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGFeatureSettings& response,
QString& errorMessage)
{
(void) response;
errorMessage = "Not implemented";
return 501;
}
int AircraftWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& featureSettingsKeys,
SWGSDRangel::SWGFeatureSettings& response,
QString& errorMessage)
{
(void) force;
(void) featureSettingsKeys;
(void) response;
errorMessage = "Not implemented";
return 501;
}

50
plugins/feature/aircraft/aircraftwebapiadapter.h

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// Some code by AI //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AIRCRAFT_WEBAPIADAPTER_H
#define INCLUDE_AIRCRAFT_WEBAPIADAPTER_H
#include "feature/featurewebapiadapter.h"
#include "aircraftsettings.h"
// Standalone API adapter only for the settings. WebAPI settings access needs a
// generated SWGAircraftSettings class, which does not exist yet - until then the
// settings blob round-trips but the REST settings endpoints report unimplemented.
class AircraftWebAPIAdapter : public FeatureWebAPIAdapter {
public:
AircraftWebAPIAdapter();
virtual ~AircraftWebAPIAdapter();
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { return m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGFeatureSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& featureSettingsKeys,
SWGSDRangel::SWGFeatureSettings& response,
QString& errorMessage);
private:
AircraftSettings m_settings;
};
#endif // INCLUDE_AIRCRAFT_WEBAPIADAPTER_H

BIN
plugins/feature/aircraft/icons/chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
plugins/feature/aircraft/icons/stats.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

354
plugins/feature/aircraft/readme.md

@ -0,0 +1,354 @@ @@ -0,0 +1,354 @@
<h1>Aircraft Feature Plugin</h1>
<h2>Introduction</h2>
The Aircraft feature collates aircraft data from multiple demodulators into a single
aircraft list, and sends the combined aircraft to the [Map feature](../map/readme.md).
Sightings are received from the [ADS-B demodulator](../../channelrx/demodadsb/readme.md)
and the [ACARS demodulator](../../channelrx/demodacars/readme.md) (VHF ACARS, VDL Mode 2
HFDL and Aero modes), from any number of channels in any device set.
Combining protocols matters because each sees a different slice of a flight: ADS-B gives
continuous positions in VHF range, VDL-2 sees logons and CPDLC near airports, and HFDL/Aero
can report an aircraft's position from thousands of kilometres away, hours after it left
ADS-B range. The feature merges these into one aircraft with one track.
<h2>Aircraft identity</h2>
Reports may identify an aircraft by any of:
* 24-bit ICAO address (ADS-B/HFDL/VDL-2 logons),
* registration (VHF ACARS header, or looked up from the ICAO address via the aircraft database),
* flight number / callsign.
The feature merges reports under whichever identities it has seen, cross referencing
registration and ICAO address through the aircraft database. A flight number is
remembered as the aircraft's most recent flight (flights change; the airframe does not).
<h2>Tables and tabs</h2>
The upper half of the window holds the traffic:
* **Aircraft** - every airframe currently being heard, one row each. See the column list
under Interface below
* **Old Aircraft** - airframes that have gone quiet for longer than the archive timeout.
They are not forgotten, only no longer current, and they come off the Map
* **Flights** - the flights seen this session, current and past: flight number, aircraft,
departure and arrival, the four OOOI times, when it was first and last heard, which
documents it has produced, and which protocols heard it
* **Old Flights** - flights that have finished, and those restored from the last session
* **Weather** - METARs, TAFs, D-ATIS, TWIPs, NOTAMs, PIREPs and SIGMETs carried by ACARS.
They arrive through whichever aircraft asked for them but describe an **airport**, not
that aircraft, so they are kept for the session rather than against a flight. Selecting
a row shows the full report
The lower half describes whatever is selected above:
* **Aircraft** - the photograph and the airframe's details. See Photo below
* **Documents** - flight plans, oceanic clearances, loadsheets, logons and OOOI events,
collected against the flight they belong to. Selecting one displays its full text
below the table. The log is kept even after the aircraft it came from has been
removed. Plain ACARS messages are not collected. CPDLC messages go to the ATC tab instead
* **ATC** - CPDLC (controller-pilot data link) messages across all channels, with the
protocol, direction (uplink from ATC, downlink from the aircraft), source and
recipient where known, and the concise message text (e.g. "WILCO")
* **Past Flights** - every flight the selected **aircraft** has operated. Shown only
while an aircraft is selected. Selecting one of its rows charts that flight's profile
and draws its track
* **Past Aircraft** - every airframe that has operated the selected **flight number**.
Shown only while a flight is selected
* **Flight Profile** - see below
Selecting an aircraft or a flight filters the Documents and ATC tables to it.
Route information comes from messages - flight plans, OOOI events, oceanic
clearances - or, where none has revealed it, from the callsign-to-route database.
<h2>Flight profile</h2>
The Flight Profile tab charts the selected flight's altitude (left axis) and speed
(right axis) against time, showing the flight profile - climb, cruise and descent - built
from all protocols and kept with the flight in the session database.
<h2>Photo</h2>
The first of the message tabs, titled Aircraft, shows a photograph of the selected
aircraft from [planespotters.net](https://www.planespotters.net/) headed by its
registration and the country flag, with the airline's logo beneath it and a table of what
the OpenSky database knows about the airframe beside it. Clicking the photograph opens it
on planespotters.net
<h2>Chart</h2>
The chart plots the message rate per protocol (and in total) over time. Click a legend
entry to show or hide a series. It is shown and hidden with the chart button, and
appears at the bottom of the splitter beneath the tables rather than in a tab, so the
rate can be watched at the same time as the traffic producing it. Right click the
button to clear the data.
<h2>Statistics</h2>
The statistics table can be shown and hidden with the statistic button.
Right click the button to reset the records.
Every figure is given twice, side by side: for this session and for all time, each with
who set it and when.
* **Maximum range**, one row per protocol - the furthest aircraft heard on ADS-B, ACARS,
VDL-2, HFDL and Aero. Per protocol rather than as one figure because the protocols are
not comparable: line of sight VHF, HF skywave and an L band satellite downlink have
nothing to do with one another, and a single "maximum range" would only ever show the
satellite
* **Fastest ground speed** and **Highest altitude**, with the aircraft that set each
* **Most aircraft at once** - the largest number heard within any 15 minute window
* **Aircraft heard** - how many different airframes
* **Total messages**, then one row per protocol giving that protocol's count and its
share of the total. The share is of that scope's own total, so a protocol that has been
quiet today shows its reduced share against its long run one rather than against nothing
* **Listening time** and **Messages per minute**
Ranges depend on the receiver position being right: see the Dist (km) column below for
where that comes from.
<h2>Settings</h2>
The gear button opens the settings dialog.
**Timeouts**
* Archive after (mins) - how long without a report before an aircraft moves to the Old
Aircraft table and comes off the Map.
* Keep for (days) - how long archived aircraft and their flights are kept in the session
database before being discarded. Zero keeps them forever, at the cost of a database
that grows without limit
* ADS-B position for (mins) - how long an aircraft stays on the Map after its last ADS-B
position
* ACARS position for (mins) - the same for a position from ACARS, VDL-2, HFDL or Aero.
Two figures rather than one because the protocols report at wildly different rates:
ADS-B about once a second, where an oceanic position report can be the only one for
many minutes.
**Session database** - the file the aircraft, flights and messages are saved in.
**Receive aircraft data from** - which demodulators this feature accepts reports from.
Unticked ones are ignored.
**Use airline callsigns in Map labels** - writes the flight on the Map the way it is
spoken on the radio rather than the way it is transmitted: SPEEDBIRD 123 instead of
BAW123, using the airline's radio callsign from the airline database.
**Show the maximum range record on the Map** - keeps the aircraft that set the all time
maximum range record permanently on the Map, drawn at the position it was in when it set
it rather than wherever it is now. The
bubble names the aircraft, the distance, the protocol it was heard on and when. It is the
best record across all protocols, and it stays until the record is beaten, the records are
reset, or this is turned off.
A record set before positions were kept alongside them has nowhere to be drawn, and in
that case nothing is drawn until the record is beaten. Not the furthest record that
*could* be placed: that would put a marker on the Map giving one distance while the
statistics table gave another. The log says so when it happens.
**Favour airline livery over aircraft type (3D map)** - when no 3D model exists of the
right type in the right livery, prefer a similar aircraft in the correct livery over an
exact type in the wrong one.
**Livery aircraft icons (2D map)** - display aircraft on the 2D map using icons showing
their airline's livery, instead of black icons. The icon follows the aircraft's matched
3D model, so this requires the 3D models to have been downloaded via the Map feature.
Aircraft without a matching model are displayed with a white version of the plain icon.
<h2>Notifications</h2>
The notifications dialog holds rules matched against each aircraft's ICAO address,
registration, flight or type with a regular expression. When an aircraft first matches
a rule, the rule's speech text is read aloud and/or its command is executed, with
${icao} ${reg} ${flight} ${type} ${protocol} substituted. Each rule fires at most once
per aircraft.
<h2>Session persistence</h2>
The collated aircraft, flights, documents and ATC log are saved to a SQLite database
(aircraft.db in the application data directory) every minute and on exit, and restored
when the feature is next opened. On restore, aircraft that have not been heard within
the removal timeout are pruned, while the document and ATC logs are restored in full;
restored aircraft with positions reappear on the Map with their full tracks.
The all time figures are kept in the preset rather than in that database, because they
are a property of the receiving setup rather than of the traffic.
The one exception is the all time aircraft count, which cannot be a running total: the
same airframe heard on two days has to count once, so it needs the set of which
airframes have been heard rather than a number. That set is a table in the database, and
it is the only thing there that is never pruned - so the count keeps growing after the
aircraft themselves have aged out.
Right clicking the statistics button offers to reset either half. Resetting the session
starts it again from that moment without touching the all time figures. Resetting all
time also clears the record of which airframes have been heard.
<h2>Finding things</h2>
The Find box highlights the next row matching what is typed, stepping through the matches
on each press of Enter. It searches the ICAO address, registration, type, flight number,
airline and departure and arrival airports at once, or a single one of them when the
column selector beside it is set to something other than All. The text turns red when
nothing matches.
<h2>Context menus</h2>
Right clicking a cell in any of the tables offers, as they apply to that cell:
* **Copy** the cell's contents to the clipboard
* **Find on map** - centre the Map on that aircraft
* **Display flight** - jump to that flight in the Flights table, from the aircraft flying it
* **Display aircraft** - jump the other way, to the airframe operating a flight
<h2>Map</h2>
Aircraft with a position are sent to the Map feature, named by registration when known.
When an Aircraft feature is present, the ADS-B and ACARS demodulators stop sending
aircraft to the Map themselves - this feature is the single source, so each aircraft
appears once, with data combined from every demodulator that hears it. ADS-B sightings
pass through the demodulator's fully-built map item, so the 3D model, animations and
the complete aircraft state driving the Map's PFD display are preserved, with the
combined track and route information added. Without an Aircraft feature, the
demodulators send to the Map directly, as before.
The map item carries:
* An icon matching the aircraft type, rotated to point along the track,
* The full track accumulated across all protocols - the whole history survives coverage
gaps, so a flight tracked on ADS-B and picked up again hours later on HFDL shows one
continuous track,
* A popup headed by a side view of the type in the operator's livery and the country
flag, followed by registration, flight, aircraft type,
departure/arrival airports and the route where messages have revealed them, and the
protocols and frequencies the **current flight** has been heard on.
The routes an aircraft has been given are drawn too - a filed flight plan and an oceanic
clearance alike - as a line through the waypoints with a marker at each one. A flight
plan comes from an FPN message or a position report's route insert; a clearance from an
oceanic clearance or its readback. Both are bookended with the departure and arrival
airports so the line starts and finishes somewhere recognisable, and the route's popup
carries the message that filed it, which is where the clearance number, entry time,
flight level and Mach are.
Each name is resolved against the airport, waypoint and navaid databases - four
characters is an airport, five a waypoint, three a VOR or NDB ident, and seven an oceanic
position such as 5530N - and any that cannot be resolved is dropped. A route is drawn
once, when it is filed, and is left on the Map after the flight is archived: it is a
record of where the aircraft was going.
Stale positions from stored performance log dumps (seen with HFDL) are ignored: a
position timestamped well before the newest known position for that aircraft does not
move it.
Aircraft are removed from the table and the Map after a configurable number of minutes
without a report.
<h2>Interface</h2>
![Aircraft feature plugin GUI](../../../doc/img/Aircraft_plugin.png)
<h3>1: Find column</h3>
Which field the Find box looks in - All, ICAO, Reg, Type or Flight.
<h3>2: Find</h3>
Highlights the next row matching the text. See Finding things above.
<h3>3: Delete aircraft</h3>
Deletes all aircraft from the tables and removes them from the Map.
<h3>4: Notifications</h3>
Opens the notifications dialog. See Notifications above.
<h3>5: ATC</h3>
When checked, aircraft labels on the Map show route, flight level, speed and type in
an ATC style, like the ADS-B demodulator's ATC button; when unchecked just the flight
number or registration is shown.
<h3>6: Statistics</h3>
Shows and hides the statistics table, which appears in the splitter beside the aircraft
and flight tables. Right click to reset the session figures or the all time ones.
<h3>7: Chart</h3>
Shows and hides the message rate chart, at the bottom of the splitter. Right click to
clear the data.
<h3>8: Settings</h3>
Opens the settings dialog - timeouts, the session database, which demodulators to accept
reports from, and the Map options. See Settings above.
<h3>Aircraft table</h3>
The table shows one row per aircraft:
* ICAO - 24-bit ICAO address, when known
* Reg - Aircraft registration
* Type - Aircraft type (ICAO type designator) from the OpenSky database
* Flight - Most recent flight number / callsign
* Airline - Airline logo, or operator name when no logo is available
* Sideview - Aircraft silhouette, coloured per airline where available
* Country - Flag of the country of registration
* Lat, Lon - Latest position in degrees
* Dist (km) - Great circle distance from the receiver to the aircraft. Measured from
the position of the **device the report arrived on** when that device knows where it
is - a remote SDR reports the position of the server, not of you - and from
Preferences > My Position otherwise. So the figure always means "from the antenna
that heard it", which matters when receiving from somewhere other than where you are
* Alt (ft) - Altitude in feet
* Hdg - Heading or track in degrees
* Spd (kn) - Speed in knots
* Protocols - Every protocol and frequency the **airframe** has been received on
(e.g. "ACARS 131.725; HFDL 5.720"), over every flight it has made and for as long as
it is kept. The Flights table has a column of the same name holding the same thing for
a single flight, and that is the one the Map shows - an airframe heard on HFDL over
the Atlantic last month is not being heard on HFDL now, so naming it beside the
aircraft on the Map would be wrong.
* Msgs - Number of messages received
* Last seen - Time of the last report
<h3>Flights table</h3>
The table shows one row per flight, and the Old Flights table the same columns for
flights that have finished:
* Flight - Flight number / callsign
* Reg - Registration of the airframe that flew it
* From, To - Departure and arrival airports
* Out, Off, On, In - The four OOOI times: off the gate, airborne, landed, on the gate
* First seen, Last seen - When the flight was first and last heard
* LS, OC, FP - A tick where the flight has produced a loadsheet, an oceanic clearance or
a flight plan. Blank where it has not, rather than a cross: a column of crosses is as
loud as a column of ticks, which makes the ticks harder to pick out
* Docs - Number of documents collected
* Protocols - Protocols and frequencies **this flight** has been heard on. The Aircraft
table's column of the same name is the airframe's, over every flight it has made
Columns in either table can be reordered by dragging, hidden via the right-click header
menu, and either table sorted by clicking a header. Widths and order are saved with the
preset.
<h2>Attribution</h2>
Aircraft and route data from the [OpenSky Network](https://opensky-network.org/).
Aircraft photographs from [PlaneSpotters](https://www.planespotters.net/).
Airline logos, sideviews and flags are by Steve Hibberd from
[RadarSpotting](https://radarspotting.com).
Airports from [OurAirports](https://ourairports.com/), and navaids and waypoints from
[OpenAIP](https://www.openaip.net/) - used to place the waypoints of a filed route.
Some code written by AI.

230517
plugins/feature/aircraft/sqlite/sqlite3.c

File diff suppressed because it is too large Load Diff

12174
plugins/feature/aircraft/sqlite/sqlite3.h

File diff suppressed because it is too large Load Diff

126
swagger/sdrangel/api/swagger/include/Aircraft.yaml

@ -0,0 +1,126 @@ @@ -0,0 +1,126 @@
AircraftSettings:
description: Aircraft
properties:
removalMins:
description: "Archive an aircraft after this many minutes without a report"
type: integer
adsbPositionMins:
description: "How long an ADS-B position stays believable, and so how long the aircraft stays on the map, in minutes"
type: integer
acarsPositionMins:
description: "How long an ACARS, VDL-2, HFDL or Aero position stays believable, in minutes. Longer than the ADS-B figure because those protocols report far less often"
type: integer
retentionDays:
description: "Discard archived aircraft after this many days. 0 keeps them for ever"
type: integer
atcLabels:
description: "Display route, altitude and speed in map labels (1 for yes, 0 for no)"
type: integer
atcCallsigns:
description: "Map labels use the airline's radio callsign (SPEEDBIRD 123) rather than its code (BAW123) (1 for yes, 0 for no). Only has an effect when atcLabels is set"
type: integer
displayMaxRangeOnMap:
description: "Keep the aircraft that set the all time maximum range record on the map, at the position it was in when it set it (1 for yes, 0 for no)"
type: integer
favourLivery:
description: "On the 3D map, prefer a similar aircraft in the correct airline livery over an exact aircraft type in the wrong one (1 for yes, 0 for no)"
type: integer
displayStatistics:
description: "Show the statistics table (1 for yes, 0 for no)"
type: integer
displayChart:
description: "Show the message rate chart (1 for yes, 0 for no)"
type: integer
databaseFilename:
description: "Where the session database is kept. Empty for the default location"
type: string
disabledSources:
description: "Channel URIs not to accept reports from. Empty accepts all"
type: array
items:
type: string
notificationSettings:
type: array
items:
$ref: "http://swgserver:8081/api/swagger/include/Aircraft.yaml#/AircraftNotificationSettings"
title:
type: string
rgbColor:
type: integer
useReverseAPI:
description: Synchronize with reverse API (1 for yes, 0 for no)
type: integer
reverseAPIAddress:
type: string
reverseAPIPort:
type: integer
reverseAPIFeatureSetIndex:
type: integer
reverseAPIFeatureIndex:
type: integer
workspaceIndex:
type: integer
rollupState:
$ref: "http://swgserver:8081/api/swagger/include/RollupState.yaml#/RollupState"
AircraftNotificationSettings:
description: "A rule matched against each aircraft, which speaks a phrase or runs a command when it matches"
properties:
matchColumn:
description: "What the regular expression is matched against. 0 ICAO address, 1 registration, 2 flight, 3 aircraft type"
type: integer
regExp:
description: "Regular expression to match"
type: string
speech:
description: "Text to speak when the rule matches. May contain ${icao}, ${reg}, ${flight}, ${type} and ${protocol}"
type: string
command:
description: "Command to run when the rule matches"
type: string
AircraftReport:
description: Aircraft
properties:
aircraftCount:
description: "Aircraft currently held, active and archived"
type: integer
activeAircraftCount:
description: "Aircraft currently being heard from"
type: integer
flightCount:
description: "Flights currently held"
type: integer
messageCount:
description: "Reports received this session, over every protocol"
type: integer
format: int64
protocols:
description: "Reports received this session, per protocol"
type: array
items:
$ref: "http://swgserver:8081/api/swagger/include/Aircraft.yaml#/AircraftProtocolReport"
AircraftProtocolReport:
description: "What one protocol has contributed this session"
properties:
protocol:
description: "Protocol name: ADS-B, ACARS, VDL-2, HFDL or Aero"
type: string
messageCount:
description: "Reports received on this protocol this session"
type: integer
format: int64
AircraftActions:
description: Aircraft
properties:
selectIcao:
description: "Select the aircraft with this 24 bit ICAO address, written in hexadecimal (e.g. 4CA1FA)"
type: string
selectRegistration:
description: "Select the aircraft with this registration (e.g. G-ABCD)"
type: string
selectFlight:
description: "Select this flight number (e.g. BAW123). The most recently heard flight with that number is chosen"
type: string

2
swagger/sdrangel/api/swagger/include/FeatureActions.yaml

@ -15,6 +15,8 @@ FeatureActions: @@ -15,6 +15,8 @@ FeatureActions:
type: integer
AFCActions:
$ref: "http://swgserver:8081/api/swagger/include/AFC.yaml#/AFCActions"
AircraftActions:
$ref: "http://swgserver:8081/api/swagger/include/Aircraft.yaml#/AircraftActions"
AMBEActions:
$ref: "http://swgserver:8081/api/swagger/include/AMBE.yaml#/AMBEActions"
GS232ControllerActions:

2
swagger/sdrangel/api/swagger/include/FeatureReport.yaml

@ -9,6 +9,8 @@ FeatureReport: @@ -9,6 +9,8 @@ FeatureReport:
type: string
AFCReport:
$ref: "http://swgserver:8081/api/swagger/include/AFC.yaml#/AFCReport"
AircraftReport:
$ref: "http://swgserver:8081/api/swagger/include/Aircraft.yaml#/AircraftReport"
AMBEReport:
$ref: "http://swgserver:8081/api/swagger/include/AMBE.yaml#/AMBEReport"
FreqDisplayReport:

2
swagger/sdrangel/api/swagger/include/FeatureSettings.yaml

@ -15,6 +15,8 @@ FeatureSettings: @@ -15,6 +15,8 @@ FeatureSettings:
type: integer
AFCSettings:
$ref: "http://swgserver:8081/api/swagger/include/AFC.yaml#/AFCSettings"
AircraftSettings:
$ref: "http://swgserver:8081/api/swagger/include/Aircraft.yaml#/AircraftSettings"
AISSettings:
$ref: "http://swgserver:8081/api/swagger/include/AIS.yaml#/AISSettings"
AMBESettings:

Loading…
Cancel
Save