mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +08:00
refs #358, adjusted samples for model matching
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
#include "blacksim/blacksimfreefunctions.h"
|
||||||
#include "servicetool.h"
|
#include "servicetool.h"
|
||||||
#include "blackcore/dbus_server.h"
|
#include "blackcore/dbus_server.h"
|
||||||
#include <QDBusMetaType>
|
#include <QDBusMetaType>
|
||||||
@@ -26,6 +27,7 @@ int main(int argc, char *argv[])
|
|||||||
// is just for testing, I did not split it up
|
// is just for testing, I did not split it up
|
||||||
|
|
||||||
BlackMisc::registerMetadata();
|
BlackMisc::registerMetadata();
|
||||||
|
BlackSim::registerMetadata();
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
// trying to get the arguments into a list
|
// trying to get the arguments into a list
|
||||||
|
|||||||
@@ -8,14 +8,16 @@ TEMPLATE = app
|
|||||||
|
|
||||||
CONFIG += console
|
CONFIG += console
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
CONFIG += blackmisc blackcore
|
CONFIG += blackmisc blackcore blacksim
|
||||||
|
|
||||||
DEPENDPATH += . ../../src/blackmisc ../../src/blackcore
|
DEPENDPATH += . ../../src/blackmisc ../../src/blackcore ../../src/blacksim
|
||||||
INCLUDEPATH += . ../../src
|
INCLUDEPATH += . ../../src
|
||||||
|
|
||||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
||||||
|
../../lib/blacksim.lib \
|
||||||
../../lib/blackcore.lib
|
../../lib/blackcore.lib
|
||||||
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
||||||
|
../../lib/libblacksim.a \
|
||||||
../../lib/libblackcore.a
|
../../lib/libblackcore.a
|
||||||
|
|
||||||
DESTDIR = ../../bin
|
DESTDIR = ../../bin
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ using namespace BlackMisc::Aviation;
|
|||||||
using namespace BlackMisc::Math;
|
using namespace BlackMisc::Math;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackSim::FsCommon;
|
||||||
using namespace BlackMiscTest;
|
using namespace BlackMiscTest;
|
||||||
|
|
||||||
namespace BlackMiscTest
|
namespace BlackMiscTest
|
||||||
@@ -125,7 +126,7 @@ namespace BlackMiscTest
|
|||||||
/*
|
/*
|
||||||
* Stations
|
* Stations
|
||||||
*/
|
*/
|
||||||
CAtcStationList ServiceTool::getStations(qint32 number)
|
CAtcStationList ServiceTool::getStations(int number)
|
||||||
{
|
{
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
@@ -146,10 +147,35 @@ namespace BlackMiscTest
|
|||||||
return list;
|
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
|
* Airports
|
||||||
*/
|
*/
|
||||||
CAirportList ServiceTool::getAirports(qint32 number)
|
CAirportList ServiceTool::getAirports(int number)
|
||||||
{
|
{
|
||||||
BlackMisc::Aviation::CAirportList list;
|
BlackMisc::Aviation::CAirportList list;
|
||||||
for (int i = 0; i < number; i++)
|
for (int i = 0; i < number; i++)
|
||||||
@@ -163,7 +189,7 @@ namespace BlackMiscTest
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
CClientList ServiceTool::getClients(qint32 number)
|
CClientList ServiceTool::getClients(int number)
|
||||||
{
|
{
|
||||||
BlackMisc::Network::CClientList list;
|
BlackMisc::Network::CClientList list;
|
||||||
for (int i = 0; i < number; i++)
|
for (int i = 0; i < number; i++)
|
||||||
@@ -176,7 +202,7 @@ namespace BlackMiscTest
|
|||||||
client.setCapability(true, CClient::FsdWithInterimPositions);
|
client.setCapability(true, CClient::FsdWithInterimPositions);
|
||||||
client.setCapability(true, CClient::FsdWithModelDescription);
|
client.setCapability(true, CClient::FsdWithModelDescription);
|
||||||
QString myFooModel = QString("fooModel %1").arg(i);
|
QString myFooModel = QString("fooModel %1").arg(i);
|
||||||
client.setAircraftModel(CAircraftModel(myFooModel, "nope"));
|
client.setAircraftModel(CAircraftModel(myFooModel, CAircraftModel::TypeQueriedFromNetwork));
|
||||||
list.push_back(client);
|
list.push_back(client);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@@ -246,10 +272,7 @@ namespace BlackMiscTest
|
|||||||
|
|
||||||
// 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
|
// and method calls (slots) that don't return
|
||||||
if (connection.send(m))
|
if (connection.send(m)) { qDebug() << "Send via low level method" << m; }
|
||||||
{
|
|
||||||
qDebug() << "Send via low level method" << m;
|
|
||||||
}
|
|
||||||
|
|
||||||
// same as interface message
|
// same as interface message
|
||||||
// but call the slot
|
// but call the slot
|
||||||
@@ -334,14 +357,14 @@ namespace BlackMiscTest
|
|||||||
qDebug() << "Send geo position" << geoPos;
|
qDebug() << "Send geo position" << geoPos;
|
||||||
|
|
||||||
qDebug() << "----------------- pings ----------------";
|
qDebug() << "----------------- pings ----------------";
|
||||||
CPropertyIndex pi({ 1, 2, 3, 4, 5});
|
CPropertyIndex pi({ 1000, 2000, 3000, 4000, 5000}); // numbers >= global index
|
||||||
pi = testserviceInterface.pingPropertyIndex(pi);
|
pi = testserviceInterface.pingPropertyIndex(pi);
|
||||||
qDebug() << "Pinged properties via interface" << pi;
|
qDebug() << "Pinged property index via interface" << pi;
|
||||||
|
|
||||||
CPropertyIndexVariantMap ivm;
|
CPropertyIndexVariantMap ivm;
|
||||||
ivm.addValue(1, "one");
|
ivm.addValue(1000, "one");
|
||||||
ivm.addValue(2, "two");
|
ivm.addValue(2000, "two");
|
||||||
ivm.addValue(3, "three");
|
ivm.addValue(3000, "three");
|
||||||
ivm = testserviceInterface.pingIndexVariantMap(ivm);
|
ivm = testserviceInterface.pingIndexVariantMap(ivm);
|
||||||
qDebug() << "Pinged variant map via interface" << ivm;
|
qDebug() << "Pinged variant map via interface" << ivm;
|
||||||
|
|
||||||
@@ -400,14 +423,14 @@ namespace BlackMiscTest
|
|||||||
qDebug() << "----------------- index variant map ----------------";
|
qDebug() << "----------------- index variant map ----------------";
|
||||||
|
|
||||||
CPropertyIndexVariantMap valueMap;
|
CPropertyIndexVariantMap valueMap;
|
||||||
valueMap.addValue(1, 111.222);
|
valueMap.addValue(1000, 111.222);
|
||||||
valueMap.addValue(2, callsign);
|
valueMap.addValue(2000, callsign);
|
||||||
valueMap.addValue(3, alt);
|
valueMap.addValue(3000, alt);
|
||||||
valueMap.addValue(4, track);
|
valueMap.addValue(4000, track);
|
||||||
valueMap.addValue(5, QDateTime::currentDateTime().addDays(1));
|
valueMap.addValue(5000, QDateTime::currentDateTime().addDays(1));
|
||||||
valueMap.addValue(6, QString("foobar"));
|
valueMap.addValue(6000, QString("foobar"));
|
||||||
testserviceInterface.receiveValueMap(valueMap);
|
testserviceInterface.receiveValueMap(valueMap);
|
||||||
qDebug() << "Send value map" << valueMap;
|
qDebug() << "Send index variant map" << valueMap;
|
||||||
|
|
||||||
// Performance tools
|
// Performance tools
|
||||||
QThread::msleep(2500);
|
QThread::msleep(2500);
|
||||||
@@ -477,10 +500,16 @@ namespace BlackMiscTest
|
|||||||
atcStationList = testserviceInterface.getAtcStationList(1000);
|
atcStationList = testserviceInterface.getAtcStationList(1000);
|
||||||
if (atcStationList.size() != 1000) qDebug() << "wrong list size" << atcStationList.size();
|
if (atcStationList.size() != 1000) qDebug() << "wrong list size" << atcStationList.size();
|
||||||
t1000 = timer.nsecsElapsed() / 1000000; // ms
|
t1000 = timer.nsecsElapsed() / 1000000; // ms
|
||||||
|
|
||||||
qDebug() << "Reading station list 10/100/1000 in ms:" << t10 << t100 << t1000;
|
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();
|
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) 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
|
#ifndef BLACKMISCTEST_SERVICETOOL_H
|
||||||
#define BLACKMISCTEST_SERVICETOOL_H
|
#define BLACKMISCTEST_SERVICETOOL_H
|
||||||
|
|
||||||
@@ -5,6 +16,7 @@
|
|||||||
#include "blackmisc/avatcstationlist.h"
|
#include "blackmisc/avatcstationlist.h"
|
||||||
#include "blackmisc/avairportlist.h"
|
#include "blackmisc/avairportlist.h"
|
||||||
#include "blackmisc/nwclientlist.h"
|
#include "blackmisc/nwclientlist.h"
|
||||||
|
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
@@ -82,21 +94,28 @@ namespace BlackMiscTest
|
|||||||
* \param number
|
* \param number
|
||||||
* \return
|
* \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
|
* \brief Get airports
|
||||||
* \param number
|
* \param number
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static BlackMisc::Aviation::CAirportList getAirports(qint32 number);
|
static BlackMisc::Aviation::CAirportList getAirports(int number);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Get clients
|
* \brief Get clients
|
||||||
* \param number
|
* \param number
|
||||||
* \return
|
* \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::Geo;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackSim::FsCommon;
|
||||||
|
|
||||||
namespace BlackMiscTest
|
namespace BlackMiscTest
|
||||||
{
|
{
|
||||||
@@ -209,7 +210,7 @@ namespace BlackMiscTest
|
|||||||
/*
|
/*
|
||||||
* Object paths
|
* Object paths
|
||||||
*/
|
*/
|
||||||
const QList<QDBusObjectPath> Testservice::getObjectPaths(const qint32 number) const
|
QList<QDBusObjectPath> Testservice::getObjectPaths(int number) const
|
||||||
{
|
{
|
||||||
QList<QDBusObjectPath> paths;
|
QList<QDBusObjectPath> paths;
|
||||||
for (int i = 0; i < number; i++)
|
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);
|
return BlackMisc::CVariant::fromValue(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "blackmisc/networkallclasses.h"
|
#include "blackmisc/networkallclasses.h"
|
||||||
#include "blackmisc/pqallquantities.h"
|
#include "blackmisc/pqallquantities.h"
|
||||||
#include "blackmisc/mathallclasses.h"
|
#include "blackmisc/mathallclasses.h"
|
||||||
|
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||||
#include "servicetool.h"
|
#include "servicetool.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -147,10 +148,13 @@ namespace BlackMiscTest
|
|||||||
BlackMisc::Aviation::CAtcStation getAtcStation() const;
|
BlackMisc::Aviation::CAtcStation getAtcStation() const;
|
||||||
|
|
||||||
//! return n ATC stations
|
//! 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
|
//! Get object paths
|
||||||
const QList<QDBusObjectPath> getObjectPaths(const qint32 number) const;
|
QList<QDBusObjectPath> getObjectPaths(int number) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const QString ServiceName;
|
static const QString ServiceName;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
#include "blackmisc/blackmiscallvalueclasses.h"
|
#include "blackmisc/blackmiscallvalueclasses.h"
|
||||||
|
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QByteArray>
|
#include <QtCore/QByteArray>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
@@ -53,6 +54,13 @@ namespace BlackMiscTest
|
|||||||
return asyncCallWithArgumentList(QLatin1String("getAtcStation"), argumentList);
|
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)
|
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStationList> getAtcStationList(int number)
|
||||||
{
|
{
|
||||||
QList<QVariant> argumentList;
|
QList<QVariant> argumentList;
|
||||||
|
|||||||
@@ -50,13 +50,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (i.startsWith("3"))
|
else if (i.startsWith("3"))
|
||||||
{
|
{
|
||||||
BlackSimTest::CSamplesModelMapping::samples(streamOut);
|
BlackSimTest::CSamplesModelMapping::samples(streamOut, streamIn);
|
||||||
}
|
}
|
||||||
else if (i.startsWith("x"))
|
else if (i.startsWith("x"))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
streamOut << endl;
|
||||||
streamOut << "time elapsed: " << t.elapsed() << "ms" << endl;
|
streamOut << "time elapsed: " << t.elapsed() << "ms" << endl;
|
||||||
streamOut << "press key to exit" << endl;
|
streamOut << "press key to exit" << endl;
|
||||||
streamIn.readLine();
|
streamIn.readLine();
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "samplesfscommon.h"
|
#include "samplesfscommon.h"
|
||||||
|
#include "blackmisc/sampleutils.h"
|
||||||
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||||
#include "blacksim/fscommon/aircraftindexer.h"
|
#include "blacksim/fscommon/aircraftmapper.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
using namespace BlackSim::FsCommon;
|
using namespace BlackSim::FsCommon;
|
||||||
|
|
||||||
namespace BlackSimTest
|
namespace BlackSimTest
|
||||||
@@ -27,51 +29,50 @@ namespace BlackSimTest
|
|||||||
*/
|
*/
|
||||||
int CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
|
int CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||||
{
|
{
|
||||||
// QString fsxDir = "P:/FlightSimulatorX (MSI)/SimObjects";
|
QString fsxDir = CSampleUtils::selectDirectory({"P:/FlightSimulatorX (MSI)/SimObjects", "P:/Temp/SimObjects"}, streamOut, streamIn);
|
||||||
QString fsxDir = "P:/Temp/SimObjects";
|
CAircraftMapper mapper;
|
||||||
streamOut << "Enter FSX directory:" << endl;
|
if (!mapper.changeCAircraftCfgEntriesDirectory(fsxDir))
|
||||||
streamOut << fsxDir << '\r';
|
{
|
||||||
streamOut.flush();
|
streamOut << "Wrong or empty directoy " << fsxDir << endl;
|
||||||
QString input = streamIn.readLine();
|
return 0;
|
||||||
if (!input.isEmpty()) fsxDir = input;
|
}
|
||||||
|
|
||||||
streamOut << "d .. direct, b .. background" << endl;
|
streamOut << "d .. direct, b .. background" << endl;
|
||||||
input = streamIn.readLine();
|
QString input = streamIn.readLine();
|
||||||
|
|
||||||
if (!input.startsWith("b"))
|
if (!input.startsWith("b"))
|
||||||
{
|
{
|
||||||
streamOut << "reading directly" << endl;
|
streamOut << "reading directly" << endl;
|
||||||
CAircraftCfgEntriesList entriesList(fsxDir);
|
QTime time;
|
||||||
if (entriesList.existsDir())
|
time.start();
|
||||||
{
|
streamOut << "reading " << mapper.getAircraftCfgEntriesList().getRootDirectory() << endl;
|
||||||
QTime time;
|
mapper.readSimObjects();
|
||||||
time.start();
|
streamOut << "read entries: " << mapper.getAircraftCfgEntriesList().size() << " in " << time.restart() << "ms" << endl;
|
||||||
streamOut << "reading " << entriesList.getRootDirectory() << endl;
|
|
||||||
entriesList.read();
|
|
||||||
streamOut << "read entries: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
|
||||||
|
|
||||||
QJsonDocument doc(entriesList.toJson());
|
CAircraftCfgEntriesList entriesList = mapper.getAircraftCfgEntriesList();
|
||||||
QByteArray jsonArray(doc.toJson());
|
QJsonDocument doc(entriesList.toJson());
|
||||||
streamOut << "write JSON array with size " << jsonArray.size() << endl;
|
QByteArray jsonArray(doc.toJson());
|
||||||
QTemporaryFile tempFile;
|
streamOut << "write JSON array with size " << jsonArray.size() << endl;
|
||||||
tempFile.open();
|
QTemporaryFile tempFile;
|
||||||
tempFile.write(jsonArray);
|
tempFile.open();
|
||||||
tempFile.close();
|
tempFile.write(jsonArray);
|
||||||
streamOut << "written to " << tempFile.fileName() << " in " << time.restart() << "ms" << endl;
|
tempFile.close();
|
||||||
|
streamOut << "written to " << tempFile.fileName() << " in " << time.restart() << "ms" << endl;
|
||||||
|
|
||||||
// re-read
|
// re-read
|
||||||
tempFile.open();
|
tempFile.open();
|
||||||
jsonArray = tempFile.readAll();
|
jsonArray = tempFile.readAll();
|
||||||
doc = QJsonDocument::fromJson(jsonArray);
|
doc = QJsonDocument::fromJson(jsonArray);
|
||||||
entriesList.clear();
|
entriesList.clear();
|
||||||
entriesList.convertFromJson(doc.object());
|
entriesList.convertFromJson(doc.object());
|
||||||
streamOut << "read JSON array with size " << jsonArray.size() << endl;
|
streamOut << "read JSON array with size " << jsonArray.size() << endl;
|
||||||
streamOut << "read entries from disk: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
streamOut << "read entries from disk: " << entriesList.size() << " in " << time.restart() << "ms" << endl;
|
||||||
tempFile.close();
|
tempFile.close();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
streamOut << "reading in background" << endl;
|
streamOut << "reading in background" << endl;
|
||||||
QFuture<int> f = BlackSim::FsCommon::CAircraftIndexer::readInBackground(fsxDir);
|
QFuture<int> f = mapper.readInBackground();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,12 +9,19 @@
|
|||||||
|
|
||||||
#include "samplesmodelmapping.h"
|
#include "samplesmodelmapping.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
#include "blackmisc/sampleutils.h"
|
||||||
#include "blacksim/blacksimfreefunctions.h"
|
#include "blacksim/blacksimfreefunctions.h"
|
||||||
#include "blacksim/fscommon/vpilotmodelmappings.h"
|
#include "blacksim/fscommon/vpilotmodelmappings.h"
|
||||||
|
#include "blacksim/fscommon/aircraftmapper.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackSim;
|
||||||
using namespace BlackSim::FsCommon;
|
using namespace BlackSim::FsCommon;
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
|
||||||
namespace BlackSimTest
|
namespace BlackSimTest
|
||||||
{
|
{
|
||||||
@@ -22,18 +29,39 @@ namespace BlackSimTest
|
|||||||
/*
|
/*
|
||||||
* Samples
|
* Samples
|
||||||
*/
|
*/
|
||||||
int CSamplesModelMapping::samples(QTextStream &streamOut)
|
int CSamplesModelMapping::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||||
{
|
{
|
||||||
BlackMisc::registerMetadata();
|
BlackMisc::registerMetadata();
|
||||||
BlackSim::registerMetadata();
|
BlackSim::registerMetadata();
|
||||||
|
|
||||||
CVPilotModelMappings cvm;
|
std::unique_ptr<ISimulatorModelMappings> cvm(new CVPilotModelMappings(true));
|
||||||
cvm.addDirectory(CVPilotModelMappings::standardMappingsDirectory());
|
bool s = cvm->read();
|
||||||
bool s = cvm.load();
|
streamOut << "directory: " << CVPilotModelMappings::standardMappingsDirectory() << endl;
|
||||||
streamOut << "loaded:" << s << "size:" << cvm.size() << endl;
|
streamOut << "loaded: " << (s ? "yes" : "no") << " size: " << cvm->size() << endl;
|
||||||
|
|
||||||
BlackMisc::Aviation::CAircraftIcao icao("C172");
|
// mapper with rule set, handing over ownership
|
||||||
streamOut << cvm.findByIcaoWildcard(icao) << endl;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace BlackSimTest
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Run the samples
|
//! Run the samples
|
||||||
static int samples(QTextStream &streamOut);
|
static int samples(QTextStream &streamOut, QTextStream &streamIn);
|
||||||
};
|
};
|
||||||
} // namespace
|
} // 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