Trigger Squelch and Mic test from GUI, refs #123

This commit is contained in:
Klaus Basan
2014-02-05 21:01:52 +01:00
committed by Mathew Sutcliffe
parent 2feab9f5e7
commit ce22fc9552
5 changed files with 149 additions and 43 deletions

View File

@@ -35,7 +35,8 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
m_contextApplication(nullptr), m_contextNetwork(nullptr), m_contextVoice(nullptr), m_contextSettings(nullptr),
// timers
m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerUpdateUsers(nullptr),
m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), m_timerStatusBar(nullptr),
m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr),
m_timerStatusBar(nullptr), m_timerAudioTests(nullptr),
// context menus
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr),
// status bar
@@ -190,13 +191,16 @@ void MainWindow::toggleNetworkConnection()
this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnecting);
if (!this->m_contextNetwork->isConnected())
{
QString cs = this->ui->le_SettingsAircraftCallsign->text();
if (cs.isEmpty())
if (this->m_ownAircraft.getCallsign().isEmpty())
{
this->displayStatusMessage(CStatusMessage::getValidationError("missing callsign"));
return;
}
// send latest aircraft to network/voice
this->m_contextNetwork->setOwnAircraft(this->m_ownAircraft);
if (this->m_contextVoiceAvailable) this->m_contextVoice->setOwnAircraft(this->m_ownAircraft);
// Login is based on setting current server
INetwork::LoginMode mode = INetwork::LoginNormal;
if (this->ui->rb_SettingsLoginStealthMode->isChecked())
@@ -209,6 +213,7 @@ void MainWindow::toggleNetworkConnection()
mode = INetwork::LoginAsObserver;
this->displayStatusMessage(CStatusMessage::getInfoMessage("login in observer mode"));
}
msgs = this->m_contextNetwork->connectToNetwork(static_cast<uint>(mode));
}
else

View File

@@ -129,7 +129,8 @@ private:
QTimer *m_timerUpdateUsers; /*!< timer for update of users */
QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */
QTimer *m_timerContextWatchdog; /*!< core available? */
QTimer *m_timerStatusBar;
QTimer *m_timerStatusBar; /*!< cleaning up status bar */
QTimer *m_timerAudioTests; /*!< cleaning up status bar */
// pixmaps
QPixmap m_resPixmapConnectionConnected;
@@ -300,6 +301,11 @@ private:
*/
QString getSelcalCode() const;
/*!
* \brief Audio test updates (timer) for progressbar and fetching results
*/
void audioTestUpdate();
private slots:
//
@@ -501,6 +507,9 @@ private slots:
* \brief Test SELCAL (code valid? play tone)
*/
void testSelcal();
//! \brief start the MIC tests (Squelch)
void startAudioTest();
};
#pragma pop_macro("interface")

View File

