swift
Loading...
Searching...
No Matches
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
19namespace swift::misc::aviation
20{
21 class CAircraftParts;
22}
23namespace swift::simplugin::fsxcommon
24{
87
90 {
91 char title[256];
92 };
93
96 {
97 double cgToGroundFt;
98 char atcType[32];
99 char atcModel[32];
100 char atcId[32];
103 char title[256];
104 };
105
108 {
109 // length here is from SimConnect_AddToDataDefinition
110 char atcId[32];
111 char atcAirline[64];
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 }
131
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
187
203
206 {
207 double latitudeDeg;
209 double altitudeFt;
210 double elevationFt;
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,
296 };
297
300 {
301 RequestOwnAircraft,
302 RequestOwnAircraftTitle,
305 RequestFacility,
307 };
308
311 {
313 SimObjectAdd,
314 SimObjectRemove,
315 SimObjectPositionData,
316 SimObjectLights,
317 SimObjectModel,
318 SimObjectMisc,
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.
Simple hardcoded info about the corresponding simulator.
SimObjectRequest
SimObject requests used for AI aircraft and probes.
@ SimObjectEndMarker
end marker, do NOT remove, also means invalid
@ 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.
swift::misc::aviation::CAircraftLights toLights() const
Convert to lights.
void setEngine(int number1based, bool on, double engineRpmPct)
Set given engine.
bool operator==(const DataDefinitionRemoteAircraftPartsWithoutLights &rhs) const
Equal to other parts.
void initFromParts(const swift::misc::aviation::CAircraftParts &parts)
Init from parts.
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.