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