mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
Ref T270, also display update aircraft (interpolation) request time
* made some ISimulator functions public, so they can be used in UI * added members for request times * better "shutdown" / "disconnect" detection
This commit is contained in:
@@ -173,6 +173,15 @@ namespace BlackCore
|
||||
//! Driver will be unloaded
|
||||
virtual void unload() = 0;
|
||||
|
||||
//! Are we connected to the simulator?
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
//! Simulator paused?
|
||||
virtual bool isPaused() const = 0;
|
||||
|
||||
//! Simulator running?
|
||||
virtual bool isSimulating() const = 0;
|
||||
|
||||
//! Clear all aircraft related data
|
||||
virtual void clearAllRemoteAircraftData() = 0;
|
||||
|
||||
@@ -252,15 +261,6 @@ namespace BlackCore
|
||||
BlackMisc::Network::IClientProvider *clientProvider,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
//! Are we connected to the simulator?
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
//! Simulator paused?
|
||||
virtual bool isPaused() const = 0;
|
||||
|
||||
//! Simulator running?
|
||||
virtual bool isSimulating() const = 0;
|
||||
|
||||
//! Add new remote aircraft physically to the simulator
|
||||
//! \sa changeRemoteAircraftEnabled to hide a remote aircraft
|
||||
virtual bool physicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) = 0;
|
||||
|
||||
@@ -587,6 +587,8 @@ namespace BlackCore
|
||||
m_statsUpdateAircraftTimeTotalMs = 0;
|
||||
m_statsPhysicallyAddedAircraft = 0;
|
||||
m_statsPhysicallyRemovedAircraft = 0;
|
||||
m_statsLastUpdateAircraftRequested = 0;
|
||||
m_statsUpdateAircraftRequestedDeltaMs = 0;
|
||||
}
|
||||
|
||||
CStatusMessageList CSimulatorCommon::debugVerifyStateAfterAllAircraftRemoved() const
|
||||
@@ -638,11 +640,14 @@ namespace BlackCore
|
||||
|
||||
void CSimulatorCommon::setStatsRemoteAircraftUpdate(qint64 startTime)
|
||||
{
|
||||
const qint64 dt = QDateTime::currentMSecsSinceEpoch() - startTime;
|
||||
const qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
const qint64 dt = now - startTime;
|
||||
m_statsUpdateAircraftTimeTotalMs += dt;
|
||||
m_statsUpdateAircraftRuns++;
|
||||
m_statsUpdateAircraftTimeAvgMs = static_cast<double>(m_statsUpdateAircraftTimeTotalMs) / static_cast<double>(m_statsUpdateAircraftRuns);
|
||||
m_updateRemoteAircraftInProgress = false;
|
||||
if (m_statsLastUpdateAircraftRequested > 0) { m_statsUpdateAircraftRequestedDeltaMs = startTime - m_statsLastUpdateAircraftRequested; }
|
||||
m_statsLastUpdateAircraftRequested = startTime;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::onRecalculatedRenderedAircraft(const CAirspaceAircraftSnapshot &snapshot)
|
||||
|
||||
@@ -123,6 +123,9 @@ namespace BlackCore
|
||||
//! Total update time in ms
|
||||
qint64 getStatisticsTotalUpdateTimeMs() const { return m_statsUpdateAircraftTimeTotalMs; }
|
||||
|
||||
//! Time between two update requests
|
||||
qint64 getStatisticsAircraftUpdatedRequestedDeltaMs() const { return m_statsUpdateAircraftRequestedDeltaMs; }
|
||||
|
||||
//! Access to logger
|
||||
const BlackMisc::Simulation::CInterpolationLogger &interpolationLogger() const { return m_interpolationLogger; }
|
||||
|
||||
@@ -239,8 +242,11 @@ namespace BlackCore
|
||||
bool m_updateRemoteAircraftInProgress = false; //!< currently updating remote aircraft
|
||||
int m_timerId = -1; //!< dispatch timer id
|
||||
int m_statsUpdateAircraftRuns = 0; //!< statistics update count
|
||||
qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics total update time
|
||||
double m_statsUpdateAircraftTimeAvgMs = 0; //!< statistics average update time
|
||||
qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics total update time
|
||||
qint64 m_statsLastUpdateAircraftRequested = 0; //!< when was the last aircraft update requested
|
||||
qint64 m_statsUpdateAircraftRequestedDeltaMs = 0; //!< delta time between 2 aircrat updates
|
||||
|
||||
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
|
||||
BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log.interpolation
|
||||
QMap<BlackMisc::Aviation::CCallsign, qint64> m_clampedLogMsg; //!< when logged last so there, can be used so there is no log message overflow
|
||||
|
||||
@@ -32,15 +32,13 @@ namespace BlackGui
|
||||
QFrame(parent),
|
||||
ui(new Ui::CInterpolationLogDisplay)
|
||||
{
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->tw_LogTabs->setCurrentIndex(TabFlow);
|
||||
constexpr int timeSecs = 5;
|
||||
ui->hs_UpdateTime->setValue(timeSecs);
|
||||
this->onSliderChanged(timeSecs);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CInterpolationLogDisplay::updateLog);
|
||||
connect(ui->hs_UpdateTime, &QSlider::valueChanged, this, &CInterpolationLogDisplay::onSliderChanged);
|
||||
connect(ui->pb_StartStop, &QPushButton::released, this, &CInterpolationLogDisplay::toggleStartStop);
|
||||
connect(ui->comp_CallsignCompleter, &CCallsignCompleter::validCallsignEntered, this, &CInterpolationLogDisplay::onCallsignEntered);
|
||||
|
||||
CLedWidget::LedShape shape = CLedWidget::Rounded;
|
||||
ui->led_Parts->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Parts received", "", 14);
|
||||
@@ -49,6 +47,13 @@ namespace BlackGui
|
||||
ui->led_Running->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Running", "Stopped", 14);
|
||||
|
||||
m_callsign = ui->comp_CallsignCompleter->getCallsign();
|
||||
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CInterpolationLogDisplay::updateLog);
|
||||
connect(ui->comp_CallsignCompleter, &CCallsignCompleter::validCallsignEntered, this, &CInterpolationLogDisplay::onCallsignEntered);
|
||||
connect(ui->hs_UpdateTime, &QSlider::valueChanged, this, &CInterpolationLogDisplay::onSliderChanged);
|
||||
connect(ui->pb_StartStop, &QPushButton::released, this, &CInterpolationLogDisplay::toggleStartStop);
|
||||
connect(ui->pb_ResetStats, &QPushButton::released, this, &CInterpolationLogDisplay::resetStatistics);
|
||||
connect(sGui, &CGuiApplication::aboutToShutdown, this, &CInterpolationLogDisplay::onAboutToShutdown);
|
||||
}
|
||||
|
||||
CInterpolationLogDisplay::~CInterpolationLogDisplay()
|
||||
@@ -65,8 +70,11 @@ namespace BlackGui
|
||||
m_simulatorCommon->disconnect(this);
|
||||
}
|
||||
m_simulatorCommon = simulatorCommon;
|
||||
if (!simulatorCommon) { return; }
|
||||
connect(m_simulatorCommon, &CSimulatorCommon::receivedRequestedElevation, this, &CInterpolationLogDisplay::onElevationReceived);
|
||||
connect(m_simulatorCommon, &CSimulatorCommon::requestedElevation, this, &CInterpolationLogDisplay::onElevationRequested);
|
||||
connect(m_simulatorCommon, &CSimulatorCommon::destroyed, this, &CInterpolationLogDisplay::onSimulatorUnloaded);
|
||||
connect(m_simulatorCommon, &CSimulatorCommon::simulatorStatusChanged, this, &CInterpolationLogDisplay::onSimulatorStatusChanged);
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::setAirspaceMonitor(CAirspaceMonitor *airspaceMonitor)
|
||||
@@ -86,7 +94,7 @@ namespace BlackGui
|
||||
void CInterpolationLogDisplay::updateLog()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
const bool hasLogger = m_simulatorCommon && m_airspaceMonitor;
|
||||
const bool hasLogger = m_airspaceMonitor && m_simulatorCommon && m_simulatorCommon->isConnected() && !m_simulatorCommon->isShuttingDown();
|
||||
if (!hasLogger || m_callsign.isEmpty())
|
||||
{
|
||||
ui->te_TextLog->setText("No logger attached or no callsign");
|
||||
@@ -106,9 +114,10 @@ namespace BlackGui
|
||||
ui->le_CG->home(false);
|
||||
ui->le_Parts->setText(boolToYesNo(m_airspaceMonitor->isRemoteAircraftSupportingParts(m_callsign)));
|
||||
|
||||
static const QString avgUpdateTime("%1ms");
|
||||
static const QString msTimeStr("%1ms");
|
||||
const QString avgUpdateTimeRounded = QString::number(m_simulatorCommon->getStatisticsAverageUpdateTimeMs(), 'f', 2);
|
||||
ui->le_AvgUpdateTimeMs->setText(avgUpdateTime.arg(avgUpdateTimeRounded));
|
||||
ui->le_AvgUpdateTimeMs->setText(msTimeStr.arg(avgUpdateTimeRounded));
|
||||
ui->le_UpdateAircraftReqTimeMs->setText(msTimeStr.arg(m_simulatorCommon->getStatisticsAircraftUpdatedRequestedDeltaMs()));
|
||||
|
||||
const CClient client = m_airspaceMonitor->getClientOrDefaultForCallsign(m_callsign);
|
||||
ui->le_GndFlag->setText(boolToYesNo(client.hasGndFlagCapability()));
|
||||
@@ -149,6 +158,7 @@ namespace BlackGui
|
||||
|
||||
m_callsign = cs;
|
||||
m_simulatorCommon->setLogInterpolation(true, cs);
|
||||
this->start();
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::toggleStartStop()
|
||||
@@ -181,6 +191,26 @@ namespace BlackGui
|
||||
return true;
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onAboutToShutdown()
|
||||
{
|
||||
m_updateTimer.stop();
|
||||
m_simulatorCommon = nullptr;
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onSimulatorUnloaded()
|
||||
{
|
||||
m_updateTimer.stop();
|
||||
m_simulatorCommon = nullptr;
|
||||
this->resetStatistics();
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onSimulatorStatusChanged(ISimulator::SimulatorStatus status)
|
||||
{
|
||||
Q_UNUSED(status);
|
||||
m_updateTimer.stop();
|
||||
this->resetStatistics();
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onSituationAdded(const CAircraftSituation &situation)
|
||||
{
|
||||
const CCallsign cs = situation.getCallsign();
|
||||
@@ -204,16 +234,21 @@ namespace BlackGui
|
||||
if (!this->logCallsign(callsign)) { return; }
|
||||
m_elvReceived++;
|
||||
ui->le_Elevation->setText(plane.toQString());
|
||||
ui->led_Elevation->blink();
|
||||
ui->le_ElevationRec->setText(QString::number(m_elvReceived));
|
||||
ui->led_Elevation->blink();
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onElevationRequested(const CCallsign &callsign)
|
||||
{
|
||||
if (!this->logCallsign(callsign)) { return; }
|
||||
m_elvRequested++;
|
||||
ui->led_Elevation->blink();
|
||||
ui->le_ElevationReq->setText(QString::number(m_elvRequested));
|
||||
ui->led_Elevation->blink();
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::resetStatistics()
|
||||
{
|
||||
if (m_simulatorCommon) { m_simulatorCommon->resetAircraftStatistics(); }
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::clear()
|
||||
@@ -227,6 +262,7 @@ namespace BlackGui
|
||||
ui->le_ElevationReq->clear();
|
||||
ui->le_Parts->clear();
|
||||
ui->le_AvgUpdateTimeMs->clear();
|
||||
ui->le_UpdateAircraftReqTimeMs->clear();
|
||||
m_elvReceived = m_elvRequested = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,18 +78,30 @@ namespace BlackGui
|
||||
//! Log the current callsign
|
||||
bool logCallsign(const BlackMisc::Aviation::CCallsign &cs) const;
|
||||
|
||||
//! About to shutdown
|
||||
void onAboutToShutdown();
|
||||
|
||||
//! Simulator unloaded
|
||||
void onSimulatorUnloaded();
|
||||
|
||||
//! \copydoc BlackCore::CAirspaceMonitor::addedAircraftSituation
|
||||
void onSituationAdded(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! \copydoc BlackCore::CAirspaceMonitor::addedAircraftSituation
|
||||
void onPartsAdded(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
//! \copydoc BlackCore::CSimulatorCommon::simulatorStatusChanged
|
||||
void onSimulatorStatusChanged(BlackCore::ISimulator::SimulatorStatus status);
|
||||
|
||||
//! \copydoc BlackCore::CSimulatorCommon::receivedRequestedElevation
|
||||
void onElevationReceived(const BlackMisc::Geo::CElevationPlane &plane, const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! \copydoc BlackCore::CSimulatorCommon::requestedElevation
|
||||
void onElevationRequested(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! \copydoc BlackCore::CSimulatorCommon::resetAircraftStatistics
|
||||
void resetStatistics();
|
||||
|
||||
//! Clear
|
||||
void clear();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<property name="title">
|
||||
<string>Log. callsign</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_LogCallsign" stretch="2,1,4,1">
|
||||
<layout class="QHBoxLayout" name="hl_LogCallsign" stretch="2,1,4,0,1">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
@@ -77,6 +77,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_ResetStats">
|
||||
<property name="text">
|
||||
<string>reset stats.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_StartStop">
|
||||
<property name="text">
|
||||
@@ -226,23 +233,6 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_CG">
|
||||
<property name="text">
|
||||
<string>CG:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_CG">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>CG</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Parts">
|
||||
<property name="text">
|
||||
@@ -277,6 +267,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_UpdateAircraftReqTime">
|
||||
<property name="toolTip">
|
||||
<string>update aircraft req.time</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update req.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_UpdateAircraftReqTimeMs">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_AverageUpdateTime">
|
||||
<property name="text">
|
||||
@@ -336,7 +343,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_Misc2">
|
||||
<layout class="QHBoxLayout" name="hl_Misc2">
|
||||
<layout class="QHBoxLayout" name="hl_Misc2" stretch="0,1,0,4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -349,6 +356,23 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_CG">
|
||||
<property name="text">
|
||||
<string>CG:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_CG">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>CG</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Elevation">
|
||||
<property name="text">
|
||||
@@ -442,7 +466,6 @@
|
||||
<tabstop>comp_CallsignCompleter</tabstop>
|
||||
<tabstop>le_UpdateTime</tabstop>
|
||||
<tabstop>hs_UpdateTime</tabstop>
|
||||
<tabstop>le_CG</tabstop>
|
||||
<tabstop>le_Parts</tabstop>
|
||||
<tabstop>le_GndFlag</tabstop>
|
||||
<tabstop>le_ElevationReq</tabstop>
|
||||
|
||||
Reference in New Issue
Block a user