From 31ba0c1520e52742d666241a05fc9caaa98c256c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 22 Nov 2018 19:44:51 +0100 Subject: [PATCH] Ref T437, samples for FSUIPC --- samples/blackmiscsim/main.cpp | 57 +++++++++---------- samples/blackmiscsim/sampleblackmiscsim.pro | 7 ++- samples/blackmiscsim/samplesfsuipc.cpp | 62 +++++++++++++++++++++ samples/blackmiscsim/samplesfsuipc.h | 29 ++++++++++ samples/samples.pro | 2 +- 5 files changed, 123 insertions(+), 34 deletions(-) create mode 100644 samples/blackmiscsim/samplesfsuipc.cpp create mode 100644 samples/blackmiscsim/samplesfsuipc.h diff --git a/samples/blackmiscsim/main.cpp b/samples/blackmiscsim/main.cpp index 85b556488..d3655f011 100644 --- a/samples/blackmiscsim/main.cpp +++ b/samples/blackmiscsim/main.cpp @@ -13,6 +13,7 @@ #include "samplesfscommon.h" #include "samplesfsx.h" #include "samplesp3d.h" +#include "samplesfsuipc.h" #include "samplesmodelmapping.h" #include "samplesvpilotrules.h" #include "blackcore/application.h" @@ -27,6 +28,7 @@ #include using namespace BlackMisc; +using namespace BlackSample; //! main int main(int argc, char *argv[]) @@ -39,40 +41,31 @@ int main(int argc, char *argv[]) QTextStream streamIn(stdin); QTextStream streamOut(stdout); - streamOut << "Run samples:" << endl; - 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(); - + bool run = true; QTime t; - t.start(); - if (i.startsWith("1")) + while (run) { - BlackSample::CSamplesFsCommon::samples(streamOut, streamIn); - } - else if (i.startsWith("2")) - { - BlackSample::CSamplesFsx::samplesMisc(streamOut); - } - else if (i.startsWith("3")) - { - BlackSample::CSamplesModelMapping::samples(streamOut, streamIn); - } - else if (i.startsWith("4")) - { - BlackSample::CSamplesVPilotRules::samples(streamOut, streamIn); - } - else if (i.startsWith("5")) - { - BlackSample::CSamplesP3D::samplesMisc(streamOut); - } - else if (i.startsWith("x")) - { - streamOut << "terminating" << endl; + streamOut << "Run samples:" << endl; + 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 << "6 .. FSUIPC read" << endl; + streamOut << "x .. exit" << endl; + QString i = streamIn.readLine().toLower().trimmed(); + + t.start(); + if (i.startsWith("1")) { CSamplesFsCommon::samples(streamOut, streamIn); } + else if (i.startsWith("2")) { CSamplesFsx::samplesMisc(streamOut); } + else if (i.startsWith("3")) { CSamplesModelMapping::samples(streamOut, streamIn); } + else if (i.startsWith("4")) { CSamplesVPilotRules::samples(streamOut, streamIn); } + else if (i.startsWith("5")) { CSamplesP3D::samplesMisc(streamOut); } + else if (i.startsWith("6")) { CSamplesFsuipc::samplesFsuipc(streamOut); } + else if (i.startsWith("x")) { run = false; streamOut << "terminating" << endl; } + + streamOut << endl; + streamOut << endl; } streamOut << endl; diff --git a/samples/blackmiscsim/sampleblackmiscsim.pro b/samples/blackmiscsim/sampleblackmiscsim.pro index c1a5567be..23c27be81 100644 --- a/samples/blackmiscsim/sampleblackmiscsim.pro +++ b/samples/blackmiscsim/sampleblackmiscsim.pro @@ -5,12 +5,17 @@ QT += core dbus network TARGET = sampleblackmiscsim TEMPLATE = app +CONFIG -= app_bundle CONFIG += console 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/blackcore +DEPENDPATH += . ../../src/plugins/fscommon INCLUDEPATH += . ../../src DESTDIR = $$DestRoot/bin diff --git a/samples/blackmiscsim/samplesfsuipc.cpp b/samples/blackmiscsim/samplesfsuipc.cpp new file mode 100644 index 000000000..8ccd44e7d --- /dev/null +++ b/samples/blackmiscsim/samplesfsuipc.cpp @@ -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 +#include + +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 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 diff --git a/samples/blackmiscsim/samplesfsuipc.h b/samples/blackmiscsim/samplesfsuipc.h new file mode 100644 index 000000000..6c4c291fe --- /dev/null +++ b/samples/blackmiscsim/samplesfsuipc.h @@ -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 diff --git a/samples/samples.pro b/samples/samples.pro index 3a522ef36..75bb2e1d3 100644 --- a/samples/samples.pro +++ b/samples/samples.pro @@ -1,7 +1,7 @@ load(common_pre) TEMPLATE = subdirs -CONFIG += ordered +CONFIG += ordered SUBDIRS += samplecliclient SUBDIRS += sampleblackmiscquantities