diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index 20f4becd5..3496201c0 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -233,6 +233,9 @@ namespace BlackCore //! Enable pseudo elevations (testing) void setTestEnablePseudoElevation(bool enable) { m_enablePseudoElevation = enable; } + //! Set an elevation for testing + void setTestElevation(const BlackMisc::Aviation::CAltitude &altitude) { m_pseudoElevation = altitude; } + //! Debug function to check state after all aircraft have been removed //! \remarks only in local developer builds virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const; @@ -603,6 +606,7 @@ namespace BlackCore qint64 m_statsLastUpdateAircraftRequestedMs = 0; //!< when was the last aircraft update requested qint64 m_statsUpdateAircraftRequestedDeltaMs = 0; //!< delta time between 2 aircraft updates + BlackMisc::Aviation::CAltitude m_pseudoElevation { BlackMisc::Aviation::CAltitude::null() }; //!< pseudo elevation for testing purposes BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup read from the sim BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log.interpolation BlackMisc::Simulation::CAutoPublishData m_autoPublishing; //!< for the DB diff --git a/src/blackgui/components/interpolationlogdisplay.cpp b/src/blackgui/components/interpolationlogdisplay.cpp index c6217e84d..77adc819c 100644 --- a/src/blackgui/components/interpolationlogdisplay.cpp +++ b/src/blackgui/components/interpolationlogdisplay.cpp @@ -245,6 +245,19 @@ namespace BlackGui { if (!m_simulator) { return; } m_simulator->setTestEnablePseudoElevation(checked); + + CAltitude elvTest = CAltitude::null(); + if (!ui->le_ElevationTestValue->text().isEmpty()) + { + CLength l; + const QString v = ui->le_ElevationTestValue->text(); + l.parseFromString(v); + if (!l.isNull()) + { + elvTest = CAltitude(l, CAltitude::MeanSeaLevel); + } + } + m_simulator->setTestElevation(elvTest); } void CInterpolationLogDisplay::toggleStartStop() diff --git a/src/blackgui/components/interpolationlogdisplay.ui b/src/blackgui/components/interpolationlogdisplay.ui index a4916064d..47aa7ef11 100644 --- a/src/blackgui/components/interpolationlogdisplay.ui +++ b/src/blackgui/components/interpolationlogdisplay.ui @@ -877,9 +877,16 @@ - + + + + + Elevation: + + + @@ -895,6 +902,12 @@ + + + 100 + 0 + + clear @@ -911,7 +924,7 @@ - 100 + 75 16777215 @@ -946,16 +959,16 @@ + + + + elv. test value + + + - - - - Elevation for coordinates: - - - diff --git a/src/plugins/simulator/emulated/simulatoremulated.cpp b/src/plugins/simulator/emulated/simulatoremulated.cpp index 5c33a5041..a94027f93 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.cpp +++ b/src/plugins/simulator/emulated/simulatoremulated.cpp @@ -215,17 +215,31 @@ namespace BlackSimPlugin if (hasRequested || !m_enablePseudoElevation) { return hasRequested; } // For TESTING purposes ONLY - // we could not request elevation - // very crude 1st implementation - const double elvRnd = CMathUtils::randomDouble(1000); - const CAltitude alt(elvRnd, CLengthUnit::ft()); + // we could not request elevation, so we provide a random value or set value CElevationPlane elv(reference, CElevationPlane::singlePointRadius()); - elv.setGeodeticHeight(alt); + if (m_pseudoElevation.isNull()) + { + const double elvRnd = CMathUtils::randomDouble(1000); + const CAltitude alt(elvRnd, CLengthUnit::ft()); + elv.setGeodeticHeight(alt); + } + else + { + elv.setGeodeticHeight(m_pseudoElevation); + } QPointer myself(this); QTimer::singleShot(444, this, [ = ] { if (!myself) { return; } + + // update in simulator + ISimulationEnvironmentProvider::rememberGroundElevation(callsign, elv); // in simulator + + // and in remote aircraft for given callsign + const int updated = CRemoteAircraftAware::updateAircraftGroundElevation(callsign, elv, CAircraftSituation::FromProvider); + Q_UNUSED(updated) + emit myself->receivedRequestedElevation(elv, callsign); });