mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
refs #358, adjusted samples for model matching
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user