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 engine1RpmPct;
74  double engine2RpmPct;
75  double engine3RpmPct;
76  double engine4RpmPct;
77  double velocityWorldX;
78  double velocityWorldY;
79  double velocityWorldZ;
83  // 48
85  // 49
86  };
87 
90  {
91  char title[256];
92  };
93 
96  {
97  double cgToGroundFt;
98  char atcType[32];
99  char atcModel[32];
100  char atcId[32];
101  char atcAirlineNumber[64];
102  char atcFlightNumber[8];
103  char title[256];
104  };
105 
108  {
109  // length here is from SimConnect_AddToDataDefinition
110  char atcId[32];
111  char atcAirline[64];
112  char atcFlightNumber[8];
113 
116  void copyAtcId(const char *c)
117  {
118  strncpy_s(atcId, c, 10);
119  atcId[9] = 0;
120  }
121  void copyAtcAirline(const char *c)
122  {
123  strncpy_s(atcAirline, c, 50);
124  atcAirline[49] = 0;
125  }
126  void copyFlightNumber(const char *c)
127  {
128  strncpy_s(atcFlightNumber, c, 6);
129  atcFlightNumber[5] = 0;
130  }
132 
135  {
136  std::fill(atcId, atcId + 10, static_cast<byte>(0));
137  std::fill(atcAirline, atcAirline + 50, static_cast<byte>(0));
138  std::fill(atcFlightNumber, atcFlightNumber + 6, static_cast<byte>(0));
139  }
140  };
141 
144  {
155  double engine1RpmPct;
156  double engine2RpmPct;
157  double engine3RpmPct;
158  double engine4RpmPct;
159 
162 
165 
167  bool operator==(const DataDefinitionRemoteAircraftPartsWithoutLights &rhs) const;
168 
170  void setAllEngines(bool on, double engineRpmPct);
171 
173  void setEngine(int number1based, bool on, double engineRpmPct);
174 
176  void resetAllFlaps();
177 
179  void resetSpoilers();
180 
182  void resetToInvalid();
183 
185  void initFromParts(const swift::misc::aviation::CAircraftParts &parts);
186  };
187 
190  {
191  double lightStrobe;
192  double lightLanding;
193  double lightTaxi;
194  double lightBeacon;
195  double lightNav;
196  double lightLogo;
198  double lightCabin;
199 
202  };
203 
206  {
207  double latitudeDeg;
208  double longitudeDeg;
209  double altitudeFt;
210  double elevationFt;
211  double cgToGroundFt;
212 
214  double aboveGroundFt() const { return altitudeFt - elevationFt; }
215 
217  bool isOnGround() const { return this->aboveGroundFt() < 1.0; }
218  };
219 
224  {
225  byte data[128] {};
226 
228  byte getTransponderMode() const { return data[17]; }
229 
231  byte getIdent() const { return data[19]; }
232 
234  bool isIdent() const { return getIdent() != 0; }
235 
237  bool isStandby() const { return getTransponderMode() != 0; }
238 
240  void setRunning(bool running) { data[0] = running ? 1 : 0; }
241 
243  void setConnected(bool connected) { data[1] = connected ? 1 : 0; }
244 
247  {
248  std::fill(data, data + 128, static_cast<byte>(0));
249  data[0] = 1; // SB running, indicates the client is running as external app, 0..not running, 1..external
250  // app, 2..FS module
251  data[1] = 0; // SB connected to FSD, 0..not connected, 1..connected
252  data[17] = 1; // 1..standby, 0..mode C
253  data[19] = 0; // no ident
254  }
255 
257  QString toQString() const;
258  };
259 
262  {
263  double transponderMode = 1;
264  double ident = 0;
265  };
266 
269  {
270  ClientAreaSquawkBox
271  };
272 
273  // TODO TZ: are there any changes in MSFS2024
276  {
277  public:
280  {
281  DataOwnAircraft,
282  DataOwnAircraftTitle,
283  DataRemoteAircraftLights,
284  DataRemoteAircraftPartsWithoutLights,
289  DataSimEnvironment,
290  DataTransponderModeMSFS,
295  DataClientAreaSbRunning
296  };
297 
299  enum Request
300  {
301  RequestOwnAircraft,
302  RequestOwnAircraftTitle,
305  RequestFacility,
306  RequestEndMarker
307  };
308 
311  {
313  SimObjectAdd,
314  SimObjectRemove,
315  SimObjectPositionData,
316  SimObjectLights,
317  SimObjectModel,
318  SimObjectMisc,
319  SimObjectEndMarker
320  };
321 
323  static const QString &requestToString(Request request);
324 
326  static const QString &simObjectRequestToString(SimObjectRequest simObjectRequest);
327 
330 
332  static HRESULT initDataDefinitionsWhenConnected(const HANDLE hSimConnect,
334 
335  private:
337  static HRESULT initOwnAircraft(const HANDLE hSimConnect);
338 
340  static HRESULT initRemoteAircraft(const HANDLE hSimConnect);
341 
343  static HRESULT initRemoteAircraftSimData(const HANDLE hSimConnect);
344 
346  static HRESULT initRemoteAircraftSimDataSet(const HANDLE hSimConnect);
347 
349  static HRESULT initSimulatorEnvironment(const HANDLE hSimConnect);
350 
352  static HRESULT initSbDataArea(const HANDLE hSimConnect);
353 
355  static HRESULT initMSFSTransponder(const HANDLE hSimConnect);
356 
358  static HRESULT initMSFS2024Transponder(const HANDLE hSimConnect);
359  };
360 } // namespace swift::simplugin::fsxcommon
361 
362 #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.