mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Improved samples and debugging information
* DBus test for CSimulatedAircraft * Output of metatypes in GUI/core * Changed output from qDebug() to QTextStream * Variant test for CSimulatedAircraft
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include <QMetaType>
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -26,14 +27,16 @@ namespace BlackMiscTest
|
||||
*/
|
||||
int CSamplesMetadata::samples()
|
||||
{
|
||||
int argv = 0;
|
||||
QTextStream cin(stdin);
|
||||
|
||||
QTextStream cout(stdout);
|
||||
QGuiApplication dummy(argv, nullptr); // otherwise no QPixmap metadata
|
||||
Q_UNUSED(dummy);
|
||||
BlackMisc::registerMetadata();
|
||||
BlackMisc::displayAllUserMetatypesTypes();
|
||||
BlackMisc::displayAllUserMetatypesTypes(cout);
|
||||
|
||||
cin.readLine();
|
||||
qDebug() << "------- Enter --------";
|
||||
|
||||
cout << "------- Enter --------" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/pqallquantities.h"
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
@@ -18,6 +19,8 @@
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
@@ -32,12 +35,16 @@ namespace BlackMiscTest
|
||||
|
||||
CHeading h1(45, CHeading::True, CAngleUnit::deg());
|
||||
CHeading h2(60, CHeading::True, CAngleUnit::deg());
|
||||
|
||||
CVariant cvh = h1.toCVariant();
|
||||
qDebug() << h1 << cvh.userType();
|
||||
|
||||
qDebug() << cva << cvh; // CVariant knows how to stringify the contained value object
|
||||
CSimulatedAircraft sa(CAircraft("FOO", CUser("123", "Joe Doe"), CAircraftSituation()));
|
||||
CVariant cvsa = sa.toCVariant();
|
||||
qDebug() << sa << cvsa.userType();
|
||||
|
||||
qDebug() << cva << cvh << cvsa; // CVariant knows how to stringify the contained value object
|
||||
|
||||
// from variant
|
||||
CAngle *ap_heading = &h1; // angle actually heading
|
||||
CAngle *ap_angle = &a1; // angle really heading
|
||||
qDebug() << (*ap_heading) << ap_heading->toCVariant().userType();
|
||||
@@ -51,6 +58,15 @@ namespace BlackMiscTest
|
||||
ap_angle->convertFromCVariant(a1.toCVariant());
|
||||
qDebug() << (*ap_angle) << ap_angle->toCVariant().userType();
|
||||
|
||||
// Sim aircraft
|
||||
CAircraft a;
|
||||
sa.convertFromCVariant(cvsa);
|
||||
a.convertFromCVariant(cvsa);
|
||||
qDebug() << sa << a;
|
||||
|
||||
qDebug() << "--";
|
||||
qDebug() << "Expected 2xASSERT";
|
||||
|
||||
// This gives me an unwanted(!) assert, canConvert is not smart enough to detect upcasting
|
||||
// because CValueObjects are not QObjects
|
||||
ap_angle->convertFromCVariant(h2.toCVariant());
|
||||
|
||||
@@ -379,6 +379,13 @@ namespace BlackMiscTest
|
||||
qDebug() << "Pinged aircraft via interface"
|
||||
<< ((aircraft == aircraftReceived) ? "OK" : "ERROR!") << aircraftReceived;
|
||||
|
||||
CSimulatedAircraft simAircraft(aircraft);
|
||||
CAircraftModel model("foobar", CAircraftModel::TypeModelMapping);
|
||||
simAircraft.setModel(model);
|
||||
CSimulatedAircraft simAircraftReceived = testserviceInterface.pingSimulatedAircraft(simAircraft);
|
||||
qDebug() << "Pinged simulated aircraft via interface"
|
||||
<< ((simAircraft == simAircraftReceived) ? "OK" : "ERROR!") << simAircraftReceived;
|
||||
|
||||
CAtcStationList atcStationList;
|
||||
atcStationList.push_back(station);
|
||||
atcStationList.push_back(station);
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace BlackMiscTest
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping aircrafts
|
||||
* Ping aircraft
|
||||
*/
|
||||
CAircraftList Testservice::pingAircraftList(const CAircraftList &aircraftList)
|
||||
{
|
||||
@@ -326,6 +326,15 @@ namespace BlackMiscTest
|
||||
return aircraft;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping simulated aircraft
|
||||
*/
|
||||
Simulation::CSimulatedAircraft Testservice::pingSimulatedAircraft(const Simulation::CSimulatedAircraft &aircraft)
|
||||
{
|
||||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping simulated aircraft:" << aircraft;
|
||||
return aircraft;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping variant
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "blackmisc/avallclasses.h"
|
||||
#include "blackmisc/networkallclasses.h"
|
||||
#include "blackmisc/pqallquantities.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/mathallclasses.h"
|
||||
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||
#include "servicetool.h"
|
||||
@@ -105,10 +106,7 @@ namespace BlackMiscTest
|
||||
//! Receive speed
|
||||
BlackMisc::PhysicalQuantities::CSpeed pingSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed);
|
||||
|
||||
/*!
|
||||
//! Receive altitude
|
||||
* \param comUnit
|
||||
*/
|
||||
BlackMisc::Aviation::CAltitude pingAltitude(const BlackMisc::Aviation::CAltitude &altitude);
|
||||
|
||||
//! Ping ATC station
|
||||
@@ -117,6 +115,9 @@ namespace BlackMiscTest
|
||||
//! Ping aircraft
|
||||
BlackMisc::Aviation::CAircraft pingAircraft(const BlackMisc::Aviation::CAircraft &aircraft);
|
||||
|
||||
//! Ping simulated aircraft
|
||||
BlackMisc::Simulation::CSimulatedAircraft pingSimulatedAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Ping ATC list
|
||||
BlackMisc::Aviation::CAtcStationList pingAtcStationList(const BlackMisc::Aviation::CAtcStationList &atcStationList) const;
|
||||
|
||||
|
||||
@@ -102,6 +102,13 @@ namespace BlackMiscTest
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAircraft"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Simulation::CSimulatedAircraft> pingSimulatedAircraft(BlackMisc::Simulation::CSimulatedAircraft aircraft)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(aircraft);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingSimulatedAircraft"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStationList> pingAtcStationList(BlackMisc::Aviation::CAtcStationList atcStationList)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
|
||||
@@ -333,13 +333,15 @@ size_t BlackMisc::heapSizeOf(const QMetaObject &)
|
||||
/*
|
||||
* Dump all user types
|
||||
*/
|
||||
void BlackMisc::displayAllUserMetatypesTypes()
|
||||
void BlackMisc::displayAllUserMetatypesTypes(QTextStream &out)
|
||||
{
|
||||
|
||||
for (int mt = QMetaType::User; mt < QMetaType::User + 1000; mt++)
|
||||
{
|
||||
if (!QMetaType::isRegistered(mt)) continue;
|
||||
if (!QMetaType::isRegistered(mt)) { continue; }
|
||||
QMetaType metaType(mt);
|
||||
qDebug() << "type:" << mt << "name:" << QMetaType::typeName(mt) << QMetaType::sizeOf(mt) << BlackMisc::heapSizeOf(metaType);
|
||||
out << "type: " << mt << " name:" << QMetaType::typeName(mt) << " | "
|
||||
<< QMetaType::sizeOf(mt) << " / " << BlackMisc::heapSizeOf(metaType) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
#include <QMetaType>
|
||||
#include <QDBusArgument>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -145,9 +147,9 @@ namespace BlackMisc
|
||||
*/
|
||||
QVariant complexQtTypeFromDbusArgument(const QDBusArgument &argument, int type);
|
||||
|
||||
//! brief Display all user metatypes
|
||||
//! Display all user metatypes
|
||||
//! \remarks Used in order to debug code, do not remove
|
||||
void displayAllUserMetatypesTypes();
|
||||
void displayAllUserMetatypesTypes(QTextStream &out = QTextStream(stdout));
|
||||
|
||||
/*!
|
||||
* \brief Calculate a single hash value based on a list of individual hash values
|
||||
|
||||
@@ -500,19 +500,18 @@ namespace BlackSound
|
||||
if (removeFileAfterPlaying) BlackMisc::CFileDeleter::addFileForDeletion(file);
|
||||
}
|
||||
|
||||
void CSoundGenerator::printAllQtSoundDevices()
|
||||
void CSoundGenerator::printAllQtSoundDevices(QTextStream &out)
|
||||
{
|
||||
QTextStream qtout(stdout);
|
||||
qtout << "output" << endl;
|
||||
out << "output:" << endl;
|
||||
foreach(QAudioDeviceInfo qd, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
|
||||
{
|
||||
qtout << qd.deviceName() << endl;
|
||||
out << qd.deviceName() << endl;
|
||||
}
|
||||
|
||||
qtout << "input" << endl;
|
||||
out << "input:" << endl;
|
||||
foreach(QAudioDeviceInfo qd, QAudioDeviceInfo::availableDevices(QAudio::AudioInput))
|
||||
{
|
||||
qtout << qd.deviceName() << endl;
|
||||
out << qd.deviceName() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace BlackSound
|
||||
static void playNotificationSound(qint32 volume, CNotificationSounds::Notification notification);
|
||||
|
||||
//! For debugging purposes
|
||||
void static printAllQtSoundDevices();
|
||||
void static printAllQtSoundDevices(QTextStream &qtout = QTextStream(stdout));
|
||||
|
||||
signals:
|
||||
/*!
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace BlackMiscTest
|
||||
{
|
||||
qtout << "-------------" << endl;
|
||||
qtout << "Qt audio devices" << endl;
|
||||
BlackSound::CSoundGenerator::printAllQtSoundDevices();
|
||||
BlackSound::CSoundGenerator::printAllQtSoundDevices(qtout);
|
||||
}
|
||||
else if (line.startsWith("level"))
|
||||
{
|
||||
@@ -105,6 +105,10 @@ namespace BlackMiscTest
|
||||
refreshSubscriptionSeverities();
|
||||
qtout << "Changed level to " << CStatusMessage::severityToString(messageSeverity) << endl;
|
||||
}
|
||||
else if (line.startsWith("meta"))
|
||||
{
|
||||
BlackMisc::displayAllUserMetatypesTypes(qtout);
|
||||
}
|
||||
else if (line.startsWith("log"))
|
||||
{
|
||||
line.replace("log", "");
|
||||
@@ -124,7 +128,8 @@ namespace BlackMiscTest
|
||||
qtout << " log + context + [e]nabled / [d]isabled" << endl;
|
||||
qtout << " contexts: app / aud / net / own (aircraft) / set / sim / all" << endl;
|
||||
qtout << " examples: logappd, lognete, logsimd, logalle" << endl;
|
||||
qtout << "3) all . commands can be used, e.g. .com1 127.35" << endl;
|
||||
qtout << "3) display metadata data: meta" << endl;
|
||||
qtout << "4) all . commands can be used, e.g. .com1 127.35" << endl;
|
||||
qtout << endl;
|
||||
}
|
||||
else if (line.startsWith("."))
|
||||
|
||||
@@ -243,8 +243,15 @@
|
||||
</property>
|
||||
<addaction name="menu_ReloadSettings"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Debug">
|
||||
<property name="title">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
<addaction name="menu_DebugMetaTypes"/>
|
||||
</widget>
|
||||
<addaction name="menu_PlanePositions"/>
|
||||
<addaction name="menu_Reload"/>
|
||||
<addaction name="menu_Debug"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Help">
|
||||
<property name="title">
|
||||
@@ -357,6 +364,11 @@
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="menu_DebugMetaTypes">
|
||||
<property name="text">
|
||||
<string>Meta types (to console)</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
||||
@@ -157,6 +157,7 @@ void SwiftGuiStd::initGuiSignals()
|
||||
connect(this->ui->menu_FileResetSettings, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
|
||||
connect(this->ui->menu_FileReloadStyleSheets, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
|
||||
connect(this->ui->menu_FileFont, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
|
||||
connect(this->ui->menu_DebugMetaTypes, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
|
||||
|
||||
// command line / text messages
|
||||
connect(this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display);
|
||||
|
||||
@@ -66,6 +66,13 @@ void SwiftGuiStd::ps_onMenuClicked()
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
this->getIContextSettings()->reset(true);
|
||||
}
|
||||
else if (sender == this->ui->menu_DebugMetaTypes)
|
||||
{
|
||||
QString metadata;
|
||||
QTextStream stream(&metadata);
|
||||
BlackMisc::displayAllUserMetatypesTypes(stream);
|
||||
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(metadata);
|
||||
}
|
||||
}
|
||||
|
||||
void SwiftGuiStd::initDynamicMenus()
|
||||
|
||||
Reference in New Issue
Block a user