swift
simconnectdatadefinition.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_SIMPLUGIN_FSXCOMMON_SIMCONNECT_DATADEFINITION_H
7 #define SWIFT_SIMPLUGIN_FSXCOMMON_SIMCONNECT_DATADEFINITION_H
8 
9 #include <algorithm>
10 
11 #include <QString>
12 #include <QtGlobal>
13 
17 #include "plugins/simulator/fsxcommon/simconnectwindows.h"
18 
19 namespace swift::misc::aviation
20 {
21  class CAircraftParts;
22 }
23 namespace swift::simplugin::fsxcommon
24 {
29  {
30  double latitudeDeg;
31  double longitudeDeg;
32  double altitudeFt;
33  double altitudeAGLFt;
35  double cgToGroundFt;
36  double trueHeadingDeg;
37  double pitchDeg;
38  double bankDeg;
39  double velocity;
40  double elevationFt;
41  double simOnGround;
42  // 12
43  double lightStrobe;
44  double lightLanding;
45  double lightTaxi;
46  double lightBeacon;
47  double lightNav;
48  double lightLogo;
49  // 18
50  double transponderCode;
51  double com1ActiveMHz;
52  double com2ActiveMHz;
53  double com1StandbyMHz;
54  double com2StandbyMHz;
55  double comTransmit1;
56  double comTransmit2;
57  double comReceiveAll;
58  double comTest1;
59  double comTest2;
60  double comStatus1;
61  double comStatus2;
62  // 30
66  // 33
67  double numberOfEngines;
72  // 38
73  double velocityWorldX;
74  double velocityWorldY;
75  double velocityWorldZ;
79  // 44
81  // 45
82  };
83 
86  {
87  char title[256];
88  };
89 
92  {
93  double cgToGroundFt;
94  char atcType[32];
95  char atcModel[32];
96  char atcId[32];
97  char atcAirlineNumber[64];
98  char atcFlightNumber[8];
99  char title[256];
100  };
101 
104  {
105  // length here is from SimConnect_AddToDataDefinition
106  char atcId[32];
107  char atcAirline[64];
108  char atcFlightNumber[8];
109 
112  void copyAtcId(const char *c)
113  {
114  strncpy_s(atcId, c, 10);
115  atcId[9] = 0;
116  }
117  void copyAtcAirline(const char *c)
118  {
119  strncpy_s(atcAirline, c, 50);
120  atcAirline[49] = 0;
121  }
122  void copyFlightNumber(const char *c)
123  {
124  strncpy_s(atcFlightNumber, c, 6);
125  atcFlightNumber[5] = 0;
126  }
128 
131  {
132  std::fill(atcId, atcId + 10, static_cast<byte>(0));
133  std::fill(atcAirline, atcAirline + 50, static_cast<byte>(0));
134  std::fill(atcFlightNumber, atcFlightNumber + 6, static_cast<byte>(0));
135  }
136  };
137 
140  {
151 
154 
157 
159  bool operator==(const DataDefinitionRemoteAircraftPartsWithoutLights &rhs) const;
160 
162  void setAllEngines(bool on);
163 
165  void setEngine(int number1based, bool on);
166 
168  void resetAllFlaps();
169 
171  void resetSpoilers();
172 
174  void resetToInvalid();
175 
177  void initFromParts(const swift::misc::aviation::CAircraftParts &parts);
178  };
179 
182  {
183  double lightStrobe;
184  double lightLanding;
185  double lightTaxi;
186  double lightBeacon;
187  double lightNav;
188  double lightLogo;
190  double lightCabin;
191 
194  };
195 
198  {
199  double latitudeDeg;
200  double longitudeDeg;
201  double altitudeFt;
202  double elevationFt;
203  double cgToGroundFt;
204 
206  double aboveGroundFt() const { return altitudeFt - elevationFt; }
207 
209  bool isOnGround() const { return this->aboveGroundFt() < 1.0; }
210  };
211 
216  {
217  byte data[128] {};
218 
220  byte getTransponderMode() const { return data[17]; }
221 
223  byte getIdent() const { return data[19]; }
224 
226  bool isIdent() const { return getIdent() != 0; }
227 
229  bool isStandby() const { return getTransponderMode() != 0; }
230 
232  void setRunning(bool running) { data[0] = running ? 1 : 0; }
233 
235  void setConnected(bool connected) { data[1] = connected ? 1 : 0; }
236 
239  {
240  std::fill(data, data + 128, static_cast<byte>(0));
241  data[0] = 1; // SB running, indicates the client is running as external app, 0..not running, 1..external
242  // app, 2..FS module
243  data[1] = 0; // SB connected to FSD, 0..not connected, 1..connected
244  data[17] = 1; // 1..standby, 0..mode C
245  data[19] = 0; // no ident
246  }
247 
249  QString toQString() const;
250  };
251 
254  {
255  double transponderMode = 1;
256  double ident = 0;
257  };
258 
261  {
262  ClientAreaSquawkBox
263  };
264 
265  // TODO TZ: are there any changes in MSFS2024
268  {
269  public:
272  {
273  DataOwnAircraft,
274  DataOwnAircraftTitle,
275  DataRemoteAircraftLights,
276  DataRemoteAircraftPartsWithoutLights,
281  DataSimEnvironment,
282  DataTransponderModeMSFS,
287  DataClientAreaSbRunning
288  };
289 
291  enum Request
292  {
293  RequestOwnAircraft,
294  RequestOwnAircraftTitle,
297  RequestFacility,
298  RequestEndMarker
299  };
300 
303  {
305  SimObjectAdd,
306  SimObjectRemove,
307  SimObjectPositionData,
308  SimObjectLights,
309  SimObjectModel,
310  SimObjectMisc,
311  SimObjectEndMarker
312  };
313 
315  static const QString &requestToString(Request request);
316 
318  static const QString &simObjectRequestToString(SimObjectRequest simObjectRequest);
319 
322 
324  static HRESULT initDataDefinitionsWhenConnected(const HANDLE hSimConnect,
326 
327  private:
329  static HRESULT initOwnAircraft(const HANDLE hSimConnect);
330 
332  static HRESULT initRemoteAircraft(const HANDLE hSimConnect);
333 
335  static HRESULT initRemoteAircraftSimData(const HANDLE hSimConnect);
336 
338  static HRESULT initRemoteAircraftSimDataSet(const HANDLE hSimConnect);
339 
341  static HRESULT initSimulatorEnvironment(const HANDLE hSimConnect);
342 
344  static HRESULT initSbDataArea(const HANDLE hSimConnect);
345 
347  static HRESULT initMSFSTransponder(const HANDLE hSimConnect);
348 
350  static HRESULT initMSFS2024Transponder(const HANDLE hSimConnect);
351  };
352 } // namespace swift::simplugin::fsxcommon
353 
354 #endif // SWIFT_SIMPLUGIN_FSXCOMMON_SIMCONNECT_DATADEFINITION_H
Value object encapsulating information about aircraft's lights.
Value object encapsulating information of aircraft's parts.
Definition: aircraftparts.h:26
Simple hardcoded info about the corresponding simulator.
Definition: simulatorinfo.h:41
SimObjectRequest
SimObject requests used for AI aircraft and probes.
@ DataClientAreaSbConnected
SB connected with network 0x7b81/1.
@ DataClientAreaSb
whole SB area, see http://squawkbox.ca/doc/sdk/fsuipc.php
@ DataRemoteAircraftModelData
model data eventually used and reported back from simulator
@ DataRemoteAircraftGetPosition
get position to evaluate altitude / AGL
#define FSXCOMMON_EXPORT
FSXCommon Export Macro.
void setConnected(bool connected)
Mark as connected with network.
Data structure for MSFS transponder mode information.
double comTransmit1
COM1 transmit, means also receiving.
double comReceiveAll
all COMs receiving, or COM:x transmitting or receiving
double comTransmit2
COM2 transmit, means also receiving.
double flapsHandlePosition
Flaps handle position in percent.
double altitudeCalibratedFt
Altitude without temperature effect (ft, FS2020)
Data for AI object and probe sent back from simulator.
void copyAtcId(const char *c)
Copy the strings, length from docu.
void copyFlightNumber(const char *c)
Copy the strings, length from docu.
void copyAtcAirline(const char *c)
Copy the strings, length from docu.