Ref T259, Ref T243 elevation provider statistics

This commit is contained in:
Klaus Basan
2018-03-29 00:50:57 +02:00
parent 52dd7a754c
commit bd7fd59d07
2 changed files with 31 additions and 3 deletions

View File

@@ -24,13 +24,12 @@ namespace BlackMisc
if (m_elvCoordinates.containsObjectInRange(elevationCoordinate, minRange(epsilon))) { return false; }
}
{
// we keep latest at fron
// we keep latest at front
// * we assume we find them faster
// * and need the more frequently (the recent ones)
QWriteLocker l(&m_lockElvCoordinates);
if (m_elvCoordinates.size() > MaxElevations) { m_elvCoordinates.pop_back(); }
m_elvCoordinates.push_front(elevationCoordinate);
}
return true;
}
@@ -95,7 +94,19 @@ namespace BlackMisc
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const
{
const CCoordinateGeodetic coordinate = this->getElevationCoordinates().findClosestWithinRange(reference, minRange(range));
return CElevationPlane(coordinate, reference); // plane with radis = distnace to reference
const bool found = !coordinate.isNull();
{
QWriteLocker l{&m_lockElvCoordinates };
if (found) { m_elvFound++; }
else { m_elvMissed++; }
}
return CElevationPlane(coordinate, reference); // plane with radis = distance to reference
}
QPair<int, int> ISimulationEnvironmentProvider::getElevationsFoundMissed() const
{
QReadLocker l(&m_lockElvCoordinates);
return QPair<int, int>(m_elvFound, m_elvMissed);
}
CSimulatorPluginInfo ISimulationEnvironmentProvider::getSimulatorPluginInfo() const
@@ -162,6 +173,7 @@ namespace BlackMisc
{
QWriteLocker l(&m_lockElvCoordinates);
m_elvCoordinates.clear();
m_elvFound = m_elvMissed = 0;
}
void ISimulationEnvironmentProvider::clearCGs()
@@ -183,6 +195,12 @@ namespace BlackMisc
return this->provider()->findClosestElevationWithinRange(reference, range);
}
QPair<int, int> CSimulationEnvironmentAware::getElevationsFoundMissed() const
{
if (!this->hasProvider()) { return QPair<int, int>(0, 0); }
return this->provider()->getElevationsFoundMissed();
}
CSimulatorPluginInfo CSimulationEnvironmentAware::getSimulatorPluginInfo() const
{
if (!this->hasProvider()) { return CSimulatorPluginInfo(); }

View File

@@ -20,6 +20,7 @@
#include <QMap>
#include <QObject>
#include <QPair>
namespace BlackMisc
{
@@ -39,6 +40,10 @@ namespace BlackMisc
//! \threadsafe
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const;
//! Elevations found/missed statistics
//! \threadsafe
QPair<int, int> getElevationsFoundMissed() const;
//! Get the represented plugin
//! \threadsafe
CSimulatorPluginInfo getSimulatorPluginInfo() const;
@@ -122,6 +127,8 @@ namespace BlackMisc
CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
Geo::CCoordinateGeodeticList m_elvCoordinates;
QMap<Aviation::CCallsign, PhysicalQuantities::CLength> m_cgs; //! CGs
mutable int m_elvFound = 0; //!< statistics only
mutable int m_elvMissed = 0; //!< statistics only
mutable QReadWriteLock m_lockElvCoordinates; //!< lock m_coordinates
mutable QReadWriteLock m_lockCG; //!< lock CGs
mutable QReadWriteLock m_lockModel; //!< lock models
@@ -137,6 +144,9 @@ namespace BlackMisc
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const;
//! \copydoc ISimulationEnvironmentProvider::getElevationsFoundMissed
QPair<int, int> getElevationsFoundMissed() const;
//! \copydoc ISimulationEnvironmentProvider::getSimulatorPluginInfo
CSimulatorPluginInfo getSimulatorPluginInfo() const;