@@ -38,9 +38,19 @@ QWidget {
color: white; /** font **/
}
QStatusBar {
background-color: darkslategray;
}
QProgressBar {
border: 1px solid green;
border-radius: 5px;
text-align: center;
padding: 0px;
height: 16px;
}
QProgressBar::chunk {
background-color: darkblue;
width: 10px;
margin: 0.5px;
}
#wi_CentralWidgetOutside {
/** there is no opacity with background image, so we need semitransparent images **/
@@ -443,7 +453,7 @@ QStatusBar QLabel {
<enum>QFrame::NoFrame</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>7</number>
</property>
<widget class="QWidget" name="pg_StatusPage">
<property name="sizePolicy">
@@ -553,8 +563,8 @@ QStatusBar QLabel {
<rect>
<x>0</x>
<y>0</y>
<width>326</width>
<height>267</height>
<width>86</width>
<height>59</height>
</rect>
</property>
<attribute name="label">
@@ -1789,7 +1799,7 @@ QStatusBar QLabel {
<item>
<widget class="QTabWidget" name="tb_Settings">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tb_SettingsTrafficNetwork">
<attribute name="title">
@@ -2160,7 +2170,7 @@ QStatusBar QLabel {
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="wi_VoiceTests" native="true">
<widget class="QWidget" name="wi_SettingsAudioTests" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
@@ -2178,37 +2188,62 @@ QStatusBar QLabel {
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pb_VoiceStartMicTest">
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Start MIC test</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_VoiceStartSquelchTest">
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Start Squelch test</string>
</property>
</widget>
<layout class="QHBoxLayout" name="hl_SettingsAudioTests">
<item>
<widget class="QPushButton" name="pb_SettingsAudioSquelchTest">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Start squelch test</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SettingsAudioMicrophoneTest">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Start microphone test</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lbl_SettingsAudioTestActionAndResult">
<property name="text">
<string>Result</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="le_SettingsAudioTestActionAndResult">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QProgressBar" name="prb_SettingsAudioTestProgress">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@@ -2852,8 +2887,6 @@ QStatusBar QLabel {
<tabstop>le_SettingsIcaoType</tabstop>
<tabstop>cb_SettingsAudioInputDevice</tabstop>
<tabstop>cb_SettingsAudioOutputDevice</tabstop>
<tabstop>pb_VoiceStartMicTest</tabstop>
<tabstop>pb_VoiceStartSquelchTest</tabstop>
<tabstop>hs_SettingsGuiOpacity</tabstop>
<tabstop>hs_SettingsGuiAircraftRefreshTime</tabstop>
<tabstop>hs_SettingsGuiAtcRefreshTime</tabstop>

View File

@@ -134,12 +134,13 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
this->ui->cb_CockpitSelcal1->addItems(BlackMisc::Aviation::CSelcal::codePairs());
this->ui->cb_CockpitSelcal2->addItems(BlackMisc::Aviation::CSelcal::codePairs());
// timer
// timers
if (this->m_timerUpdateAircraftsInRange == nullptr) this->m_timerUpdateAircraftsInRange = new QTimer(this);
if (this->m_timerUpdateAtcStationsOnline == nullptr) this->m_timerUpdateAtcStationsOnline = new QTimer(this);
if (this->m_timerUpdateUsers == nullptr) this->m_timerUpdateUsers = new QTimer(this);
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);
// context
if (this->m_coreMode != GuiModes::CoreInGuiProcess)
@@ -184,7 +185,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
this->ui->sb_MainStatusBar->addWidget(this->m_statusBarLabel, 1);
}
// signal / slots
// signal / slots contexts / timers
bool connect;
this->connect(this->m_contextNetwork, &IContextNetwork::statusMessage, this, &MainWindow::displayStatusMessage);
this->connect(this->m_contextNetwork, &IContextNetwork::statusMessages, this, &MainWindow::displayStatusMessages);
@@ -198,6 +199,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
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);
// start timers, update timers will be started when network is connected
this->m_timerContextWatchdog->start(2 * 1000);
@@ -207,6 +209,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
// voice panel
this->setAudioDeviceLists();
this->ui->prb_SettingsAudioTestProgress->setVisible(false);
// data
this->initialDataReads();
@@ -301,6 +304,8 @@ void MainWindow::initGuiSignals()
Q_ASSERT(connected);
connected = this->connect(this->ui->cb_SettingsAudioOutputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int)));
Q_ASSERT(connected);
this->connect(this->ui->pb_SettingsAudioMicrophoneTest, &QPushButton::clicked, this, &MainWindow::startAudioTest);
this->connect(this->ui->pb_SettingsAudioSquelchTest, &QPushButton::clicked, this, &MainWindow::startAudioTest);
// ATC
connected = this->connect(this->ui->le_AtcStationsOnlineMetar, SIGNAL(returnPressed()), this, SLOT(getMetar()));
@@ -370,6 +375,7 @@ void MainWindow::stopUpdateTimers(bool disconnect)
this->m_timerUpdateAircraftsInRange->stop();
this->m_timerUpdateAtcStationsOnline->stop();
this->m_timerUpdateUsers->stop();
this->m_timerAudioTests->stop();
if (!disconnect) return;
this->disconnect(this->m_timerUpdateAircraftsInRange);
this->disconnect(this->m_timerUpdateAtcStationsOnline);

View File

@@ -145,3 +145,56 @@ void MainWindow::audioVolumes()
this->m_ownAircraft.setCom2System(com2);
this->m_contextVoice->setVolumes(this->m_ownAircraft.getCom1System(), this->m_ownAircraft.getCom2System());
}
/*
* Start the voice tests
*/
void MainWindow::startAudioTest()
{
if (!this->m_contextVoiceAvailable)
{
CStatusMessage m(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "voice context not available");
this->displayStatusMessage(m);
return;
}
if (this->m_timerAudioTests->isActive())
{
CStatusMessage m(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "test running, wait until completed");
this->displayStatusMessage(m);
return;
}
QObject *sender = QObject::sender();
this->m_timerAudioTests->start(625); // I let this run for 10*625ms, so there is enough overhead to really complete it
this->ui->prb_SettingsAudioTestProgress->setValue(0);
if (sender == this->ui->pb_SettingsAudioMicrophoneTest)
{
this->m_contextVoice->runMicrophoneTest();
this->ui->le_SettingsAudioTestActionAndResult->setText("Speak normally for 5 seconds");
}
else if (sender == this->ui->pb_SettingsAudioSquelchTest)
{
this->m_contextVoice->runSquelchTest();
this->ui->le_SettingsAudioTestActionAndResult->setText("Silence for 5 seconds");
}
this->ui->prb_SettingsAudioTestProgress->setVisible(true);
}
/*
* Start the voice tests
*/
void MainWindow::audioTestUpdate()
{
int v = this->ui->prb_SettingsAudioTestProgress->value();
if (v < 100)
{
this->ui->prb_SettingsAudioTestProgress->setValue(v + 10);
}
else
{
// fetch results
// TODO
this->m_timerAudioTests->stop();
this->ui->prb_SettingsAudioTestProgress->setVisible(false);
}
}