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:
Klaus Basan
2020-01-31 22:14:11 +01:00
committed by Mat Sutcliffe
parent e47dea2967
commit b4a7d59b7b
7 changed files with 200 additions and 17 deletions

View File

@@ -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()

View File

@@ -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();

View File

@@ -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>