mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refs #445, samples for vPilot rules
* new samples for vPilot rules * also adjusted other samples to latest changes (livery, new readers)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
c760f1d424
commit
3c9f95356e
@@ -60,8 +60,7 @@ namespace BlackMiscTest
|
||||
aircraft.setTransponder(CTransponder::getStandardTransponder(7000, CTransponder::ModeC));
|
||||
aircraft.setIcaoInfo(CAircraftIcaoData(
|
||||
CAircraftIcaoCode("B737", "L2J"),
|
||||
CAirlineIcaoCode("DLH"),
|
||||
"CCDDFF"
|
||||
CAirlineIcaoCode("DLH")
|
||||
));
|
||||
|
||||
json = aircraft.toJson();
|
||||
|
||||
@@ -376,7 +376,6 @@ namespace BlackMiscTest
|
||||
|
||||
CAircraftIcaoData icaoData("B737", "DLH");
|
||||
icaoData.setAircraftCombinedType("L2J");
|
||||
icaoData.setAircraftColor("green");
|
||||
CAircraftIcaoData icaoReceived = testserviceInterface.pingIcaoData(icaoData);
|
||||
qDebug() << "Pinged ICAO data via interface"
|
||||
<< ((icaoData == icaoReceived) ? "OK" : "ERROR!") << icaoReceived;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "samplesfscommon.h"
|
||||
#include "samplesfsx.h"
|
||||
#include "samplesmodelmapping.h"
|
||||
#include "samplesvpilotrules.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTextStream>
|
||||
@@ -33,6 +34,7 @@ int main(int argc, char *argv[])
|
||||
streamOut << "1 .. FS common / Simulation (with cfg files reading)" << endl;
|
||||
streamOut << "2 .. FSX" << endl;
|
||||
streamOut << "3 .. Mappings" << endl;
|
||||
streamOut << "4 .. vPilot rules" << endl;
|
||||
streamOut << "x .. exit" << endl;
|
||||
QString i = streamIn.readLine().toLower().trimmed();
|
||||
|
||||
@@ -50,14 +52,18 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
BlackSimTest::CSamplesModelMapping::samples(streamOut, streamIn);
|
||||
}
|
||||
else if (i.startsWith("4"))
|
||||
{
|
||||
BlackSimTest::CSamplesVPilotRules::samples(streamOut, streamIn);
|
||||
}
|
||||
else if (i.startsWith("x"))
|
||||
{
|
||||
return 0;
|
||||
streamOut << "terminating" << endl;
|
||||
}
|
||||
|
||||
streamOut << endl;
|
||||
streamOut << "time elapsed: " << t.elapsed() << "ms" << endl;
|
||||
streamOut << "press key to exit" << endl;
|
||||
streamIn.readLine();
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace BlackSimTest
|
||||
/*
|
||||
* Samples
|
||||
*/
|
||||
int CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
void CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
QString fsxDir = CSampleUtils::selectDirectory({"C:/Program Files (x86)/Microsoft Games/Microsoft Flight Simulator X/SimObjects",
|
||||
"C:/Flight Simulator 9/Aircraft"}, streamOut, streamIn);
|
||||
@@ -66,7 +66,6 @@ namespace BlackSimTest
|
||||
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
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace BlackSimTest
|
||||
{
|
||||
public:
|
||||
//! Run the samples
|
||||
static int samples(QTextStream &streamOut, QTextStream &streamIn);
|
||||
static void samples(QTextStream &streamOut, QTextStream &streamIn);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -20,19 +20,11 @@ namespace BlackSimTest
|
||||
/*
|
||||
* Samples
|
||||
*/
|
||||
int CSamplesFsx::samplesMisc(QTextStream &streamOut)
|
||||
void CSamplesFsx::samplesMisc(QTextStream &streamOut)
|
||||
{
|
||||
BlackMisc::registerMetadata();
|
||||
streamOut << CSimConnectUtilities::simConnectExceptionToString(CSimConnectUtilities::SIMCONNECT_EXCEPTION_ALREADY_SUBSCRIBED) << endl;
|
||||
streamOut << CSimConnectUtilities::simConnectExceptionToString(CSimConnectUtilities::SIMCONNECT_EXCEPTION_ILLEGAL_OPERATION) << endl;
|
||||
streamOut << CSimConnectUtilities::simConnectSurfaceTypeToString(CSimConnectUtilities::Bituminus) << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CSamplesFsx::driverTest(QTextStream &streamOut)
|
||||
{
|
||||
Q_UNUSED(streamOut);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -21,11 +21,7 @@ namespace BlackSimTest
|
||||
{
|
||||
public:
|
||||
//! Run the misc. samples
|
||||
static int samplesMisc(QTextStream &streamOut);
|
||||
|
||||
//! Driver test / SimConnect test
|
||||
static int driverTest(QTextStream &streamOut);
|
||||
|
||||
static void samplesMisc(QTextStream &streamOut);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -29,13 +29,13 @@ namespace BlackSimTest
|
||||
/*
|
||||
* Samples
|
||||
*/
|
||||
int CSamplesModelMapping::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
void CSamplesModelMapping::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
BlackMisc::registerMetadata();
|
||||
|
||||
std::unique_ptr<IModelMappingsProvider> cvm(new CModelMappingsProviderVPilot(true));
|
||||
bool s = cvm->read();
|
||||
streamOut << "directory: " << CModelMappingsProviderVPilot::standardMappingsDirectory() << endl;
|
||||
streamOut << "directory: " << CVPilotRulesReader::standardMappingsDirectory() << endl;
|
||||
streamOut << "loaded: " << BlackMisc::boolToYesNo(s) << " size: " << cvm->getMappingList().size() << endl;
|
||||
|
||||
// mapper with rule set, handing over ownership
|
||||
@@ -47,7 +47,7 @@ namespace BlackSimTest
|
||||
if (!cfgParser.changeRootDirectory(fsxDir))
|
||||
{
|
||||
streamOut << "Wrong or empty directoy " << fsxDir << endl;
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
streamOut << "Start reading models" << endl;
|
||||
@@ -66,8 +66,6 @@ namespace BlackSimTest
|
||||
CAircraftIcaoData icao("C172");
|
||||
streamOut << "Searching for " << icao << endl;
|
||||
streamOut << matcher.getAircraftMappingList().findByIcaoCodeExact(icao) << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace BlackSimTest
|
||||
{
|
||||
public:
|
||||
//! Run the samples
|
||||
static int samples(QTextStream &streamOut, QTextStream &streamIn);
|
||||
static void samples(QTextStream &streamOut, QTextStream &streamIn);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
40
samples/blackmiscsim/samplesvpilotrules.cpp
Normal file
40
samples/blackmiscsim/samplesvpilotrules.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "samplesvpilotrules.h"
|
||||
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/sampleutils.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QScopedPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
|
||||
namespace BlackSimTest
|
||||
{
|
||||
|
||||
/*
|
||||
* Samples
|
||||
*/
|
||||
void CSamplesVPilotRules::samples(QTextStream &streamOut, QTextStream &streamIn)
|
||||
{
|
||||
BlackMisc::registerMetadata();
|
||||
QScopedPointer<CVPilotRulesReader> vPilotReader(new CVPilotRulesReader());
|
||||
bool s = vPilotReader->read();
|
||||
streamOut << "Read success: " << BlackMisc::boolToYesNo(s) << endl;
|
||||
streamOut << "Read " << vPilotReader->countRulesLoaded() << " rules from " << vPilotReader->countFilesLoaded() << " files" << endl;
|
||||
streamOut << "Distributors: " << vPilotReader->getRules().getSortedDistributors().join(", ");
|
||||
|
||||
Q_UNUSED(streamIn);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
28
samples/blackmiscsim/samplesvpilotrules.h
Normal file
28
samples/blackmiscsim/samplesvpilotrules.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 BLACKSIMTEST_SAMPLESVPILOTRULES_H
|
||||
#define BLACKSIMTEST_SAMPLESVPILOTRULES_H
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
namespace BlackSimTest
|
||||
{
|
||||
//! Samples for vPilot rules
|
||||
class CSamplesVPilotRules
|
||||
{
|
||||
public:
|
||||
//! Run the samples
|
||||
static void samples(QTextStream &streamOut, QTextStream &streamIn);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
@@ -164,14 +164,10 @@ void Client::presetIcaoCodesCmd(QTextStream &args)
|
||||
QString acTypeICAO;
|
||||
QString combinedIcaoType; // e.g. "L2J"
|
||||
QString airlineICAO;
|
||||
QString livery;
|
||||
QString color;
|
||||
args >> acTypeICAO >> combinedIcaoType >> airlineICAO >> livery >> color;
|
||||
args >> acTypeICAO >> combinedIcaoType >> airlineICAO;
|
||||
BlackMisc::Aviation::CAircraftIcaoData icaoData(
|
||||
CAircraftIcaoCode(acTypeICAO, combinedIcaoType),
|
||||
CAirlineIcaoCode(airlineICAO),
|
||||
color);
|
||||
icaoData.setLivery(livery);
|
||||
CAirlineIcaoCode(airlineICAO));
|
||||
emit presetIcaoCodes(icaoData);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user