mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
[xswiftbus] display FPS in simulator data window
* added driver getAverageFPS function * display in simulator component
This commit is contained in:
committed by
Mat Sutcliffe
parent
548a12a502
commit
72c3abb1e7
@@ -259,6 +259,7 @@ namespace BlackCore
|
||||
void ISimulator::reset()
|
||||
{
|
||||
this->clearAllRemoteAircraftData(); // reset
|
||||
m_averageFps = -1.0;
|
||||
}
|
||||
|
||||
bool ISimulator::isUpdateAllRemoteAircraft(qint64 currentTimestamp) const
|
||||
@@ -316,7 +317,7 @@ namespace BlackCore
|
||||
|
||||
void ISimulator::injectWeatherGrid(const CWeatherGrid &weatherGrid)
|
||||
{
|
||||
Q_UNUSED(weatherGrid);
|
||||
Q_UNUSED(weatherGrid)
|
||||
}
|
||||
|
||||
void ISimulator::blinkHighlightedAircraft()
|
||||
@@ -350,8 +351,8 @@ namespace BlackCore
|
||||
|
||||
bool ISimulator::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign)
|
||||
{
|
||||
Q_UNUSED(reference);
|
||||
Q_UNUSED(callsign);
|
||||
Q_UNUSED(reference)
|
||||
Q_UNUSED(callsign)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -361,7 +362,7 @@ namespace BlackCore
|
||||
|
||||
ISimulationEnvironmentProvider::rememberGroundElevation(callsign, plane); // in simulator
|
||||
const int updated = CRemoteAircraftAware::updateAircraftGroundElevation(callsign, plane, CAircraftSituation::FromProvider);
|
||||
Q_UNUSED(updated);
|
||||
Q_UNUSED(updated)
|
||||
emit this->receivedRequestedElevation(plane, callsign);
|
||||
}
|
||||
|
||||
@@ -1032,7 +1033,7 @@ namespace BlackCore
|
||||
|
||||
bool ISimulator::disconnectFrom()
|
||||
{
|
||||
// supposed to be overridden
|
||||
m_averageFps = -1.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace BlackCore
|
||||
virtual bool connectTo() = 0;
|
||||
|
||||
//! Disconnect from simulator
|
||||
virtual bool disconnectFrom() = 0;
|
||||
virtual bool disconnectFrom();
|
||||
|
||||
//! Logically add a new aircraft.
|
||||
//! Depending on max. aircraft, enabled status etc. it will physically added to the simulator.
|
||||
@@ -215,6 +215,9 @@ namespace BlackCore
|
||||
//! Test mode?
|
||||
bool isTestMode() const { return m_test; }
|
||||
|
||||
//! Average FPS (frames per second)
|
||||
double getAverageFPS() const { return m_averageFps; }
|
||||
|
||||
//! Send situation/parts for testing
|
||||
virtual bool testSendSituationAndParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CAircraftParts &parts) = 0;
|
||||
|
||||
@@ -575,6 +578,7 @@ namespace BlackCore
|
||||
int m_statsUpdateAircraftRuns = 0; //!< statistics update count
|
||||
int m_statsUpdateAircraftLimited = 0; //!< skipped because of max.update limitations
|
||||
double m_statsUpdateAircraftTimeAvgMs = 0; //!< statistics average update time
|
||||
double m_averageFps = -1.0; //!< FPS
|
||||
qint64 m_updateAllRemoteAircraftUntil = 0; //!< force an update of all remote aircraft, used when own aircraft is moved, paused to make sure all remote aircraft are updated
|
||||
qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics total update time
|
||||
qint64 m_statsCurrentUpdateTimeMs = 0; //!< statistics current update time
|
||||
|
||||
@@ -146,7 +146,14 @@ namespace BlackGui
|
||||
if (m_simulator.isAnySimulator())
|
||||
{
|
||||
this->addOrUpdateLiveDataByName("simulator", m_simulator.toQString(true), m_simulator.toIcon());
|
||||
|
||||
if (sGui->getISimulator())
|
||||
{
|
||||
const double fps = sGui->getISimulator()->getAverageFPS();
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("FPS"), fps < 0 ? QStringLiteral("N/A") : QString::number(fps, 'g', 1), CIconList::allIcons().findByIndex(CIcons::ApplicationSimulator));
|
||||
}
|
||||
}
|
||||
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("latitude"), s.latitude().toQString(), iconLatLng);
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("longitude"), s.longitude().toQString(), iconLatLng);
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("altitude, true (ft)"), s.getAltitude().valueRoundedWithUnit(CLengthUnit::ft(), 1), iconAlt);
|
||||
@@ -157,7 +164,7 @@ namespace BlackGui
|
||||
if (s.hasGroundElevation())
|
||||
{
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("elevation (ft)"), s.getGroundElevation().valueRoundedWithUnit(CLengthUnit::ft(), 1), iconAlt);
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("elevation (m)"), s.getGroundElevation().valueRoundedWithUnit(CLengthUnit::m(), 2), iconAlt);
|
||||
this->addOrUpdateLiveDataByName(QStringLiteral("elevation (m)"), s.getGroundElevation().valueRoundedWithUnit(CLengthUnit::m(), 2), iconAlt);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -236,6 +236,8 @@ namespace BlackSimPlugin
|
||||
{
|
||||
if (this->isConnected())
|
||||
{
|
||||
m_fastTimerCalls++;
|
||||
|
||||
m_serviceProxy->getOwnAircraftSituationDataAsync(&m_xplaneData);
|
||||
m_serviceProxy->getOwnAircraftCom1DataAsync(&m_xplaneData);
|
||||
m_serviceProxy->getOwnAircraftCom2DataAsync(&m_xplaneData);
|
||||
@@ -313,6 +315,8 @@ namespace BlackSimPlugin
|
||||
{
|
||||
if (isConnected())
|
||||
{
|
||||
m_slowTimerCalls++;
|
||||
|
||||
// own aircraft data
|
||||
m_serviceProxy->getOwnAircraftModelDataAsync(&m_xplaneData);
|
||||
m_serviceProxy->getOwnAircraftLightsAsync(&m_xplaneData);
|
||||
@@ -360,6 +364,13 @@ namespace BlackSimPlugin
|
||||
{
|
||||
this->triggerRemoveAircraft(cs, ++i * 100);
|
||||
}
|
||||
|
||||
// FPS
|
||||
if ((m_slowTimerCalls % 5) == 0)
|
||||
{
|
||||
// reading FPS resets average, so we only monitor over some time
|
||||
m_averageFps = m_serviceProxy->getAverageFPS();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +446,9 @@ namespace BlackSimPlugin
|
||||
m_serviceProxy = nullptr;
|
||||
m_trafficProxy = nullptr;
|
||||
m_weatherProxy = nullptr;
|
||||
m_fastTimerCalls = 0;
|
||||
m_slowTimerCalls = 0;
|
||||
|
||||
this->emitSimulatorCombinedStatus();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -250,6 +250,9 @@ namespace BlackSimPlugin
|
||||
QTimer m_slowTimer;
|
||||
QTimer m_airportUpdater;
|
||||
QTimer m_pendingAddedTimer;
|
||||
int m_fastTimerCalls = 0; //!< how often called
|
||||
int m_slowTimerCalls = 0; //!< how often called
|
||||
|
||||
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_pendingToBeAddedAircraft; //!< aircraft to be added
|
||||
QHash<BlackMisc::Aviation::CCallsign, qint64> m_addingInProgressAircraft; //!< aircraft just adding
|
||||
|
||||
Reference in New Issue
Block a user