swift
samplesfsuipc.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
6 
7 #include "samplesfsuipc.h"
8 
9 #include <QScopedPointer>
10 #include <QTextStream>
11 
12 #include "misc/registermetadata.h"
15 
16 using namespace swift::misc;
17 using namespace swift::misc::simulation;
18 
19 namespace swift::sample
20 {
21 #ifdef Q_OS_WIN
22  void CSamplesFsuipc::samplesFsuipc(QTextStream &streamOut)
23  {
24  using namespace swift::simplugin::fscommon;
25 
27  QScopedPointer<CFsuipc> fsuipc(new CFsuipc());
28  streamOut << "FSUIPC initialized" << Qt::endl;
29 
30  if (fsuipc->open()) { streamOut << "FSUIPC connected" << Qt::endl; }
31  else
32  {
33  streamOut << "FSUIPC NOT(!) connected" << Qt::endl;
34  streamOut << "Need FS WideClient?" << Qt::endl;
35  return;
36  }
37 
38  CSimulatedAircraft aircraft;
39  if (fsuipc->read(aircraft, true, true, true))
40  {
41  streamOut << "Aircraft read: " << aircraft.toQString(true) << Qt::endl;
42  }
43 
44  fsuipc->close();
45  }
46 
47 #else
48  void CSamplesFsuipc::samplesFsuipc(QTextStream &) {}
49 #endif
50 
51 } // namespace swift::sample
QString toQString(bool i18n=false) const
Cast as QString.
Definition: mixinstring.h:76
Comprehensive information of an aircraft.
Class representing a FSUIPC "interface".
Definition: fsuipc.h:18
Free functions in swift::misc.
void registerMetadata()
Register all relevant metadata in Misc.