LTAPI
API to access LiveTraffic's aircraft information
|
Go to the documentation of this file.
40 #include "XPLMDataAccess.h"
41 #include "XPLMGraphics.h"
169 { memset(
this, 0,
sizeof(*
this)); }
216 std::string
getKey()
const {
return key; }
330 std::unique_ptr<LTAPIAircraft::LTAPIBulkData[]>
vBulkNum;
332 std::unique_ptr<LTAPIAircraft::LTAPIBulkInfoTexts[]>
vInfoTexts;
431 std::unique_ptr<T[]> &vBulk);
468 xplmType_Int | xplmType_Float | xplmType_Data;
479 int getData(
void* pOut,
int inOffset,
int inMaxBytes);
LTAPIAircraft()
Definition: LTAPI.cpp:117
LTAPIBulkData bulk
numerical plane's data
Definition: LTAPI.h:186
char cslModel[40]
name of CSL model used for actual rendering of plane
Definition: LTAPI.h:165
char wtc[4]
wake turbulence category like H,M,L/M,L
Definition: LTAPI.h:150
std::string getDestination() const
destination airport (IATA or ICAO) like "FRA" or "EDDF"
Definition: LTAPI.h:234
float bearing
[°] to current camera position
Definition: LTAPI.h:108
float flaps
flap position: 0.0 retracted, 1.0 fully extended
Definition: LTAPI.h:104
static bool doesLTControlAI()
Does LiveTaffic control AI planes?
Definition: LTAPI.cpp:342
static constexpr XPLMDataTypeID usefulTypes
Defines which types to work with to become valid
Definition: LTAPI.h:467
float heading
[°] heading
Definition: LTAPI.h:95
std::map< std::string, SPtrLTAPIAircraft > MapLTAPIAircraft
Map of all aircrafts stored as smart pointers to LTAPIAircraft objects.
Definition: LTAPI.h:296
float pitch
[°] pitch: positive up
Definition: LTAPI.h:98
uint64_t keyNum
a/c id, usually transp hex code, or any other unique id (FLARM etc.)
Definition: LTAPI.h:90
@ FPH_LIFT_OFF
Lift-off, until "gear-up" height.
Definition: LTAPI.h:69
bool taxi
taxi lights
Definition: LTAPI.h:178
float lat_f
deprecated: [°] latitude
Definition: LTAPI.h:92
double lon
[°] longitude
Definition: LTAPI.h:131
static std::chrono::system_clock::time_point getLTSimTimePoint()
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)?
Definition: LTAPI.cpp:368
SPtrLTAPIAircraft getAcInCameraView() const
Returns the aircraft being viewed in LiveTraffic's camera view, if any.
Definition: LTAPI.cpp:463
unsigned filler1
unused
Definition: LTAPI.h:120
std::chrono::time_point< std::chrono::steady_clock > lastExpsvFetch
Last fetching of expensive data.
Definition: LTAPI.h:342
float getTrack() const
[°] track over ground
Definition: LTAPI.h:243
float getGear() const
gear position: 0.0 retracted, 1.0 fully extended
Definition: LTAPI.h:255
bool beacon
beacon light
Definition: LTAPI.h:174
void resetUpdated()
Helper in update loop, resets bUpdated flag.
Definition: LTAPI.h:212
float terrainAlt_ft
[ft] terrain altitude beneath plane
Definition: LTAPI.h:101
LTLights(const LTAPIBulkData::BulkBitsTy b)
Type conversion constructor.
Definition: LTAPI.h:181
const int iBulkAc
Number of aircraft to fetch in one bulk operation.
Definition: LTAPI.h:328
LTAPIAircraft * fCreateAcObject()
Callback function type passed in to LTAPIConnect()
Definition: LTAPI.h:319
bool bValid
does this object have a valid binding to a dataRef already?
Definition: LTAPI.h:450
bool isUpdated() const
Helper in update loop to detected removed aircrafts.
Definition: LTAPI.h:210
char flightNumber[8]
flight number like "LH1113"
Definition: LTAPI.h:159
float getBearing() const
[°] to current camera position
Definition: LTAPI.h:260
std::list< SPtrLTAPIAircraft > ListLTAPIAircraft
Simple list of smart pointers to LTAPIAircraft objects.
Definition: LTAPI.h:302
@ FPH_INITIAL_CLIMB
Initial climb, until "flaps-up" height.
Definition: LTAPI.h:70
char registration[8]
tail number like "D-AISD"
Definition: LTAPI.h:146
static int getLTVerDate()
LiveTraffic's version date.
Definition: LTAPI.cpp:313
std::string getOpIcao() const
ICAO-code of operator like "DLH".
Definition: LTAPI.h:223
MapLTAPIAircraft mapAc
THE map of aircrafts.
Definition: LTAPI.h:339
float getHeightFt() const
[ft] height AGL
Definition: LTAPI.h:249
double lat
[°] latitude
Definition: LTAPI.h:130
@ 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
bool nav
navigaton lights
Definition: LTAPI.h:119
char modelIcao[8]
ICAO aircraft type like "A321".
Definition: LTAPI.h:148
void set(int i)
Writes an integer value to the dataRef.
Definition: LTAPI.cpp:576
float getSpeedKn() const
[kt] ground speed
Definition: LTAPI.h:246
std::string getOp() const
human-readable operator like "Lufthansa"
Definition: LTAPI.h:227
@ FPH_ROLL_OUT
Roll-out after touch-down until reaching taxi speed or stopping.
Definition: LTAPI.h:79
constexpr size_t LTAPIBulkInfoTexts_v122
Definition: LTAPI.h:500
float roll
[°] roll: positive right
Definition: LTAPI.h:97
char man[40]
human-readable manufacturer like "Airbus"
Definition: LTAPI.h:152
static bool isLTAvail()
Is LiveTraffic available? (checks via XPLMFindPluginBySignature)
Definition: LTAPI.cpp:292
char trackedBy[24]
name of channel deliverying the underlying tracking data
Definition: LTAPI.h:162
@ FPH_CRUISE
Cruising, no altitude change.
Definition: LTAPI.h:72
double getAltFt() const
[ft] altitude
Definition: LTAPI.h:241
std::string getMan() const
human-readable manufacturer like "Airbus"
Definition: LTAPI.h:224
bool taxi
taxi lights
Definition: LTAPI.h:115
std::string getModelIcao() const
ICAO aircraft type like "A321".
Definition: LTAPI.h:220
Structure to return plane's lights status.
Definition: LTAPI.h:173
float height_ft
[ft] height AGL
Definition: LTAPI.h:102
std::string getRegistration() const
tail number like "D-AISD"
Definition: LTAPI.h:218
std::string getFlightNumber() const
flight number like "LH1113"
Definition: LTAPI.h:232
Represents a dataRef and covers late binding.
Definition: LTAPI.h:445
bool bcn
beacon light
Definition: LTAPI.h:117
virtual ~LTAPIConnect()
Definition: LTAPI.cpp:288
@ FPH_TAXI
Taxiing.
Definition: LTAPI.h:65
struct LTAPIAircraft::LTAPIBulkData::BulkBitsTy bits
Flights phase, on-ground status, lights.
static LTAPIAircraft * CreateNewObject()
Standard object creation callback.
Definition: LTAPI.h:276
std::string getSquawk() const
squawk code (as text) like "1000"
Definition: LTAPI.h:231
bool strb
strobe light
Definition: LTAPI.h:118
float alt_ft_f
deprecated: [ft] altitude
Definition: LTAPI.h:94
unsigned filler2
Definition: LTAPI.h:125
bool bUpdated
update helper, gets reset before updates, set during updates, stays false if not updated
Definition: LTAPI.h:190
float reversers
reversers position: 0.0 closed, 1.0 fully opened
Definition: LTAPI.h:106
XPLMDataTypeID getDataRefTypes() const
Get types supported by the dataRef.
Definition: LTAPI.h:461
int getData(void *pOut, int inOffset, int inMaxBytes)
Gets dataRef's binary data.
Definition: LTAPI.cpp:570
@ FPH_CLIMB
Regular climbout.
Definition: LTAPI.h:71
bool camera
is LiveTraffic's camera on this aircraft?
Definition: LTAPI.h:121
bool nav
navigaton lights
Definition: LTAPI.h:176
char model[40]
human-readable a/c model like "A321-231"
Definition: LTAPI.h:153
std::string getPhaseStr() const
flight phase as string
Definition: LTAPI.cpp:250
std::unique_ptr< LTAPIAircraft::LTAPIBulkInfoTexts[]> vInfoTexts
bulk info text array for communication with LT
Definition: LTAPI.h:332
static bool doesLTDisplayAc()
Does LiveTraffic display aircrafts? (Is it activated?)
Definition: LTAPI.cpp:326
bool land
landing lights
Definition: LTAPI.h:116
@ FPH_UNKNOWN
used for initializations
Definition: LTAPI.h:64
std::string getWtc() const
wake turbulence category like H,M,L/M,L
Definition: LTAPI.h:222
XPLMDataRef dataRef
dataRef identifier returned by X-Plane
Definition: LTAPI.h:448
std::string getAcClass() const
a/c class like "L2J"
Definition: LTAPI.h:221
char opIcao[8]
ICAO-code of operator like "DLH".
Definition: LTAPI.h:151
std::string getCallSign() const
call sign like "DLH56C"
Definition: LTAPI.h:230
std::string getTrackedBy() const
name of channel deliverying the underlying tracking data
Definition: LTAPI.h:235
XPLMDataTypeID dataTypes
supported data types
Definition: LTAPI.h:449
int getInt()
Get dataRef's integer value. Silently returns 0 if dataRef doesn't exist.
Definition: LTAPI.cpp:558
fCreateAcObject * pfCreateAcObject
Pointer to callback function returning new aircraft objects.
Definition: LTAPI.h:336
bool strobe
strobe light
Definition: LTAPI.h:175
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
float getTerrainFt() const
[ft] terrain altitude beneath plane
Definition: LTAPI.h:248
std::chrono::seconds sPeriodExpsv
Definition: LTAPI.h:324
constexpr size_t LTAPIBulkData_v120
Size of original bulk structure as per LiveTraffic v1.20.
Definition: LTAPI.h:494
LTFlightPhase
Flight phase, definition copied from LiveTraffic.
Definition: LTAPI.h:63
static int getLTNumAc()
How many aircraft does LiveTraffic display right now?
Definition: LTAPI.cpp:336
LTDataRef(std::string _sDataRef)
Constructor, set the dataRef's name.
Definition: LTAPI.cpp:537
const MapLTAPIAircraft & getAcMap() const
Returns the map of aircraft as it currently stands.
Definition: LTAPI.h:410
std::string getCatDescr() const
human-readable category description
Definition: LTAPI.h:226
std::unique_ptr< LTAPIAircraft::LTAPIBulkData[]> vBulkNum
bulk data array for communication with LT
Definition: LTAPI.h:330
bool needsInit() const
Definition: LTAPI.h:453
Bulk text transfer structur for communication with LTAPI.
Definition: LTAPI.h:142
char callSign[8]
call sign like "DLH56C"
Definition: LTAPI.h:157
@ FPH_DESCEND
Descend, more then 100ft/min descend.
Definition: LTAPI.h:73
Represents one aircraft as controlled by LiveTraffic.
Definition: LTAPI.h:52
LTAPIBulkInfoTexts()
Constructor initializes all data with zeroes.
Definition: LTAPI.h:168
uint64_t keyNum
a/c id, usually transp hex code, or any other unique id (FLARM etc.)
Definition: LTAPI.h:145
SPtrLTAPIAircraft getAcByMultIdx(int multiIdx) const
Finds an aircraft for a given multiplayer slot.
Definition: LTAPI.cpp:445
double getLon() const
[°] longitude
Definition: LTAPI.h:240
bool hasInt() const
Is int a supported dataRef type?
Definition: LTAPI.h:463
unsigned filler3
Definition: LTAPI.h:126
@ FPH_TAKE_OFF
Group of status for take-off:
Definition: LTAPI.h:66
constexpr size_t LTAPIBulkData_v122
Size of current bulk structure.
Definition: LTAPI.h:496
int getMultiIdx() const
multiplayer index if plane reported via sim/multiplayer/position dataRefs, 0 if not
Definition: LTAPI.h:262
float vsi_ft
[ft/minute] vertical speed, positive up
Definition: LTAPI.h:100
constexpr size_t LTAPIBulkInfoTexts_v240
Size of current bulk info structure.
Definition: LTAPI.h:502
char acClass[4]
a/c class like "L2J"
Definition: LTAPI.h:149
std::shared_ptr< LTAPIAircraft > SPtrLTAPIAircraft
Smart pointer to an TLAPIAircraft object.
Definition: LTAPI.h:284
@ FPH_FLARE
Flare, when reaching "flare " height.
Definition: LTAPI.h:77
bool hasFloat() const
Is float a supported dataRef type?
Definition: LTAPI.h:465
LTAPIConnect(fCreateAcObject *_pfCreateAcObject=LTAPIAircraft::CreateNewObject, int numBulkAc=50)
Constructor.
Definition: LTAPI.cpp:279
@ FPH_STOPPED_ON_RWY
Stopped on runway because ran out of tracking data, plane will disappear soon.
Definition: LTAPI.h:80
bool FindDataRef()
Finds the dataRef (and would try again and again, no matter what bValid says)
Definition: LTAPI.cpp:550
virtual bool updateAircraft(const LTAPIBulkData &__bulk, size_t __inSize)
Updates the aircraft with fresh numerical values, called from LTAPIConnect::UpdateAcList()
Definition: LTAPI.cpp:168
std::string getCslModel() const
name of CSL model used for actual rendering of plane
Definition: LTAPI.h:228
bool landing
landing lights
Definition: LTAPI.h:177
char squawk[8]
squawk code (as text) like "1000"
Definition: LTAPI.h:158
@ FPH_ROTATE
Rotating.
Definition: LTAPI.h:68
LTAPIBulkData()
Constructor initializes some data without defaults.
Definition: LTAPI.h:136
double getLat() const
[°] latitude
Definition: LTAPI.h:239
LTFlightPhase phase
flight phase, see LTAircraft::FlightPhase
Definition: LTAPI.h:112
@ FPH_FINAL
Final, below "gear-down" height.
Definition: LTAPI.h:75
const MapLTAPIAircraft & UpdateAcList(ListLTAPIAircraft *plistRemovedAc=nullptr)
Main function: updates map of aircrafts and returns reference to it.
Definition: LTAPI.cpp:374
bool isValid()
Found the dataRef and it contains formats we can work with?
Definition: LTAPI.cpp:543
char op[40]
human-readable operator like "Lufthansa"
Definition: LTAPI.h:155
constexpr size_t LTAPIBulkInfoTexts_v120
Size of original bulk info structure as per previous versions of LiveTraffic.
Definition: LTAPI.h:499
char destination[8]
destination airport (IATA or ICAO) like "FRA" or "EDDF"
Definition: LTAPI.h:161
static time_t getLTSimTime()
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)?
Definition: LTAPI.cpp:348
float speed_kt
[kt] ground speed
Definition: LTAPI.h:99
LTAPIBulkInfoTexts info
textual plane's data
Definition: LTAPI.h:187
float getFloat()
Get dataRef's float value. Silently returns 0.0f if dataRef doesn't exist.
Definition: LTAPI.cpp:564
float getFlaps() const
flap position: 0.0 retracted, 1.0 fully extended
Definition: LTAPI.h:254
@ FPH_LANDING
Group of status for landing:
Definition: LTAPI.h:76
float getPitch() const
[°] pitch: positive up
Definition: LTAPI.h:245
float getVSIft() const
[ft/minute] vertical speed, positive up
Definition: LTAPI.h:247
bool isOnGnd() const
Is plane on ground?
Definition: LTAPI.h:250
float getReversers() const
reversers position: 0.0 closed, 1.0 fully opened
Definition: LTAPI.h:256
float gear
gear position: 0.0 retracted, 1.0 fully extended
Definition: LTAPI.h:105
char origin[8]
origin airport (IATA or ICAO) like "MAD" or "LEMD"
Definition: LTAPI.h:160
bool onGnd
Is plane on ground?
Definition: LTAPI.h:113
void getLocalCoord(double &x, double &y, double &z) const
lat/lon/alt converted to local coordinates
Definition: LTAPI.h:270
std::string sDataRef
dataRef name, passed in via constructor
Definition: LTAPI.h:447
double alt_ft
[ft] altitude
Definition: LTAPI.h:132
std::string getModel() const
human-readable a/c model like "A321-231"
Definition: LTAPI.h:225
LTLights getLights() const
all plane's lights
Definition: LTAPI.h:257
int multiIdx
multiplayer index if plane reported via sim/multiplayer/position dataRefs, 0 if not
Definition: LTAPI.h:123
Bulk data transfer structur for communication with LTAPI.
Definition: LTAPI.h:87
bool isOnCamera() const
is currently seen on LiveTraffic's internal camera view?
Definition: LTAPI.h:258
static int getLTVerNr()
LiveTraffic's version number.
Definition: LTAPI.cpp:298
virtual ~LTAPIAircraft()
Definition: LTAPI.cpp:120
std::string getOrigin() const
origin airport (IATA or ICAO) like "MAD" or "LEMD"
Definition: LTAPI.h:233
bool getBool()
Gets dataRef's integer value and returns if it is not zero.
Definition: LTAPI.h:477
@ FPH_APPROACH
Approach, below "flaps-down" height.
Definition: LTAPI.h:74
float track
[°] track over ground
Definition: LTAPI.h:96
std::string getKey() const
Unique key for this aircraft, usually ICAO transponder hex code.
Definition: LTAPI.h:216
char catDescr[40]
human-readable category description
Definition: LTAPI.h:154
Connects to LiveTraffic's dataRefs and returns aircraft information.
Definition: LTAPI.h:308
float getDistNm() const
[nm] distance to current camera
Definition: LTAPI.h:261
float getRoll() const
[°] roll: positive right
Definition: LTAPI.h:244
@ FPH_TO_ROLL
Take-off roll.
Definition: LTAPI.h:67
float lon_f
deprecated: [°] longitude
Definition: LTAPI.h:93
float getHeading() const
[°] heading
Definition: LTAPI.h:242
float dist_nm
[nm] distance to current camera
Definition: LTAPI.h:109
std::string getDescription() const
some reasonable descriptive string formed from the above, like an identifier, type,...
Definition: LTAPI.cpp:128
LTFlightPhase getPhase() const
flight phase
Definition: LTAPI.h:251