Ref T268, simulator improvements

* use virtual function to emit setup signal
* callback public so it can be used from "log display" for testing
* sim. environment provider statistics
This commit is contained in:
Klaus Basan
2018-07-09 22:24:04 +02:00
parent 6e880b950c
commit 29536dac4d
4 changed files with 122 additions and 45 deletions

View File

@@ -14,6 +14,7 @@
#include <QFlag>
#include <Qt>
#include <QtGlobal>
#include <QPointer>
using namespace BlackConfig;
using namespace BlackMisc;
@@ -55,9 +56,8 @@ namespace BlackCore
{
if (this->isShuttingDown()) { return; }
// CLogMessage(this).info("'%1' Received req. elevation") << callsign.asString();
this->rememberGroundElevation(plane);
const int updated = this->updateAircraftGroundElevation(callsign, plane, CAircraftSituation::FromProvider);
ISimulationEnvironmentProvider::rememberGroundElevation(callsign, plane); // in simulator
const int updated = CRemoteAircraftAware::updateAircraftGroundElevation(callsign, plane, CAircraftSituation::FromProvider);
if (updated < 1) { return; }
emit this->receivedRequestedElevation(plane, callsign);
}
@@ -113,8 +113,8 @@ namespace BlackCore
if (!elevation.isNull())
{
const int aircraftCount = this->getAircraftInRangeCount();
this->setRememberMaxElevations(aircraftCount * 3); // at least 3 elevations per aircraft, even better as not all are requesting elevations
this->rememberGroundElevation(elevation);
this->setMaxElevationsRemembered(aircraftCount * 3); // at least 3 elevations per aircraft, even better as not all are requesting elevations
this->rememberGroundElevation(callsign, elevation);
}
if (!cg.isNull() && !this->hasSameCG(cg, callsign)) { this->insertCG(cg, modelString, callsign); }
}
@@ -135,31 +135,27 @@ namespace BlackCore
}
}
void ISimulator::emitInterpolationSetupChanged()
{
QPointer<ISimulator> myself(this);
QTimer::singleShot(0, this, [ = ]
{
if (!myself) { return; }
emit this->interpolationAndRenderingSetupChanged();
});
}
bool ISimulator::setInterpolationSetupGlobal(const CInterpolationAndRenderingSetupGlobal &setup)
{
if (!IInterpolationSetupProvider::setInterpolationSetupGlobal(setup)) { return false; }
const bool r = setup.isRenderingRestricted();
const bool e = setup.isRenderingEnabled();
emit this->interpolationAndRenderingSetupChanged();
emit this->renderRestrictionsChanged(r, e, setup.getMaxRenderedAircraft(), setup.getMaxRenderedDistance());
return true;
}
bool ISimulator::setInterpolationSetupsPerCallsign(const CInterpolationSetupList &setups, bool ignoreSameAsGlobal)
{
if (!IInterpolationSetupProvider::setInterpolationSetupsPerCallsign(setups, ignoreSameAsGlobal)) { return false; }
emit this->interpolationAndRenderingSetupChanged();
return true;
}
bool ISimulator::setInterpolationSetupPerCallsign(const CInterpolationAndRenderingSetupPerCallsign &setup, const CCallsign &callsign, bool removeGlobalSetup)
{
if (!IInterpolationSetupProvider::setInterpolationSetupPerCallsign(setup, callsign, removeGlobalSetup)) { return false; }
emit this->interpolationAndRenderingSetupChanged();
return true;
}
ISimulatorListener::ISimulatorListener(const CSimulatorPluginInfo &info) :
QObject(), m_info(info)
{

View File

@@ -198,6 +198,10 @@ namespace BlackCore
//! \sa ISimulator::callbackReceivedRequestedElevation
virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign) override;
//! A requested elevation has been received
//! \remark public for testing purposes
virtual void callbackReceivedRequestedElevation(const BlackMisc::Geo::CElevationPlane &plane, const BlackMisc::Aviation::CCallsign &callsign);
//! Allows to print out simulator specific statistics
virtual QString getStatisticsSimulatorSpecific() const { return QString(); }
@@ -224,9 +228,6 @@ namespace BlackCore
//! \copydoc BlackMisc::Simulation::IInterpolationSetupProvider::setInterpolationSetupGlobal
virtual bool setInterpolationSetupGlobal(const BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal &setup) override;
//! \copydoc BlackMisc::Simulation::IInterpolationSetupProvider::setInterpolationSetupsPerCallsign
virtual bool setInterpolationSetupsPerCallsign(const BlackMisc::Simulation::CInterpolationSetupList &setups, bool ignoreSameAsGlobal = true) override;
//! Register help
static void registerHelp();
@@ -295,16 +296,13 @@ namespace BlackCore
//! Set elevation and CG in the providers
void rememberElevationAndCG(const BlackMisc::Aviation::CCallsign &callsign, const QString &modelString, const BlackMisc::Geo::CElevationPlane &elevation, const BlackMisc::PhysicalQuantities::CLength &cg);
//! A requested elevation has been received
virtual void callbackReceivedRequestedElevation(const BlackMisc::Geo::CElevationPlane &plane, const BlackMisc::Aviation::CCallsign &callsign);
//! \copydoc BlackMisc::Simulation::IInterpolationSetupProvider::setInterpolationSetupPerCallsign
virtual bool setInterpolationSetupPerCallsign(const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup, const BlackMisc::Aviation::CCallsign &callsign, bool removeGlobalSetup) override;
//! Emit the combined status
//! \param oldStatus optionally one can capture and provide the old status for comparison. In case of equal status values no signal will be sent
//! \sa simulatorStatusChanged;
void emitSimulatorCombinedStatus(SimulatorStatus oldStatus = Unspecified);
//! Emit the signal
virtual void emitInterpolationSetupChanged() override;
};
//! Interface to a simulator listener.