mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T261, provider support for CG/elevation update
This commit is contained in:
committed by
Roland Winklmeier
parent
c7d11975f0
commit
adeea182da
@@ -12,16 +12,30 @@
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/json.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Json;
|
||||
using namespace BlackConfig;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
CAircraftSituationChange IRemoteAircraftProvider::remoteAircraftSituationChange(const CCallsign &callsign) const
|
||||
{
|
||||
const CAircraftSituationList situations(this->remoteAircraftSituations(callsign));
|
||||
if (situations.isEmpty()) { return CAircraftSituationChange::null(); }
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
Q_ASSERT_X(situations.isSortedAdjustedLatestFirstWithoutNullPositions(), Q_FUNC_INFO, "Expect latest first");
|
||||
}
|
||||
const CAircraftSituationChange change = CAircraftSituationChange(situations, true, true);
|
||||
return change;
|
||||
}
|
||||
|
||||
const CLogCategoryList &CRemoteAircraftProvider::getLogCategories()
|
||||
{
|
||||
static const CLogCategoryList cats { CLogCategory::matching(), CLogCategory::network() };
|
||||
@@ -182,21 +196,28 @@ namespace BlackMisc
|
||||
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
// for testing only
|
||||
CAircraftSituation situationOs(situation);
|
||||
this->testAddAltitudeOffsetToSituation(situationOs);
|
||||
CAircraftSituation situationOffset(situation);
|
||||
this->testAddAltitudeOffsetToSituation(situationOffset);
|
||||
|
||||
// verify
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
BLACK_VERIFY_X(situation.getTimeOffsetMs() > 0, Q_FUNC_INFO, "Missing offset");
|
||||
}
|
||||
|
||||
// list from new to old
|
||||
QWriteLocker lock(&m_lockSituations);
|
||||
m_situationsAdded++;
|
||||
m_situationsLastModified[cs] = ts;
|
||||
CAircraftSituationList &situationList = m_situationsByCallsign[cs];
|
||||
if (situationList.isEmpty())
|
||||
const int situations = situationList.size();
|
||||
if (situations < 1)
|
||||
{
|
||||
situationList.prefillLatestAdjustedFirst(situationOs, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
situationList.prefillLatestAdjustedFirst(situationOffset, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
}
|
||||
else
|
||||
{
|
||||
situationList.push_frontKeepLatestFirstAdjustOffset(situationOs, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
situationList.push_frontKeepLatestFirstAdjustOffset(situationOffset, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
}
|
||||
|
||||
// unify all inbound ground information
|
||||
@@ -206,8 +227,11 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
// check sort order
|
||||
Q_ASSERT_X(situationList.isSortedAdjustedLatestFirst(), Q_FUNC_INFO, "wrong sort order");
|
||||
Q_ASSERT_X(situationList.size() <= IRemoteAircraftProvider::MaxSituationsPerCallsign, Q_FUNC_INFO, "Wrong size");
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
BLACK_VERIFY_X(situationList.isSortedAdjustedLatestFirstWithoutNullPositions(), Q_FUNC_INFO, "wrong sort order");
|
||||
BLACK_VERIFY_X(situationList.size() <= IRemoteAircraftProvider::MaxSituationsPerCallsign, Q_FUNC_INFO, "Wrong size");
|
||||
}
|
||||
}
|
||||
|
||||
void CRemoteAircraftProvider::storeAircraftParts(const CCallsign &callsign, const CAircraftParts &parts, bool removeOutdated)
|
||||
@@ -356,23 +380,17 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
int CRemoteAircraftProvider::updateAircraftGroundElevation(const CCallsign &callsign, const CElevationPlane &elevation)
|
||||
{
|
||||
return this->updateAircraftGroundElevationExt(callsign, elevation, false, CLength::null(), false);
|
||||
}
|
||||
|
||||
int CRemoteAircraftProvider::updateAircraftGroundElevationExt(const CCallsign &callsign, const CElevationPlane &elevation, bool isVtol, const CLength &cg, bool autoGuessGnd)
|
||||
{
|
||||
if (!this->isAircraftInRange(callsign)) { return 0; }
|
||||
|
||||
// update aircraft situation
|
||||
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
|
||||
const CAircraftModel model = this->getAircraftInRangeModelForCallsign(callsign);
|
||||
int updated = 0;
|
||||
{
|
||||
QWriteLocker l(&m_lockSituations);
|
||||
CAircraftSituationList situations = m_situationsByCallsign[callsign];
|
||||
updated = autoGuessGnd ?
|
||||
situations.setGroundElevationCheckedAndGuessGround(elevation, isVtol, cg) :
|
||||
situations.setGroundElevationChecked(elevation);
|
||||
CAircraftSituationList &situations = m_situationsByCallsign[callsign];
|
||||
updated = situations.setGroundElevationCheckedAndGuessGround(elevation, model);
|
||||
if (updated < 1) { return 0; }
|
||||
m_situationsLastModified[callsign] = ts;
|
||||
}
|
||||
@@ -385,6 +403,13 @@ namespace BlackMisc
|
||||
return updated; // updated situations
|
||||
}
|
||||
|
||||
bool CRemoteAircraftProvider::updateCG(const CCallsign &callsign, const CLength &cg)
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
const int c = m_aircraftInRange.setCG(callsign, cg);
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
void CRemoteAircraftProvider::updateMarkAllAsNotRendered()
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
@@ -628,6 +653,12 @@ namespace BlackMisc
|
||||
return this->provider()->remoteAircraftSituations(callsign);
|
||||
}
|
||||
|
||||
CAircraftSituationChange CRemoteAircraftAware::remoteAircraftSituationChange(const CCallsign &callsign) const
|
||||
{
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
return this->provider()->remoteAircraftSituationChange(callsign);
|
||||
}
|
||||
|
||||
CAircraftPartsList CRemoteAircraftAware::remoteAircraftParts(const CCallsign &callsign, qint64 cutoffTimeBefore) const
|
||||
{
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationchange.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
@@ -105,6 +106,10 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
virtual int remoteAircraftPartsCount(const Aviation::CCallsign &callsign, qint64 cutoffTimeBefore = -1) const = 0;
|
||||
|
||||
//! Get the change object for callsign
|
||||
//! \threadsafe
|
||||
Aviation::CAircraftSituationChange remoteAircraftSituationChange(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Is remote aircraft supporting parts?
|
||||
//! \threadsafe
|
||||
virtual bool isRemoteAircraftSupportingParts(const Aviation::CCallsign &callsign) const = 0;
|
||||
@@ -149,6 +154,10 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation) = 0;
|
||||
|
||||
//! Update the CG
|
||||
//! \threadsafe
|
||||
virtual bool updateCG(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg) = 0;
|
||||
|
||||
//! Get reverse lookup meesages
|
||||
//! \threadsafe
|
||||
virtual CStatusMessageList getReverseLookupMessages(const Aviation::CCallsign &callsign) const = 0;
|
||||
@@ -253,6 +262,7 @@ namespace BlackMisc
|
||||
virtual bool updateFastPositionEnabled(const Aviation::CCallsign &callsign, bool enableFastPositonUpdates) override;
|
||||
virtual bool updateAircraftRendered(const Aviation::CCallsign &callsign, bool rendered) override;
|
||||
virtual int updateAircraftGroundElevation(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation) override;
|
||||
virtual bool updateCG(const Aviation::CCallsign &callsign, const PhysicalQuantities::CLength &cg) override;
|
||||
virtual void updateMarkAllAsNotRendered() override;
|
||||
virtual CStatusMessageList getAircraftPartsHistory(const Aviation::CCallsign &callsign) const override;
|
||||
virtual bool isAircraftPartsHistoryEnabled() const override;
|
||||
@@ -356,10 +366,6 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
void storeAircraftSituation(const Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! An extended of IRemoteAircraftProvider::updateAircraftGroundElevation version which allows also guessing of ground
|
||||
//! \sa IRemoteAircraftProvider::updateAircraftGroundElevation
|
||||
int updateAircraftGroundElevationExt(const Aviation::CCallsign &callsign, const Geo::CElevationPlane &elevation, bool isVtol, const PhysicalQuantities::CLength &cg, bool autoGuessGnd);
|
||||
|
||||
//! Store an aircraft part
|
||||
//! \remark latest parts are kept first
|
||||
//! \threadsafe
|
||||
@@ -437,6 +443,9 @@ namespace BlackMisc
|
||||
//! \copydoc IRemoteAircraftProvider::remoteAircraftPartsCount
|
||||
int remoteAircraftPartsCount(const Aviation::CCallsign &callsign, qint64 cutoffTimeBefore = -1) const;
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::remoteAircraftSituationChange
|
||||
Aviation::CAircraftSituationChange remoteAircraftSituationChange(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc IRemoteAircraftProvider::remoteAircraftSupportingParts
|
||||
Aviation::CCallsignSet remoteAircraftSupportingParts() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user