mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Ref T260, remember timestamp for last situation changed
* skip ground elevation updates if not near ground * function no longer const * renamings
This commit is contained in:
committed by
Roland Winklmeier
parent
94a334ad75
commit
302411e056
@@ -19,11 +19,13 @@
|
||||
#include "blackmisc/range.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QList>
|
||||
#include <array>
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Math;
|
||||
@@ -90,7 +92,7 @@ namespace BlackMisc
|
||||
CInterpolatorLinear::Interpolant CInterpolatorLinear::getInterpolant(
|
||||
qint64 currentTimeMsSinceEpoc,
|
||||
const CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
CInterpolationStatus &status, SituationLog &log) const
|
||||
CInterpolationStatus &status, SituationLog &log)
|
||||
{
|
||||
Q_UNUSED(setup);
|
||||
status.reset();
|
||||
@@ -98,8 +100,14 @@ namespace BlackMisc
|
||||
// with the latest updates of T243 the order and the offsets are supposed to be correct
|
||||
// so even mixing fast/slow updates shall work
|
||||
const CAircraftSituationList validSituations = this->remoteAircraftSituations(m_callsign); // if needed, we could also copy here
|
||||
BLACK_VERIFY_X(validSituations.isSortedAdjustedLatestFirst(), Q_FUNC_INFO, "Wrong sort order");
|
||||
Q_ASSERT_X(validSituations.size() <= IRemoteAircraftProvider::MaxSituationsPerCallsign, Q_FUNC_INFO, "Wrong size");
|
||||
m_situationsLastModifiedUsed = this->situationsLastModified(m_callsign);
|
||||
|
||||
// checks
|
||||
if (!CBuildConfig::isReleaseBuild())
|
||||
{
|
||||
BLACK_VERIFY_X(validSituations.isSortedAdjustedLatestFirst(), Q_FUNC_INFO, "Wrong sort order");
|
||||
Q_ASSERT_X(validSituations.size() <= IRemoteAircraftProvider::MaxSituationsPerCallsign, Q_FUNC_INFO, "Wrong size");
|
||||
}
|
||||
|
||||
// find the first situation earlier than the current time
|
||||
const auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto &&s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });
|
||||
@@ -150,17 +158,22 @@ namespace BlackMisc
|
||||
Q_ASSERT(oldSituation.getAdjustedMSecsSinceEpoch() < newSituation.getAdjustedMSecsSinceEpoch());
|
||||
}
|
||||
|
||||
// take hint into account to calculate elevation and above ground level
|
||||
// do not call for XP (lazy init)
|
||||
const CElevationPlane planeOld = this->findClosestElevationWithinRange(oldSituation, CElevationPlane::singlePointRadius());
|
||||
const CElevationPlane planeNew = this->findClosestElevationWithinRange(newSituation, CElevationPlane::singlePointRadius());
|
||||
oldSituation.setGroundElevationChecked(planeOld);
|
||||
newSituation.setGroundElevationChecked(planeNew);
|
||||
// adjust ground if required
|
||||
if (!oldSituation.canLikelySkipNearGroundInterpolation() && !oldSituation.hasGroundElevation())
|
||||
{
|
||||
const CElevationPlane planeOld = this->findClosestElevationWithinRange(oldSituation, CElevationPlane::singlePointRadius());
|
||||
oldSituation.setGroundElevationChecked(planeOld);
|
||||
}
|
||||
if (!newSituation.canLikelySkipNearGroundInterpolation() && !newSituation.hasGroundElevation())
|
||||
{
|
||||
const CElevationPlane planeNew = this->findClosestElevationWithinRange(newSituation, CElevationPlane::singlePointRadius());
|
||||
newSituation.setGroundElevationChecked(planeNew);
|
||||
}
|
||||
|
||||
CAircraftSituation currentSituation(oldSituation); // also sets ground elevation if available
|
||||
|
||||
// Time between start and end packet
|
||||
const double sampleDeltaTimeMs = newSituation.getAdjustedMSecsSinceEpoch() - oldSituation.getAdjustedMSecsSinceEpoch();
|
||||
const qint64 sampleDeltaTimeMs = newSituation.getAdjustedMSecsSinceEpoch() - oldSituation.getAdjustedMSecsSinceEpoch();
|
||||
Q_ASSERT_X(sampleDeltaTimeMs >= 0, Q_FUNC_INFO, "Negative delta time");
|
||||
log.interpolator = 'l';
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace BlackMisc
|
||||
public:
|
||||
//! Constructor
|
||||
CInterpolatorLinear(const Aviation::CCallsign &callsign,
|
||||
ISimulationEnvironmentProvider *p1, IInterpolationSetupProvider *p2, IRemoteAircraftProvider *p3,
|
||||
ISimulationEnvironmentProvider *simEnvProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
CInterpolationLogger *logger = nullptr) :
|
||||
CInterpolator(callsign, p1, p2, p3, logger) {}
|
||||
CInterpolator(callsign, simEnvProvider, setupProvider, remoteAircraftProvider, logger) {}
|
||||
|
||||
//! Linear function that performs the actual interpolation
|
||||
class Interpolant
|
||||
@@ -71,7 +71,7 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Get the interpolant for the given time point
|
||||
Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, CInterpolationStatus &status, SituationLog &log) const;
|
||||
Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, CInterpolationStatus &status, SituationLog &log);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -345,9 +345,12 @@ namespace BlackMisc
|
||||
CAircraftSituationList situations = this->remoteAircraftSituations(callsign);
|
||||
const int updated = situations.setGroundElevationChecked(elevation);
|
||||
if (updated < 1) { return false; }
|
||||
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
{
|
||||
QWriteLocker l(&m_lockSituations);
|
||||
m_situationsByCallsign[callsign] = situations;
|
||||
m_situationsLastModified[callsign] = ts;
|
||||
}
|
||||
|
||||
// aircraft updates
|
||||
|
||||
Reference in New Issue
Block a user