mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #879, use test data in samples/unit tests
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4b506f20ab
commit
e73c8c4f36
@@ -11,6 +11,7 @@
|
|||||||
//! \ingroup sampleblackmisc
|
//! \ingroup sampleblackmisc
|
||||||
|
|
||||||
#include "samplescontainer.h"
|
#include "samplescontainer.h"
|
||||||
|
#include "blackmisc/test/testdata.h"
|
||||||
#include "blackmisc/aviation/atcstation.h"
|
#include "blackmisc/aviation/atcstation.h"
|
||||||
#include "blackmisc/aviation/atcstationlist.h"
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
#include "blackmisc/aviation/callsign.h"
|
#include "blackmisc/aviation/callsign.h"
|
||||||
@@ -35,27 +36,16 @@ using namespace BlackMisc::Aviation;
|
|||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackMisc::Test;
|
||||||
|
|
||||||
namespace BlackSample
|
namespace BlackSample
|
||||||
{
|
{
|
||||||
int CSamplesContainer::samples()
|
int CSamplesContainer::samples()
|
||||||
{
|
{
|
||||||
// ATC stations
|
// ATC stations
|
||||||
QDateTime dtFrom = QDateTime::currentDateTimeUtc();
|
const CAtcStation station1(CTestData::getMunichTower());
|
||||||
QDateTime dtUntil = dtFrom.addSecs(60 * 60); // 1 hour
|
|
||||||
QDateTime dtFrom2 = dtUntil;
|
|
||||||
QDateTime dtUntil2 = dtUntil.addSecs(60 * 60);
|
|
||||||
CFrequency freqEddmTwr(118.7, CFrequencyUnit::MHz());
|
|
||||||
CCallsign callsignEddmTwr("eddm_twr");
|
|
||||||
CCoordinateGeodetic geoPos =
|
|
||||||
CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
|
|
||||||
CAtcStation station1(callsignEddmTwr, CUser("123456", "Joe Doe"),
|
|
||||||
freqEddmTwr,
|
|
||||||
geoPos, CLength(50, CLengthUnit::km()), false, dtFrom, dtUntil);
|
|
||||||
CAtcStation station2(station1);
|
CAtcStation station2(station1);
|
||||||
CAtcStation station3(CCallsign("eddm_app"), CUser("654321", "Jen Doe"),
|
CAtcStation station3(CTestData::getMunichApproach());
|
||||||
CFrequency(120.7, CFrequencyUnit::MHz()),
|
|
||||||
geoPos, CLength(100, CLengthUnit::km()), false, dtFrom2, dtUntil2);
|
|
||||||
|
|
||||||
// ATC List
|
// ATC List
|
||||||
CAtcStationList atcList;
|
CAtcStationList atcList;
|
||||||
@@ -85,7 +75,6 @@ namespace BlackSample
|
|||||||
CFrequency changedFrequency(118.25, CFrequencyUnit::MHz());
|
CFrequency changedFrequency(118.25, CFrequencyUnit::MHz());
|
||||||
CPropertyIndexVariantMap vm(CAtcStation::IndexFrequency, CVariant::from(changedFrequency));
|
CPropertyIndexVariantMap vm(CAtcStation::IndexFrequency, CVariant::from(changedFrequency));
|
||||||
|
|
||||||
|
|
||||||
// demonstration apply
|
// demonstration apply
|
||||||
CPropertyIndexList changedProperties;
|
CPropertyIndexList changedProperties;
|
||||||
changedProperties = station1Cpy.apply(vm, true);
|
changedProperties = station1Cpy.apply(vm, true);
|
||||||
@@ -95,11 +84,11 @@ namespace BlackSample
|
|||||||
|
|
||||||
// applyIf
|
// applyIf
|
||||||
int changed;
|
int changed;
|
||||||
changed = atcList.applyIf(&CAtcStation::getCallsign, callsignEddmTwr, vm);
|
changed = atcList.applyIf(&CAtcStation::getCallsign, CTestData::getMunichTower().getCallsign(), vm);
|
||||||
qDebug() << "applyIf, changed" << changed << vm << "expected 1";
|
qDebug() << "applyIf, changed" << changed << vm << "expected 1";
|
||||||
changed = atcList.applyIf(&CAtcStation::getCallsign, callsignEddmTwr, vm);
|
changed = atcList.applyIf(&CAtcStation::getCallsign, CTestData::getMunichTower().getCallsign(), vm);
|
||||||
qDebug() << "applyIf, changed" << changed << vm << "expected 1";
|
qDebug() << "applyIf, changed" << changed << vm << "expected 1";
|
||||||
changed = atcList.applyIf(&CAtcStation::getCallsign, callsignEddmTwr, vm, true);
|
changed = atcList.applyIf(&CAtcStation::getCallsign, CTestData::getMunichTower().getCallsign(), vm, true);
|
||||||
qDebug() << "applyIf, changed" << changed << vm << "expected 0";
|
qDebug() << "applyIf, changed" << changed << vm << "expected 0";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "blackmisc/pq/speed.h"
|
#include "blackmisc/pq/speed.h"
|
||||||
#include "blackmisc/pq/units.h"
|
#include "blackmisc/pq/units.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||||
|
#include "blackmisc/test/testdata.h"
|
||||||
#include "blackmisc/stringutils.h"
|
#include "blackmisc/stringutils.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -45,13 +46,10 @@ using namespace BlackMisc::Simulation;
|
|||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackMisc::Test;
|
||||||
|
|
||||||
namespace BlackSample
|
namespace BlackSample
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
|
||||||
* Samples
|
|
||||||
*/
|
|
||||||
int CSamplesJson::samples()
|
int CSamplesJson::samples()
|
||||||
{
|
{
|
||||||
QTextStream cin(stdin);
|
QTextStream cin(stdin);
|
||||||
@@ -61,14 +59,10 @@ namespace BlackSample
|
|||||||
l.convertFromJson(json);
|
l.convertFromJson(json);
|
||||||
qDebug() << json << l;
|
qDebug() << json << l;
|
||||||
qDebug() << "-------";
|
qDebug() << "-------";
|
||||||
QDateTime dtFrom = QDateTime::currentDateTimeUtc();
|
CAtcStation station = CTestData::getMunichTower();
|
||||||
QDateTime dtUntil = dtFrom.addSecs(60 * 60); // 1 hour
|
|
||||||
CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
|
|
||||||
CAtcStation station(CCallsign("eddm_twr"), CUser("123456", "Joe Doe"),
|
|
||||||
CFrequency(118.7, CFrequencyUnit::MHz()), geoPos, CLength(50, CLengthUnit::km()), false, dtFrom, dtUntil);
|
|
||||||
json = station.toJson();
|
json = station.toJson();
|
||||||
QJsonDocument doc(json);
|
QJsonDocument doc(json);
|
||||||
qDebug() << doc.toJson(QJsonDocument::Indented);
|
qDebug().noquote() << doc.toJson(QJsonDocument::Indented);
|
||||||
qDebug() << "-------";
|
qDebug() << "-------";
|
||||||
|
|
||||||
station = CAtcStation();
|
station = CAtcStation();
|
||||||
@@ -77,14 +71,11 @@ namespace BlackSample
|
|||||||
qDebug() << "------- Enter -----";
|
qDebug() << "------- Enter -----";
|
||||||
cin.readLine();
|
cin.readLine();
|
||||||
|
|
||||||
CAircraftSituation situation(geoPos, CHeading(10, CHeading::True, CAngleUnit::deg()),
|
CSimulatedAircraft aircraft(CCallsign("DAMBZ"), CUser("123456", "Joe Pilot"), CTestData::getAircraftSituationAboveMunichTower());
|
||||||
CAngle(12, CAngleUnit::deg()), CAngle(5, CAngleUnit::deg()),
|
|
||||||
CSpeed(111, CSpeedUnit::km_h()));
|
|
||||||
CSimulatedAircraft aircraft(CCallsign("DAMBZ"), CUser("123456", "Joe Pilot"), situation);
|
|
||||||
aircraft.setCom1System(CComSystem::getCom1System(122.8, 118.75));
|
aircraft.setCom1System(CComSystem::getCom1System(122.8, 118.75));
|
||||||
aircraft.setCom2System(CComSystem::getCom2System(123.8, 124.00));
|
aircraft.setCom2System(CComSystem::getCom2System(123.8, 124.00));
|
||||||
aircraft.setTransponder(CTransponder::getStandardTransponder(7000, CTransponder::ModeC));
|
aircraft.setTransponder(CTransponder::getStandardTransponder(7000, CTransponder::ModeC));
|
||||||
aircraft.setIcaoCodes(CAircraftIcaoCode("B737", "L2J"), CAirlineIcaoCode("DLH"));
|
aircraft.setIcaoCodes(CTestData::getDBAircraftIcaoB737(), CAirlineIcaoCode("DLH"));
|
||||||
|
|
||||||
json = aircraft.toJson();
|
json = aircraft.toJson();
|
||||||
doc = QJsonDocument(json);
|
doc = QJsonDocument(json);
|
||||||
@@ -97,10 +88,7 @@ namespace BlackSample
|
|||||||
qDebug() << "------- Enter -----";
|
qDebug() << "------- Enter -----";
|
||||||
cin.readLine();
|
cin.readLine();
|
||||||
|
|
||||||
CAtcStationList stations;
|
CAtcStationList stations = CTestData::getAtcStations();
|
||||||
stations.push_back(station);
|
|
||||||
station.setCallsign(CCallsign("eddn_gnd"));
|
|
||||||
stations.push_back(station);
|
|
||||||
json = stations.toJson();
|
json = stations.toJson();
|
||||||
doc.setObject(json);
|
doc.setObject(json);
|
||||||
qDebug() << doc.toJson(QJsonDocument::Indented);
|
qDebug() << doc.toJson(QJsonDocument::Indented);
|
||||||
@@ -124,5 +112,4 @@ namespace BlackSample
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "blackmisc/test/testserviceinterface.h"
|
#include "blackmisc/test/testserviceinterface.h"
|
||||||
#include "blackmisc/dbusserver.h"
|
#include "blackmisc/dbusserver.h"
|
||||||
#include "blackmisc/network/server.h"
|
#include "blackmisc/network/server.h"
|
||||||
|
#include "blackmisc/test/testdata.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -96,7 +97,6 @@ namespace BlackSample
|
|||||||
ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(), connection);
|
ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(), connection);
|
||||||
QTextStream qtin(stdin);
|
QTextStream qtin(stdin);
|
||||||
QTextStream qtout(stdout);
|
QTextStream qtout(stdout);
|
||||||
QString line;
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@@ -138,17 +138,15 @@ namespace BlackSample
|
|||||||
speed.switchUnit(CSpeedUnit::kts());
|
speed.switchUnit(CSpeedUnit::kts());
|
||||||
testServiceInterface.receiveSpeed(speed);
|
testServiceInterface.receiveSpeed(speed);
|
||||||
qtout << "Send speed via interface " << speed << endl;
|
qtout << "Send speed via interface " << speed << endl;
|
||||||
QThread::msleep(2500);
|
|
||||||
speed.switchUnit(CSpeedUnit::km_h());
|
speed.switchUnit(CSpeedUnit::km_h());
|
||||||
speed.addValueSameUnit(1.0);
|
speed.addValueSameUnit(1.0);
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
const CServer trafficServer("fooserver", "a foo server", "localhost", 1234,
|
const CServer trafficServer = CTestData::getTrafficServer();
|
||||||
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());
|
||||||
qtout << "Send server via interface and variant " << trafficServer << tsqv.userType() << endl;
|
qtout << "Send server via interface and variant '" << trafficServer << QLatin1Literal("' ") << tsqv.userType() << endl;
|
||||||
|
|
||||||
// Aviation
|
// Aviation
|
||||||
const CComSystem comSystem = CComSystem("DBUS COM1", CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress(), CPhysicalQuantitiesConstants::FrequencyUnicom());
|
const CComSystem comSystem = CComSystem("DBUS COM1", CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress(), CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||||
@@ -179,59 +177,34 @@ namespace BlackSample
|
|||||||
testServiceInterface.receiveLength(alt);
|
testServiceInterface.receiveLength(alt);
|
||||||
qtout << "Send altitude via interface " << alt << endl;
|
qtout << "Send altitude via interface " << alt << endl;
|
||||||
|
|
||||||
const CCallsign callsign("d-ambz");
|
const CCallsign callsign = CTestData::getRandomPilotCallsign();
|
||||||
testServiceInterface.receiveCallsign(callsign);
|
testServiceInterface.receiveCallsign(callsign);
|
||||||
qtout << "Send callsign via interface " << callsign << endl;
|
qtout << "Send callsign via interface " << callsign << endl;
|
||||||
|
|
||||||
CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() }); // Munich
|
const CAtcStation station = CTestData::getMunichTower();
|
||||||
CAtcStation station(CCallsign("eddm_twr"), CUser("123456", "Joe Controller"),
|
|
||||||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
|
||||||
geoPos, CLength(50, CLengthUnit::km()));
|
|
||||||
|
|
||||||
testServiceInterface.receiveAtcStation(station);
|
testServiceInterface.receiveAtcStation(station);
|
||||||
qtout << "Send ATC " << station << endl;
|
qtout << "Send ATC " << station << endl;
|
||||||
|
|
||||||
// Geo
|
// Geo
|
||||||
// EDDF: 50° 2′ 0″ N, 8° 34′ 14″ E, 100m MSL
|
const CCoordinateGeodetic geoPos = CTestData::getCoordinateFrankfurtTower();
|
||||||
geoPos = CCoordinateGeodetic::fromWgs84("50° 2′ 1″ 23 N", "8° 34′ 14″ E", { 111, CLengthUnit::m() });
|
|
||||||
testServiceInterface.receiveGeoPosition(geoPos);
|
testServiceInterface.receiveGeoPosition(geoPos);
|
||||||
qtout << "Send geo position " << geoPos << endl;
|
qtout << "Send geo position " << geoPos << endl;
|
||||||
|
CApplication::processEventsFor(1000);
|
||||||
|
|
||||||
qtout << "----------------- variant tests ----------------" << endl;
|
qtout << "----------------- variant tests ----------------" << endl;
|
||||||
CVariantList cvList;
|
const CVariantList cvList = CTestData::getCVariantList();
|
||||||
cvList.push_back(CVariant::fromValue(len));
|
testServiceInterface.receiveVariantList(cvList);
|
||||||
cvList.push_back(CVariant::fromValue(alt));
|
qtout << "Send " << cvList.size() << " variants via interface as CVariantList" << endl;
|
||||||
CVariantList lengthsV;
|
|
||||||
lengthsV.push_back(CVariant::fromValue(len));
|
|
||||||
lengthsV.push_back(CVariant::fromValue(alt));
|
|
||||||
testServiceInterface.receiveLengthsQvl(cvList);
|
|
||||||
qtout << "Send lengths via interface as CVariantList" << endl;
|
|
||||||
testServiceInterface.receiveLengthsQl(lengthsV);
|
|
||||||
qtout << "Send lengths via interface as QList<CVariant>" << endl;
|
|
||||||
for (const CVariant &lv : cvList)
|
|
||||||
{
|
|
||||||
qtout << " " << "Send length in list: " << lv << endl;
|
|
||||||
}
|
|
||||||
CApplication::processEventsFor(2000);
|
|
||||||
|
|
||||||
// Value map
|
const CPropertyIndexVariantMap valueMap = CTestData::getCPropertyIndexVariantMap();
|
||||||
qtout << "----------------- index variant map ----------------" << endl;
|
|
||||||
|
|
||||||
CPropertyIndexVariantMap valueMap;
|
|
||||||
valueMap.addValue(1000, 111.222);
|
|
||||||
valueMap.addValue(2000, callsign);
|
|
||||||
valueMap.addValue(3000, alt);
|
|
||||||
valueMap.addValue(4000, track);
|
|
||||||
valueMap.addValue(5000, QDateTime::currentDateTime().addDays(1));
|
|
||||||
valueMap.addValue(6000, QString("foobar"));
|
|
||||||
testServiceInterface.receiveValueMap(valueMap);
|
testServiceInterface.receiveValueMap(valueMap);
|
||||||
qtout << "Send index variant map " << valueMap << endl;
|
qtout << "Send " << valueMap.size() << " index variant map entries" << endl;
|
||||||
CApplication::processEventsFor(2000);
|
CApplication::processEventsFor(1000);
|
||||||
|
|
||||||
qtout << "----------------- pings ----------------" << endl;
|
qtout << "----------------- pings ----------------" << endl;
|
||||||
int errors = ITestServiceInterface::pingTests(testServiceInterface, false);
|
const int errors = ITestServiceInterface::pingTests(testServiceInterface, false);
|
||||||
qtout << "Ping errors " << errors << endl;
|
qtout << "Ping errors " << errors << endl;
|
||||||
CApplication::processEventsFor(2000);
|
CApplication::processEventsFor(1000);
|
||||||
|
|
||||||
// Performance tools
|
// Performance tools
|
||||||
qtout << "----------------- performance ----------------" << endl;
|
qtout << "----------------- performance ----------------" << endl;
|
||||||
@@ -240,24 +213,24 @@ namespace BlackSample
|
|||||||
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 = testServiceInterface.getSpeed();
|
||||||
speedDummy = testServiceInterface.getSpeed();
|
Q_UNUSED(speedDummy);
|
||||||
}
|
}
|
||||||
qint64 t10 = timer.elapsed(); // 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 = testServiceInterface.getSpeed();
|
||||||
speedDummy = testServiceInterface.getSpeed();
|
Q_UNUSED(speedDummy);
|
||||||
}
|
}
|
||||||
qint64 t100 = timer.elapsed(); // 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 = testServiceInterface.getSpeed();
|
||||||
speedDummy = testServiceInterface.getSpeed();
|
Q_UNUSED(speedDummy);
|
||||||
}
|
}
|
||||||
qint64 t1000 = timer.elapsed(); // ms
|
qint64 t1000 = timer.elapsed(); // ms
|
||||||
timer.invalidate();
|
timer.invalidate();
|
||||||
@@ -266,22 +239,22 @@ namespace BlackSample
|
|||||||
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 = testServiceInterface.getAtcStation();
|
||||||
stationDummy = testServiceInterface.getAtcStation();
|
Q_UNUSED(stationDummy);
|
||||||
}
|
}
|
||||||
t10 = timer.elapsed(); // 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 = testServiceInterface.getAtcStation();
|
||||||
stationDummy = testServiceInterface.getAtcStation();
|
Q_UNUSED(stationDummy);
|
||||||
}
|
}
|
||||||
t100 = timer.elapsed(); // 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 = testServiceInterface.getAtcStation();
|
||||||
stationDummy = testServiceInterface.getAtcStation();
|
Q_UNUSED(stationDummy);
|
||||||
}
|
}
|
||||||
t1000 = timer.elapsed(); // ms
|
t1000 = timer.elapsed(); // ms
|
||||||
qtout << "Reading station objects 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << endl;
|
qtout << "Reading station objects 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << endl;
|
||||||
@@ -326,7 +299,7 @@ namespace BlackSample
|
|||||||
// next round?
|
// next round?
|
||||||
qtout << "---------------------------------------" << endl;
|
qtout << "---------------------------------------" << endl;
|
||||||
qtout << "Key ....... x to exit" << endl;
|
qtout << "Key ....... x to exit" << endl;
|
||||||
line = qtin.readLine().toLower().trimmed();
|
QString line = qtin.readLine().toLower().trimmed();
|
||||||
if (line.startsWith('x'))
|
if (line.startsWith('x'))
|
||||||
{
|
{
|
||||||
qtout << "Ending!" << endl;
|
qtout << "Ending!" << endl;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "blackmisc/pq/frequency.h"
|
#include "blackmisc/pq/frequency.h"
|
||||||
#include "blackmisc/pq/length.h"
|
#include "blackmisc/pq/length.h"
|
||||||
#include "blackmisc/pq/units.h"
|
#include "blackmisc/pq/units.h"
|
||||||
|
#include "blackmisc/test/testdata.h"
|
||||||
#include "blackmisc/range.h"
|
#include "blackmisc/range.h"
|
||||||
#include "blackmisc/stringutils.h"
|
#include "blackmisc/stringutils.h"
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ using namespace BlackMisc::Aviation;
|
|||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackMisc::Test;
|
||||||
|
|
||||||
namespace BlackSample
|
namespace BlackSample
|
||||||
{
|
{
|
||||||
@@ -69,19 +71,11 @@ namespace BlackSample
|
|||||||
CCallsign callsign2("DAmbz");
|
CCallsign callsign2("DAmbz");
|
||||||
out << callsign1 << " " << callsign2 << " " << (callsign1 == callsign2) << endl;
|
out << callsign1 << " " << callsign2 << " " << (callsign1 == callsign2) << endl;
|
||||||
|
|
||||||
QDateTime dtFrom = QDateTime::currentDateTimeUtc();
|
CAtcStation station1 = CTestData::getFrankfurtTower();
|
||||||
QDateTime dtUntil = dtFrom.addSecs(60 * 60); // 1 hour
|
|
||||||
QDateTime dtFrom2 = dtUntil;
|
|
||||||
QDateTime dtUntil2 = dtUntil.addSecs(60 * 60);
|
|
||||||
CCoordinateGeodetic geoPos =
|
|
||||||
CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
|
|
||||||
CAtcStation station1(CCallsign("eddm_twr"), CUser("123456", "Joe Doe"),
|
|
||||||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
|
||||||
geoPos, CLength(50, CLengthUnit::km()), false, dtFrom, dtUntil);
|
|
||||||
CAtcStation station2(station1);
|
CAtcStation station2(station1);
|
||||||
CAtcStation station3(CCallsign("eddm_twr"), CUser("654321", "Jen Doe"),
|
CAtcStation station3(station1);
|
||||||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
station3.setController(CTestData::getRandomController());
|
||||||
geoPos, CLength(100, CLengthUnit::km()), false, dtFrom2, dtUntil2);
|
|
||||||
out << station1 << " " << station2 << " " << (station1.getCallsign() == station2.getCallsign()) << endl;
|
out << station1 << " " << station2 << " " << (station1.getCallsign() == station2.getCallsign()) << endl;
|
||||||
|
|
||||||
// User parsing
|
// User parsing
|
||||||
@@ -89,13 +83,8 @@ namespace BlackSample
|
|||||||
out << user.getRealName() << user.getHomeBase() << endl;
|
out << user.getRealName() << user.getHomeBase() << endl;
|
||||||
|
|
||||||
// ATC List
|
// ATC List
|
||||||
CAtcStationList atcList;
|
CAtcStationList atcList = CTestData::getAtcStations();
|
||||||
atcList.push_back(station1);
|
atcList.push_back(CTestData::getAtcStations());
|
||||||
atcList.push_back(station2);
|
|
||||||
atcList.push_back(station3);
|
|
||||||
atcList.push_back(station1);
|
|
||||||
atcList.push_back(station2);
|
|
||||||
atcList.push_back(station3);
|
|
||||||
atcList = atcList.findBy(&CAtcStation::getCallsign, "eddm_twr", &CAtcStation::getFrequency, CFrequency(118.7, CFrequencyUnit::MHz()));
|
atcList = atcList.findBy(&CAtcStation::getCallsign, "eddm_twr", &CAtcStation::getFrequency, CFrequency(118.7, CFrequencyUnit::MHz()));
|
||||||
atcList = atcList.sortedBy(&CAtcStation::getBookedFromUtc, &CAtcStation::getCallsign, &CAtcStation::getControllerRealName);
|
atcList = atcList.sortedBy(&CAtcStation::getBookedFromUtc, &CAtcStation::getCallsign, &CAtcStation::getControllerRealName);
|
||||||
out << atcList << endl;
|
out << atcList << endl;
|
||||||
|
|||||||
@@ -167,25 +167,12 @@ namespace BlackMisc
|
|||||||
if (m_verbose) out() << "Pid: " << CTestService::getPid() << " Received length: " << length << endl;
|
if (m_verbose) out() << "Pid: " << CTestService::getPid() << " Received length: " << length << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTestService::receiveLengthsQvl(const QVariantList &lengthsVariantList) const
|
void CTestService::receiveVariantList(const CVariantList &variantList) const
|
||||||
{
|
{
|
||||||
if (m_verbose) out() << "Pid: " << CTestService::getPid() << " " << lengthsVariantList.size() << endl;
|
if (m_verbose) out() << "Pid: " << CTestService::getPid() << " " << variantList.size() << endl;
|
||||||
foreach (QVariant lv, lengthsVariantList)
|
for (CVariant lv : variantList)
|
||||||
{
|
{
|
||||||
BlackMisc::PhysicalQuantities::CLength l;
|
if (m_verbose) out() << " Received variant: " << lv.toQString() << endl;
|
||||||
lv.value<QDBusArgument>() >> l;
|
|
||||||
if (m_verbose) out() << " Received length in list: " << l << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CTestService::receiveLengthsQl(const QList<QVariant> &lengthsList) const
|
|
||||||
{
|
|
||||||
if (m_verbose) out() << "Pid: " << CTestService::getPid() << " Received " << lengthsList.size() << endl;
|
|
||||||
foreach (QVariant lv, lengthsList)
|
|
||||||
{
|
|
||||||
BlackMisc::PhysicalQuantities::CLength l;
|
|
||||||
lv.value<QDBusArgument>() >> l;
|
|
||||||
if (m_verbose) out() << " Received length in list: " << l << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "blackmisc/pq/speed.h"
|
#include "blackmisc/pq/speed.h"
|
||||||
#include "blackmisc/propertyindex.h"
|
#include "blackmisc/propertyindex.h"
|
||||||
#include "blackmisc/propertyindexvariantmap.h"
|
#include "blackmisc/propertyindexvariantmap.h"
|
||||||
|
#include "blackmisc/variantlist.h"
|
||||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||||
@@ -136,11 +137,8 @@ namespace BlackMisc
|
|||||||
//! Receive a length
|
//! Receive a length
|
||||||
void receiveLength(const BlackMisc::PhysicalQuantities::CLength &length) const;
|
void receiveLength(const BlackMisc::PhysicalQuantities::CLength &length) const;
|
||||||
|
|
||||||
//! Receive lengths
|
//! Receive variant list
|
||||||
void receiveLengthsQl(const QList<QVariant> &lengthsList) const;
|
void receiveVariantList(const BlackMisc::CVariantList &variantList) const;
|
||||||
|
|
||||||
//! Receive lengths
|
|
||||||
void receiveLengthsQvl(const QVariantList &lengthsVariantList) const;
|
|
||||||
|
|
||||||
//! Receive ATC station
|
//! Receive ATC station
|
||||||
void receiveAtcStation(const BlackMisc::Aviation::CAtcStation &station) const;
|
void receiveAtcStation(const BlackMisc::Aviation::CAtcStation &station) const;
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ namespace BlackMisc
|
|||||||
ok = pingCompare(pi, piPing, out, verbose, errors);
|
ok = pingCompare(pi, piPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged property index via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged property index via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
CPropertyIndexVariantMap ivm;
|
const CPropertyIndexVariantMap ivm = CTestData::getCPropertyIndexVariantMap();
|
||||||
ivm.addValue(1000, "one");
|
|
||||||
ivm.addValue(2000, "two");
|
|
||||||
ivm.addValue(3000, "three");
|
|
||||||
const CPropertyIndexVariantMap ivmPing = testServiceInterface.pingIndexVariantMap(ivm);
|
const CPropertyIndexVariantMap ivmPing = testServiceInterface.pingIndexVariantMap(ivm);
|
||||||
ok = pingCompare(ivm, ivmPing, out, verbose, errors);
|
ok = pingCompare(ivm, ivmPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged variant map via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged variant map via interface" << errorInfo(ok) << endl; }
|
||||||
@@ -69,24 +66,22 @@ namespace BlackMisc
|
|||||||
ok = pingCompare(speedNull, speedNullPing, out, verbose, errors);
|
ok = pingCompare(speedNull, speedNullPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged null speed via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged null speed via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
const CAtcStation station = CTestData::getAtcStation();
|
const CAtcStation station = CTestData::getRandomAtcStation();
|
||||||
const CAtcStation stationPing = testServiceInterface.pingAtcStation(station);
|
const CAtcStation stationPing = testServiceInterface.pingAtcStation(station);
|
||||||
ok = pingCompare(station, stationPing, out, verbose, errors);
|
ok = pingCompare(station, stationPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged ATC station via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged ATC station via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
const CAircraftIcaoCode icaoData("B737", "L2J");
|
const CAircraftIcaoCode icaoData = CTestData::getDBAircraftIcaoB737();
|
||||||
const CAircraftIcaoCode icaoDataPing = testServiceInterface.pingAircraftIcaoData(icaoData);
|
const CAircraftIcaoCode icaoDataPing = testServiceInterface.pingAircraftIcaoData(icaoData);
|
||||||
ok = pingCompare(icaoData, icaoDataPing, out, verbose, errors);
|
ok = pingCompare(icaoData, icaoDataPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged ICAO data via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged ICAO data via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
const CUser user("223344", "Ping Me User");
|
const CUser user = CTestData::getRandomPilot();
|
||||||
const CUser userPing = testServiceInterface.pingUser(user);
|
const CUser userPing = testServiceInterface.pingUser(user);
|
||||||
ok = pingCompare(user, userPing, out, verbose, errors);
|
ok = pingCompare(user, userPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged user via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged user via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
// EDDF: 50° 2′ 0″ N, 8° 34′ 14″ E, 2000m MSL
|
const CAircraftSituation situation = CTestData::getAircraftSituationAboveMunichTower();
|
||||||
const CCoordinateGeodetic coordinate = CCoordinateGeodetic::fromWgs84("50° 2′ 1″ 23 N", "8° 34′ 14″ E", { 2000, CLengthUnit::m() });
|
|
||||||
const CAircraftSituation situation = CAircraftSituation("DAMBZ", coordinate);
|
|
||||||
const CAircraftSituation situationPing = testServiceInterface.pingSituation(situation);
|
const CAircraftSituation situationPing = testServiceInterface.pingSituation(situation);
|
||||||
ok = pingCompare(situation, situationPing, out, verbose, errors);
|
ok = pingCompare(situation, situationPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged situation via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged situation via interface" << errorInfo(ok) << endl; }
|
||||||
@@ -112,33 +107,23 @@ namespace BlackMisc
|
|||||||
ok = pingCompare(parts, partsPing, out, verbose, errors);
|
ok = pingCompare(parts, partsPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged engine via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged engine via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
const CAircraftModel model("foobar", CAircraftModel::TypeManuallySet);
|
const CAircraftModel model = CTestData::getDbAircraftModelFsxAerosoftA320();
|
||||||
const CAircraftModel modelPing = testServiceInterface.pingAircraftModel(model);
|
const CAircraftModel modelPing = testServiceInterface.pingAircraftModel(model);
|
||||||
ok = pingCompare(model, modelPing, out, verbose, errors);
|
ok = pingCompare(model, modelPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged model via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged model via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
const CAircraftModel model2("mymodel", CAircraftModel::TypeFSInnData);
|
const CAircraftModelList models({ model, CTestData::getDbAircraftModelFsxA2AC172Skyhawk() });
|
||||||
const CAircraftModelList models({ model, model2});
|
|
||||||
const CAircraftModelList modelsPing = testServiceInterface.pingAircraftModelList(models);
|
const CAircraftModelList modelsPing = testServiceInterface.pingAircraftModelList(models);
|
||||||
ok = pingCompare(models, modelsPing, out, verbose, errors);
|
ok = pingCompare(models, modelsPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged model list via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged model list via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
const CCallsign callsign("DEMBZ");
|
const CSimulatedAircraft aircraft = CTestData::getA320Aircraft();
|
||||||
CSimulatedAircraft aircraft(callsign, CUser("123456", "Joe Pilot"), situation);
|
|
||||||
aircraft.setTransponder(transponder);
|
|
||||||
aircraft.setModel(model);
|
|
||||||
aircraft.setNetworkModel(model2);
|
|
||||||
const CSimulatedAircraft aircraftPing = testServiceInterface.pingSimulatedAircraft(aircraft);
|
const CSimulatedAircraft aircraftPing = testServiceInterface.pingSimulatedAircraft(aircraft);
|
||||||
ok = pingCompare(aircraft, aircraftPing, out, verbose, errors);
|
ok = pingCompare(aircraft, aircraftPing, out, verbose, errors);
|
||||||
pingCompare(aircraft.getModel(), aircraftPing.getModel(), out, verbose, errors);
|
|
||||||
pingCompare(aircraft.getNetworkModel(), aircraftPing.getNetworkModel(), out, verbose, errors);
|
|
||||||
if (verbose) { out << "Pinged simulated aircraft via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged simulated aircraft via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
CAtcStationList atcStationList;
|
const CAtcStationList atcStationList = CTestData::getAtcStations();
|
||||||
atcStationList.push_back(station);
|
const CAtcStationList atcStationListPing = testServiceInterface.pingAtcStationList(atcStationList);
|
||||||
atcStationList.push_back(station);
|
|
||||||
atcStationList.push_back(station);
|
|
||||||
CAtcStationList atcStationListPing = testServiceInterface.pingAtcStationList(atcStationList);
|
|
||||||
ok = pingCompare(atcStationList, atcStationListPing, out, verbose, errors);
|
ok = pingCompare(atcStationList, atcStationListPing, out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged ATC station list via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged ATC station list via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
@@ -163,8 +148,8 @@ namespace BlackMisc
|
|||||||
if (verbose) { out << "Pinged CVariant(clients) list via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged CVariant(clients) list via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
const CVariant cv2 = CVariant::fromValue(aircraft);
|
const CVariant cv2 = CVariant::fromValue(aircraft);
|
||||||
const CVariant cvPing2 = testServiceInterface.pingCVariant(cv2);
|
const CVariant cv2Ping = testServiceInterface.pingCVariant(cv2);
|
||||||
ok = pingCompare(cv2.value<CSimulatedAircraft>(), cvPing2.value<CSimulatedAircraft>(), out, verbose, errors);
|
ok = pingCompare(cv2.value<CSimulatedAircraft>(), cv2Ping.value<CSimulatedAircraft>(), out, verbose, errors);
|
||||||
if (verbose) { out << "Pinged CVariant(aircraft) list via interface" << errorInfo(ok) << endl; }
|
if (verbose) { out << "Pinged CVariant(aircraft) list via interface" << errorInfo(ok) << endl; }
|
||||||
|
|
||||||
// end
|
// end
|
||||||
|
|||||||
@@ -314,18 +314,11 @@ namespace BlackMisc
|
|||||||
return asyncCallWithArgumentList(QLatin1Literal("receiveLength"), argumentList);
|
return asyncCallWithArgumentList(QLatin1Literal("receiveLength"), argumentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusPendingReply<> receiveLengthsQl(const BlackMisc::CVariantList &lengthsList)
|
QDBusPendingReply<> receiveVariantList(const BlackMisc::CVariantList &list)
|
||||||
{
|
{
|
||||||
QList<QVariant> argumentList;
|
QList<QVariant> argumentList;
|
||||||
argumentList << QVariant::fromValue(lengthsList);
|
argumentList << QVariant::fromValue(list);
|
||||||
return asyncCallWithArgumentList(QLatin1Literal("receiveLengthsQl"), argumentList);
|
return asyncCallWithArgumentList(QLatin1Literal("receiveVariantList"), argumentList);
|
||||||
}
|
|
||||||
|
|
||||||
QDBusPendingReply<> receiveLengthsQvl(const BlackMisc::CVariantList &lengthsVariantList)
|
|
||||||
{
|
|
||||||
QList<QVariant> argumentList;
|
|
||||||
argumentList << QVariant::fromValue(lengthsVariantList);
|
|
||||||
return asyncCallWithArgumentList(QLatin1Literal("receiveLengthsQvl"), argumentList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusPendingReply<> receiveList(const QList<double> &list)
|
QDBusPendingReply<> receiveList(const QList<double> &list)
|
||||||
|
|||||||
Reference in New Issue
Block a user