Ref T259, Ref T243 access to last interpolated situation to check if near ground

This commit is contained in:
Klaus Basan
2018-03-29 00:49:46 +02:00
parent 9d484df5ed
commit 52dd7a754c
9 changed files with 53 additions and 6 deletions

View File

@@ -10,7 +10,7 @@
#include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/aircraftpartslist.h"
#include "blackmisc/geo/elevationplane.h"
#include "blackmisc/pq/physicalquantity.h"
#include "blackmisc/pq/length.h"
#include "blackmisc/pq/units.h"
#include "blackmisc/propertyindex.h"
#include "blackmisc/comparefunctions.h"
@@ -108,6 +108,18 @@ namespace BlackMisc
return small;
}
const CAircraftSituation &CAircraftSituation::null()
{
static const CAircraftSituation n;
return n;
}
const CLength &CAircraftSituation::defaultCG()
{
static const CLength cg(2.5, CLengthUnit::m());
return cg;
}
CVariant CAircraftSituation::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
@@ -412,7 +424,19 @@ namespace BlackMisc
bool CAircraftSituation::canLikelySkipNearGroundInterpolation() const
{
// those we can exclude
if (this->isOnGround() && this->hasInboundGroundInformation()) { return false; }
// cases where we can skip
if (this->isNull()) { return true; }
if (this->getGroundSpeed().value(CSpeedUnit::kts()) > 250) { return true; }
if (this->hasGroundElevation())
{
static const CLength threshold(400, CLengthUnit::m());
const CLength a = this->getHeightAboveGround();
if (!a.isNull() && a >= threshold) { return true; } // too high for ground
}
return false;
}

View File

@@ -327,6 +327,12 @@ namespace BlackMisc
//! Delta distance, near to ground
static const PhysicalQuantities::CLength &deltaNearGround();
//! Null situation
static const CAircraftSituation &null();
//! A default CG if not other value is available
static const PhysicalQuantities::CLength &defaultCG();
private:
CCallsign m_correspondingCallsign;
Geo::CCoordinateGeodetic m_position; //!< NULL position as default

View File

@@ -146,6 +146,12 @@ namespace BlackSimPlugin
return m_interpolator->getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
}
const CAircraftSituation &CSimConnectObject::getLastInterpolatedSituation() const
{
if (!m_interpolator) { return CAircraftSituation::null(); }
return m_interpolator->getLastInterpolatedSituation();
}
bool CSimConnectObjects::setSimConnectObjectIdForRequestId(DWORD requestId, DWORD objectId, bool resetSentParts)
{
// First check, if this request id belongs to us

View File

@@ -161,6 +161,9 @@ namespace BlackSimPlugin
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
BlackMisc::Simulation::CPartsStatus &partsStatus, bool log) const;
//! Last interpolated situation
const BlackMisc::Aviation::CAircraftSituation &getLastInterpolatedSituation() const;
//! Interpolator
BlackMisc::Simulation::CInterpolatorMulti *getInterpolator() const { return m_interpolator.data(); }

View File

@@ -485,6 +485,9 @@ namespace BlackSimPlugin
}
// CElevationPlane: deg, deg, feet
// we only remember near ground
if (simObject.getLastInterpolatedSituation().canLikelySkipNearGroundInterpolation()) { return; }
CElevationPlane elevation(remoteAircraftData.latitudeDeg, remoteAircraftData.longitudeDeg, remoteAircraftData.elevationFt);
elevation.setSinglePointRadius();
this->rememberElevationAndCG(simObject.getCallsign(), elevation, CLength(remoteAircraftData.cgToGroundFt, CLengthUnit::ft()));

View File

@@ -707,7 +707,7 @@ namespace BlackSimPlugin
// update situation
if (!xplaneAircraft.isSameAsSent(interpolatedSituation))
{
m_xplaneAircraftObjects[xplaneAircraft.getCallsign()].setPositionAsSent(interpolatedSituation);
m_xplaneAircraftObjects[xplaneAircraft.getCallsign()].setSituationAsSent(interpolatedSituation);
m_trafficProxy->setPlanePosition(interpolatedSituation.getCallsign().asString(),
interpolatedSituation.latitude().value(CAngleUnit::deg()),
interpolatedSituation.longitude().value(CAngleUnit::deg()),
@@ -784,8 +784,10 @@ namespace BlackSimPlugin
void CSimulatorXPlane::updateRemoteAircraftFromSimulator(const QString &callsign, double latitudeDeg, double longitudeDeg, double elevationMeters, double modelVerticalOffsetMeters)
{
// we skip if we are not near ground
const CCallsign cs(callsign);
if (!m_xplaneAircraftObjects.contains(cs)) { return; }
if (m_xplaneAircraftObjects[cs].getSituationAsSent().canLikelySkipNearGroundInterpolation()) { return; }
CElevationPlane elevation(CLatitude(latitudeDeg, CAngleUnit::deg()), CLongitude(longitudeDeg, CAngleUnit::deg()), CAltitude(elevationMeters, CLengthUnit::m()));
elevation.setSinglePointRadius();

View File

@@ -165,7 +165,7 @@ namespace BlackSimPlugin
CXSwiftBusWeatherProxy *m_weatherProxy { nullptr };
QTimer m_fastTimer;
QTimer m_slowTimer;
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft
BlackMisc::Aviation::CAirportList m_airportsInRange; //!< aiports in range of own aircraft
BlackMisc::CData<BlackMisc::Simulation::Data::TModelSetCacheXP> m_modelSet { this };
// Driver Interpolation

View File

@@ -32,7 +32,7 @@ namespace BlackSimPlugin
bool CXPlaneMPAircraft::isSameAsSent(const CAircraftSituation &position) const
{
return m_positionAsSent == position;
return m_situationAsSent == position;
}
void CXPlaneMPAircraft::toggleInterpolatorMode()

View File

@@ -55,8 +55,11 @@ namespace BlackSimPlugin
//! Parts as sent to simulator
void setPartsAsSent(const BlackMisc::Aviation::CAircraftParts &parts) { m_partsAsSent = parts; }
//! Situation as sent to simulator
const BlackMisc::Aviation::CAircraftSituation &getSituationAsSent() const { return m_situationAsSent; }
//! Position as sent
void setPositionAsSent(const BlackMisc::Aviation::CAircraftSituation &position) { m_positionAsSent = position; }
void setSituationAsSent(const BlackMisc::Aviation::CAircraftSituation &position) { m_situationAsSent = position; }
//! Same as sent
bool isSameAsSent(const BlackMisc::Aviation::CAircraftSituation &position) const;
@@ -94,7 +97,7 @@ namespace BlackSimPlugin
private:
BlackMisc::Simulation::CSimulatedAircraft m_aircraft; //!< corresponding aircraft
QSharedPointer<BlackMisc::Simulation::CInterpolatorMulti> m_interpolator; //!< shared pointer because CSimConnectObject can be copied
BlackMisc::Aviation::CAircraftSituation m_positionAsSent;
BlackMisc::Aviation::CAircraftSituation m_situationAsSent;
BlackMisc::Aviation::CAircraftParts m_partsAsSent;
};