mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T275, remember CG per model string
This commit is contained in:
@@ -511,6 +511,16 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CRemoteAircraftProvider::updateCGAndModelString(const CCallsign &callsign, const CLength &cg, const QString &modelString)
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
if (!m_aircraftInRange.contains(callsign)) { return false; }
|
||||
CSimulatedAircraft &aircraft = m_aircraftInRange[callsign];
|
||||
if (!cg.isNull()) { aircraft.setCG(cg); }
|
||||
if (!modelString.isEmpty()) { aircraft.setModelString(modelString); }
|
||||
return true;
|
||||
}
|
||||
|
||||
void CRemoteAircraftProvider::updateMarkAllAsNotRendered()
|
||||
{
|
||||
const CCallsignSet callsigns = this->getAircraftInRangeCallsigns();
|
||||
@@ -856,6 +866,18 @@ namespace BlackMisc
|
||||
return this->provider()->updateAircraftGroundElevation(callsign, elevation, info);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::updateCG(const CCallsign &callsign, const CLength &cg)
|
||||
{
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateCG(callsign, cg);
|
||||
}
|
||||
|
||||
bool CRemoteAircraftAware::updateCGAndModelString(const CCallsign &callsign, const CLength &cg, const QString &modelString)
|
||||
{
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->updateCGAndModelString(callsign, cg, modelString);
|
||||
}
|
||||
|
||||
void CRemoteAircraftAware::updateMarkAllAsNotRendered()
|
||||
{
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
|
||||
@@ -175,6 +175,10 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
virtual bool updateCG(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg) = 0;
|
||||
|
||||
//! Update the CG and model string
|
||||
//! \threadsafe
|
||||
virtual bool updateCGAndModelString(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg, const QString &modelString) = 0;
|
||||
|
||||
//! Get reverse lookup meesages
|
||||
//! \threadsafe
|
||||
virtual CStatusMessageList getReverseLookupMessages(const Aviation::CCallsign &callsign) const = 0;
|
||||
@@ -286,6 +290,7 @@ namespace BlackMisc
|
||||
virtual bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered) override;
|
||||
virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, Aviation::CAircraftSituation::GndElevationInfo info) override;
|
||||
virtual bool updateCG(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg) override;
|
||||
virtual bool updateCGAndModelString(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg, const QString &modelString) override;
|
||||
virtual void updateMarkAllAsNotRendered() override;
|
||||
virtual CStatusMessageList getAircraftPartsHistory(const Aviation::CCallsign &callsign) const override;
|
||||
virtual bool isAircraftPartsHistoryEnabled() const override;
|
||||
@@ -515,6 +520,12 @@ namespace BlackMisc
|
||||
//! \copydoc IRemoteAircraftProvider::updateAircraftGroundElevation
|
||||
int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, Aviation::CAircraftSituation::GndElevationInfo info);
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::updateCG
|
||||
bool updateCG(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg);
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::updateCGAndModelString
|
||||
bool updateCGAndModelString(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg, const QString &modelString);
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::updateMarkAllAsNotRendered
|
||||
void updateMarkAllAsNotRendered();
|
||||
|
||||
|
||||
@@ -49,20 +49,37 @@ namespace BlackMisc
|
||||
if (remove)
|
||||
{
|
||||
QWriteLocker l(&m_lockCG);
|
||||
m_cgs.remove(cs);
|
||||
m_cgsPerCallsign.remove(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
QWriteLocker l(&m_lockCG);
|
||||
m_cgs[cs] = cg;
|
||||
m_cgsPerCallsign[cs] = cg;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ISimulationEnvironmentProvider::insertCG(const CLength &cg, const QString &modelString, const CCallsign &cs)
|
||||
{
|
||||
bool ok = false;
|
||||
QWriteLocker l(&m_lockCG);
|
||||
if (!cs.isEmpty()) { m_cgsPerCallsign[cs] = cg; ok = true; }
|
||||
if (!modelString.isEmpty()) { m_cgsPerModel[modelString.toLower()] = cg; ok = true; }
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ISimulationEnvironmentProvider::insertCGForModelString(const CLength &cg, const QString &modelString)
|
||||
{
|
||||
if (modelString.isEmpty()) { return false; }
|
||||
QWriteLocker l(&m_lockCG);
|
||||
m_cgsPerModel[modelString.toLower()] = cg;
|
||||
return true;
|
||||
}
|
||||
|
||||
int ISimulationEnvironmentProvider::removeCG(const CCallsign &cs)
|
||||
{
|
||||
QWriteLocker l(&m_lockCG);
|
||||
return m_cgs.remove(cs);
|
||||
return m_cgsPerCallsign.remove(cs);
|
||||
}
|
||||
|
||||
CLength ISimulationEnvironmentProvider::minRange(const CLength &range)
|
||||
@@ -170,23 +187,33 @@ namespace BlackMisc
|
||||
|
||||
CLength ISimulationEnvironmentProvider::getCG(const Aviation::CCallsign &callsign) const
|
||||
{
|
||||
if (callsign.isEmpty()) { return CLength::null(); }
|
||||
QReadLocker l(&m_lockCG);
|
||||
if (!m_cgs.contains(callsign)) { return CLength::null(); }
|
||||
return m_cgs.value(callsign);
|
||||
if (!m_cgsPerCallsign.contains(callsign)) { return CLength::null(); }
|
||||
return m_cgsPerCallsign.value(callsign);
|
||||
}
|
||||
|
||||
CLength ISimulationEnvironmentProvider::getCGPerModelString(const QString &modelString) const
|
||||
{
|
||||
if (modelString.isEmpty()) { return CLength::null(); }
|
||||
const QString ms = modelString.toLower();
|
||||
QReadLocker l(&m_lockCG);
|
||||
if (!m_cgsPerModel.contains(ms)) { return CLength::null(); }
|
||||
return m_cgsPerModel.value(ms);
|
||||
}
|
||||
|
||||
bool ISimulationEnvironmentProvider::hasCG(const Aviation::CCallsign &callsign) const
|
||||
{
|
||||
if (callsign.isEmpty()) { return false; }
|
||||
QReadLocker l(&m_lockCG);
|
||||
return m_cgs.contains(callsign);
|
||||
return m_cgsPerCallsign.contains(callsign);
|
||||
}
|
||||
|
||||
bool ISimulationEnvironmentProvider::hasSameCG(const CLength &cg, const CCallsign &callsign) const
|
||||
{
|
||||
if (callsign.isEmpty()) { return false; }
|
||||
QReadLocker l(&m_lockCG);
|
||||
return m_cgs[callsign] == cg;
|
||||
return m_cgsPerCallsign[callsign] == cg;
|
||||
}
|
||||
|
||||
int ISimulationEnvironmentProvider::setRememberMaxElevations(int max)
|
||||
@@ -262,7 +289,8 @@ namespace BlackMisc
|
||||
void ISimulationEnvironmentProvider::clearCGs()
|
||||
{
|
||||
QWriteLocker l(&m_lockCG);
|
||||
m_cgs.clear();
|
||||
m_cgsPerCallsign.clear();
|
||||
// intentionally not cleaning CGs per model, as models will not change, callsign do!
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::clearSimulationEnvironmentData()
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/geo/coordinategeodeticlist.h"
|
||||
#include "blackmisc/geo/elevationplane.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
|
||||
@@ -72,6 +71,10 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
PhysicalQuantities::CLength getCG(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Get CG per model string, NULL if not found
|
||||
//! \threadsafe
|
||||
PhysicalQuantities::CLength getCGPerModelString(const QString &modelString) const;
|
||||
|
||||
//! Has a CG?
|
||||
//! \threadsafe
|
||||
bool hasCG(const Aviation::CCallsign &callsign) const;
|
||||
@@ -153,6 +156,16 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
bool insertCG(const PhysicalQuantities::CLength &cg, const Aviation::CCallsign &cs);
|
||||
|
||||
//! Insert or replace a CG
|
||||
//! \remark passing a NULL value will remove the CG
|
||||
//! \threadsafe
|
||||
bool insertCG(const PhysicalQuantities::CLength &cg, const QString &modelString, const Aviation::CCallsign &cs);
|
||||
|
||||
//! Insert or replace a CG
|
||||
//! \remark passing a NULL value will remove the CG
|
||||
//! \threadsafe
|
||||
bool insertCGForModelString(const PhysicalQuantities::CLength &cg, const QString &modelString);
|
||||
|
||||
//! Remove a CG
|
||||
//! \threadsafe
|
||||
int removeCG(const Aviation::CCallsign &cs);
|
||||
@@ -162,15 +175,16 @@ namespace BlackMisc
|
||||
|
||||
private:
|
||||
CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
|
||||
QString m_simulatorName; //!< name of simulator
|
||||
QString m_simulatorDetails; //!< describes version etc.
|
||||
QString m_simulatorVersion; //!< Simulator version
|
||||
QString m_simulatorName; //!< name of simulator
|
||||
QString m_simulatorDetails; //!< describes version etc.
|
||||
QString m_simulatorVersion; //!< Simulator version
|
||||
CAircraftModel m_defaultModel; //!< default model
|
||||
int m_maxElevations = 100; //!< How many elevations we keep
|
||||
int m_maxElevations = 100; //!< How many elevations we keep
|
||||
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
|
||||
QHash<Aviation::CCallsign, PhysicalQuantities::CLength> m_cgsPerCallsign; //! CGs per callsign
|
||||
QHash<QString, PhysicalQuantities::CLength> m_cgsPerModel; //!< CGs per model string
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user