mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Add new page in sample_blackgui to display user aircraft data
refs #143
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "blackgui/atcstationlistmodel.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
using namespace BlackCore;
|
||||
@@ -33,10 +34,11 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
|
||||
m_coreMode(GuiModes::CoreExternal),
|
||||
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextVoiceAvailable(false),
|
||||
m_contextApplication(nullptr), m_contextNetwork(nullptr), m_contextVoice(nullptr), m_contextSettings(nullptr),
|
||||
m_contextSimulator(nullptr),
|
||||
// timers
|
||||
m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerUpdateUsers(nullptr),
|
||||
m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr),
|
||||
m_timerStatusBar(nullptr), m_timerAudioTests(nullptr),
|
||||
m_timerStatusBar(nullptr), m_timerAudioTests(nullptr), m_timerSimulator(nullptr),
|
||||
// context menus
|
||||
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr),
|
||||
// cockpit
|
||||
@@ -165,6 +167,8 @@ void MainWindow::setMainPage(bool start)
|
||||
this->ui->sw_MainMiddle->setCurrentIndex(MainPageFlightplan);
|
||||
else if (sender == this->ui->pb_MainSettings)
|
||||
this->ui->sw_MainMiddle->setCurrentIndex(MainPageSettings);
|
||||
else if (sender == this->ui->pb_MainSimulator)
|
||||
this->ui->sw_MainMiddle->setCurrentIndex(MainPageSimulator);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -314,6 +318,11 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::simulatorAvailable()
|
||||
{
|
||||
m_timerSimulator->start(500);
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer event
|
||||
*/
|
||||
@@ -343,6 +352,10 @@ void MainWindow::timerBasedUpdates()
|
||||
this->setContextAvailability();
|
||||
this->updateGuiStatusInformation();
|
||||
}
|
||||
else if (sender == this->m_timerSimulator)
|
||||
{
|
||||
updateSimulatorData();
|
||||
}
|
||||
|
||||
// own aircraft
|
||||
if (sender == this->m_timerUpdateAircraftsInRange || sender == this->m_timerUpdateAtcStationsOnline)
|
||||
@@ -489,3 +502,27 @@ void MainWindow::reloadAllUsers()
|
||||
this->ui->tv_AllUsers->resizeRowsToContents();
|
||||
this->ui->tv_AllUsers->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
|
||||
void MainWindow::updateSimulatorData()
|
||||
{
|
||||
if (m_contextSimulator->isConnected())
|
||||
ui->le_SimulatorStatus->setText("Connected");
|
||||
else
|
||||
ui->le_SimulatorStatus->setText("Not connected");
|
||||
|
||||
CAircraft ownAircraft = m_contextSimulator->ownAircraft();
|
||||
ui->le_SimulatorLatitude->setText(ownAircraft.getSituation().latitude().toFormattedQString());
|
||||
ui->le_SimulatorLongitude->setText(ownAircraft.getSituation().longitude().toFormattedQString());
|
||||
ui->le_SimulatorAltitude->setText(ownAircraft.getSituation().getAltitude().toFormattedQString());
|
||||
ui->le_SimulatorPitch->setText(ownAircraft.getSituation().getPitch().toFormattedQString());
|
||||
ui->le_SimulatorBank->setText(ownAircraft.getSituation().getBank().toFormattedQString());
|
||||
ui->le_SimulatorHeading->setText(ownAircraft.getSituation().getHeading().toFormattedQString());
|
||||
ui->le_SimulatorGroundSpeed->setText(ownAircraft.getSituation().getGroundSpeed().toFormattedQString());
|
||||
|
||||
|
||||
ui->le_SimulatorCom1Active->setText(ownAircraft.getCom1System().getFrequencyActive().toFormattedQString());
|
||||
ui->le_SimulatorCom1Standby->setText(ownAircraft.getCom1System().getFrequencyStandby().toFormattedQString());
|
||||
ui->le_SimulatorCom2Active->setText(ownAircraft.getCom2System().getFrequencyActive().toFormattedQString());
|
||||
ui->le_SimulatorCom2Standby->setText(ownAircraft.getCom2System().getFrequencyStandby().toFormattedQString());
|
||||
ui->le_SimulatorTransponder->setText(ownAircraft.getTransponderCodeFormatted());
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "blackcore/context_network_interface.h"
|
||||
#include "blackcore/context_settings_interface.h"
|
||||
#include "blackcore/context_application_interface.h"
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include "blackgui/atcstationlistmodel.h"
|
||||
#include "blackgui/serverlistmodel.h"
|
||||
@@ -93,7 +94,8 @@ protected:
|
||||
MainPageCockpit = 4,
|
||||
MainPageTextMessages = 5,
|
||||
MainPageFlightplan = 6,
|
||||
MainPageSettings = 7
|
||||
MainPageSettings = 7,
|
||||
MainPageSimulator = 8
|
||||
};
|
||||
|
||||
enum AudioTest
|
||||
@@ -133,6 +135,7 @@ private:
|
||||
BlackCore::IContextNetwork *m_contextNetwork;
|
||||
BlackCore::IContextVoice *m_contextVoice;
|
||||
BlackCore::IContextSettings *m_contextSettings;
|
||||
BlackCore::IContextSimulator *m_contextSimulator;
|
||||
BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */
|
||||
QTimer *m_timerUpdateAtcStationsOnline; /*!< timer for update of stations */
|
||||
QTimer *m_timerUpdateAircraftsInRange; /*!< timer for update of aircrafts */
|
||||
@@ -141,6 +144,7 @@ private:
|
||||
QTimer *m_timerContextWatchdog; /*!< core available? */
|
||||
QTimer *m_timerStatusBar; /*!< cleaning up status bar */
|
||||
QTimer *m_timerAudioTests; /*!< cleaning up status bar */
|
||||
QTimer *m_timerSimulator; /*!< update simulator data */
|
||||
|
||||
// pixmaps
|
||||
QPixmap m_resPixmapConnectionConnected;
|
||||
@@ -313,6 +317,9 @@ private:
|
||||
* \brief Play notifcation sound
|
||||
*/
|
||||
void playNotifcationSound(BlackSound::CSoundGenerator::Notification notification) const;
|
||||
|
||||
//! \brief Update simulator page with latest user aircraft data
|
||||
void updateSimulatorData();
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -372,6 +379,8 @@ private slots:
|
||||
//! \brief Send cockpit updates
|
||||
void sendCockpitUpdates();
|
||||
|
||||
void simulatorAvailable();
|
||||
|
||||
//
|
||||
// GUI related slots
|
||||
//
|
||||
|
||||
@@ -554,7 +554,7 @@ QStatusBar QLabel {
|
||||
<item>
|
||||
<widget class="QToolBox" name="tb_StatusPage">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="tabSpacing">
|
||||
<number>3</number>
|
||||
@@ -2485,6 +2485,190 @@ QStatusBar QLabel {
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pg_Simulator">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_OwnAircraftSituationLongitude">
|
||||
<property name="text">
|
||||
<string>Longitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorStatus">
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbl_OwnAircraftSituationBank">
|
||||
<property name="text">
|
||||
<string>Bank</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_OwnAircraftSituationLatitude">
|
||||
<property name="text">
|
||||
<string>Latitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorGroundSpeed">
|
||||
<property name="text">
|
||||
<string>Ground Speed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorHeading">
|
||||
<property name="text">
|
||||
<string>Heading</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorOnGround">
|
||||
<property name="text">
|
||||
<string>On ground</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_OwnAircraftSituationAltitude">
|
||||
<property name="text">
|
||||
<string>Altitude</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_OwnAircraftSituationPitch">
|
||||
<property name="text">
|
||||
<string>Pitch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorStatus">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorLatitude">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorLongitude">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorAltitude">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorPitch">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorCom1Active">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorCom1Standby">
|
||||
<property name="text">
|
||||
<string>COM1 Standby</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorCom1Active">
|
||||
<property name="text">
|
||||
<string>COM1 Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorCom2Active">
|
||||
<property name="text">
|
||||
<string>COM2 Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorCom2Standby">
|
||||
<property name="text">
|
||||
<string>COM2 Standby</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorCom1Standby"/>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorCom2Active"/>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorCom2Standby"/>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorBank">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorHeading">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorGroundSpeed">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorOnGround">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<widget class="QLineEdit" name="le_SimulatorTransponder"/>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="lbl_SimulatorTransponder">
|
||||
<property name="text">
|
||||
<string>Transponder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -2813,6 +2997,13 @@ QStatusBar QLabel {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="pb_MainSimulator">
|
||||
<property name="text">
|
||||
<string>Simulator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "ui_mainwindow.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_simulator_impl.h"
|
||||
#include "blackcore/context_simulator_proxy.h"
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include "blackgui/atcstationlistmodel.h"
|
||||
#include "blackgui/keyboardkeylistmodel.h"
|
||||
@@ -156,6 +158,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
||||
if (this->m_timerContextWatchdog == nullptr) this->m_timerContextWatchdog = new QTimer(this);
|
||||
if (this->m_timerCollectedCockpitUpdates == nullptr) this->m_timerCollectedCockpitUpdates = new QTimer(this);
|
||||
if (this->m_timerAudioTests == nullptr) this->m_timerAudioTests = new QTimer(this);
|
||||
if (this->m_timerSimulator == nullptr) this->m_timerSimulator = new QTimer(this);
|
||||
|
||||
// context
|
||||
if (this->m_coreMode != GuiModes::CoreInGuiProcess)
|
||||
@@ -165,6 +168,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
||||
this->m_contextVoice = new BlackCore::IContextVoice(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||
this->m_contextSettings = new BlackCore::IContextSettings(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||
this->m_contextApplication = new BlackCore::IContextApplication(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||
this->m_contextSimulator = new BlackCore::CContextSimulatorProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -173,6 +177,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
||||
this->m_contextVoice = this->m_coreRuntime->getIContextVoice();
|
||||
this->m_contextSettings = this->m_coreRuntime->getIContextSettings();
|
||||
this->m_contextApplication = this->m_coreRuntime->getIContextApplication();
|
||||
this->m_contextSimulator = this->m_coreRuntime->getIContextSimulator();
|
||||
}
|
||||
|
||||
// wire GUI signals
|
||||
@@ -209,12 +214,14 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
||||
this->connect(this->m_contextSettings, &IContextSettings::changedSettings, this, &MainWindow::changedSettings);
|
||||
connect = this->connect(this->m_contextNetwork, SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList)));
|
||||
Q_ASSERT(connect);
|
||||
this->connect(this->m_contextSimulator, &IContextSimulator::connectionChanged, this, &MainWindow::simulatorAvailable);
|
||||
this->connect(this->m_timerUpdateAircraftsInRange, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
|
||||
this->connect(this->m_timerUpdateAtcStationsOnline, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
|
||||
this->connect(this->m_timerUpdateUsers, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
|
||||
this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
|
||||
this->connect(this->m_timerCollectedCockpitUpdates, &QTimer::timeout, this, &MainWindow::sendCockpitUpdates);
|
||||
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &MainWindow::audioTestUpdate);
|
||||
this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
|
||||
connect = this->connect(this->m_contextVoice, &IContextVoice::audioTestCompleted, this, &MainWindow::audioTestUpdate);
|
||||
|
||||
// start timers, update timers will be started when network is connected
|
||||
@@ -239,6 +246,9 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
||||
// do this as last statement, so it can be used as flag
|
||||
// whether init has been completed
|
||||
this->m_init = true;
|
||||
|
||||
// TODO remove later
|
||||
simulatorAvailable();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -267,6 +277,8 @@ void MainWindow::initGuiSignals()
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->pb_MainSettings, SIGNAL(released()), this, SLOT(setMainPage()));
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->pb_MainSimulator, SIGNAL(released()), this, SLOT(setMainPage()));
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->pb_MainStatus, SIGNAL(released()), this, SLOT(setMainPage()));
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->pb_MainUsers, SIGNAL(released()), this, SLOT(setMainPage()));
|
||||
|
||||
Reference in New Issue
Block a user