mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 21:05:31 +08:00
refs #875, adjusted servicetool (DBus samples)
* use functions from blackcore/test * show signatures
This commit is contained in:
committed by
Mathew Sutcliffe
parent
9beb6c79e1
commit
f2e49987e0
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
#include "blackmisc/dbusserver.h"
|
#include "blackmisc/dbusserver.h"
|
||||||
#include "blackmisc/registermetadata.h"
|
#include "blackmisc/registermetadata.h"
|
||||||
|
#include "blackmisc/network/networkutils.h"
|
||||||
|
#include "blackcore/test/testutils.h"
|
||||||
#include "servicetool.h"
|
#include "servicetool.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDBusServer>
|
#include <QDBusServer>
|
||||||
@@ -33,6 +34,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
BlackMisc::registerMetadata();
|
BlackMisc::registerMetadata();
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
QTextStream out(stdout, QIODevice::WriteOnly);
|
||||||
|
QTextStream qtin(stdin);
|
||||||
|
const bool verbose = false;
|
||||||
|
|
||||||
// trying to get the arguments into a list
|
// trying to get the arguments into a list
|
||||||
const QStringList cmdlineArgs = QCoreApplication::arguments();
|
const QStringList cmdlineArgs = QCoreApplication::arguments();
|
||||||
@@ -69,19 +73,34 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Create a Testservice instance and register it with the session bus only if
|
// Create a Testservice instance and register it with the session bus only if
|
||||||
// the service isn't already available.
|
// the service isn't already available.
|
||||||
if (!clientFlag)
|
if (clientFlag)
|
||||||
|
{
|
||||||
|
// 2nd Process !!! Running on the client's side
|
||||||
|
// This runs in a second process, hence cannot be directly debugged within Qt Creators
|
||||||
|
out << "Running client side " << QCoreApplication::applicationPid() << endl;
|
||||||
|
|
||||||
|
// run tests
|
||||||
|
if (cmdlineArgs.contains("testservice", Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
BlackSample::ServiceTool::dataTransferTestClient(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
// loop
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Configure tests
|
|
||||||
Menu:
|
Menu:
|
||||||
qDebug() << "1 .. Run testservice to test data transfer" << addressTcp;
|
out << "Pid: " << QCoreApplication::applicationPid() << endl;
|
||||||
qDebug() << "1sb. Run testservice via session bus";
|
out << "1 .. Run testservice to test data transfer" << addressTcp << endl;
|
||||||
qDebug() << "----- Change address / port (no validation, do before starting server)";
|
out << "1sb. Run testservice via session bus" << endl;
|
||||||
qDebug() << "loop Address to loopback, 127.0.0.1";
|
out << "2 .. Show signatures" << endl;
|
||||||
qDebug() << "ip some IP address, e.g 192.168.100.100";
|
out << "----- Change address / port (no validation, do before starting server)" << endl;
|
||||||
qDebug() << "port some port, e.g 12345";
|
out << "loop Address to loopback, 127.0.0.1" << endl;
|
||||||
qDebug() << "-----";
|
out << "ip some IP address, e.g " << ip << endl;
|
||||||
qDebug() << "x .. Bye";
|
out << "port some port, e.g 12345" << endl;
|
||||||
QTextStream qtin(stdin);
|
out << "-----" << endl;
|
||||||
|
out << "x .. Bye" << endl;
|
||||||
QString mode = qtin.readLine().toLower().trimmed();
|
QString mode = qtin.readLine().toLower().trimmed();
|
||||||
|
|
||||||
if (mode.startsWith("l"))
|
if (mode.startsWith("l"))
|
||||||
@@ -92,7 +111,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (mode.startsWith("i"))
|
if (mode.startsWith("i"))
|
||||||
{
|
{
|
||||||
QStringList p = mode.split(QRegExp("\\s"));
|
const QStringList p = mode.split(QRegExp("\\s"));
|
||||||
if (p.length() > 1)
|
if (p.length() > 1)
|
||||||
{
|
{
|
||||||
ip = p.at(1);
|
ip = p.at(1);
|
||||||
@@ -102,7 +121,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (mode.startsWith("p"))
|
if (mode.startsWith("p"))
|
||||||
{
|
{
|
||||||
QStringList p = mode.split(QRegExp("\\s"));
|
const QStringList p = mode.split(QRegExp("\\s"));
|
||||||
if (p.length() > 1)
|
if (p.length() > 1)
|
||||||
{
|
{
|
||||||
port = p.at(1);
|
port = p.at(1);
|
||||||
@@ -110,6 +129,13 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
goto Menu;
|
goto Menu;
|
||||||
}
|
}
|
||||||
|
if (mode.startsWith("2"))
|
||||||
|
{
|
||||||
|
out << "---------------------------------" << endl;
|
||||||
|
BlackCore::Test::CTestUtils::showDBusSignatures(out);
|
||||||
|
out << "---------------------------------" << endl;
|
||||||
|
goto Menu;
|
||||||
|
}
|
||||||
|
|
||||||
// start DBus
|
// start DBus
|
||||||
address = QString(useSessionBusForServer ? "session" : addressTcp); // testing with real transfer
|
address = QString(useSessionBusForServer ? "session" : addressTcp); // testing with real transfer
|
||||||
@@ -125,13 +151,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// I know I am in the "server process here", so I can safely create a CDBusServer
|
// I know I am in the "server process here", so I can safely create a CDBusServer
|
||||||
// this runs in the original process and can be directly debugged
|
// this runs in the original process and can be directly debugged
|
||||||
qDebug();
|
out << "--------------------------------------------------------" << endl;
|
||||||
qDebug("--------------------------------------------------------");
|
|
||||||
|
|
||||||
BlackMisc::CDBusServer *dBusServer = new BlackMisc::CDBusServer(useSessionBusForServer ? "session" : address);
|
BlackMisc::CDBusServer *dBusServer = new BlackMisc::CDBusServer(useSessionBusForServer ? "session" : address);
|
||||||
if (dBusServer->hasQDBusServer())
|
if (dBusServer->hasQDBusServer())
|
||||||
{
|
{
|
||||||
qDebug() << "server" << dBusServer->qDBusServer()->address() << "connected:" << dBusServer->qDBusServer()->isConnected();
|
out << "server" << dBusServer->qDBusServer()->address() <<
|
||||||
|
" connected:" << dBusServer->qDBusServer()->isConnected() << endl;
|
||||||
}
|
}
|
||||||
// start client process
|
// start client process
|
||||||
QStringList args;
|
QStringList args;
|
||||||
@@ -139,7 +165,7 @@ int main(int argc, char *argv[])
|
|||||||
args << mode;
|
args << mode;
|
||||||
if (address == "session")
|
if (address == "session")
|
||||||
{
|
{
|
||||||
args << address; // set session as cmd arg
|
args << "session"; // set session as cmd arg
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -150,29 +176,15 @@ int main(int argc, char *argv[])
|
|||||||
// run tests
|
// run tests
|
||||||
if (mode == "testservice")
|
if (mode == "testservice")
|
||||||
{
|
{
|
||||||
BlackSample::ServiceTool::dataTransferTestServer(dBusServer);
|
BlackSample::ServiceTool::dataTransferTestServer(dBusServer, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
// in new process
|
// testing in new process
|
||||||
BlackSample::ServiceTool::startNewProcess(executable, args, &a);
|
BlackSample::ServiceTool::startNewProcess(executable, args, &a);
|
||||||
|
|
||||||
// in same process
|
// testing in same process
|
||||||
// BlackSample::ServiceTool::dataTransferTestClient(address);
|
// BlackSample::ServiceTool::dataTransferTestClient(address);
|
||||||
|
|
||||||
// loop
|
|
||||||
return a.exec();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 2nd Process !!! Running on the client's side
|
|
||||||
// This runs in a second process, hence cannot be directly debugged within Qt Creators
|
|
||||||
|
|
||||||
// run tests
|
|
||||||
if (cmdlineArgs.contains("testservice", Qt::CaseInsensitive))
|
|
||||||
{
|
|
||||||
BlackSample::ServiceTool::dataTransferTestClient(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
// loop
|
// loop
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,38 +11,12 @@
|
|||||||
//! \ingroup sampleblackmiscdbus
|
//! \ingroup sampleblackmiscdbus
|
||||||
|
|
||||||
#include "servicetool.h"
|
#include "servicetool.h"
|
||||||
#include "testservice.h"
|
#include "blackcore/application.h"
|
||||||
#include "testserviceinterface.h"
|
#include "blackcore/test/testservice.h"
|
||||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
#include "blackcore/test/testserviceinterface.h"
|
||||||
#include "blackmisc/aviation/aircraftsituation.h"
|
#include "blackcore/test/testutils.h"
|
||||||
#include "blackmisc/aviation/airport.h"
|
|
||||||
#include "blackmisc/aviation/altitude.h"
|
|
||||||
#include "blackmisc/aviation/atcstation.h"
|
|
||||||
#include "blackmisc/aviation/comsystem.h"
|
|
||||||
#include "blackmisc/aviation/track.h"
|
|
||||||
#include "blackmisc/aviation/transponder.h"
|
|
||||||
#include "blackmisc/compare.h"
|
|
||||||
#include "blackmisc/dbusserver.h"
|
#include "blackmisc/dbusserver.h"
|
||||||
#include "blackmisc/geo/coordinategeodetic.h"
|
|
||||||
#include "blackmisc/iterator.h"
|
|
||||||
#include "blackmisc/network/client.h"
|
|
||||||
#include "blackmisc/network/server.h"
|
#include "blackmisc/network/server.h"
|
||||||
#include "blackmisc/network/user.h"
|
|
||||||
#include "blackmisc/pq/constants.h"
|
|
||||||
#include "blackmisc/pq/frequency.h"
|
|
||||||
#include "blackmisc/pq/length.h"
|
|
||||||
#include "blackmisc/pq/speed.h"
|
|
||||||
#include "blackmisc/pq/units.h"
|
|
||||||
#include "blackmisc/propertyindex.h"
|
|
||||||
#include "blackmisc/propertyindexvariantmap.h"
|
|
||||||
#include "blackmisc/sequence.h"
|
|
||||||
#include "blackmisc/simulation/aircraftmodel.h"
|
|
||||||
#include "blackmisc/simulation/fscommon/aircraftcfgentries.h"
|
|
||||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
|
||||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
|
||||||
#include "blackmisc/stringutils.h"
|
|
||||||
#include "blackmisc/variant.h"
|
|
||||||
#include "blackmisc/variantlist.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -69,8 +43,6 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
class QDBusObjectPath;
|
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
@@ -79,6 +51,8 @@ using namespace BlackMisc::Math;
|
|||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Simulation::FsCommon;
|
using namespace BlackMisc::Simulation::FsCommon;
|
||||||
|
using namespace BlackCore;
|
||||||
|
using namespace BlackCore::Test;
|
||||||
|
|
||||||
namespace BlackSample
|
namespace BlackSample
|
||||||
{
|
{
|
||||||
@@ -89,413 +63,160 @@ namespace BlackSample
|
|||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceTool::displayQDBusArgument(const QDBusArgument &arg, qint32 level)
|
void ServiceTool::dataTransferTestServer(BlackMisc::CDBusServer *dBusServer, bool verbose)
|
||||||
{
|
|
||||||
arg.beginArray();
|
|
||||||
QVariant qv;
|
|
||||||
QString indent(level * 2, ' ');
|
|
||||||
|
|
||||||
while (!arg.atEnd())
|
|
||||||
{
|
|
||||||
QDBusArgument::ElementType type = arg.currentType();
|
|
||||||
QString signature = arg.currentSignature();
|
|
||||||
qv = arg.asVariant(); // this advances in the stream
|
|
||||||
if (qv.canConvert<QDBusArgument>())
|
|
||||||
{
|
|
||||||
qDebug() << indent << type << "signature" << signature;
|
|
||||||
ServiceTool::displayQDBusArgument(qv.value<QDBusArgument>(), level + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug() << indent << "type:" << type << "signature" << signature << "value" << qv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
arg.endArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServiceTool::dataTransferTestServer(BlackMisc::CDBusServer *dBusServer)
|
|
||||||
{
|
{
|
||||||
QDBusConnection sessionBusConnection = QDBusConnection::sessionBus();
|
QDBusConnection sessionBusConnection = QDBusConnection::sessionBus();
|
||||||
if (sessionBusConnection.interface()->isServiceRegistered(Testservice::InterfaceName))
|
if (sessionBusConnection.interface()->isServiceRegistered(CTestService::InterfaceName()))
|
||||||
{
|
{
|
||||||
qFatal("Testservice already registed on session bus");
|
qFatal("Testservice already registed on session bus");
|
||||||
}
|
}
|
||||||
|
|
||||||
// as this is the receiver side, the slots can be debugged too
|
// as this is the receiver side, the slots can be debugged too
|
||||||
Testservice *testservice = ServiceTool::registerTestservice(sessionBusConnection, QCoreApplication::instance());
|
CTestService *testService = CTestService::registerTestService(sessionBusConnection, verbose, QCoreApplication::instance());
|
||||||
dBusServer->addObject(Testservice::ObjectPath, testservice);
|
dBusServer->addObject(CTestService::ObjectPath(), testService);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceTool::dataTransferTestClient(const QString &address)
|
void ServiceTool::dataTransferTestClient(const QString &address)
|
||||||
{
|
{
|
||||||
// send data as P2P to server (this can be session bus, too, but usually is P2P)
|
// send data as P2P to server (this can be session bus, too, but usually is P2P)
|
||||||
bool sb = (address.toLower().startsWith("session"));
|
const bool sb = (address.toLower().startsWith("session"));
|
||||||
QDBusConnection p2pConnection = sb ?
|
QDBusConnection connection = sb ?
|
||||||
QDBusConnection::sessionBus() :
|
QDBusConnection::sessionBus() :
|
||||||
QDBusConnection::connectToPeer(address, "p2pConnection");
|
QDBusConnection::connectToPeer(address, "p2pConnection");
|
||||||
|
|
||||||
qDebug() << "------------ connection info ---------------";
|
// qtout << "server connection has interface? " << connection.interface(); // returns 0 with server and a real interface with session bus
|
||||||
qDebug() << "server connection has interface?" << p2pConnection.interface(); // returns 0 with server and a real interface with session bus
|
// qtout << "address: " << address;
|
||||||
qDebug() << "address:" << address;
|
// qtout << "name: " << connection.name();
|
||||||
qDebug() << "name:" << p2pConnection.name();
|
|
||||||
qDebug() << "------------ connection info ---------------";
|
|
||||||
|
|
||||||
ServiceTool::sendDataToTestservice(p2pConnection);
|
ServiceTool::sendDataToTestservice(connection);
|
||||||
}
|
|
||||||
|
|
||||||
CCallsign ServiceTool::getRandomAtcCallsign()
|
|
||||||
{
|
|
||||||
static QList<CCallsign> callsigns;
|
|
||||||
if (callsigns.isEmpty())
|
|
||||||
{
|
|
||||||
callsigns << CCallsign("EDDM_TWR");
|
|
||||||
callsigns << CCallsign("EDDM_APP");
|
|
||||||
callsigns << CCallsign("EDDM_GND");
|
|
||||||
callsigns << CCallsign("EDDF_TWR");
|
|
||||||
callsigns << CCallsign("EDDF_APP");
|
|
||||||
callsigns << CCallsign("EDDF_GND");
|
|
||||||
}
|
|
||||||
int i = (rand() % (callsigns.size()));
|
|
||||||
CCallsign cs = callsigns.at(i);
|
|
||||||
return cs;
|
|
||||||
}
|
|
||||||
|
|
||||||
CAtcStationList ServiceTool::getStations(int number)
|
|
||||||
{
|
|
||||||
QElapsedTimer timer;
|
|
||||||
timer.start();
|
|
||||||
|
|
||||||
BlackMisc::Aviation::CAtcStationList list;
|
|
||||||
for (int i = 0; i < number; i++)
|
|
||||||
{
|
|
||||||
BlackMisc::Aviation::CAtcStation s;
|
|
||||||
s.setCallsign(QString::number(i));
|
|
||||||
s.setFrequency(BlackMisc::PhysicalQuantities::CFrequency(i, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
|
||||||
s.setController(CUser(QString::number(i), "FooBar", "", ""));
|
|
||||||
s.setOnline(i % 2 == 0 ? true : false);
|
|
||||||
s.setPosition(CCoordinateGeodetic(i, i, i));
|
|
||||||
list.push_back(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << number << "stations in" << timer.nsecsElapsed() / 1000000; // ms
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
CAircraftCfgEntriesList ServiceTool::getAircraftCfgEntries(int number)
|
|
||||||
{
|
|
||||||
QElapsedTimer timer;
|
|
||||||
timer.start();
|
|
||||||
|
|
||||||
CAircraftCfgEntriesList list;
|
|
||||||
for (int i = 0; i < number; i++)
|
|
||||||
{
|
|
||||||
CAircraftCfgEntries e;
|
|
||||||
e.setAtcModel("atc model");
|
|
||||||
e.setAtcParkingCode(QString::number(i));
|
|
||||||
e.setIndex(i);
|
|
||||||
e.setFileName("this will be the file path and pretty long");
|
|
||||||
e.setTitle("i am the aircraft title foobar");
|
|
||||||
e.setAtcType("B737");
|
|
||||||
list.push_back(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << number << "aircraft entries in" << timer.nsecsElapsed() / 1000000; // ms
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
CAirportList ServiceTool::getAirports(int number)
|
|
||||||
{
|
|
||||||
BlackMisc::Aviation::CAirportList list;
|
|
||||||
for (int i = 0; i < number; i++)
|
|
||||||
{
|
|
||||||
char cc = 65 + (i % 26);
|
|
||||||
QString icao = QString("EXX%1").arg(QLatin1Char(cc));
|
|
||||||
BlackMisc::Aviation::CAirport a(icao);
|
|
||||||
a.setPosition(CCoordinateGeodetic(i, i, i));
|
|
||||||
list.push_back(a);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
CClientList ServiceTool::getClients(int number)
|
|
||||||
{
|
|
||||||
BlackMisc::Network::CClientList list;
|
|
||||||
for (int i = 0; i < number; i++)
|
|
||||||
{
|
|
||||||
CCallsign cs(QString("DXX%1").arg(i));
|
|
||||||
QString rn = QString("Joe Doe%1").arg(i);
|
|
||||||
CUser user(QString::number(i), rn, cs);
|
|
||||||
user.setCallsign(cs);
|
|
||||||
CClient client(user);
|
|
||||||
client.setCapability(true, CClient::FsdWithInterimPositions);
|
|
||||||
client.setCapability(true, CClient::FsdWithIcaoCodes);
|
|
||||||
const QString myFooModel = QString("fooModel %1").arg(i);
|
|
||||||
client.setQueriedModelString(myFooModel);
|
|
||||||
list.push_back(client);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
Testservice *ServiceTool::registerTestservice(QDBusConnection &connection, QObject *parent)
|
|
||||||
{
|
|
||||||
Testservice *pTestservice = new Testservice(parent); // just a QObject with signals / slots and Q_CLASSINFO("D-Bus Interface", some service name)
|
|
||||||
if (!connection.registerService(Testservice::InterfaceName))
|
|
||||||
{
|
|
||||||
QDBusError err = connection.lastError();
|
|
||||||
qWarning() << err.message();
|
|
||||||
qWarning() << "Started dbus-daemon.exe --session (Windows)?";
|
|
||||||
qWarning() << "Created directory session.d (e.g. ../Qt/Qt5.1.0Vatsim/5.1.0-32/qtbase/etc/dbus-1/session.d)?";
|
|
||||||
qWarning() << "See https://dev.vatsim-germany.org/projects/vatpilotclient/wiki/DBusExample#Running-the-example";
|
|
||||||
qFatal("Could not register service!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!connection.registerObject(Testservice::ObjectPath, pTestservice, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals | QDBusConnection::ExportAdaptors))
|
|
||||||
{
|
|
||||||
qFatal("Could not register service object!");
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Registration running as pid:" << ServiceTool::getPid();
|
|
||||||
if (pTestservice) qDebug() << "Service registered";
|
|
||||||
|
|
||||||
QString service; // service not needed
|
|
||||||
if (connection.connect(
|
|
||||||
service, Testservice::ObjectPath, Testservice::InterfaceName,
|
|
||||||
"sendStringMessage", pTestservice, SLOT(receiveStringMessage(const QString &))))
|
|
||||||
{
|
|
||||||
qDebug() << "Connected object with bus sendStringMessage";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qFatal("Cannot connect service with DBus");
|
|
||||||
}
|
|
||||||
return pTestservice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceTool::sendDataToTestservice(const QDBusConnection &connection)
|
void ServiceTool::sendDataToTestservice(const QDBusConnection &connection)
|
||||||
{
|
{
|
||||||
// on the client's side
|
// on the client's side
|
||||||
TestServiceInterface testserviceInterface(Testservice::InterfaceName, Testservice::ObjectPath, connection);
|
ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(), connection);
|
||||||
|
|
||||||
CSpeed speed(200, CSpeedUnit::km_h());
|
|
||||||
CSpeed speedNull(0, nullptr);
|
|
||||||
CAltitude al(1000, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
|
||||||
QTextStream qtin(stdin);
|
QTextStream qtin(stdin);
|
||||||
|
QTextStream qtout(stdout);
|
||||||
QString line;
|
QString line;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
QDBusMessage m = QDBusMessage::createSignal(
|
QDBusMessage m = QDBusMessage::createSignal(
|
||||||
Testservice::ObjectPath, Testservice::InterfaceName,
|
CTestService::ObjectPath(), CTestService::InterfaceName(),
|
||||||
"sendStringMessage");
|
"sendStringMessage");
|
||||||
|
|
||||||
// The << operator is used to add the parameters for the slot
|
// The << operator is used to add the parameters for the slot
|
||||||
QDateTime dtnow = QDateTime::currentDateTimeUtc();
|
const QDateTime dtnow = QDateTime::currentDateTimeUtc();
|
||||||
QString msg = QString("Message from %1 at %2").arg(ServiceTool::getPid()).arg(dtnow.toString("MM/dd/yyyy @ hh:mm:ss"));
|
const QString msg = QString("Message at %1").arg(dtnow.toString("MM/dd/yyyy @ hh:mm:ss"));
|
||||||
m << msg;
|
m << msg;
|
||||||
|
|
||||||
// We send this as a non-replying message. This is used for sending errors, replys, signals,
|
// We send this as a non-replying message. This is used for sending errors, replys, signals.
|
||||||
// and method calls (slots) that don't return
|
// Values can be seen on the receiver side
|
||||||
if (connection.send(m)) { qDebug() << "Send via low level method" << m; }
|
qtout << "----------------- receiver tests ----------------" << endl;
|
||||||
|
|
||||||
|
// Low level test
|
||||||
|
if (connection.send(m)) { qtout << "Send via low level method " << endl; }
|
||||||
|
|
||||||
// same as interface message
|
// same as interface message
|
||||||
// but call the slot
|
// but call the slot
|
||||||
testserviceInterface.receiveStringMessage(msg);
|
testServiceInterface.receiveStringMessage(msg);
|
||||||
qDebug() << "Send string via interface" << msg;
|
qtout << "Send string via interface " << msg << endl;
|
||||||
|
|
||||||
// a list
|
// a list
|
||||||
QList<double> list;
|
QList<double> list;
|
||||||
list << 1.0 << 2.0 << 3.0;
|
list << 1.0 << 2.0 << 3.0;
|
||||||
testserviceInterface.receiveList(list);
|
testServiceInterface.receiveList(list);
|
||||||
qDebug() << "Send list via interface" << list;
|
qtout << "Send list via interface " << list.size() << endl;
|
||||||
|
|
||||||
// PQs
|
// PQs
|
||||||
testserviceInterface.receiveSpeed(speed);
|
CSpeed speed(200, CSpeedUnit::km_h());
|
||||||
qDebug() << "Send speed via interface" << speed;
|
const CSpeed speedNull(0, nullptr);
|
||||||
testserviceInterface.receiveSpeed(speedNull);
|
|
||||||
qDebug() << "Send null speed via interface" << speedNull;
|
testServiceInterface.receiveSpeed(speed);
|
||||||
|
qtout << "Send speed via interface " << speed << endl;
|
||||||
|
testServiceInterface.receiveSpeed(speedNull);
|
||||||
|
qtout << "Send null speed via interface " << speedNull << endl;
|
||||||
speed.switchUnit(CSpeedUnit::kts());
|
speed.switchUnit(CSpeedUnit::kts());
|
||||||
testserviceInterface.receiveSpeed(speed);
|
testServiceInterface.receiveSpeed(speed);
|
||||||
qDebug() << "Send speed via interface" << speed;
|
qtout << "Send speed via interface " << speed << endl;
|
||||||
QThread::msleep(2500);
|
QThread::msleep(2500);
|
||||||
speed.switchUnit(CSpeedUnit::km_h());
|
speed.switchUnit(CSpeedUnit::km_h());
|
||||||
speed.addValueSameUnit(1.0);
|
speed.addValueSameUnit(1.0);
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
CServer trafficServer("fooserver", "a foo server", "localhost", 1234,
|
const CServer trafficServer("fooserver", "a foo server", "localhost", 1234,
|
||||||
CUser("112233", "Some real name", "email@xyz.com", "secret"));
|
CUser("112233", "Some real name", "email@xyz.com", "secret"));
|
||||||
QVariant tsqv = QVariant::fromValue(trafficServer);
|
QVariant tsqv = QVariant::fromValue(trafficServer);
|
||||||
QDBusVariant tsv(tsqv);
|
QDBusVariant tsv(tsqv);
|
||||||
testserviceInterface.receiveVariant(tsv, tsqv.userType());
|
testServiceInterface.receiveVariant(tsv, tsqv.userType());
|
||||||
qDebug() << "Send server via interface and variant" << trafficServer << tsqv.userType();
|
qtout << "Send server via interface and variant " << trafficServer << tsqv.userType() << endl;
|
||||||
|
|
||||||
// Aviation
|
// Aviation
|
||||||
CComSystem comSystem = CComSystem("DBUS COM1", CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress(), CPhysicalQuantitiesConstants::FrequencyUnicom());
|
const CComSystem comSystem = CComSystem("DBUS COM1", CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress(), CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||||
testserviceInterface.receiveComUnit(comSystem);
|
testServiceInterface.receiveComUnit(comSystem);
|
||||||
qDebug() << "Send COM via interface" << comSystem;
|
qtout << "Send COM via interface " << comSystem << endl;
|
||||||
|
|
||||||
QVariant qvAl = QVariant::fromValue(al);
|
CAltitude altitude(1000, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
||||||
|
QVariant qvAl = QVariant::fromValue(altitude);
|
||||||
QDBusVariant qv(qvAl);
|
QDBusVariant qv(qvAl);
|
||||||
testserviceInterface.receiveVariant(qv, qvAl.userType());
|
testServiceInterface.receiveVariant(qv, qvAl.userType());
|
||||||
testserviceInterface.receiveAltitude(al);
|
testServiceInterface.receiveAltitude(altitude);
|
||||||
qDebug() << "Send altitude via interface and variant" << al << qvAl.userType();
|
qtout << "Send altitude via interface and variant " << altitude << qvAl.userType() << endl;
|
||||||
al.addValueSameUnit(1);
|
altitude.addValueSameUnit(1);
|
||||||
|
|
||||||
CTransponder transponder(7000, CTransponder::ModeC);
|
const CTransponder transponder(7000, CTransponder::ModeC);
|
||||||
testserviceInterface.receiveTransponder(transponder);
|
testServiceInterface.receiveTransponder(transponder);
|
||||||
qDebug() << "Send transponder via interface" << transponder;
|
qtout << "Send transponder via interface " << transponder << endl;
|
||||||
|
|
||||||
CTrack track(123.45, CTrack::Magnetic, CAngleUnit::deg());
|
const CTrack track(123.45, CTrack::Magnetic, CAngleUnit::deg());
|
||||||
testserviceInterface.receiveTrack(track);
|
testServiceInterface.receiveTrack(track);
|
||||||
qDebug() << "Send track via interface" << track;
|
qtout << "Send track via interface " << track << endl;
|
||||||
|
|
||||||
CLength len(33, CLengthUnit::m());
|
const CLength len(33, CLengthUnit::m());
|
||||||
testserviceInterface.receiveLength(len);
|
testServiceInterface.receiveLength(len);
|
||||||
qDebug() << "Send length via interface" << len;
|
qtout << "Send length via interface " << len << endl;
|
||||||
|
|
||||||
CAltitude alt(44, CAltitude::MeanSeaLevel, CLengthUnit::m());
|
const CAltitude alt(44, CAltitude::MeanSeaLevel, CLengthUnit::m());
|
||||||
testserviceInterface.receiveLength(alt);
|
testServiceInterface.receiveLength(alt);
|
||||||
qDebug() << "Send altitude via interface" << alt;
|
qtout << "Send altitude via interface " << alt << endl;
|
||||||
|
|
||||||
CCallsign callsign("d-ambz");
|
const CCallsign callsign("d-ambz");
|
||||||
testserviceInterface.receiveCallsign(callsign);
|
testServiceInterface.receiveCallsign(callsign);
|
||||||
qDebug() << "Send callsign via interface" << callsign;
|
qtout << "Send callsign via interface " << callsign << endl;
|
||||||
|
|
||||||
CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() }); // Munich
|
CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() }); // Munich
|
||||||
CAtcStation station(CCallsign("eddm_twr"), CUser("123456", "Joe Controller"),
|
CAtcStation station(CCallsign("eddm_twr"), CUser("123456", "Joe Controller"),
|
||||||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
CFrequency(118.7, CFrequencyUnit::MHz()),
|
||||||
geoPos, CLength(50, CLengthUnit::km()));
|
geoPos, CLength(50, CLengthUnit::km()));
|
||||||
|
|
||||||
testserviceInterface.receiveAtcStation(station);
|
testServiceInterface.receiveAtcStation(station);
|
||||||
qDebug() << "Send ATC" << station;
|
qtout << "Send ATC " << station << endl;
|
||||||
|
|
||||||
// Geo
|
// Geo
|
||||||
// EDDF: 50° 2′ 0″ N, 8° 34′ 14″ E, 100m MSL
|
// EDDF: 50° 2′ 0″ N, 8° 34′ 14″ E, 100m MSL
|
||||||
geoPos = CCoordinateGeodetic::fromWgs84("50° 2′ 1″ 23 N", "8° 34′ 14″ E", { 111, CLengthUnit::m() });
|
geoPos = CCoordinateGeodetic::fromWgs84("50° 2′ 1″ 23 N", "8° 34′ 14″ E", { 111, CLengthUnit::m() });
|
||||||
testserviceInterface.receiveGeoPosition(geoPos);
|
testServiceInterface.receiveGeoPosition(geoPos);
|
||||||
qDebug() << "Send geo position" << geoPos;
|
qtout << "Send geo position " << geoPos << endl;
|
||||||
|
|
||||||
qDebug() << "----------------- pings ----------------";
|
qtout << "----------------- variant tests ----------------" << endl;
|
||||||
CPropertyIndex pi({ 1000, 2000, 3000, 4000, 5000}); // numbers >= global index
|
|
||||||
pi = testserviceInterface.pingPropertyIndex(pi);
|
|
||||||
qDebug() << "Pinged property index via interface" << pi;
|
|
||||||
|
|
||||||
CPropertyIndexVariantMap ivm;
|
|
||||||
ivm.addValue(1000, "one");
|
|
||||||
ivm.addValue(2000, "two");
|
|
||||||
ivm.addValue(3000, "three");
|
|
||||||
ivm = testserviceInterface.pingIndexVariantMap(ivm);
|
|
||||||
qDebug() << "Pinged variant map via interface" << ivm;
|
|
||||||
|
|
||||||
CSimulatorPluginInfo pluginInfo("fsx", "FSX Simulator", "FSX", "Flight Simulator X", true);
|
|
||||||
CSimulatorPluginInfo pluginInfoReceived = testserviceInterface.pingPluginInfo(pluginInfo);
|
|
||||||
qDebug() << "Pinged info via interface"
|
|
||||||
<< ((pluginInfo == pluginInfoReceived) ? "OK" : "------------- ERROR! ------------") << pluginInfoReceived;
|
|
||||||
|
|
||||||
CSpeed speedNotNull(22, CSpeedUnit::m_s());
|
|
||||||
speedNull = CSpeed(0, CSpeedUnit::nullUnit());
|
|
||||||
speed = testserviceInterface.pingSpeed(speedNotNull);
|
|
||||||
qDebug() << "Pinged not null speed via interface"
|
|
||||||
<< ((speedNotNull == speed) ? "OK" : "------------- ERROR! ------------") << speed;
|
|
||||||
speed = testserviceInterface.pingSpeed(speedNull);
|
|
||||||
qDebug() << "Pinged null speed via interface"
|
|
||||||
<< ((speedNull == speed) ? "OK" : "------------- ERROR! ------------") << speed;
|
|
||||||
|
|
||||||
CAtcStation stationReceived = testserviceInterface.pingAtcStation(station);
|
|
||||||
qDebug() << "Pinged ATC station via interface"
|
|
||||||
<< ((station == stationReceived) ? "OK" : "------------- ERROR! ------------") << stationReceived;
|
|
||||||
|
|
||||||
CAircraftIcaoCode icaoData("B737", "L2J");
|
|
||||||
CAircraftIcaoCode icaoReceived = testserviceInterface.pingAircraftIcaoData(icaoData);
|
|
||||||
qDebug() << "Pinged ICAO data via interface"
|
|
||||||
<< ((icaoData == icaoReceived) ? "OK" : "------------- ERROR! ------------") << icaoReceived;
|
|
||||||
qDebug() << icaoData << icaoReceived;
|
|
||||||
|
|
||||||
CUser pingUser("223344", "Ping Me User");
|
|
||||||
CUser userReceived = testserviceInterface.pingUser(pingUser);
|
|
||||||
qDebug() << "Pinged user via interface"
|
|
||||||
<< ((userReceived == pingUser) ? "OK" : "------------- ERROR! ------------") << userReceived;
|
|
||||||
|
|
||||||
CAircraftSituation situation;
|
|
||||||
CAircraftSituation situationReceived = testserviceInterface.pingSituation(situation);
|
|
||||||
qDebug() << "Pinged situation via interface"
|
|
||||||
<< ((situation == situationReceived) ? "OK" : "------------- ERROR! ------------") << situationReceived;
|
|
||||||
|
|
||||||
CTransponder transponderReceived = testserviceInterface.pingTransponder(transponder);
|
|
||||||
qDebug() << "Pinged transponder via interface"
|
|
||||||
<< ((transponderReceived == transponder) ? "OK" : "------------- ERROR! ------------") << transponderReceived;
|
|
||||||
|
|
||||||
CAircraftLights lights(true, false, true, false, true, false);
|
|
||||||
CAircraftLights lightsReceived = testserviceInterface.pingAircraftLights(lights);
|
|
||||||
qDebug() << "Pinged lights via interface"
|
|
||||||
<< ((lightsReceived == lights) ? "OK" : "------------- ERROR! ------------") << lightsReceived;
|
|
||||||
|
|
||||||
CAircraftEngine engine(3, true);
|
|
||||||
CAircraftEngine engineReceived = testserviceInterface.pingAircraftEngine(engine);
|
|
||||||
qDebug() << "Pinged engine via interface"
|
|
||||||
<< ((engineReceived == engine) ? "OK" : "------------- ERROR! ------------") << engineReceived;
|
|
||||||
|
|
||||||
CAircraftEngineList engines({engine});
|
|
||||||
CAircraftParts parts(lights, true, 11, true, engines, true);
|
|
||||||
CAircraftParts partsReceived = testserviceInterface.pingAircraftParts(parts);
|
|
||||||
qDebug() << "Pinged parts via interface"
|
|
||||||
<< ((partsReceived == parts) ? "OK" : "------------- ERROR! ------------") << partsReceived;
|
|
||||||
|
|
||||||
CSimulatedAircraft aircraft(callsign, CUser("123456", "Joe Pilot"), situation);
|
|
||||||
aircraft.setTransponder(transponder);
|
|
||||||
CSimulatedAircraft aircraftReceived(testserviceInterface.pingSimulatedAircraft(aircraft));
|
|
||||||
qDebug() << "Pinged aircraft via interface"
|
|
||||||
<< ((aircraft == aircraftReceived) ? "OK" : "------------- ERROR! ------------") << aircraftReceived;
|
|
||||||
|
|
||||||
CSimulatedAircraft simAircraft(aircraft);
|
|
||||||
CAircraftModel model("foobar", CAircraftModel::TypeManuallySet);
|
|
||||||
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);
|
|
||||||
atcStationList.push_back(station);
|
|
||||||
atcStationList = testserviceInterface.pingAtcStationList(atcStationList);
|
|
||||||
qDebug() << "Pinged ATC station list via interface" << atcStationList.size() << atcStationList;
|
|
||||||
|
|
||||||
CAirportList airportList = ServiceTool::getAirports(10);
|
|
||||||
airportList = testserviceInterface.pingAirportList(airportList);
|
|
||||||
qDebug() << "Pinged airport list via interface" << airportList.size() << airportList;
|
|
||||||
|
|
||||||
CClientList clients = ServiceTool::getClients(10);
|
|
||||||
CClient client = clients.front();
|
|
||||||
client = testserviceInterface.pingClient(client);
|
|
||||||
qDebug() << "Pinged client via interface" << client;
|
|
||||||
clients = testserviceInterface.pingClientList(clients);
|
|
||||||
qDebug() << "Pinged client list via interface" << clients.size() << clients;
|
|
||||||
|
|
||||||
CVariant cv = CVariant::fromValue(clients);
|
|
||||||
qDebug() << "cv" << cv.toQString();
|
|
||||||
cv = testserviceInterface.pingCVariant(client);
|
|
||||||
qDebug() << "Pinged CVariant via interface" << cv.toQString();
|
|
||||||
|
|
||||||
// test variant lists with different types wrapped in CVariant
|
|
||||||
qDebug() << "----------------- variant tests ----------------";
|
|
||||||
CVariantList cvList;
|
CVariantList cvList;
|
||||||
cvList.push_back(CVariant::fromValue(len));
|
cvList.push_back(CVariant::fromValue(len));
|
||||||
cvList.push_back(CVariant::fromValue(alt));
|
cvList.push_back(CVariant::fromValue(alt));
|
||||||
CVariantList lengthsV;
|
CVariantList lengthsV;
|
||||||
lengthsV.push_back(CVariant::fromValue(len));
|
lengthsV.push_back(CVariant::fromValue(len));
|
||||||
lengthsV.push_back(CVariant::fromValue(alt));
|
lengthsV.push_back(CVariant::fromValue(alt));
|
||||||
testserviceInterface.receiveLengthsQvl(cvList);
|
testServiceInterface.receiveLengthsQvl(cvList);
|
||||||
qDebug() << "Send lengths via interface as CVariantList:";
|
qtout << "Send lengths via interface as CVariantList" << endl;
|
||||||
testserviceInterface.receiveLengthsQl(lengthsV);
|
testServiceInterface.receiveLengthsQl(lengthsV);
|
||||||
qDebug() << "Send lengths via interface as QList<CVariant>:";
|
qtout << "Send lengths via interface as QList<CVariant>" << endl;
|
||||||
foreach (CVariant lv, cvList)
|
for (const CVariant &lv : cvList)
|
||||||
{
|
{
|
||||||
qDebug() << " " << "Send length in list:" << lv;
|
qtout << " " << "Send length in list: " << lv << endl;
|
||||||
}
|
}
|
||||||
QThread::msleep(2500);
|
CApplication::processEventsFor(2000);
|
||||||
|
|
||||||
// Value map
|
// Value map
|
||||||
qDebug() << "----------------- index variant map ----------------";
|
qtout << "----------------- index variant map ----------------" << endl;
|
||||||
|
|
||||||
CPropertyIndexVariantMap valueMap;
|
CPropertyIndexVariantMap valueMap;
|
||||||
valueMap.addValue(1000, 111.222);
|
valueMap.addValue(1000, 111.222);
|
||||||
@@ -504,112 +225,112 @@ namespace BlackSample
|
|||||||
valueMap.addValue(4000, track);
|
valueMap.addValue(4000, track);
|
||||||
valueMap.addValue(5000, QDateTime::currentDateTime().addDays(1));
|
valueMap.addValue(5000, QDateTime::currentDateTime().addDays(1));
|
||||||
valueMap.addValue(6000, QString("foobar"));
|
valueMap.addValue(6000, QString("foobar"));
|
||||||
testserviceInterface.receiveValueMap(valueMap);
|
testServiceInterface.receiveValueMap(valueMap);
|
||||||
qDebug() << "Send index variant map" << valueMap;
|
qtout << "Send index variant map " << valueMap << endl;
|
||||||
|
CApplication::processEventsFor(2000);
|
||||||
|
|
||||||
|
qtout << "----------------- pings ----------------" << endl;
|
||||||
|
int errors = ITestServiceInterface::pingTests(testServiceInterface, false);
|
||||||
|
qtout << "Ping errors " << errors << endl;
|
||||||
|
CApplication::processEventsFor(2000);
|
||||||
|
|
||||||
// Performance tools
|
// Performance tools
|
||||||
QThread::msleep(2500);
|
qtout << "----------------- performance ----------------" << endl;
|
||||||
qDebug() << "----------------- performance ----------------";
|
|
||||||
|
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
CSpeed speedDummy(i, CSpeedUnit::km_h());
|
CSpeed speedDummy(i, CSpeedUnit::km_h());
|
||||||
speedDummy = testserviceInterface.getSpeed();
|
speedDummy = testServiceInterface.getSpeed();
|
||||||
}
|
}
|
||||||
qint64 t10 = timer.nsecsElapsed() / 1000000; // ms
|
qint64 t10 = timer.elapsed(); // ms
|
||||||
|
|
||||||
timer.restart();
|
timer.restart();
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
CSpeed speedDummy(i, CSpeedUnit::km_h());
|
CSpeed speedDummy(i, CSpeedUnit::km_h());
|
||||||
speedDummy = testserviceInterface.getSpeed();
|
speedDummy = testServiceInterface.getSpeed();
|
||||||
}
|
}
|
||||||
qint64 t100 = timer.nsecsElapsed() / 1000000; // ms
|
qint64 t100 = timer.elapsed(); // ms
|
||||||
|
|
||||||
timer.restart();
|
timer.restart();
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
CSpeed speedDummy(i, CSpeedUnit::km_h());
|
CSpeed speedDummy(i, CSpeedUnit::km_h());
|
||||||
speedDummy = testserviceInterface.getSpeed();
|
speedDummy = testServiceInterface.getSpeed();
|
||||||
}
|
}
|
||||||
qint64 t1000 = timer.nsecsElapsed() / 1000000; // ms
|
qint64 t1000 = timer.elapsed(); // ms
|
||||||
timer.invalidate();
|
timer.invalidate();
|
||||||
qDebug() << "Reading speed objects 10/100/1000 in ms:" << t10 << t100 << t1000;
|
qtout << "Reading speed objects 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << endl;
|
||||||
|
|
||||||
timer.start();
|
timer.start();
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
CAtcStation stationDummy(QString::number(i));
|
CAtcStation stationDummy(QString::number(i));
|
||||||
stationDummy = testserviceInterface.getAtcStation();
|
stationDummy = testServiceInterface.getAtcStation();
|
||||||
}
|
}
|
||||||
t10 = timer.nsecsElapsed() / 1000000; // ms
|
t10 = timer.elapsed(); // ms
|
||||||
timer.restart();
|
timer.restart();
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
CAtcStation stationDummy(QString::number(i));
|
CAtcStation stationDummy(QString::number(i));
|
||||||
stationDummy = testserviceInterface.getAtcStation();
|
stationDummy = testServiceInterface.getAtcStation();
|
||||||
}
|
}
|
||||||
t100 = timer.nsecsElapsed() / 1000000; // ms
|
t100 = timer.elapsed(); // ms
|
||||||
timer.restart();
|
timer.restart();
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
CAtcStation stationDummy(QString::number(i));
|
CAtcStation stationDummy(QString::number(i));
|
||||||
stationDummy = testserviceInterface.getAtcStation();
|
stationDummy = testServiceInterface.getAtcStation();
|
||||||
}
|
}
|
||||||
t1000 = timer.nsecsElapsed() / 1000000; // ms
|
t1000 = timer.elapsed(); // ms
|
||||||
qDebug() << "Reading station objects 10/100/1000 in ms:" << t10 << t100 << t1000;
|
qtout << "Reading station objects 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << endl;
|
||||||
|
|
||||||
timer.restart();
|
timer.restart();
|
||||||
atcStationList = testserviceInterface.getAtcStationList(10);
|
CAtcStationList atcStationList = testServiceInterface.getAtcStationList(10);
|
||||||
if (atcStationList.size() != 10) qDebug() << "wrong list size" << atcStationList.size();
|
if (atcStationList.size() != 10) qtout << "wrong list size" << atcStationList.size() << endl;
|
||||||
t10 = timer.nsecsElapsed() / 1000000; // ms
|
t10 = timer.elapsed(); // ms
|
||||||
QThread::msleep(1000);
|
|
||||||
|
|
||||||
timer.restart();
|
timer.restart();
|
||||||
atcStationList = testserviceInterface.getAtcStationList(100);
|
atcStationList = testServiceInterface.getAtcStationList(100);
|
||||||
if (atcStationList.size() != 100) qDebug() << "wrong list size" << atcStationList.size();
|
if (atcStationList.size() != 100) qtout << "wrong list size" << atcStationList.size() << endl;
|
||||||
t100 = timer.nsecsElapsed() / 1000000; // ms
|
t100 = timer.elapsed(); // ms
|
||||||
QThread::msleep(1000);
|
|
||||||
|
|
||||||
timer.restart();
|
timer.restart();
|
||||||
atcStationList = testserviceInterface.getAtcStationList(1000);
|
atcStationList = testServiceInterface.getAtcStationList(1000);
|
||||||
if (atcStationList.size() != 1000) qDebug() << "wrong list size" << atcStationList.size();
|
if (atcStationList.size() != 1000) qtout << "wrong list size" << atcStationList.size() << endl;
|
||||||
t1000 = timer.nsecsElapsed() / 1000000; // ms
|
t1000 = timer.elapsed(); // ms
|
||||||
qDebug() << "Reading station list 10/100/1000 in ms:" << t10 << t100 << t1000;
|
qtout << "Reading station list 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << endl;
|
||||||
|
|
||||||
// test reading model entries with a realistic size
|
// test reading model entries with a realistic size
|
||||||
timer.restart();
|
timer.restart();
|
||||||
CAircraftCfgEntriesList entriesList = testserviceInterface.getAircraftCfgEntriesList(5000);
|
CAircraftCfgEntriesList entriesList = testServiceInterface.getAircraftCfgEntriesList(5000);
|
||||||
if (entriesList.size() != 5000) qDebug() << "wrong list size" << entriesList.size();
|
if (entriesList.size() != 5000) qtout << "wrong list size" << entriesList.size() << endl;
|
||||||
qint64 t5000 = timer.nsecsElapsed() / 1000000; // ms
|
qint64 t5000 = timer.elapsed(); // ms
|
||||||
qDebug() << "Reading aircraft cfg entries in ms:" << t5000;
|
qtout << "Reading aircraft cfg entries in ms: " << t5000 << endl;
|
||||||
|
|
||||||
// object paths
|
// object paths
|
||||||
timer.restart();
|
timer.restart();
|
||||||
QList<QDBusObjectPath> objectPaths = testserviceInterface.getObjectPaths(10);
|
QList<QDBusObjectPath> objectPaths = testServiceInterface.getObjectPaths(10);
|
||||||
if (objectPaths.size() != 10) qDebug() << "wrong list size" << objectPaths.size();
|
if (objectPaths.size() != 10) qtout << "wrong list size" << objectPaths.size() << endl;
|
||||||
t10 = timer.nsecsElapsed() / 1000000; // ms
|
t10 = timer.elapsed(); // ms
|
||||||
|
|
||||||
timer.restart();
|
timer.restart();
|
||||||
objectPaths = testserviceInterface.getObjectPaths(100);
|
objectPaths = testServiceInterface.getObjectPaths(100);
|
||||||
if (objectPaths.size() != 100) qDebug() << "wrong list size" << objectPaths.size();
|
if (objectPaths.size() != 100) qtout << "wrong list size" << objectPaths.size() << endl;
|
||||||
t100 = timer.nsecsElapsed() / 1000000; // ms
|
t100 = timer.elapsed(); // ms
|
||||||
|
|
||||||
timer.restart();
|
timer.restart();
|
||||||
objectPaths = testserviceInterface.getObjectPaths(1000);
|
objectPaths = testServiceInterface.getObjectPaths(1000);
|
||||||
if (objectPaths.size() != 1000) qDebug() << "wrong list size" << objectPaths.size();
|
if (objectPaths.size() != 1000) qtout << "wrong list size" << objectPaths.size() << endl;
|
||||||
t1000 = timer.nsecsElapsed() / 1000000; // ms
|
t1000 = timer.elapsed(); // ms
|
||||||
|
qtout << "Reading paths list 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << endl;
|
||||||
qDebug() << "Reading paths list 10/100/1000 in ms:" << t10 << t100 << t1000;
|
|
||||||
timer.invalidate();
|
timer.invalidate();
|
||||||
|
|
||||||
// next round?
|
// next round?
|
||||||
qDebug() << "---------------------------------------";
|
qtout << "---------------------------------------" << endl;
|
||||||
qDebug() << "Key ....... x to exit, pid:" << ServiceTool::getPid();
|
qtout << "Key ....... x to exit" << endl;
|
||||||
line = qtin.readLine().toLower().trimmed();
|
line = qtin.readLine().toLower().trimmed();
|
||||||
if (line.startsWith('x'))
|
if (line.startsWith('x'))
|
||||||
{
|
{
|
||||||
qDebug() << "Ending!";
|
qtout << "Ending!" << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,6 @@
|
|||||||
#ifndef BLACKSAMPLE_SERVICETOOL_H
|
#ifndef BLACKSAMPLE_SERVICETOOL_H
|
||||||
#define BLACKSAMPLE_SERVICETOOL_H
|
#define BLACKSAMPLE_SERVICETOOL_H
|
||||||
|
|
||||||
#include "blackmisc/aviation/airportlist.h"
|
|
||||||
#include "blackmisc/aviation/atcstationlist.h"
|
|
||||||
#include "blackmisc/aviation/callsign.h"
|
|
||||||
#include "blackmisc/network/clientlist.h"
|
|
||||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDBusArgument>
|
#include <QDBusArgument>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -39,21 +33,12 @@ namespace BlackSample
|
|||||||
*/
|
*/
|
||||||
class ServiceTool
|
class ServiceTool
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
ServiceTool() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Process id
|
|
||||||
static qint64 getPid()
|
|
||||||
{
|
|
||||||
return QCoreApplication::applicationPid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Client side of data transfer test
|
//! Client side of data transfer test
|
||||||
static void dataTransferTestClient(const QString &address);
|
static void dataTransferTestClient(const QString &address);
|
||||||
|
|
||||||
//! Server side of data transfer test
|
//! Server side of data transfer test
|
||||||
static void dataTransferTestServer(BlackMisc::CDBusServer *dBusServer);
|
static void dataTransferTestServer(BlackMisc::CDBusServer *dBusServer, bool verbose);
|
||||||
|
|
||||||
//! Start a new process
|
//! Start a new process
|
||||||
static QProcess *startNewProcess(const QString &executable, const QStringList &arguments = QStringList(), QObject *parent = 0);
|
static QProcess *startNewProcess(const QString &executable, const QStringList &arguments = QStringList(), QObject *parent = 0);
|
||||||
@@ -61,26 +46,9 @@ namespace BlackSample
|
|||||||
//! Loop to send data to test service (slots on server)
|
//! Loop to send data to test service (slots on server)
|
||||||
static void sendDataToTestservice(const QDBusConnection &connection);
|
static void sendDataToTestservice(const QDBusConnection &connection);
|
||||||
|
|
||||||
//! Display QDBusArgument
|
private:
|
||||||
static void displayQDBusArgument(const QDBusArgument &arg, qint32 level = 0);
|
//! No constructor
|
||||||
|
ServiceTool() = delete;
|
||||||
//! Register testservice with connection
|
|
||||||
static Testservice *registerTestservice(QDBusConnection &connection, QObject *parent = 0);
|
|
||||||
|
|
||||||
//! Get a random callsign
|
|
||||||
static BlackMisc::Aviation::CCallsign getRandomAtcCallsign();
|
|
||||||
|
|
||||||
//! Get stations
|
|
||||||
static BlackMisc::Aviation::CAtcStationList getStations(int number);
|
|
||||||
|
|
||||||
//! Get aircraft cfg entries
|
|
||||||
static BlackMisc::Simulation::FsCommon::CAircraftCfgEntriesList getAircraftCfgEntries(int number);
|
|
||||||
|
|
||||||
//! Get airports
|
|
||||||
static BlackMisc::Aviation::CAirportList getAirports(int number);
|
|
||||||
|
|
||||||
//! Get clients
|
|
||||||
static BlackMisc::Network::CClientList getClients(int number);
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user