mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Ref T171, Ref T136, moved statistics counter to base class
* removed from emulated driver * since we have the remote access providers functions, the counter functions have been moved to the base class. Therby we can use them for all drivers.
This commit is contained in:
@@ -100,7 +100,7 @@ namespace BlackCore
|
||||
if (!remoteAircraft.isEnabled()) { return false; }
|
||||
|
||||
// if not restriced, directly change
|
||||
if (!renderingRestricted) { this->physicallyAddRemoteAircraft(remoteAircraft); return true; }
|
||||
if (!renderingRestricted) { this->callPhysicallyAddRemoteAircraft(remoteAircraft); return true; }
|
||||
|
||||
// restricted -> will be added with next snapshot onRecalculatedRenderedAircraft
|
||||
return false;
|
||||
@@ -109,7 +109,11 @@ namespace BlackCore
|
||||
bool CSimulatorCommon::logicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
||||
{
|
||||
// if not restriced, directly change
|
||||
if (!m_interpolationRenderingSetup.isRenderingRestricted()) { this->physicallyRemoveRemoteAircraft(callsign); return true; }
|
||||
if (!m_interpolationRenderingSetup.isRenderingRestricted())
|
||||
{
|
||||
m_statsPhysicallyAddedAircraft++;
|
||||
this->callPhysicallyRemoveRemoteAircraft(callsign); return true;
|
||||
}
|
||||
|
||||
// will be added with next snapshot ps_recalculateRenderedAircraft
|
||||
return false;
|
||||
@@ -139,11 +143,11 @@ namespace BlackCore
|
||||
{
|
||||
if (m_blinkCycle)
|
||||
{
|
||||
this->physicallyRemoveRemoteAircraft(aircraft.getCallsign());
|
||||
this->callPhysicallyRemoveRemoteAircraft(aircraft.getCallsign());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->physicallyAddRemoteAircraft(aircraft); // blink
|
||||
this->callPhysicallyAddRemoteAircraft(aircraft); // blink
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,12 +175,12 @@ namespace BlackCore
|
||||
// are we already visible?
|
||||
if (!this->isPhysicallyRenderedAircraft(callsign))
|
||||
{
|
||||
this->physicallyAddRemoteAircraft(aircraft); // enable/disable
|
||||
this->callPhysicallyAddRemoteAircraft(aircraft); // enable/disable
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->physicallyRemoveRemoteAircraft(callsign);
|
||||
this->callPhysicallyRemoveRemoteAircraft(callsign);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,7 +368,7 @@ namespace BlackCore
|
||||
int removed = 0;
|
||||
for (const CCallsign &callsign : callsigns)
|
||||
{
|
||||
this->physicallyRemoveRemoteAircraft(callsign);
|
||||
this->callPhysicallyRemoveRemoteAircraft(callsign);
|
||||
removed++;
|
||||
}
|
||||
return removed;
|
||||
@@ -461,6 +465,14 @@ namespace BlackCore
|
||||
CSimpleCommandParser::registerCommand({".drv spline|linear <callsign>", "set spline/linear interpolator for one/all callsign(s)"});
|
||||
}
|
||||
|
||||
void CSimulatorCommon::resetStatistics()
|
||||
{
|
||||
m_statsPhysicallyAddedAircraft = 0;
|
||||
m_statsPhysicallyRemovedAircraft = 0;
|
||||
m_statsPartsAdded = 0;
|
||||
m_statsSituationAdded = 0;
|
||||
}
|
||||
|
||||
void CSimulatorCommon::oneSecondTimerTimeout()
|
||||
{
|
||||
this->blinkHighlightedAircraft();
|
||||
@@ -497,7 +509,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT_X(aircraft.isEnabled(), Q_FUNC_INFO, "Disabled aircraft detected as to be added");
|
||||
Q_ASSERT_X(aircraft.hasModelString(), Q_FUNC_INFO, "Missing model string");
|
||||
this->physicallyAddRemoteAircraft(aircraft); // recalcuate snapshot
|
||||
this->callPhysicallyAddRemoteAircraft(aircraft); // recalcuate snapshot
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -539,6 +551,7 @@ namespace BlackCore
|
||||
m_statsUpdateAircraftTimeTotalMs = 0;
|
||||
m_blinkCycle = false;
|
||||
m_highlightEndTimeMsEpoch = false;
|
||||
this->resetStatistics();
|
||||
this->clearAllAircraft();
|
||||
}
|
||||
|
||||
@@ -570,12 +583,14 @@ namespace BlackCore
|
||||
void CSimulatorCommon::rapOnRemoteProviderAddedAircraftSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
if (!this->isConnected()) return;
|
||||
m_statsSituationAdded++;
|
||||
this->onRemoteProviderAddedAircraftSituation(situation);
|
||||
}
|
||||
|
||||
void CSimulatorCommon::rapOnRemoteProviderAddedAircraftParts(const CCallsign &callsign, const CAircraftParts &parts)
|
||||
{
|
||||
if (!this->isConnected()) return;
|
||||
m_statsPartsAdded++;
|
||||
this->onRemoteProviderAddedAircraftParts(callsign, parts);
|
||||
}
|
||||
|
||||
@@ -584,4 +599,18 @@ namespace BlackCore
|
||||
if (!this->isConnected()) return;
|
||||
this->onRemoteProviderRemovedAircraft(callsign);
|
||||
}
|
||||
|
||||
void CSimulatorCommon::callPhysicallyAddRemoteAircraft(const CSimulatedAircraft &remoteAircraft)
|
||||
{
|
||||
m_statsPhysicallyAddedAircraft++;
|
||||
this->physicallyAddRemoteAircraft(remoteAircraft);
|
||||
}
|
||||
|
||||
void CSimulatorCommon::callPhysicallyRemoveRemoteAircraft(const CCallsign &remoteCallsign)
|
||||
{
|
||||
m_statsPhysicallyRemovedAircraft++;
|
||||
this->physicallyRemoveRemoteAircraft(remoteCallsign);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -106,6 +106,21 @@ namespace BlackCore
|
||||
|
||||
// --------- ISimulator implementations ------------
|
||||
|
||||
//! Reset the statistics counters
|
||||
void resetStatistics();
|
||||
|
||||
//! Counter added aircraft
|
||||
int getStatisticsPhysicallyAddedAircraft() const { return m_statsPhysicallyAddedAircraft; }
|
||||
|
||||
//! Counter removed aircraft
|
||||
int getStatisticsPhysicallyRemovedAircraft() const { return m_statsPhysicallyRemovedAircraft; }
|
||||
|
||||
//! Counter situation added
|
||||
int getStatisticsSituationAdded() const { return m_statsSituationAdded; }
|
||||
|
||||
//! Counter added parts
|
||||
int getStatisticsPartsAdded() const { return m_statsPartsAdded; }
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CSimulatorCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
@@ -225,6 +240,9 @@ namespace BlackCore
|
||||
void rapOnRemoteProviderAddedAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
void rapOnRemoteProviderRemovedAircraft(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
void callPhysicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft);
|
||||
void callPhysicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &remoteCallsign);
|
||||
|
||||
bool m_blinkCycle = false; //!< used for highlighting
|
||||
qint64 m_highlightEndTimeMsEpoch = 0; //!< end highlighting
|
||||
int m_timerCounter = 0; //!< allows to calculate n seconds
|
||||
@@ -233,6 +251,13 @@ namespace BlackCore
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_highlightedAircraft; //!< all other aircraft are to be ignored
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToBeRendered; //!< callsigns which will be rendered
|
||||
BlackMisc::CConnectionGuard m_remoteAircraftProviderConnections; //!< connected signal/slots
|
||||
|
||||
// statistics values of how often those functions are called
|
||||
// those are the added counters, overflow will not be an issue here (discussed in T171 review)
|
||||
int m_statsPhysicallyAddedAircraft = 0; //!< statistics, how many aircraft added
|
||||
int m_statsPhysicallyRemovedAircraft = 0; //!< statistics, how many aircraft removed
|
||||
int m_statsPartsAdded = 0; //!< statistics, how many aircraft parts added
|
||||
int m_statsSituationAdded = 0; //!< statistics, how many situations added
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -234,14 +234,6 @@ namespace BlackSimPlugin
|
||||
return this->updateOwnParts(parts);
|
||||
}
|
||||
|
||||
void CSimulatorEmulated::resetStatistics()
|
||||
{
|
||||
m_physicallyAdded = 0;
|
||||
m_physicallyRemoved = 0;
|
||||
m_partsAdded = 0;
|
||||
m_situationAdded = 0;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::isConnected() const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
@@ -268,7 +260,6 @@ namespace BlackSimPlugin
|
||||
m_renderedAircraft.push_back(aircraft); // my simulator list
|
||||
const CCallsign cs = aircraft.getCallsign();
|
||||
this->updateAircraftRendered(cs, true); // in provider
|
||||
m_physicallyAdded++;
|
||||
emit this->aircraftRenderingChanged(aircraft);
|
||||
return true;
|
||||
}
|
||||
@@ -276,24 +267,10 @@ namespace BlackSimPlugin
|
||||
bool CSimulatorEmulated::physicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsign.toQString());
|
||||
m_physicallyRemoved++;
|
||||
const int c = m_renderedAircraft.removeByCallsign(callsign);
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
void CSimulatorEmulated::onRemoteProviderAddedAircraftSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
Q_UNUSED(situation);
|
||||
m_situationAdded++;
|
||||
}
|
||||
|
||||
void CSimulatorEmulated::onRemoteProviderAddedAircraftParts(const CCallsign &callsign, const CAircraftParts &parts)
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
Q_UNUSED(parts);
|
||||
m_partsAdded++;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::setInterpolatorMode(CInterpolatorMulti::Mode mode, const CCallsign &callsign)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, CInterpolatorMulti::modeToString(mode), callsign.toQString());
|
||||
|
||||
@@ -99,9 +99,6 @@ namespace BlackSimPlugin
|
||||
//! \remark normally used by corresponding BlackSimPlugin::Emulated::CSimulatorEmulatedMonitorDialog
|
||||
bool changeInternalParts(const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
//! Reset statistics
|
||||
void resetStatistics();
|
||||
|
||||
//! Register help
|
||||
static void registerHelp();
|
||||
|
||||
@@ -115,8 +112,6 @@ namespace BlackSimPlugin
|
||||
virtual bool isSimulating() const override;
|
||||
virtual bool physicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override;
|
||||
virtual bool physicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void onRemoteProviderAddedAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
||||
virtual void onRemoteProviderAddedAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts) override;
|
||||
|
||||
// just logged
|
||||
virtual int physicallyRemoveAllRemoteAircraft() override;
|
||||
@@ -145,10 +140,6 @@ namespace BlackSimPlugin
|
||||
bool m_connected = true;
|
||||
bool m_simulating = true;
|
||||
bool m_timeSyncronized = false;
|
||||
int m_physicallyAdded = 0; //!< statistics, how often called
|
||||
int m_physicallyRemoved = 0; //!< statistics, how often called
|
||||
int m_partsAdded = 0;
|
||||
int m_situationAdded = 0;
|
||||
BlackMisc::PhysicalQuantities::CTime m_offsetTime;
|
||||
BlackMisc::Simulation::CSimulatedAircraft m_myAircraft; //!< represents own aircraft of simulator
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_renderedAircraft; //!< represents remote aircraft in simulator
|
||||
|
||||
@@ -180,10 +180,10 @@ namespace BlackSimPlugin
|
||||
void CSimulatorEmulatedMonitorDialog::timerBasedUiUpdates()
|
||||
{
|
||||
if (!m_simulator) { return; }
|
||||
ui->le_PhysicallyAddedAircraft->setText(QString::number(m_simulator->m_physicallyAdded));
|
||||
ui->le_PhysicallyRemovedAircraft->setText(QString::number(m_simulator->m_physicallyRemoved));
|
||||
ui->le_SituationAdded->setText(QString::number(m_simulator->m_situationAdded));
|
||||
ui->le_PartsAdded->setText(QString::number(m_simulator->m_partsAdded));
|
||||
ui->le_PhysicallyAddedAircraft->setText(QString::number(m_simulator->getStatisticsPhysicallyAddedAircraft()));
|
||||
ui->le_PhysicallyRemovedAircraft->setText(QString::number(m_simulator->getStatisticsPhysicallyRemovedAircraft()));
|
||||
ui->le_SituationAdded->setText(QString::number(m_simulator->getStatisticsSituationAdded()));
|
||||
ui->le_PartsAdded->setText(QString::number(m_simulator->getStatisticsPartsAdded()));
|
||||
ui->le_AircraftRendered->setText(QString::number(m_simulator->m_renderedAircraft.size()));
|
||||
ui->le_PartsEnabledAircraft->setText(QString::number(m_simulator->getRemoteAircraftSupportingPartsCount()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user