LTAPI
API to access LiveTraffic's aircraft information
LTAPI.h
Go to the documentation of this file.
1 
30 #ifndef LTAPI_h
31 #define LTAPI_h
32 
33 #include <cstring>
34 #include <memory>
35 #include <string>
36 #include <list>
37 #include <map>
38 #include <chrono>
39 
40 #include "XPLMDataAccess.h"
41 #include "XPLMGraphics.h"
42 
43 class LTDataRef;
44 
52 {
53 private:
56  unsigned keyNum = 0;
58  std::string key;
59 
60 public:
61 
65  FPH_TAXI = 10,
66  FPH_TAKE_OFF = 20,
71  FPH_CLIMB = 30,
72  FPH_CRUISE = 40,
73  FPH_DESCEND = 50,
74  FPH_APPROACH = 60,
76  FPH_LANDING = 70,
81  };
82 
87  struct LTAPIBulkData {
88  public:
89  // identification
90  uint64_t keyNum = 0;
91  // position, attitude
92  float lat_f = 0.0f;
93  float lon_f = 0.0f;
94  float alt_ft_f = 0.0f;
95  float heading = 0.0f;
96  float track = 0.0f;
97  float roll = 0.0f;
98  float pitch = 0.0f;
99  float speed_kt = 0.0f;
100  float vsi_ft = 0.0f;
101  float terrainAlt_ft = 0.0f;
102  float height_ft = 0.0f;
103  // configuration
104  float flaps = 0.0f;
105  float gear = 0.0f;
106  float reversers = 0.0f;
107  // simulation
108  float bearing = 0.0f;
109  float dist_nm = 0.0f;
110 
111  struct BulkBitsTy {
113  bool onGnd : 1;
114  // Lights:
115  bool taxi : 1;
116  bool land : 1;
117  bool bcn : 1;
118  bool strb : 1;
119  bool nav : 1;
120  unsigned filler1 : 1;
121  bool camera : 1;
122  // Misc
123  int multiIdx : 8;
124  // Filler for 8-byte alignment
125  unsigned filler2 : 8;
126  unsigned filler3 : 32;
127  } bits;
128 
129  // V1.22 additions
130  double lat = 0.0f;
131  double lon = 0.0f;
132  double alt_ft = 0.0f;
133 
134 
137  { memset(&bits, 0, sizeof(bits)); }
138  };
139 
143  public:
144  // identification
145  uint64_t keyNum;
146  char registration[8];
147  // aircraft model/operator
148  char modelIcao[8];
149  char acClass[4];
150  char wtc[4];
151  char opIcao[8];
152  char man[40];
153  char model[40];
154  char catDescr[40];
155  char op[40];
156  // flight data
157  char callSign[8];
158  char squawk[8];
159  char flightNumber[8];
160  char origin[8];
161  char destination[8];
162  char trackedBy[24];
163 
164  // V1.22 additions, in V2.40 extended from 24 to 40 chars
165  char cslModel[40];
166 
169  { memset(this, 0, sizeof(*this)); }
170  };
171 
173  struct LTLights {
174  bool beacon : 1;
175  bool strobe : 1;
176  bool nav : 1;
177  bool landing : 1;
178  bool taxi : 1;
179 
182  beacon(b.bcn), strobe(b.strb), nav(b.nav), landing(b.land), taxi(b.taxi){}
183  };
184 
185 protected:
188 
190  bool bUpdated = false;
191 
192 public:
193  LTAPIAircraft();
194  virtual ~LTAPIAircraft();
195 
196  // Updates an aircraft. If our key is defined it first verifies that the
197  // key matches with the one currently available in the dataRefs.
198  // Returns false if not.
199  // If our key is not defined it just accepts anything available.
200  // Updates all fields, set bUpdated and returns true.
204  virtual bool updateAircraft(const LTAPIBulkData& __bulk, size_t __inSize);
208  virtual bool updateAircraft(const LTAPIBulkInfoTexts& __info, size_t __inSize);
210  bool isUpdated () const { return bUpdated; }
212  void resetUpdated () { bUpdated = false; }
213 
214  // data access
215 public:
216  std::string getKey() const { return key; }
217  // identification
218  std::string getRegistration() const { return info.registration; }
219  // aircraft model/operator
220  std::string getModelIcao() const { return info.modelIcao; }
221  std::string getAcClass() const { return info.acClass; }
222  std::string getWtc() const { return info.wtc; }
223  std::string getOpIcao() const { return info.opIcao; }
224  std::string getMan() const { return info.man; }
225  std::string getModel() const { return info.model; }
226  std::string getCatDescr() const { return info.catDescr; }
227  std::string getOp() const { return info.op; }
228  std::string getCslModel() const { return info.cslModel; }
229  // flight data
230  std::string getCallSign() const { return info.callSign; }
231  std::string getSquawk() const { return info.squawk; }
232  std::string getFlightNumber() const { return info.flightNumber; }
233  std::string getOrigin() const { return info.origin; }
234  std::string getDestination() const { return info.destination; }
235  std::string getTrackedBy() const { return info.trackedBy; }
236  // combined info
237  std::string getDescription() const;
238  // position, attitude
239  double getLat() const { return bulk.lat; }
240  double getLon() const { return bulk.lon; }
241  double getAltFt() const { return bulk.alt_ft; }
242  float getHeading() const { return bulk.heading; }
243  float getTrack() const { return bulk.track; }
244  float getRoll() const { return bulk.roll; }
245  float getPitch() const { return bulk.pitch; }
246  float getSpeedKn() const { return bulk.speed_kt; }
247  float getVSIft() const { return bulk.vsi_ft; }
248  float getTerrainFt() const { return bulk.terrainAlt_ft; }
249  float getHeightFt() const { return bulk.height_ft; }
250  bool isOnGnd() const { return bulk.bits.onGnd; }
251  LTFlightPhase getPhase() const { return bulk.bits.phase; }
252  std::string getPhaseStr() const;
253  // configuration
254  float getFlaps() const { return bulk.flaps; }
255  float getGear() const { return bulk.gear; }
256  float getReversers() const { return bulk.reversers; }
257  LTLights getLights() const { return bulk.bits; }
258  bool isOnCamera() const { return bulk.bits.camera; }
259  // simulation
260  float getBearing() const { return bulk.bearing; }
261  float getDistNm() const { return bulk.dist_nm; }
262  int getMultiIdx() const { return bulk.bits.multiIdx; }
263 
264  // calculated
270  void getLocalCoord (double& x, double& y, double& z) const
271  { XPLMWorldToLocal(bulk.lat,bulk.lon,bulk.alt_ft, &x,&y,&z); }
272 
273 public:
276  static LTAPIAircraft* CreateNewObject() { return new LTAPIAircraft(); }
277 };
278 
279 //
280 // MapLTAPIAircraft
281 //
282 
284 typedef std::shared_ptr<LTAPIAircraft> SPtrLTAPIAircraft;
285 
296 typedef std::map<std::string,SPtrLTAPIAircraft> MapLTAPIAircraft;
297 
302 typedef std::list<SPtrLTAPIAircraft> ListLTAPIAircraft;
303 
308 {
309 public:
320 
324  std::chrono::seconds sPeriodExpsv = std::chrono::seconds(3);
325 
326 protected:
328  const int iBulkAc = 50;
330  std::unique_ptr<LTAPIAircraft::LTAPIBulkData[]> vBulkNum;
332  std::unique_ptr<LTAPIAircraft::LTAPIBulkInfoTexts[]> vInfoTexts;
333 
334 protected:
337 
340 
342  std::chrono::time_point<std::chrono::steady_clock> lastExpsvFetch;
343 
344 public:
350  int numBulkAc = 50);
351  virtual ~LTAPIConnect();
352 
354  static bool isLTAvail ();
355 
367  static int getLTVerNr();
368 
373  static int getLTVerDate();
374 
380  static bool doesLTDisplayAc ();
381 
383  static int getLTNumAc ();
384 
392  static bool doesLTControlAI ();
393 
395  static time_t getLTSimTime ();
396 
398  static std::chrono::system_clock::time_point getLTSimTimePoint ();
399 
407  const MapLTAPIAircraft& UpdateAcList (ListLTAPIAircraft* plistRemovedAc = nullptr);
408 
410  const MapLTAPIAircraft& getAcMap () const { return mapAc; }
411 
415  SPtrLTAPIAircraft getAcByMultIdx (int multiIdx) const;
416 
420 
421 protected:
429  template <class T>
430  bool DoBulkFetch (int numAc, LTDataRef& DR, int& outSizeLT,
431  std::unique_ptr<T[]> &vBulk);
432 
433 };
434 
435 
444 
445 class LTDataRef {
446 protected:
447  std::string sDataRef;
448  XPLMDataRef dataRef = NULL;
449  XPLMDataTypeID dataTypes = xplmType_Unknown;
450  bool bValid = true;
451 public:
452  LTDataRef (std::string _sDataRef);
453  inline bool needsInit () const { return bValid && !dataRef; }
455  bool isValid ();
457  bool FindDataRef ();
458 
459  // types
461  XPLMDataTypeID getDataRefTypes() const { return dataTypes; }
463  bool hasInt () const { return dataTypes & xplmType_Int; }
465  bool hasFloat () const { return dataTypes & xplmType_Float; }
467  static constexpr XPLMDataTypeID usefulTypes =
468  xplmType_Int | xplmType_Float | xplmType_Data;
469 
472  int getInt();
475  float getFloat();
477  inline bool getBool() { return getInt() != 0; }
479  int getData(void* pOut, int inOffset, int inMaxBytes);
480 
482  void set(int i);
484  void set(float f);
485 
486 protected:
487 };
488 
489 //
490 // Sizes for version compatibility comparison
491 //
492 
494 constexpr size_t LTAPIBulkData_v120 = 80;
497 
499 constexpr size_t LTAPIBulkInfoTexts_v120 = 264;
500 constexpr size_t LTAPIBulkInfoTexts_v122 = 288;
503 
504 #endif /* LTAPI_h */
LTAPIAircraft::LTAPIAircraft
LTAPIAircraft()
Definition: LTAPI.cpp:117
LTAPIAircraft::bulk
LTAPIBulkData bulk
numerical plane's data
Definition: LTAPI.h:186
LTAPIAircraft::LTAPIBulkInfoTexts::cslModel
char cslModel[40]
name of CSL model used for actual rendering of plane
Definition: LTAPI.h:165
LTAPIAircraft::LTAPIBulkInfoTexts::wtc
char wtc[4]
wake turbulence category like H,M,L/M,L
Definition: LTAPI.h:150
LTAPIAircraft::getDestination
std::string getDestination() const
destination airport (IATA or ICAO) like "FRA" or "EDDF"
Definition: LTAPI.h:234
LTAPIAircraft::LTAPIBulkData::bearing
float bearing
[°] to current camera position
Definition: LTAPI.h:108
LTAPIAircraft::LTAPIBulkData::flaps
float flaps
flap position: 0.0 retracted, 1.0 fully extended
Definition: LTAPI.h:104
LTAPIConnect::doesLTControlAI
static bool doesLTControlAI()
Does LiveTaffic control AI planes?
Definition: LTAPI.cpp:342
LTDataRef::usefulTypes
static constexpr XPLMDataTypeID usefulTypes
Defines which types to work with to become valid
Definition: LTAPI.h:467
LTAPIAircraft::LTAPIBulkData::heading
float heading
[°] heading
Definition: LTAPI.h:95
MapLTAPIAircraft
std::map< std::string, SPtrLTAPIAircraft > MapLTAPIAircraft
Map of all aircrafts stored as smart pointers to LTAPIAircraft objects.
Definition: LTAPI.h:296
LTAPIAircraft::LTAPIBulkData::pitch
float pitch
[°] pitch: positive up
Definition: LTAPI.h:98
LTAPIAircraft::LTAPIBulkData::keyNum
uint64_t keyNum
a/c id, usually transp hex code, or any other unique id (FLARM etc.)
Definition: LTAPI.h:90
LTAPIAircraft::FPH_LIFT_OFF
@ FPH_LIFT_OFF
Lift-off, until "gear-up" height.
Definition: LTAPI.h:69
LTAPIAircraft::LTLights::taxi
bool taxi
taxi lights
Definition: LTAPI.h:178
LTAPIAircraft::LTAPIBulkData::lat_f
float lat_f
deprecated: [°] latitude
Definition: LTAPI.h:92
LTAPIAircraft::LTAPIBulkData::lon
double lon
[°] longitude
Definition: LTAPI.h:131
LTAPIConnect::getLTSimTimePoint
static std::chrono::system_clock::time_point getLTSimTimePoint()
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)?
Definition: LTAPI.cpp:368
LTAPIConnect::getAcInCameraView
SPtrLTAPIAircraft getAcInCameraView() const
Returns the aircraft being viewed in LiveTraffic's camera view, if any.
Definition: LTAPI.cpp:463
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::filler1
unsigned filler1
unused
Definition: LTAPI.h:120
LTAPIConnect::lastExpsvFetch
std::chrono::time_point< std::chrono::steady_clock > lastExpsvFetch
Last fetching of expensive data.
Definition: LTAPI.h:342
LTAPIAircraft::getTrack
float getTrack() const
[°] track over ground
Definition: LTAPI.h:243
LTAPIAircraft::getGear
float getGear() const
gear position: 0.0 retracted, 1.0 fully extended
Definition: LTAPI.h:255
LTAPIAircraft::LTLights::beacon
bool beacon
beacon light
Definition: LTAPI.h:174
LTAPIAircraft::resetUpdated
void resetUpdated()
Helper in update loop, resets bUpdated flag.
Definition: LTAPI.h:212
LTAPIAircraft::LTAPIBulkData::terrainAlt_ft
float terrainAlt_ft
[ft] terrain altitude beneath plane
Definition: LTAPI.h:101
LTAPIAircraft::LTLights::LTLights
LTLights(const LTAPIBulkData::BulkBitsTy b)
Type conversion constructor.
Definition: LTAPI.h:181
LTAPIConnect::iBulkAc
const int iBulkAc
Number of aircraft to fetch in one bulk operation.
Definition: LTAPI.h:328
LTAPIConnect::fCreateAcObject
LTAPIAircraft * fCreateAcObject()
Callback function type passed in to LTAPIConnect()
Definition: LTAPI.h:319
LTDataRef::bValid
bool bValid
does this object have a valid binding to a dataRef already?
Definition: LTAPI.h:450
LTAPIAircraft::isUpdated
bool isUpdated() const
Helper in update loop to detected removed aircrafts.
Definition: LTAPI.h:210
LTAPIAircraft::LTAPIBulkInfoTexts::flightNumber
char flightNumber[8]
flight number like "LH1113"
Definition: LTAPI.h:159
LTAPIAircraft::getBearing
float getBearing() const
[°] to current camera position
Definition: LTAPI.h:260
ListLTAPIAircraft
std::list< SPtrLTAPIAircraft > ListLTAPIAircraft
Simple list of smart pointers to LTAPIAircraft objects.
Definition: LTAPI.h:302
LTAPIAircraft::FPH_INITIAL_CLIMB
@ FPH_INITIAL_CLIMB
Initial climb, until "flaps-up" height.
Definition: LTAPI.h:70
LTAPIAircraft::LTAPIBulkInfoTexts::registration
char registration[8]
tail number like "D-AISD"
Definition: LTAPI.h:146
LTAPIConnect::getLTVerDate
static int getLTVerDate()
LiveTraffic's version date.
Definition: LTAPI.cpp:313
LTAPIAircraft::getOpIcao
std::string getOpIcao() const
ICAO-code of operator like "DLH".
Definition: LTAPI.h:223
LTAPIConnect::mapAc
MapLTAPIAircraft mapAc
THE map of aircrafts.
Definition: LTAPI.h:339
LTAPIAircraft::getHeightFt
float getHeightFt() const
[ft] height AGL
Definition: LTAPI.h:249
LTAPIAircraft::LTAPIBulkData::lat
double lat
[°] latitude
Definition: LTAPI.h:130
LTAPIAircraft::FPH_TOUCH_DOWN
@ FPH_TOUCH_DOWN
The one cycle when plane touches down, don't rely on catching it...it's really one cycle only.
Definition: LTAPI.h:78
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::nav
bool nav
navigaton lights
Definition: LTAPI.h:119
LTAPIAircraft::LTAPIBulkInfoTexts::modelIcao
char modelIcao[8]
ICAO aircraft type like "A321".
Definition: LTAPI.h:148
LTDataRef::set
void set(int i)
Writes an integer value to the dataRef.
Definition: LTAPI.cpp:576
LTAPIAircraft::getSpeedKn
float getSpeedKn() const
[kt] ground speed
Definition: LTAPI.h:246
LTAPIAircraft::getOp
std::string getOp() const
human-readable operator like "Lufthansa"
Definition: LTAPI.h:227
LTAPIAircraft::FPH_ROLL_OUT
@ FPH_ROLL_OUT
Roll-out after touch-down until reaching taxi speed or stopping.
Definition: LTAPI.h:79
LTAPIBulkInfoTexts_v122
constexpr size_t LTAPIBulkInfoTexts_v122
Definition: LTAPI.h:500
LTAPIAircraft::LTAPIBulkData::roll
float roll
[°] roll: positive right
Definition: LTAPI.h:97
LTAPIAircraft::LTAPIBulkInfoTexts::man
char man[40]
human-readable manufacturer like "Airbus"
Definition: LTAPI.h:152
LTAPIConnect::isLTAvail
static bool isLTAvail()
Is LiveTraffic available? (checks via XPLMFindPluginBySignature)
Definition: LTAPI.cpp:292
LTAPIAircraft::LTAPIBulkInfoTexts::trackedBy
char trackedBy[24]
name of channel deliverying the underlying tracking data
Definition: LTAPI.h:162
LTAPIAircraft::FPH_CRUISE
@ FPH_CRUISE
Cruising, no altitude change.
Definition: LTAPI.h:72
LTAPIAircraft::getAltFt
double getAltFt() const
[ft] altitude
Definition: LTAPI.h:241
LTAPIAircraft::getMan
std::string getMan() const
human-readable manufacturer like "Airbus"
Definition: LTAPI.h:224
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::taxi
bool taxi
taxi lights
Definition: LTAPI.h:115
LTAPIAircraft::getModelIcao
std::string getModelIcao() const
ICAO aircraft type like "A321".
Definition: LTAPI.h:220
LTAPIAircraft::LTLights
Structure to return plane's lights status.
Definition: LTAPI.h:173
LTAPIAircraft::LTAPIBulkData::height_ft
float height_ft
[ft] height AGL
Definition: LTAPI.h:102
LTAPIAircraft::getRegistration
std::string getRegistration() const
tail number like "D-AISD"
Definition: LTAPI.h:218
LTAPIAircraft::getFlightNumber
std::string getFlightNumber() const
flight number like "LH1113"
Definition: LTAPI.h:232
LTDataRef
Represents a dataRef and covers late binding.
Definition: LTAPI.h:445
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::bcn
bool bcn
beacon light
Definition: LTAPI.h:117
LTAPIConnect::~LTAPIConnect
virtual ~LTAPIConnect()
Definition: LTAPI.cpp:288
LTAPIAircraft::FPH_TAXI
@ FPH_TAXI
Taxiing.
Definition: LTAPI.h:65
LTAPIAircraft::LTAPIBulkData::bits
struct LTAPIAircraft::LTAPIBulkData::BulkBitsTy bits
Flights phase, on-ground status, lights.
LTAPIAircraft::CreateNewObject
static LTAPIAircraft * CreateNewObject()
Standard object creation callback.
Definition: LTAPI.h:276
LTAPIAircraft::getSquawk
std::string getSquawk() const
squawk code (as text) like "1000"
Definition: LTAPI.h:231
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::strb
bool strb
strobe light
Definition: LTAPI.h:118
LTAPIAircraft::LTAPIBulkData::alt_ft_f
float alt_ft_f
deprecated: [ft] altitude
Definition: LTAPI.h:94
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::filler2
unsigned filler2
Definition: LTAPI.h:125
LTAPIAircraft::bUpdated
bool bUpdated
update helper, gets reset before updates, set during updates, stays false if not updated
Definition: LTAPI.h:190
LTAPIAircraft::LTAPIBulkData::reversers
float reversers
reversers position: 0.0 closed, 1.0 fully opened
Definition: LTAPI.h:106
LTDataRef::getDataRefTypes
XPLMDataTypeID getDataRefTypes() const
Get types supported by the dataRef.
Definition: LTAPI.h:461
LTDataRef::getData
int getData(void *pOut, int inOffset, int inMaxBytes)
Gets dataRef's binary data.
Definition: LTAPI.cpp:570
LTAPIAircraft::FPH_CLIMB
@ FPH_CLIMB
Regular climbout.
Definition: LTAPI.h:71
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::camera
bool camera
is LiveTraffic's camera on this aircraft?
Definition: LTAPI.h:121
LTAPIAircraft::LTLights::nav
bool nav
navigaton lights
Definition: LTAPI.h:176
LTAPIAircraft::LTAPIBulkInfoTexts::model
char model[40]
human-readable a/c model like "A321-231"
Definition: LTAPI.h:153
LTAPIAircraft::getPhaseStr
std::string getPhaseStr() const
flight phase as string
Definition: LTAPI.cpp:250
LTAPIConnect::vInfoTexts
std::unique_ptr< LTAPIAircraft::LTAPIBulkInfoTexts[]> vInfoTexts
bulk info text array for communication with LT
Definition: LTAPI.h:332
LTAPIConnect::doesLTDisplayAc
static bool doesLTDisplayAc()
Does LiveTraffic display aircrafts? (Is it activated?)
Definition: LTAPI.cpp:326
LTAPIAircraft::LTAPIBulkData::BulkBitsTy
Definition: LTAPI.h:111
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::land
bool land
landing lights
Definition: LTAPI.h:116
LTAPIAircraft::FPH_UNKNOWN
@ FPH_UNKNOWN
used for initializations
Definition: LTAPI.h:64
LTAPIAircraft::getWtc
std::string getWtc() const
wake turbulence category like H,M,L/M,L
Definition: LTAPI.h:222
LTDataRef::dataRef
XPLMDataRef dataRef
dataRef identifier returned by X-Plane
Definition: LTAPI.h:448
LTAPIAircraft::getAcClass
std::string getAcClass() const
a/c class like "L2J"
Definition: LTAPI.h:221
LTAPIAircraft::LTAPIBulkInfoTexts::opIcao
char opIcao[8]
ICAO-code of operator like "DLH".
Definition: LTAPI.h:151
LTAPIAircraft::getCallSign
std::string getCallSign() const
call sign like "DLH56C"
Definition: LTAPI.h:230
LTAPIAircraft::getTrackedBy
std::string getTrackedBy() const
name of channel deliverying the underlying tracking data
Definition: LTAPI.h:235
LTDataRef::dataTypes
XPLMDataTypeID dataTypes
supported data types
Definition: LTAPI.h:449
LTDataRef::getInt
int getInt()
Get dataRef's integer value. Silently returns 0 if dataRef doesn't exist.
Definition: LTAPI.cpp:558
LTAPIConnect::pfCreateAcObject
fCreateAcObject * pfCreateAcObject
Pointer to callback function returning new aircraft objects.
Definition: LTAPI.h:336
LTAPIAircraft::LTLights::strobe
bool strobe
strobe light
Definition: LTAPI.h:175
LTAPIConnect::DoBulkFetch
bool DoBulkFetch(int numAc, LTDataRef &DR, int &outSizeLT, std::unique_ptr< T[]> &vBulk)
fetch bulk data and create/update aircraft objects
Definition: LTAPI.cpp:478
LTAPIAircraft::getTerrainFt
float getTerrainFt() const
[ft] terrain altitude beneath plane
Definition: LTAPI.h:248
LTAPIConnect::sPeriodExpsv
std::chrono::seconds sPeriodExpsv
Definition: LTAPI.h:324
LTAPIBulkData_v120
constexpr size_t LTAPIBulkData_v120
Size of original bulk structure as per LiveTraffic v1.20.
Definition: LTAPI.h:494
LTAPIAircraft::LTFlightPhase
LTFlightPhase
Flight phase, definition copied from LiveTraffic.
Definition: LTAPI.h:63
LTAPIConnect::getLTNumAc
static int getLTNumAc()
How many aircraft does LiveTraffic display right now?
Definition: LTAPI.cpp:336
LTDataRef::LTDataRef
LTDataRef(std::string _sDataRef)
Constructor, set the dataRef's name.
Definition: LTAPI.cpp:537
LTAPIConnect::getAcMap
const MapLTAPIAircraft & getAcMap() const
Returns the map of aircraft as it currently stands.
Definition: LTAPI.h:410
LTAPIAircraft::getCatDescr
std::string getCatDescr() const
human-readable category description
Definition: LTAPI.h:226
LTAPIConnect::vBulkNum
std::unique_ptr< LTAPIAircraft::LTAPIBulkData[]> vBulkNum
bulk data array for communication with LT
Definition: LTAPI.h:330
LTDataRef::needsInit
bool needsInit() const
Definition: LTAPI.h:453
LTAPIAircraft::LTAPIBulkInfoTexts
Bulk text transfer structur for communication with LTAPI.
Definition: LTAPI.h:142
LTAPIAircraft::LTAPIBulkInfoTexts::callSign
char callSign[8]
call sign like "DLH56C"
Definition: LTAPI.h:157
LTAPIAircraft::FPH_DESCEND
@ FPH_DESCEND
Descend, more then 100ft/min descend.
Definition: LTAPI.h:73
LTAPIAircraft
Represents one aircraft as controlled by LiveTraffic.
Definition: LTAPI.h:52
LTAPIAircraft::LTAPIBulkInfoTexts::LTAPIBulkInfoTexts
LTAPIBulkInfoTexts()
Constructor initializes all data with zeroes.
Definition: LTAPI.h:168
LTAPIAircraft::LTAPIBulkInfoTexts::keyNum
uint64_t keyNum
a/c id, usually transp hex code, or any other unique id (FLARM etc.)
Definition: LTAPI.h:145
LTAPIConnect::getAcByMultIdx
SPtrLTAPIAircraft getAcByMultIdx(int multiIdx) const
Finds an aircraft for a given multiplayer slot.
Definition: LTAPI.cpp:445
LTAPIAircraft::getLon
double getLon() const
[°] longitude
Definition: LTAPI.h:240
LTDataRef::hasInt
bool hasInt() const
Is int a supported dataRef type?
Definition: LTAPI.h:463
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::filler3
unsigned filler3
Definition: LTAPI.h:126
LTAPIAircraft::FPH_TAKE_OFF
@ FPH_TAKE_OFF
Group of status for take-off:
Definition: LTAPI.h:66
LTAPIBulkData_v122
constexpr size_t LTAPIBulkData_v122
Size of current bulk structure.
Definition: LTAPI.h:496
LTAPIAircraft::getMultiIdx
int getMultiIdx() const
multiplayer index if plane reported via sim/multiplayer/position dataRefs, 0 if not
Definition: LTAPI.h:262
LTAPIAircraft::LTAPIBulkData::vsi_ft
float vsi_ft
[ft/minute] vertical speed, positive up
Definition: LTAPI.h:100
LTAPIBulkInfoTexts_v240
constexpr size_t LTAPIBulkInfoTexts_v240
Size of current bulk info structure.
Definition: LTAPI.h:502
LTAPIAircraft::LTAPIBulkInfoTexts::acClass
char acClass[4]
a/c class like "L2J"
Definition: LTAPI.h:149
SPtrLTAPIAircraft
std::shared_ptr< LTAPIAircraft > SPtrLTAPIAircraft
Smart pointer to an TLAPIAircraft object.
Definition: LTAPI.h:284
LTAPIAircraft::FPH_FLARE
@ FPH_FLARE
Flare, when reaching "flare " height.
Definition: LTAPI.h:77
LTDataRef::hasFloat
bool hasFloat() const
Is float a supported dataRef type?
Definition: LTAPI.h:465
LTAPIConnect::LTAPIConnect
LTAPIConnect(fCreateAcObject *_pfCreateAcObject=LTAPIAircraft::CreateNewObject, int numBulkAc=50)
Constructor.
Definition: LTAPI.cpp:279
LTAPIAircraft::FPH_STOPPED_ON_RWY
@ FPH_STOPPED_ON_RWY
Stopped on runway because ran out of tracking data, plane will disappear soon.
Definition: LTAPI.h:80
LTDataRef::FindDataRef
bool FindDataRef()
Finds the dataRef (and would try again and again, no matter what bValid says)
Definition: LTAPI.cpp:550
LTAPIAircraft::updateAircraft
virtual bool updateAircraft(const LTAPIBulkData &__bulk, size_t __inSize)
Updates the aircraft with fresh numerical values, called from LTAPIConnect::UpdateAcList()
Definition: LTAPI.cpp:168
LTAPIAircraft::getCslModel
std::string getCslModel() const
name of CSL model used for actual rendering of plane
Definition: LTAPI.h:228
LTAPIAircraft::LTLights::landing
bool landing
landing lights
Definition: LTAPI.h:177
LTAPIAircraft::LTAPIBulkInfoTexts::squawk
char squawk[8]
squawk code (as text) like "1000"
Definition: LTAPI.h:158
LTAPIAircraft::FPH_ROTATE
@ FPH_ROTATE
Rotating.
Definition: LTAPI.h:68
LTAPIAircraft::LTAPIBulkData::LTAPIBulkData
LTAPIBulkData()
Constructor initializes some data without defaults.
Definition: LTAPI.h:136
LTAPIAircraft::getLat
double getLat() const
[°] latitude
Definition: LTAPI.h:239
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::phase
LTFlightPhase phase
flight phase, see LTAircraft::FlightPhase
Definition: LTAPI.h:112
LTAPIAircraft::FPH_FINAL
@ FPH_FINAL
Final, below "gear-down" height.
Definition: LTAPI.h:75
LTAPIConnect::UpdateAcList
const MapLTAPIAircraft & UpdateAcList(ListLTAPIAircraft *plistRemovedAc=nullptr)
Main function: updates map of aircrafts and returns reference to it.
Definition: LTAPI.cpp:374
LTDataRef::isValid
bool isValid()
Found the dataRef and it contains formats we can work with?
Definition: LTAPI.cpp:543
LTAPIAircraft::LTAPIBulkInfoTexts::op
char op[40]
human-readable operator like "Lufthansa"
Definition: LTAPI.h:155
LTAPIBulkInfoTexts_v120
constexpr size_t LTAPIBulkInfoTexts_v120
Size of original bulk info structure as per previous versions of LiveTraffic.
Definition: LTAPI.h:499
LTAPIAircraft::LTAPIBulkInfoTexts::destination
char destination[8]
destination airport (IATA or ICAO) like "FRA" or "EDDF"
Definition: LTAPI.h:161
LTAPIConnect::getLTSimTime
static time_t getLTSimTime()
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)?
Definition: LTAPI.cpp:348
LTAPIAircraft::LTAPIBulkData::speed_kt
float speed_kt
[kt] ground speed
Definition: LTAPI.h:99
LTAPIAircraft::info
LTAPIBulkInfoTexts info
textual plane's data
Definition: LTAPI.h:187
LTDataRef::getFloat
float getFloat()
Get dataRef's float value. Silently returns 0.0f if dataRef doesn't exist.
Definition: LTAPI.cpp:564
LTAPIAircraft::getFlaps
float getFlaps() const
flap position: 0.0 retracted, 1.0 fully extended
Definition: LTAPI.h:254
LTAPIAircraft::FPH_LANDING
@ FPH_LANDING
Group of status for landing:
Definition: LTAPI.h:76
LTAPIAircraft::getPitch
float getPitch() const
[°] pitch: positive up
Definition: LTAPI.h:245
LTAPIAircraft::getVSIft
float getVSIft() const
[ft/minute] vertical speed, positive up
Definition: LTAPI.h:247
LTAPIAircraft::isOnGnd
bool isOnGnd() const
Is plane on ground?
Definition: LTAPI.h:250
LTAPIAircraft::getReversers
float getReversers() const
reversers position: 0.0 closed, 1.0 fully opened
Definition: LTAPI.h:256
LTAPIAircraft::LTAPIBulkData::gear
float gear
gear position: 0.0 retracted, 1.0 fully extended
Definition: LTAPI.h:105
LTAPIAircraft::LTAPIBulkInfoTexts::origin
char origin[8]
origin airport (IATA or ICAO) like "MAD" or "LEMD"
Definition: LTAPI.h:160
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::onGnd
bool onGnd
Is plane on ground?
Definition: LTAPI.h:113
LTAPIAircraft::getLocalCoord
void getLocalCoord(double &x, double &y, double &z) const
lat/lon/alt converted to local coordinates
Definition: LTAPI.h:270
LTDataRef::sDataRef
std::string sDataRef
dataRef name, passed in via constructor
Definition: LTAPI.h:447
LTAPIAircraft::LTAPIBulkData::alt_ft
double alt_ft
[ft] altitude
Definition: LTAPI.h:132
LTAPIAircraft::getModel
std::string getModel() const
human-readable a/c model like "A321-231"
Definition: LTAPI.h:225
LTAPIAircraft::getLights
LTLights getLights() const
all plane's lights
Definition: LTAPI.h:257
LTAPIAircraft::LTAPIBulkData::BulkBitsTy::multiIdx
int multiIdx
multiplayer index if plane reported via sim/multiplayer/position dataRefs, 0 if not
Definition: LTAPI.h:123
LTAPIAircraft::LTAPIBulkData
Bulk data transfer structur for communication with LTAPI.
Definition: LTAPI.h:87
LTAPIAircraft::isOnCamera
bool isOnCamera() const
is currently seen on LiveTraffic's internal camera view?
Definition: LTAPI.h:258
LTAPIConnect::getLTVerNr
static int getLTVerNr()
LiveTraffic's version number.
Definition: LTAPI.cpp:298
LTAPIAircraft::~LTAPIAircraft
virtual ~LTAPIAircraft()
Definition: LTAPI.cpp:120
LTAPIAircraft::getOrigin
std::string getOrigin() const
origin airport (IATA or ICAO) like "MAD" or "LEMD"
Definition: LTAPI.h:233
LTDataRef::getBool
bool getBool()
Gets dataRef's integer value and returns if it is not zero.
Definition: LTAPI.h:477
LTAPIAircraft::FPH_APPROACH
@ FPH_APPROACH
Approach, below "flaps-down" height.
Definition: LTAPI.h:74
LTAPIAircraft::LTAPIBulkData::track
float track
[°] track over ground
Definition: LTAPI.h:96
LTAPIAircraft::getKey
std::string getKey() const
Unique key for this aircraft, usually ICAO transponder hex code.
Definition: LTAPI.h:216
LTAPIAircraft::LTAPIBulkInfoTexts::catDescr
char catDescr[40]
human-readable category description
Definition: LTAPI.h:154
LTAPIConnect
Connects to LiveTraffic's dataRefs and returns aircraft information.
Definition: LTAPI.h:308
LTAPIAircraft::getDistNm
float getDistNm() const
[nm] distance to current camera
Definition: LTAPI.h:261
LTAPIAircraft::getRoll
float getRoll() const
[°] roll: positive right
Definition: LTAPI.h:244
LTAPIAircraft::FPH_TO_ROLL
@ FPH_TO_ROLL
Take-off roll.
Definition: LTAPI.h:67
LTAPIAircraft::LTAPIBulkData::lon_f
float lon_f
deprecated: [°] longitude
Definition: LTAPI.h:93
LTAPIAircraft::getHeading
float getHeading() const
[°] heading
Definition: LTAPI.h:242
LTAPIAircraft::LTAPIBulkData::dist_nm
float dist_nm
[nm] distance to current camera
Definition: LTAPI.h:109
LTAPIAircraft::getDescription
std::string getDescription() const
some reasonable descriptive string formed from the above, like an identifier, type,...
Definition: LTAPI.cpp:128
LTAPIAircraft::getPhase
LTFlightPhase getPhase() const
flight phase
Definition: LTAPI.h:251