mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
Ref T259, Ref T243 prefill provider situations, so interpolator can immediately start
This commit is contained in:
@@ -167,7 +167,14 @@ namespace BlackMisc
|
||||
// list from new to old
|
||||
QWriteLocker lock(&m_lockSituations);
|
||||
CAircraftSituationList &situationList = m_situationsByCallsign[situation.getCallsign()];
|
||||
situationList.push_frontKeepLatestFirstAdjustOffset(situation, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
if (situationList.isEmpty())
|
||||
{
|
||||
situationList.prefillLatestAdjustedFirst(situation, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
}
|
||||
else
|
||||
{
|
||||
situationList.push_frontKeepLatestFirstAdjustOffset(situation, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
}
|
||||
|
||||
// check sort order
|
||||
Q_ASSERT_X(situationList.isSortedAdjustedLatestFirst(), Q_FUNC_INFO, "wrong sort order");
|
||||
|
||||
@@ -377,6 +377,20 @@ namespace BlackMisc
|
||||
// 0: os 5 adj 5
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
void ITimestampWithOffsetObjectList<OBJ, CONTAINER>::prefillLatestAdjustedFirst(const OBJ &value, int elements, qint64 deltaTimeMs)
|
||||
{
|
||||
this->container().clear();
|
||||
const qint64 os = -1 * qAbs(deltaTimeMs < 0 ? value.getTimeOffsetMs() : deltaTimeMs);
|
||||
this->container().push_front(value);
|
||||
for (int i = 1; i < elements; i++)
|
||||
{
|
||||
OBJ copy(value);
|
||||
copy.addMsecs(os * i);
|
||||
this->container().push_back(copy);
|
||||
}
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
bool ITimestampWithOffsetObjectList<OBJ, CONTAINER>::isSortedAdjustedLatestLast() const
|
||||
{
|
||||
|
||||
@@ -147,6 +147,9 @@ namespace BlackMisc
|
||||
//! \remark adjust offset to average offset of two adjacent elements so adjusted values are sorted
|
||||
void push_frontKeepLatestFirstAdjustOffset(const OBJ &value, int maxElements = -1);
|
||||
|
||||
//! Prefill with elements
|
||||
void prefillLatestAdjustedFirst(const OBJ &value, int elements, qint64 deltaTimeMs = -1);
|
||||
|
||||
//! Is completely sorted: latest last
|
||||
//! \remark all object must have a valid timestamp
|
||||
bool isSortedAdjustedLatestLast() const;
|
||||
|
||||
Reference in New Issue
Block a user