Ref T423, changed strategy to force position updates

* force update for "some time", and remove all sent information
* no longer update some cycles, but for some time
* updated FSX/P3D/XPlane drivers
This commit is contained in:
Klaus Basan
2018-11-06 01:38:41 +01:00
parent f8efd19a3e
commit 64b0ec87b1
4 changed files with 43 additions and 5 deletions

View File

@@ -110,6 +110,11 @@ namespace BlackCore
return false;
}
void ISimulator::recalculateAllAircraft()
{
this->setUpdateAllRemoteAircraft();
}
void ISimulator::setWeatherActivated(bool activated)
{
m_isWeatherActivated = activated;
@@ -234,6 +239,26 @@ namespace BlackCore
this->clearAllRemoteAircraftData();
}
bool ISimulator::isUpdateAllRemoteAircraft(qint64 currentTimestamp) const
{
if (m_updateAllRemoteAircraftUntil < 1) { return false; }
if (currentTimestamp < 0) { currentTimestamp = QDateTime::currentMSecsSinceEpoch(); }
return (m_updateAllRemoteAircraftUntil > currentTimestamp);
}
void ISimulator::setUpdateAllRemoteAircraft(qint64 currentTimestamp, qint64 forMs)
{
if (currentTimestamp < 0) { currentTimestamp = QDateTime::currentMSecsSinceEpoch(); }
if (forMs < 0) { forMs = 10 * 1000; }
m_updateAllRemoteAircraftUntil = currentTimestamp + forMs;
this->resetLastSentValues();
}
void ISimulator::resetUpdateAllRemoteAircraft()
{
m_updateAllRemoteAircraftUntil = -1;
}
void ISimulator::resetHighlighting()
{
m_highlightedAircraft.clear();
@@ -783,7 +808,7 @@ namespace BlackCore
// now simulating
if (newStatus.testFlag(Simulating))
{
m_updateAllRemoteAircraftCycles = 10; // force an update of every remote aircraft
this->setUpdateAllRemoteAircraft(); // force an update of every remote aircraft
}
emit this->simulatorStatusChanged(newStatus); // only place where we should emit the signal, use emitSimulatorCombinedStatus to emit
@@ -1016,7 +1041,8 @@ namespace BlackCore
m_updateRemoteAircraftInProgress = false;
m_statsLastUpdateAircraftRequestedMs = startTime;
if (m_updateAllRemoteAircraftCycles > 0) { m_updateAllRemoteAircraftCycles--; }
if (!this->isUpdateAllRemoteAircraft(startTime)) { this->resetUpdateAllRemoteAircraft(); }
if (m_statsMaxUpdateTimeMs < dt) { m_statsMaxUpdateTimeMs = dt; }
if (m_statsLastUpdateAircraftRequestedMs > 0) { m_statsUpdateAircraftRequestedDeltaMs = startTime - m_statsLastUpdateAircraftRequestedMs; }
if (limited) { m_statsUpdateAircraftLimited++; }

View File

@@ -174,6 +174,9 @@ namespace BlackCore
//! Follow aircraft
virtual bool followAircraft(const BlackMisc::Aviation::CCallsign &callsign);
//! Recalculate all aircraft
virtual void recalculateAllAircraft();
//! Activates or deactivates simulator weather
virtual void setWeatherActivated(bool activated);
@@ -457,6 +460,15 @@ namespace BlackCore
//! \sa ISimulator::clearAllRemoteAircraftData
virtual void reset();
//! Do update all remote aircraft?
bool isUpdateAllRemoteAircraft(qint64 currentTimestamp = -1) const;
//! Update all aircraft for ms
void setUpdateAllRemoteAircraft(qint64 currentTimestamp = -1, qint64 forMs = -1);
//! Reset
void resetUpdateAllRemoteAircraft();
//! Reset highlighting
void resetHighlighting();
@@ -528,11 +540,11 @@ namespace BlackCore
bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold)
bool m_updateRemoteAircraftInProgress = false; //!< currently updating remote aircraft
int m_updateAllRemoteAircraftCycles = 0; //!< force an update of all remote aircraft, used when own aircraft is moved, paused to make sure all remote aircraft are updated
int m_timerId = -1; //!< dispatch timer id
int m_statsUpdateAircraftRuns = 0; //!< statistics update count
int m_statsUpdateAircraftLimited = 0; //!< skipped because of max.update limitations
double m_statsUpdateAircraftTimeAvgMs = 0; //!< statistics average update time
qint64 m_updateAllRemoteAircraftUntil = 0; //!< force an update of all remote aircraft, used when own aircraft is moved, paused to make sure all remote aircraft are updated
qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics total update time
qint64 m_statsCurrentUpdateTimeMs = 0; //!< statistics current update time
qint64 m_statsMaxUpdateTimeMs = 0; //!< statistics max.update time

View File

@@ -1741,7 +1741,7 @@ namespace BlackSimPlugin
int simObjectNumber = 0;
const bool traceSendId = this->isTracingSendId();
const bool updateAllAircraft = m_updateAllRemoteAircraftCycles > 0;
const bool updateAllAircraft = this->isUpdateAllRemoteAircraft(currentTimestamp);
for (const CSimConnectObject &simObject : simObjects)
{
// happening if aircraft is not yet added to simulator or to be deleted

View File

@@ -795,7 +795,7 @@ namespace BlackSimPlugin
PlanesTransponders planesTransponders;
int aircraftNumber = 0;
const bool updateAllAircraft = m_updateAllRemoteAircraftCycles > 0;
const bool updateAllAircraft = this->isUpdateAllRemoteAircraft(currentTimestamp);
for (const CXPlaneMPAircraft &xplaneAircraft : xplaneAircraftList)
{
const CCallsign callsign(xplaneAircraft.getCallsign());