mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #396, move subproject BlackSim into BlackMisc::Simulation
* removed unused samples / tests * fixed found Doxygen issues * removed blacksimfreefunctions, now in BlackMisc::Simulation::registerMetadata() * samples_vetcor_geo to samples_geo
This commit is contained in:
committed by
Roland Winklmeier
parent
a6ca57265e
commit
32f60722c8
73
samples/blackmiscsim/samplesfscommon.cpp
Normal file
73
samples/blackmiscsim/samplesfscommon.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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 "samplesfscommon.h"
|
||||
#include "blackmisc/sampleutils.h"
|
||||
#include "blacksim/fscommon/aircraftcfgentrieslist.h"
|
||||
#include "blacksim/fscommon/aircraftmapper.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFuture>
|
||||
#include <QTime>
|
||||
#include <QTextStream>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackSim::FsCommon;
|
||||
|
||||
namespace BlackSimTest
|
||||
{
|
||||
|
||||
/*
|
||||
* Samples
|
||||
*/
|
||||
int CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
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 << "start reading" << endl;
|
||||
QString input = streamIn.readLine();
|
||||
Q_UNUSED(input);
|
||||
|
||||
streamOut << "reading directly" << endl;
|
||||
QTime time;
|
||||
time.start();
|
||||
streamOut << "reading " << mapper.getAircraftCfgEntriesList().getRootDirectory() << endl;
|
||||
mapper.readSimObjects();
|
||||
streamOut << "read entries: " << mapper.getAircraftCfgEntriesList().size() << " 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();
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user