Ref T437, samples for FSUIPC

This commit is contained in:
Klaus Basan
2018-11-22 19:44:51 +01:00
parent 9292b63be6
commit 31ba0c1520
5 changed files with 123 additions and 34 deletions

View File

@@ -13,6 +13,7 @@
#include "samplesfscommon.h" #include "samplesfscommon.h"
#include "samplesfsx.h" #include "samplesfsx.h"
#include "samplesp3d.h" #include "samplesp3d.h"
#include "samplesfsuipc.h"
#include "samplesmodelmapping.h" #include "samplesmodelmapping.h"
#include "samplesvpilotrules.h" #include "samplesvpilotrules.h"
#include "blackcore/application.h" #include "blackcore/application.h"
@@ -27,6 +28,7 @@
#include <QtGlobal> #include <QtGlobal>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackSample;
//! main //! main
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@@ -39,40 +41,31 @@ int main(int argc, char *argv[])
QTextStream streamIn(stdin); QTextStream streamIn(stdin);
QTextStream streamOut(stdout); QTextStream streamOut(stdout);
streamOut << "Run samples:" << endl; bool run = true;
streamOut << "1 .. FS common / Simulation (with cfg files reading)" << endl;
streamOut << "2 .. FSX" << endl;
streamOut << "3 .. Mappings" << endl;
streamOut << "4 .. vPilot rules" << endl;
streamOut << "5 .. P3D cfg files" << endl;
streamOut << "x .. exit" << endl;
QString i = streamIn.readLine().toLower().trimmed();
QTime t; QTime t;
t.start(); while (run)
if (i.startsWith("1"))
{ {
BlackSample::CSamplesFsCommon::samples(streamOut, streamIn); streamOut << "Run samples:" << endl;
} streamOut << "1 .. FS common / Simulation (with cfg files reading)" << endl;
else if (i.startsWith("2")) streamOut << "2 .. FSX" << endl;
{ streamOut << "3 .. Mappings" << endl;
BlackSample::CSamplesFsx::samplesMisc(streamOut); streamOut << "4 .. vPilot rules" << endl;
} streamOut << "5 .. P3D cfg files" << endl;
else if (i.startsWith("3")) streamOut << "6 .. FSUIPC read" << endl;
{ streamOut << "x .. exit" << endl;
BlackSample::CSamplesModelMapping::samples(streamOut, streamIn); QString i = streamIn.readLine().toLower().trimmed();
}
else if (i.startsWith("4")) t.start();
{ if (i.startsWith("1")) { CSamplesFsCommon::samples(streamOut, streamIn); }
BlackSample::CSamplesVPilotRules::samples(streamOut, streamIn); else if (i.startsWith("2")) { CSamplesFsx::samplesMisc(streamOut); }
} else if (i.startsWith("3")) { CSamplesModelMapping::samples(streamOut, streamIn); }
else if (i.startsWith("5")) else if (i.startsWith("4")) { CSamplesVPilotRules::samples(streamOut, streamIn); }
{ else if (i.startsWith("5")) { CSamplesP3D::samplesMisc(streamOut); }
BlackSample::CSamplesP3D::samplesMisc(streamOut); else if (i.startsWith("6")) { CSamplesFsuipc::samplesFsuipc(streamOut); }
} else if (i.startsWith("x")) { run = false; streamOut << "terminating" << endl; }
else if (i.startsWith("x"))
{ streamOut << endl;
streamOut << "terminating" << endl; streamOut << endl;
} }
streamOut << endl; streamOut << endl;

View File

@@ -5,12 +5,17 @@ QT += core dbus network
TARGET = sampleblackmiscsim TARGET = sampleblackmiscsim
TEMPLATE = app TEMPLATE = app
CONFIG -= app_bundle
CONFIG += console CONFIG += console
CONFIG += blackmisc blacksim blackcore CONFIG += blackmisc blacksim blackcore
CONFIG -= app_bundle
# actually not belonging in samples "blackmisc"
# but before we have not more tests we keep it here
win32 { CONFIG += fsuipc simulatorfscommon }
DEPENDPATH += . ../../src/blackmisc DEPENDPATH += . ../../src/blackmisc
DEPENDPATH += . ../../src/blackcore DEPENDPATH += . ../../src/blackcore
DEPENDPATH += . ../../src/plugins/fscommon
INCLUDEPATH += . ../../src INCLUDEPATH += . ../../src
DESTDIR = $$DestRoot/bin DESTDIR = $$DestRoot/bin

View File

@@ -0,0 +1,62 @@
/* Copyright (C) 2018
* 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
//! \ingroup sampleblackmiscsim
#include "plugins/simulator/fscommon/fsuipc.h"
#include "samplesfsuipc.h"
#include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/registermetadata.h"
#include <QTextStream>
#include <QScopedPointer>
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
namespace BlackSample
{
#ifdef Q_OS_WIN
void CSamplesFsuipc::samplesFsuipc(QTextStream &streamOut)
{
using namespace BlackSimPlugin::FsCommon;
BlackMisc::registerMetadata();
QScopedPointer<CFsuipc> fsuipc(new CFsuipc());
streamOut << "FSUIPC initialized" << endl;
if (fsuipc->open())
{
streamOut << "FSUIPC connected" << endl;
}
else
{
streamOut << "FSUIPC NOT(!) connected" << endl;
streamOut << "Need FS WideClient?" << endl;
return;
}
CSimulatedAircraft aircraft;
if (fsuipc->read(aircraft, true, true, true))
{
streamOut << "Aircraft read: " << aircraft.toQString(true) << endl;
}
fsuipc->close();
}
#else
void CSamplesFsuipc::samplesFsuipc(QTextStream &streamOut)
{
Q_UNUSED(streamOut);
}
#endif
} // namespace

View File

@@ -0,0 +1,29 @@
/* Copyright (C) 2018
* 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
//! \ingroup sampleblackmiscsim
#ifndef BLACKSAMPLE_SAMPLESFSUIPC_H
#define BLACKSAMPLE_SAMPLESFSUIPC_H
class QTextStream;
namespace BlackSample
{
//! Samples for FSUIPC
class CSamplesFsuipc
{
public:
//! Run the misc. samples
static void samplesFsuipc(QTextStream &streamOut);
};
} // namespace
#endif

View File

@@ -1,7 +1,7 @@
load(common_pre) load(common_pre)
TEMPLATE = subdirs TEMPLATE = subdirs
CONFIG += ordered CONFIG += ordered
SUBDIRS += samplecliclient SUBDIRS += samplecliclient
SUBDIRS += sampleblackmiscquantities SUBDIRS += sampleblackmiscquantities