mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-24 07:55:35 +08:00
refs #570 Each CAircraftSituation can have its own time offset, instead of a hardcoded 6 seconds.
This commit is contained in:
@@ -1113,6 +1113,12 @@ namespace BlackCore
|
||||
|
||||
// check sort order
|
||||
Q_ASSERT_X(l.size() < 2 || l[0].getMSecsSinceEpoch() >= l[1].getMSecsSinceEpoch(), Q_FUNC_INFO, "wrong sort order");
|
||||
|
||||
// a full position update received after an interim position update should use the time offset of the interim position
|
||||
if (l.size() >= 2 && (l[0].isInterim() || l[1].isInterim()))
|
||||
{
|
||||
l[0].setTimeOffsetMs(std::min(l[0].getTimeOffsetMs(), l[1].getTimeOffsetMs()));
|
||||
}
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::storeAircraftParts(const CCallsign &callsign, const CAircraftParts &parts)
|
||||
|
||||
@@ -745,7 +745,7 @@ namespace BlackCore
|
||||
void CNetworkVatlib::onPilotPositionUpdate(VatSessionID, const char *callsignChar , const VatPilotPosition *position, void *cbvar)
|
||||
{
|
||||
const CCallsign callsign(callsignChar, CCallsign::Aircraft);
|
||||
const CAircraftSituation situation(
|
||||
CAircraftSituation situation(
|
||||
callsign,
|
||||
CCoordinateGeodetic(position->latitude, position->longitude, 0.0),
|
||||
CAltitude(position->altitudeTrue, CAltitude::MeanSeaLevel, CLengthUnit::ft()),
|
||||
@@ -754,6 +754,7 @@ namespace BlackCore
|
||||
CAngle(position->bank, CAngleUnit::deg()),
|
||||
CSpeed(position->groundSpeed, CSpeedUnit::kts())
|
||||
);
|
||||
situation.setTimeOffsetMs(6000);
|
||||
|
||||
QString transponderName("transponder ");
|
||||
transponderName.append(callsign.asString());
|
||||
@@ -820,9 +821,8 @@ namespace BlackCore
|
||||
|
||||
void CNetworkVatlib::onInterimPilotPositionUpdate(VatSessionID, const char *sender, const VatInterimPilotPosition *position, void *cbvar)
|
||||
{
|
||||
const CCallsign callsign(sender);
|
||||
const CAircraftSituation situation(
|
||||
callsign,
|
||||
CAircraftSituation situation(
|
||||
CCallsign(sender),
|
||||
CCoordinateGeodetic(position->latitude, position->longitude, 0.0),
|
||||
CAltitude(position->altitudeTrue, CAltitude::MeanSeaLevel, CLengthUnit::ft()),
|
||||
CHeading(position->heading, CHeading::True, CAngleUnit::deg()),
|
||||
@@ -831,6 +831,8 @@ namespace BlackCore
|
||||
// There is no speed information in a interim packet
|
||||
CSpeed(0.0, CSpeedUnit::kts())
|
||||
);
|
||||
situation.setTimeOffsetMs(2000);
|
||||
situation.setInterimFlag(true);
|
||||
|
||||
emit cbvar_cast(cbvar)->aircraftInterimPositionUpdate(situation);
|
||||
}
|
||||
|
||||
@@ -154,6 +154,21 @@ namespace BlackMisc
|
||||
//! Corresponding callsign
|
||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Milliseconds to add to timestamp for interpolation
|
||||
void setTimeOffsetMs(qint64 offset) { this->m_timeOffsetMs = offset; }
|
||||
|
||||
//! Milliseconds to add to timestamp for interpolation
|
||||
qint64 getTimeOffsetMs() const { return this->m_timeOffsetMs; }
|
||||
|
||||
//! Timestamp with offset added for interpolation
|
||||
qint64 getAdjustedMSecsSinceEpoch() const { return this->getMSecsSinceEpoch() + this->getTimeOffsetMs(); }
|
||||
|
||||
//! Set flag indicating this is an interim position update
|
||||
void setInterimFlag(bool flag) { this->m_isInterim = flag; }
|
||||
|
||||
//! Get flag indicating this is an interim position update
|
||||
bool isInterim() const { return this->m_isInterim; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -165,6 +180,8 @@ namespace BlackMisc
|
||||
BlackMisc::PhysicalQuantities::CAngle m_pitch;
|
||||
BlackMisc::PhysicalQuantities::CAngle m_bank;
|
||||
BlackMisc::PhysicalQuantities::CSpeed m_groundSpeed;
|
||||
qint64 m_timeOffsetMs = 0;
|
||||
bool m_isInterim = false;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAircraftSituation,
|
||||
@@ -175,7 +192,9 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(pitch),
|
||||
BLACK_METAMEMBER(bank),
|
||||
BLACK_METAMEMBER(groundSpeed),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch)
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch),
|
||||
BLACK_METAMEMBER(timeOffsetMs),
|
||||
BLACK_METAMEMBER(isInterim)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user