mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-10 19:46:10 +08:00
refs #358, adjusted samples for model matching
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blacksim/blacksimfreefunctions.h"
|
||||
#include "servicetool.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include <QDBusMetaType>
|
||||
@@ -26,6 +27,7 @@ int main(int argc, char *argv[])
|
||||
// is just for testing, I did not split it up
|
||||
|
||||
BlackMisc::registerMetadata();
|
||||
BlackSim::registerMetadata();
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
// trying to get the arguments into a list
|
||||
|
||||
@@ -8,14 +8,16 @@ TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
CONFIG += blackmisc blackcore
|
||||
CONFIG += blackmisc blackcore blacksim
|
||||
|
||||
DEPENDPATH += . ../../src/blackmisc ../../src/blackcore
|
||||
DEPENDPATH += . ../../src/blackmisc ../../src/blackcore ../../src/blacksim
|
||||
INCLUDEPATH += . ../../src
|
||||
|
||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
||||
../../lib/blacksim.lib \
|
||||
../../lib/blackcore.lib
|
||||
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
||||
../../lib/libblacksim.a \
|
||||
../../lib/libblackcore.a
|
||||
|
||||
DESTDIR = ../../bin
|
||||
|
||||
@@ -24,6 +24,7 @@ using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Math;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackSim::FsCommon;
|
||||
using namespace BlackMiscTest;
|
||||
|
||||
namespace BlackMiscTest
|
||||
@@ -125,7 +126,7 @@ namespace BlackMiscTest
|
||||
/*
|
||||
* Stations
|
||||
*/
|
||||
CAtcStationList ServiceTool::getStations(qint32 number)
|
||||
CAtcStationList ServiceTool::getStations(int number)
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
@@ -146,10 +147,35 @@ namespace BlackMiscTest
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* Aircraft cfg entries
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Airports
|
||||
*/
|
||||
CAirportList ServiceTool::getAirports(qint32 number)
|
||||
CAirportList ServiceTool::getAirports(int number)
|
||||
{
|
||||
BlackMisc::Aviation::CAirportList list;
|
||||
for (int i = 0; i < number; i++)
|
||||
@@ -163,7 +189,7 @@ namespace BlackMiscTest
|
||||
return list;
|
||||
}
|
||||
|
||||
CClientList ServiceTool::getClients(qint32 number)
|
||||
CClientList ServiceTool::getClients(int number)
|
||||
{
|
||||
BlackMisc::Network::CClientList list;
|
||||
for (int i = 0; i < number; i++)
|
||||
@@ -176,7 +202,7 @@ namespace BlackMiscTest
|
||||
client.setCapability(true, CClient::FsdWithInterimPositions);
|
||||
client.setCapability(true, CClient::FsdWithModelDescription);
|
||||
QString myFooModel = QString("fooModel %1").arg(i);
|
||||
client.setAircraftModel(CAircraftModel(myFooModel, "nope"));
|
||||
client.setAircraftModel(CAircraftModel(myFooModel, CAircraftModel::TypeQueriedFromNetwork));
|
||||
list.push_back(client);
|
||||
}
|
||||
return list;
|
||||
@@ -246,10 +272,7 @@ namespace BlackMiscTest
|
||||
|
||||
// We send this as a non-replying message. This is used for sending errors, replys, signals,
|
||||
// and method calls (slots) that don't return
|
||||
if (connection.send(m))
|
||||
{
|
||||
qDebug() << "Send via low level method" << m;
|
||||
}
|
||||
if (connection.send(m)) { qDebug() << "Send via low level method" << m; }
|
||||
|
||||
// same as interface message
|
||||
// but call the slot
|
||||
@@ -334,14 +357,14 @@ namespace BlackMiscTest
|
||||
qDebug() << "Send geo position" << geoPos;
|
||||
|
||||
qDebug() << "----------------- pings ----------------";
|
||||
CPropertyIndex pi({ 1, 2, 3, 4, 5});
|
||||
CPropertyIndex pi({ 1000, 2000, 3000, 4000, 5000}); // numbers >= global index
|
||||
pi = testserviceInterface.pingPropertyIndex(pi);
|
||||
qDebug() << "Pinged properties via interface" << pi;
|
||||
qDebug() << "Pinged property index via interface" << pi;
|
||||
|
||||
CPropertyIndexVariantMap ivm;
|
||||
ivm.addValue(1, "one");
|
||||
ivm.addValue(2, "two");
|
||||
ivm.addValue(3, "three");
|
||||
ivm.addValue(1000, "one");
|
||||
ivm.addValue(2000, "two");
|
||||
ivm.addValue(3000, "three");
|
||||
ivm = testserviceInterface.pingIndexVariantMap(ivm);
|
||||
qDebug() << "Pinged variant map via interface" << ivm;
|
||||
|
||||
@@ -400,14 +423,14 @@ namespace BlackMiscTest
|
||||
qDebug() << "----------------- index variant map ----------------";
|
||||
|
||||
CPropertyIndexVariantMap valueMap;
|
||||
valueMap.addValue(1, 111.222);
|
||||
valueMap.addValue(2, callsign);
|
||||
valueMap.addValue(3, alt);
|
||||
valueMap.addValue(4, track);
|
||||
valueMap.addValue(5, QDateTime::currentDateTime().addDays(1));
|
||||
valueMap.addValue(6, QString("foobar"));
|
||||
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);
|
||||
qDebug() << "Send value map" << valueMap;
|
||||
qDebug() << "Send index variant map" << valueMap;
|
||||
|
||||
// Performance tools
|
||||
QThread::msleep(2500);
|
||||
@@ -477,10 +500,16 @@ namespace BlackMiscTest
|
||||
atcStationList = testserviceInterface.getAtcStationList(1000);
|
||||
if (atcStationList.size() != 1000) qDebug() << "wrong list size" << atcStationList.size();
|
||||
t1000 = timer.nsecsElapsed() / 1000000; // ms
|
||||
|
||||
qDebug() << "Reading station list 10/100/1000 in ms:" << t10 << t100 << t1000;
|
||||
timer.invalidate();
|
||||
|
||||
// test reading model entries with a realistic size
|
||||
timer.restart();
|
||||
CAircraftCfgEntriesList entriesList = testserviceInterface.getAircraftCfgEntriesList(5000);
|
||||
if (entriesList.size() != 5000) qDebug() << "wrong list size" << entriesList.size();
|
||||
int t5000 = timer.nsecsElapsed() / 1000000; // ms
|
||||
qDebug() << "Reading aircraft cfg entries in ms:" << t5000;
|
||||
|
||||
// object paths
|
||||
timer.restart();
|
||||
QList<QDBusObjectPath> objectPaths = testserviceInterface.getObjectPaths(10);
|
||||
if (objectPaths.size() != 10) qDebug() << "wrong list size" << objectPaths.size();
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISCTEST_SERVICETOOL_H
|
||||
#define BLACKMISCTEST_SERVICETOOL_H
|
||||
|
||||
@@ -5,6 +16,7 @@
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include "blackmisc/avairportlist.h"
|
||||
#include "blackmisc/nwclientlist.h"
|
||||
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QProcess>
|
||||
#include <QDBusConnection>
|
||||
@@ -82,21 +94,28 @@ namespace BlackMiscTest
|
||||
* \param number
|
||||
* \return
|
||||
*/
|
||||
static BlackMisc::Aviation::CAtcStationList getStations(qint32 number);
|
||||
static BlackMisc::Aviation::CAtcStationList getStations(int number);
|
||||
|
||||
/*!
|
||||
* \brief Get aircraft cfg entries
|
||||
* \param number
|
||||
* \return
|
||||
*/
|
||||
static BlackSim::FsCommon::CAircraftCfgEntriesList getAircraftCfgEntries(int number);
|
||||
|
||||
/*!
|
||||
* \brief Get airports
|
||||
* \param number
|
||||
* \return
|
||||
*/
|
||||
static BlackMisc::Aviation::CAirportList getAirports(qint32 number);
|
||||
static BlackMisc::Aviation::CAirportList getAirports(int number);
|
||||
|
||||
/*!
|
||||
* \brief Get clients
|
||||
* \param number
|
||||
* \return
|
||||
*/
|
||||
static BlackMisc::Network::CClientList getClients(qint32 number);
|
||||
static BlackMisc::Network::CClientList getClients(int number);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackSim::FsCommon;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
@@ -209,7 +210,7 @@ namespace BlackMiscTest
|
||||
/*
|
||||
* Object paths
|
||||
*/
|
||||
const QList<QDBusObjectPath> Testservice::getObjectPaths(const qint32 number) const
|
||||
QList<QDBusObjectPath> Testservice::getObjectPaths(int number) const
|
||||
{
|
||||
QList<QDBusObjectPath> paths;
|
||||
for (int i = 0; i < number; i++)
|
||||
@@ -220,11 +221,19 @@ namespace BlackMiscTest
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping ATC station list
|
||||
* Get ATC station list
|
||||
*/
|
||||
const BlackMisc::Aviation::CAtcStationList Testservice::getAtcStationList(const qint32 number) const
|
||||
CAtcStationList Testservice::getAtcStationList(int number) const
|
||||
{
|
||||
return BlackMisc::Aviation::CAtcStationList(ServiceTool::getStations(number));
|
||||
return CAtcStationList(ServiceTool::getStations(number));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get aircraft entries
|
||||
*/
|
||||
CAircraftCfgEntriesList Testservice::getAircraftCfgEntriesList(int number) const
|
||||
{
|
||||
return CAircraftCfgEntriesList(ServiceTool::getAircraftCfgEntries(number));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -327,5 +336,4 @@ namespace BlackMiscTest
|
||||
return BlackMisc::CVariant::fromValue(client);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "blackmisc/networkallclasses.h"
|
||||
#include "blackmisc/pqallquantities.h"
|
||||
#include "blackmisc/mathallclasses.h"
|
||||
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||
#include "servicetool.h"
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
@@ -147,10 +148,13 @@ namespace BlackMiscTest
|
||||
BlackMisc::Aviation::CAtcStation getAtcStation() const;
|
||||
|
||||
//! return n ATC stations
|
||||
const BlackMisc::Aviation::CAtcStationList getAtcStationList(const qint32 number) const;
|
||||
BlackMisc::Aviation::CAtcStationList getAtcStationList(int number) const;
|
||||
|
||||
//! return n aircraft cfg entries
|
||||
BlackSim::FsCommon::CAircraftCfgEntriesList getAircraftCfgEntriesList(int number) const;
|
||||
|
||||
//! Get object paths
|
||||
const QList<QDBusObjectPath> getObjectPaths(const qint32 number) const;
|
||||
QList<QDBusObjectPath> getObjectPaths(int number) const;
|
||||
|
||||
public:
|
||||
static const QString ServiceName;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/blackmiscallvalueclasses.h"
|
||||
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
@@ -53,6 +54,13 @@ namespace BlackMiscTest
|
||||
return asyncCallWithArgumentList(QLatin1String("getAtcStation"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackSim::FsCommon::CAircraftCfgEntriesList> getAircraftCfgEntriesList(int number)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(number);
|
||||
return asyncCallWithArgumentList(QLatin1String("getAircraftCfgEntriesList"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStationList> getAtcStationList(int number)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
|
||||
@@ -50,13 +50,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (i.startsWith("3"))
|
||||
{
|
||||
BlackSimTest::CSamplesModelMapping::samples(streamOut);
|
||||
BlackSimTest::CSamplesModelMapping::samples(streamOut, streamIn);
|
||||
}
|
||||
else if (i.startsWith("x"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
streamOut << endl;
|
||||
streamOut << "time elapsed: " << t.elapsed() << "ms" << endl;
|
||||
streamOut << "press key to exit" << endl;
|
||||
streamIn.readLine();
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
*/
|
||||
|
||||
#include "samplesfscommon.h"
|
||||
#include "blackmisc/sampleutils.h"
|
||||
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||
#include "blacksim/fscommon/aircraftindexer.h"
|
||||
#include "blacksim/fscommon/aircraftmapper.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFuture>
|
||||
@@ -17,6 +18,7 @@
|
||||
#include <QTextStream>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackSim::FsCommon;
|
||||
|
||||
namespace BlackSimTest
|
||||
@@ -27,51 +29,50 @@ namespace BlackSimTest
|
||||
*/
|
||||
int CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
// QString fsxDir = "P:/FlightSimulatorX (MSI)/SimObjects";
|
||||
QString fsxDir = "P:/Temp/SimObjects";
|
||||
streamOut << "Enter FSX directory:" << endl;
|
||||
streamOut << fsxDir << '\r';
|
||||
streamOut.flush();
|
||||
QString input = streamIn.readLine();
|
||||
if (!input.isEmpty()) fsxDir = input;
|
||||
QString fsxDir = CSampleUtils::selectDirectory({"P:/FlightSimulatorX (MSI)/SimObjects", "P:/Temp/SimObjects"}, streamOut, streamIn);
|
||||
CAircraftMapper mapper;
|
||||
if (!mapper.changeCAircraftCfgEntriesDirectory(fsxDir))
|
||||
{
|
||||
streamOut << "Wrong or empty directoy " << fsxDir << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
streamOut << "d .. direct, b .. background" << endl;
|
||||
input = streamIn.readLine();
|
||||
QString input = streamIn.readLine();
|
||||
|
||||
if (!input.startsWith("b"))
|
||||
{
|
||||
streamOut << "reading directly" << endl;
|
||||
CAircraftCfgEntriesList entriesList(fsxDir);
|
||||
if (entriesList.existsDir())
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
streamOut << "reading " << entriesList.getRootDirectory() << endl;
|
||||
entriesList.read();
|
||||
streamOut << "read entries: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
||||
QTime time;
|
||||
time.start();
|
||||
streamOut << "reading " << mapper.getAircraftCfgEntriesList().getRootDirectory() << endl;
|
||||
mapper.readSimObjects();
|
||||
streamOut << "read entries: " << mapper.getAircraftCfgEntriesList().size() << " in " << time.restart() << "ms" << endl;
|
||||
|
||||
QJsonDocument doc(entriesList.toJson());
|
||||
QByteArray jsonArray(doc.toJson());
|
||||
streamOut << "write JSON array with size " << jsonArray.size() << endl;
|
||||
QTemporaryFile tempFile;
|
||||
tempFile.open();
|
||||
tempFile.write(jsonArray);
|
||||
tempFile.close();
|
||||
streamOut << "written to " << tempFile.fileName() << " in " << time.restart() << "ms" << endl;
|
||||
CAircraftCfgEntriesList entriesList = mapper.getAircraftCfgEntriesList();
|
||||
QJsonDocument doc(entriesList.toJson());
|
||||
QByteArray jsonArray(doc.toJson());
|
||||
streamOut << "write JSON array with size " << jsonArray.size() << endl;
|
||||
QTemporaryFile tempFile;
|
||||
tempFile.open();
|
||||
tempFile.write(jsonArray);
|
||||
tempFile.close();
|
||||
streamOut << "written to " << tempFile.fileName() << " in " << time.restart() << "ms" << endl;
|
||||
|
||||
// re-read
|
||||
tempFile.open();
|
||||
jsonArray = tempFile.readAll();
|
||||
doc = QJsonDocument::fromJson(jsonArray);
|
||||
entriesList.clear();
|
||||
entriesList.convertFromJson(doc.object());
|
||||
streamOut << "read JSON array with size " << jsonArray.size() << endl;
|
||||
streamOut << "read entries from disk: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
||||
tempFile.close();
|
||||
}
|
||||
// re-read
|
||||
tempFile.open();
|
||||
jsonArray = tempFile.readAll();
|
||||
doc = QJsonDocument::fromJson(jsonArray);
|
||||
entriesList.clear();
|
||||
entriesList.convertFromJson(doc.object());
|
||||
streamOut << "read JSON array with size " << jsonArray.size() << endl;
|
||||
streamOut << "read entries from disk: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
||||
tempFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
streamOut << "reading in background" << endl;
|
||||
QFuture<int> f = BlackSim::FsCommon::CAircraftIndexer::readInBackground(fsxDir);
|
||||
QFuture<int> f = mapper.readInBackground();
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
|
||||
@@ -9,12 +9,19 @@
|
||||
|
||||
#include "samplesmodelmapping.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/sampleutils.h"
|
||||
#include "blacksim/blacksimfreefunctions.h"
|
||||
#include "blacksim/fscommon/vpilotmodelmappings.h"
|
||||
#include "blacksim/fscommon/aircraftmapper.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackSim;
|
||||
using namespace BlackSim::FsCommon;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackSimTest
|
||||
{
|
||||
@@ -22,18 +29,39 @@ namespace BlackSimTest
|
||||
/*
|
||||
* Samples
|
||||
*/
|
||||
int CSamplesModelMapping::samples(QTextStream &streamOut)
|
||||
int CSamplesModelMapping::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
BlackMisc::registerMetadata();
|
||||
BlackSim::registerMetadata();
|
||||
|
||||
CVPilotModelMappings cvm;
|
||||
cvm.addDirectory(CVPilotModelMappings::standardMappingsDirectory());
|
||||
bool s = cvm.load();
|
||||
streamOut << "loaded:" << s << "size:" << cvm.size() << endl;
|
||||
std::unique_ptr<ISimulatorModelMappings> cvm(new CVPilotModelMappings(true));
|
||||
bool s = cvm->read();
|
||||
streamOut << "directory: " << CVPilotModelMappings::standardMappingsDirectory() << endl;
|
||||
streamOut << "loaded: " << (s ? "yes" : "no") << " size: " << cvm->size() << endl;
|
||||
|
||||
BlackMisc::Aviation::CAircraftIcao icao("C172");
|
||||
streamOut << cvm.findByIcaoWildcard(icao) << endl;
|
||||
// mapper with rule set, handing over ownership
|
||||
CAircraftMapper mapper(std::move(cvm));
|
||||
QString fsxDir = CSampleUtils::selectDirectory({"P:/FlightSimulatorX (MSI)/SimObjects", "P:/Temp/SimObjects"}, streamOut, streamIn);
|
||||
if (!mapper.changeCAircraftCfgEntriesDirectory(fsxDir))
|
||||
{
|
||||
streamOut << "Wrong or empty directoy " << fsxDir << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
streamOut << "Start reading models" << endl;
|
||||
mapper.changeCAircraftCfgEntriesDirectory(fsxDir);
|
||||
mapper.readSimObjects();
|
||||
streamOut << "Read models: " << mapper.countAircraftCfgEntries() << endl;
|
||||
streamOut << "Ambigious models: " << mapper.getAircraftCfgEntriesList().detectAmbiguousTitles().join(", ") << endl;
|
||||
|
||||
// sync definitions, remove redundant ones
|
||||
streamOut << "Now synchronizing defintions: " << mapper.countMappingRules() << endl;
|
||||
int afterSync = mapper.synchronize();
|
||||
streamOut << "After synchronizing definitions: " << afterSync << endl;
|
||||
|
||||
CAircraftIcao icao("C172");
|
||||
streamOut << "Searching for " << icao << endl;
|
||||
streamOut << mapper.getAircraftMappingList().findByIcaoCodeExact(icao) << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace BlackSimTest
|
||||
{
|
||||
public:
|
||||
//! Run the samples
|
||||
static int samples(QTextStream &streamOut);
|
||||
static int samples(QTextStream &streamOut, QTextStream &streamIn);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
45
src/blackmisc/sampleutils.cpp
Normal file
45
src/blackmisc/sampleutils.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "sampleutils.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
QString CSampleUtils::selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
Q_ASSERT(!directoryOptions.isEmpty());
|
||||
if (directoryOptions.isEmpty()) { return ""; }
|
||||
if (directoryOptions.size() < 2) { return directoryOptions.first(); }
|
||||
|
||||
QString selectedDir;
|
||||
do
|
||||
{
|
||||
for (int i = 0; i < directoryOptions.size(); i++)
|
||||
{
|
||||
if (i > 0) { streamOut << " "; }
|
||||
streamOut << (i + 1) << ") " << directoryOptions.at(i) ;
|
||||
}
|
||||
streamOut << endl;
|
||||
streamOut << "Select [1-" << directoryOptions.size() << "]: ";
|
||||
streamOut.flush();
|
||||
|
||||
QString input = streamIn.readLine();
|
||||
bool ok;
|
||||
int s = input.trimmed().toInt(&ok);
|
||||
if (ok && s > 0 && s <= directoryOptions.size())
|
||||
{
|
||||
selectedDir = directoryOptions.at(s - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
return selectedDir;
|
||||
}
|
||||
}
|
||||
33
src/blackmisc/sampleutils.h
Normal file
33
src/blackmisc/sampleutils.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SAMPLEUTILS_H
|
||||
#define BLACKMISC_SAMPLEUTILS_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
//! Utils for sample programms
|
||||
class CSampleUtils
|
||||
{
|
||||
|
||||
public:
|
||||
//! Select directory among given ones
|
||||
static QString selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut, QTextStream &streamIn);
|
||||
|
||||
private:
|
||||
CSampleUtils() = delete;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user