mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
Ref T773, allow to "fake" elevations for testing purposes and improved elevation logging in the interpolation log. display
* history of requested elevations * bogus elevations for testing if needed (mostly to test the display)
This commit is contained in:
committed by
Mat Sutcliffe
parent
e47dea2967
commit
b4a7d59b7b
@@ -122,7 +122,7 @@ namespace BlackCore
|
||||
|
||||
bool ISimulator::followAircraft(const CCallsign &callsign)
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
Q_UNUSED(callsign)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1160,7 +1160,7 @@ namespace BlackCore
|
||||
|
||||
void ISimulator::onOwnModelChanged(const CAircraftModel &newModel)
|
||||
{
|
||||
Q_UNUSED(newModel);
|
||||
Q_UNUSED(newModel)
|
||||
// can be overridden
|
||||
}
|
||||
|
||||
@@ -1190,7 +1190,7 @@ namespace BlackCore
|
||||
const CLength radius = settings.getRecordedGndRadius().isNull() ? CElevationPlane::singlePointRadius() : settings.getRecordedGndRadius();
|
||||
const CElevationPlane ep(situation, radius);
|
||||
const bool remembered = this->rememberGroundElevation(cs, ep, radius);
|
||||
Q_UNUSED(remembered); // false means it was already in that cache, or something else is wrong
|
||||
Q_UNUSED(remembered) // false means it was already in that cache, or something else is wrong
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,10 +209,10 @@ namespace BlackCore
|
||||
//! Simulator running?
|
||||
virtual bool isSimulating() const { return this->isConnected(); }
|
||||
|
||||
//! Set test mode
|
||||
//! Set test mode (driver can skip code parts etc., driver dependent)
|
||||
void setTestMode(bool test) { m_test = test; }
|
||||
|
||||
//! Test mode?
|
||||
//! Test mode? (driver can skip code parts etc., driver dependent)
|
||||
bool isTestMode() const { return m_test; }
|
||||
|
||||
//! Average FPS (frames per second)
|
||||
@@ -230,6 +230,9 @@ namespace BlackCore
|
||||
//! Send situation/parts for testing
|
||||
virtual bool testSendSituationAndParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CAircraftParts &parts) = 0;
|
||||
|
||||
//! Enable pseudo elevations (testing)
|
||||
void setTestEnablePseudoElevation(bool enable) { m_enablePseudoElevation = enable; }
|
||||
|
||||
//! Debug function to check state after all aircraft have been removed
|
||||
//! \remarks only in local developer builds
|
||||
virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const;
|
||||
@@ -583,6 +586,7 @@ 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
|
||||
bool m_enablePseudoElevation = false; //!< return faked elevations (testing)
|
||||
int m_timerId = -1; //!< dispatch timer id
|
||||
int m_statsUpdateAircraftRuns = 0; //!< statistics update count
|
||||
int m_statsUpdateAircraftLimited = 0; //!< skipped because of max.update limitations
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include "blackmisc/timestampobjectlist.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
#include <QStringLiteral>
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Context;
|
||||
using namespace BlackGui::Views;
|
||||
@@ -44,7 +46,7 @@ namespace BlackGui
|
||||
ui->hs_UpdateTime->setValue(timeSecs);
|
||||
this->onSliderChanged(timeSecs);
|
||||
|
||||
CLedWidget::LedShape shape = CLedWidget::Rounded;
|
||||
const CLedWidget::LedShape shape = CLedWidget::Rounded;
|
||||
ui->led_Parts->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Parts received", "", 14);
|
||||
ui->led_Situation->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Situation received", "", 14);
|
||||
ui->led_Elevation->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Elevation received", "", 14);
|
||||
@@ -54,6 +56,14 @@ namespace BlackGui
|
||||
m_callsign = ui->comp_CallsignCompleter->getCallsign();
|
||||
ui->tvp_InboundAircraftSituations->setWithMenuRequestElevation(true);
|
||||
|
||||
m_elvHistoryModel = new QStringListModel(this);
|
||||
ui->lv_ElevevationHistory->setModel(m_elvHistoryModel);
|
||||
ui->lv_ElevevationHistory->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
|
||||
const int elvHistoryCount = 100;
|
||||
m_elvHistoryCount = elvHistoryCount;
|
||||
ui->le_ElvHistoryCount->setText(QString::number(elvHistoryCount));
|
||||
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CInterpolationLogDisplay::updateLog);
|
||||
connect(ui->comp_CallsignCompleter, &CCallsignCompleter::editingFinishedDigest, this, &CInterpolationLogDisplay::onCallsignEntered);
|
||||
connect(ui->hs_UpdateTime, &QSlider::valueChanged, this, &CInterpolationLogDisplay::onSliderChanged);
|
||||
@@ -66,9 +76,12 @@ namespace BlackGui
|
||||
connect(ui->pb_RequestElevation2, &QPushButton::released, this, &CInterpolationLogDisplay::requestElevationClicked);
|
||||
connect(ui->pb_GetLastInterpolation, &QPushButton::released, this, &CInterpolationLogDisplay::getLogAmdDisplayLastInterpolation);
|
||||
connect(ui->pb_InjectElevation, &QPushButton::released, this, &CInterpolationLogDisplay::onInjectElevation);
|
||||
connect(ui->pb_ElvClear, &QPushButton::released, this, &CInterpolationLogDisplay::clearElevationResults);
|
||||
connect(ui->tvp_InboundAircraftSituations, &CAircraftSituationView::requestElevation, this, &CInterpolationLogDisplay::requestElevation);
|
||||
connect(ui->le_InjectElevation, &QLineEdit::returnPressed, this, &CInterpolationLogDisplay::onInjectElevation);
|
||||
connect(ui->le_InjectElevation, &QLineEdit::returnPressed, this, &CInterpolationLogDisplay::onInjectElevation);
|
||||
connect(ui->le_ElvHistoryCount, &QLineEdit::editingFinished, this, &CInterpolationLogDisplay::onElevationHistoryCountFinished);
|
||||
connect(ui->editor_ElevationCoordinate, &CCoordinateForm::changedCoordinate, this, &CInterpolationLogDisplay::requestElevationAtPosition);
|
||||
connect(ui->cb_ElvAllowPseudo, &QCheckBox::toggled, this, &CInterpolationLogDisplay::onPseudoElevationToggled);
|
||||
connect(sGui, &CGuiApplication::aboutToShutdown, this, &CInterpolationLogDisplay::onAboutToShutdown, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
@@ -228,6 +241,12 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onPseudoElevationToggled(bool checked)
|
||||
{
|
||||
if (!m_simulator) { return; }
|
||||
m_simulator->setTestEnablePseudoElevation(checked);
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::toggleStartStop()
|
||||
{
|
||||
const bool running = m_updateTimer.isActive();
|
||||
@@ -240,7 +259,7 @@ namespace BlackGui
|
||||
if (m_callsign.isEmpty()) { return; }
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }
|
||||
|
||||
const QString cmd = QStringLiteral(".drv pos ") + m_callsign.asString();
|
||||
const QString cmd = QStringLiteral(".drv pos ") % m_callsign.asString();
|
||||
sGui->getIContextSimulator()->parseCommandLine(cmd, this->identifier());
|
||||
}
|
||||
|
||||
@@ -294,7 +313,7 @@ namespace BlackGui
|
||||
|
||||
void CInterpolationLogDisplay::onSimulatorStatusChanged(ISimulator::SimulatorStatus status)
|
||||
{
|
||||
Q_UNUSED(status);
|
||||
Q_UNUSED(status)
|
||||
m_updateTimer.stop();
|
||||
this->resetStatistics();
|
||||
}
|
||||
@@ -327,6 +346,23 @@ namespace BlackGui
|
||||
void CInterpolationLogDisplay::onElevationReceived(const CElevationPlane &elevationPlane, const CCallsign &callsign)
|
||||
{
|
||||
m_elvReceived++;
|
||||
|
||||
if (m_elvHistoryCount > 0)
|
||||
{
|
||||
const QString history = callsign.asString() %
|
||||
QStringLiteral(": ") % QTime::currentTime().toString("hh:mm:ss.zzz") %
|
||||
QStringLiteral(" ") % elevationPlane.toQString(true);
|
||||
m_elvHistoryModel->insertRow(0);
|
||||
const QModelIndex index = m_elvHistoryModel->index(0, 0);
|
||||
m_elvHistoryModel->setData(index, history);
|
||||
|
||||
const int c = m_elvHistoryModel->rowCount();
|
||||
if (m_elvHistoryCount < c)
|
||||
{
|
||||
m_elvHistoryModel->removeRows(m_elvHistoryCount, c - m_elvHistoryCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (callsign == CInterpolationLogDisplay::pseudoCallsignElevation())
|
||||
{
|
||||
this->displayArbitraryElevation(elevationPlane);
|
||||
@@ -364,6 +400,19 @@ namespace BlackGui
|
||||
m_simulator->callbackReceivedRequestedElevation(ep, m_callsign);
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::onElevationHistoryCountFinished()
|
||||
{
|
||||
const QString cs = ui->le_ElvHistoryCount->text().trimmed();
|
||||
int c = -1;
|
||||
if (!cs.isEmpty())
|
||||
{
|
||||
bool ok = false;
|
||||
const int cc = cs.toInt(&ok);
|
||||
if (ok) { c = cc; }
|
||||
}
|
||||
m_elvHistoryCount = c;
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::resetStatistics()
|
||||
{
|
||||
if (m_simulator) { m_simulator->resetAircraftStatistics(); }
|
||||
@@ -388,6 +437,17 @@ namespace BlackGui
|
||||
ui->le_Limited->clear();
|
||||
m_elvReceived = m_elvRequested = 0;
|
||||
m_lastInterpolations.clear();
|
||||
|
||||
this->clearElevationResults();
|
||||
}
|
||||
|
||||
void CInterpolationLogDisplay::clearElevationResults()
|
||||
{
|
||||
ui->pte_ElevationAtPosition->clear();
|
||||
if (m_elvHistoryModel)
|
||||
{
|
||||
m_elvHistoryModel->removeRows(0, m_elvHistoryModel->rowCount());
|
||||
}
|
||||
}
|
||||
|
||||
bool CInterpolationLogDisplay::checkLogPrerequisites()
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
|
||||
#include <QStringListModel>
|
||||
#include <QFrame>
|
||||
#include <QTimer>
|
||||
#include <QScopedPointer>
|
||||
@@ -84,6 +86,9 @@ namespace BlackGui
|
||||
//! Callsign has been changed
|
||||
void onCallsignEntered();
|
||||
|
||||
//! Use pseudo elevation
|
||||
void onPseudoElevationToggled(bool checked);
|
||||
|
||||
//! Toggle start/stop
|
||||
void toggleStartStop();
|
||||
|
||||
@@ -126,6 +131,9 @@ namespace BlackGui
|
||||
//! Call the callback of requested elevations as it would come from the simulator
|
||||
void onInjectElevation();
|
||||
|
||||
//! Entering a count failed
|
||||
void onElevationHistoryCountFinished();
|
||||
|
||||
//! \copydoc BlackCore::ISimulator::resetAircraftStatistics
|
||||
void resetStatistics();
|
||||
|
||||
@@ -135,6 +143,10 @@ namespace BlackGui
|
||||
//! Clear
|
||||
void clear();
|
||||
|
||||
//! Clear elevation results
|
||||
void clearElevationResults();
|
||||
|
||||
|
||||
//! Check if can do logging, otherwise stop and display message
|
||||
bool checkLogPrerequisites();
|
||||
|
||||
@@ -165,8 +177,10 @@ namespace BlackGui
|
||||
QPointer<BlackCore::CAirspaceMonitor> m_airspaceMonitor; //!< related airspace monitor
|
||||
BlackMisc::Aviation::CAircraftSituationList m_lastInterpolations; //!< list of last interpolations
|
||||
BlackMisc::Aviation::CCallsign m_callsign; //!< current callsign
|
||||
int m_elvRequested = 0; //!< counted via signal
|
||||
int m_elvReceived = 0; //!< counted via signal
|
||||
int m_elvRequested = 0; //!< counted via signal
|
||||
int m_elvReceived = 0; //!< counted via signal
|
||||
int m_elvHistoryCount = -1; //!< how many in history
|
||||
QStringListModel *m_elvHistoryModel = nullptr;
|
||||
|
||||
static const QString &startText();
|
||||
static const QString &stopText();
|
||||
|
||||
@@ -860,14 +860,89 @@
|
||||
<property name="title">
|
||||
<string>Result</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_ElevationAtPositionResult">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_Elevation" columnstretch="4,6">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPlainTextEdit" name="pte_ElevationAtPosition">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QListView" name="lv_ElevevationHistory"/>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QWidget" name="wi_ElvButtons" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="hs_Elevation">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_ElvClear">
|
||||
<property name="text">
|
||||
<string>clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_ElvHistory">
|
||||
<property name="text">
|
||||
<string>history</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_ElvHistoryCount">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_ElevationGap">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_ElvAllowPseudo">
|
||||
<property name="text">
|
||||
<string>fake elevation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/aviation/altitude.h"
|
||||
#include "blackmisc/math/mathutils.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QTimer>
|
||||
#include <QApplication>
|
||||
|
||||
using namespace BlackGui;
|
||||
@@ -19,6 +23,7 @@ using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Math;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
using namespace BlackMisc::Weather;
|
||||
@@ -204,6 +209,30 @@ namespace BlackSimPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign)
|
||||
{
|
||||
const bool hasRequested = CSimulatorPluginCommon::requestElevation(reference, callsign);
|
||||
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());
|
||||
CElevationPlane elv(reference, CElevationPlane::singlePointRadius());
|
||||
elv.setGeodeticHeight(alt);
|
||||
|
||||
QPointer<CSimulatorEmulated> myself(this);
|
||||
QTimer::singleShot(444, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
emit myself->receivedRequestedElevation(elv, callsign);
|
||||
});
|
||||
|
||||
emit this->requestedElevation(callsign);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimulatorEmulated::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
if (canLog()) { m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraftToHighlight.toQString(), boolToTrueFalse(enableHighlight), displayTime.toQString()); }
|
||||
@@ -348,8 +377,8 @@ namespace BlackSimPlugin
|
||||
// debugging/logging (just here for debugging purposes)
|
||||
const CAircraftModel networkModel = remoteAircraft.getNetworkModel();
|
||||
const CAircraftModel currentModel = remoteAircraft.getModel();
|
||||
Q_UNUSED(networkModel);
|
||||
Q_UNUSED(currentModel);
|
||||
Q_UNUSED(networkModel)
|
||||
Q_UNUSED(currentModel)
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -513,8 +542,8 @@ namespace BlackSimPlugin
|
||||
const CAircraftParts p = result;
|
||||
m_countInterpolatedParts++;
|
||||
m_countInterpolatedSituations++;
|
||||
Q_UNUSED(s);
|
||||
Q_UNUSED(p);
|
||||
Q_UNUSED(s)
|
||||
Q_UNUSED(p)
|
||||
}
|
||||
|
||||
this->finishUpdateRemoteAircraftAndSetStatistics(now);
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace BlackSimPlugin
|
||||
virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const override;
|
||||
virtual BlackMisc::CStatusMessageList getInterpolationMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual bool testSendSituationAndParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CAircraftParts &parts) override;
|
||||
virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
// ----- functions just logged -------
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
|
||||
Reference in New Issue
Block a user