Ref T698, display network statistics in UI (internals)

This commit is contained in:
Klaus Basan
2019-07-04 00:15:37 +02:00
committed by Mat Sutcliffe
parent f754154455
commit ab83d55d7c
3 changed files with 76 additions and 23 deletions

View File

@@ -72,11 +72,11 @@ namespace BlackGui
connect(ui->pb_SendAircraftPartsJson, &QPushButton::released, this, &CInternalsComponent::sendAircraftParts);
connect(ui->pb_CurrentParts, &QPushButton::released, this, &CInternalsComponent::setCurrentParts);
connect(ui->cb_DebugContextAudio, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextAudio, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextApplication, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextNetwork, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextNetwork, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextOwnAircraft, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextSimulator, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextSimulator, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->pb_SendTextMessageDirectly, &QPushButton::released, this, &CInternalsComponent::sendTextMessage, Qt::QueuedConnection);
connect(ui->pb_SendTextMessageDeferred, &QPushButton::released, this, &CInternalsComponent::sendTextMessage, Qt::QueuedConnection);
@@ -85,10 +85,14 @@ namespace BlackGui
connect(ui->le_StatusMessage, &QLineEdit::returnPressed, this, &CInternalsComponent::logStatusMessage);
connect(ui->pb_LatestInterpolationLog, &QPushButton::released, this, &CInternalsComponent::showLogFiles);
connect(ui->pb_LatestPartsLog, &QPushButton::released, this, &CInternalsComponent::showLogFiles);
connect(ui->pb_RequestFromNetwork, &QPushButton::released, this, &CInternalsComponent::requestPartsFromNetwork);
connect(ui->pb_DisplayLog, &QPushButton::released, this, &CInternalsComponent::displayLogInSimulator);
connect(ui->pb_SendAtis, &QPushButton::released, this, &CInternalsComponent::sendAtis);
connect(ui->pb_LatestPartsLog, &QPushButton::released, this, &CInternalsComponent::showLogFiles);
connect(ui->pb_RequestFromNetwork, &QPushButton::released, this, &CInternalsComponent::requestPartsFromNetwork);
connect(ui->pb_DisplayLog, &QPushButton::released, this, &CInternalsComponent::displayLogInSimulator);
connect(ui->pb_SendAtis, &QPushButton::released, this, &CInternalsComponent::sendAtis);
connect(ui->pb_NetworkUpdateAndReset, &QPushButton::released, this, &CInternalsComponent::networkStatistics);
connect(ui->pb_NetworkUpdate, &QPushButton::released, this, &CInternalsComponent::networkStatistics);
connect(ui->cb_NetworkStatistics, &QCheckBox::stateChanged, this, &CInternalsComponent::onNetworkStatisticsToggled);
connect(ui->comp_RemoteAircraftSelector, &CRemoteAircraftSelector::changedCallsign, this, &CInternalsComponent::selectorChanged);
@@ -354,5 +358,20 @@ namespace BlackGui
sGui->enableCrashDumpUpload(checked);
}
}
void CInternalsComponent::networkStatistics()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return; }
const bool reset = (QObject::sender() == ui->pb_NetworkUpdateAndReset);
const QString statistics = sGui->getIContextNetwork()->getNetworkStatistics(reset, "\n");
ui->pte_NetworkCalls->setPlainText(statistics);
}
void CInternalsComponent::onNetworkStatisticsToggled(bool checked)
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return; }
const bool on = sGui->getIContextNetwork()->setNetworkStatisticsEnable(checked);
CLogMessage(this).info(u"Network statistics is %1") << boolToOnOff(on);
}
} // namespace
} // namespace

View File

@@ -81,6 +81,12 @@ namespace BlackGui
//! Checkbox toggled
void onCrashDumpUploadToggled(bool checked);
//! Show network statistics
void networkStatistics();
//! Enable/disable statistics
void onNetworkStatisticsToggled(bool checked);
QScopedPointer<Ui::CInternalsComponent> ui;
};
} // namespace

View File

@@ -324,7 +324,7 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<spacer name="vs_Debug">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@@ -343,13 +343,6 @@
<string>Statistics / Logs</string>
</attribute>
<layout class="QGridLayout" name="gl_Statistics" columnstretch="0,0,0">
<item row="0" column="1">
<widget class="QPushButton" name="pb_LatestInterpolationLog">
<property name="text">
<string>show</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pb_LatestPartsLog">
<property name="text">
@@ -364,10 +357,10 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_LatestInterpolationLog">
<item row="0" column="1">
<widget class="QPushButton" name="pb_LatestInterpolationLog">
<property name="text">
<string>Latest interpolation log</string>
<string>show</string>
</property>
</widget>
</item>
@@ -384,7 +377,14 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<item row="0" column="0">
<widget class="QLabel" name="lbl_LatestInterpolationLog">
<property name="text">
<string>Latest interpolation log</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="vs_Statistics">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -397,6 +397,30 @@
</property>
</spacer>
</item>
<item row="2" column="0" colspan="3">
<widget class="QPlainTextEdit" name="pte_NetworkCalls"/>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pb_NetworkUpdateAndReset">
<property name="text">
<string>update and reset</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pb_NetworkUpdate">
<property name="text">
<string>update</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cb_NetworkStatistics">
<property name="text">
<string>network statistics</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_AircraftParts">
@@ -705,6 +729,7 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tw_Internals</tabstop>
<tabstop>le_StatusMessage</tabstop>
<tabstop>tb_LogStatusMessage</tabstop>
<tabstop>rb_StatusMessageInfo</tabstop>
@@ -728,14 +753,17 @@
<tabstop>pb_SimulateCrash</tabstop>
<tabstop>pb_LatestInterpolationLog</tabstop>
<tabstop>pb_LatestPartsLog</tabstop>
<tabstop>pte_NetworkCalls</tabstop>
<tabstop>cb_NetworkStatistics</tabstop>
<tabstop>pb_NetworkUpdate</tabstop>
<tabstop>pb_NetworkUpdateAndReset</tabstop>
<tabstop>pb_DisplayLog</tabstop>
<tabstop>pb_RequestFromNetwork</tabstop>
<tabstop>tb_History</tabstop>
<tabstop>cb_AircraftPartsIncremental</tabstop>
<tabstop>pb_CurrentParts</tabstop>
<tabstop>pb_SendAircraftPartsJson</tabstop>
<tabstop>pb_SendAircraftPartsGui</tabstop>
<tabstop>tw_Internals</tabstop>
<tabstop>pb_CurrentParts</tabstop>
<tabstop>cb_AircraftPartsIncremental</tabstop>
<tabstop>pb_SendAircraftPartsJson</tabstop>
</tabstops>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>