41#include "XPLMDataAccess.h"
42#include "XPLMGraphics.h"
200 { memset(
this, 0,
sizeof(*
this)); }
256 std::string
getKey()
const {
return key; }
384 std::unique_ptr<LTAPIAircraft::LTAPIBulkData[]>
vBulkNum;
386 std::unique_ptr<LTAPIAircraft::LTAPIBulkInfoTexts[]>
vInfoTexts;
488 std::unique_ptr<T[]> &vBulk);
527 xplmType_Int | xplmType_Float | xplmType_Data;
538 int getData(
void* pOut,
int inOffset,
int inMaxBytes);
std::map< std::string, SPtrLTAPIAircraft > MapLTAPIAircraft
Map of all aircrafts stored as smart pointers to LTAPIAircraft objects.
Definition LTAPI.h:350
constexpr size_t LTAPIBulkData_v122
Size of bulk structure as per LiveTraffic v1.22.
Definition LTAPI.h:558
std::list< SPtrLTAPIAircraft > ListLTAPIAircraft
Simple list of smart pointers to LTAPIAircraft objects.
Definition LTAPI.h:356
constexpr size_t LTAPIBulkInfoTexts_v120
Size of original bulk info structure as per previous versions of LiveTraffic.
Definition LTAPI.h:570
constexpr size_t LTAPIBulkData_v120
Size of original bulk structure as per LiveTraffic v1.20.
Definition LTAPI.h:553
std::shared_ptr< LTAPIAircraft > SPtrLTAPIAircraft
Smart pointer to an LTAPIAircraft object.
Definition LTAPI.h:48
constexpr size_t LTAPIBulkData_v440
Size of current bulk structure.
Definition LTAPI.h:562
constexpr size_t LTAPIBulkInfoTexts_v240
Size of current bulk info structure.
Definition LTAPI.h:573
constexpr size_t LTAPIBulkInfoTexts_v122
Definition LTAPI.h:571
Represents one aircraft as controlled by LiveTraffic.
Definition LTAPI.h:57
std::string getKey() const
Unique key for this aircraft, usually ICAO transponder hex code.
Definition LTAPI.h:256
float getPitch() const
[°] pitch: positive up
Definition LTAPI.h:285
float getFlaps() const
flap position: 0.0 retracted, 1.0 fully extended
Definition LTAPI.h:295
bool isOnGnd() const
Is plane on ground?
Definition LTAPI.h:290
LTFlightPhase getPhase() const
flight phase
Definition LTAPI.h:291
std::string getPhaseStr() const
flight phase as string
std::string getDestination() const
destination airport (IATA or ICAO) like "FRA" or "EDDF"
Definition LTAPI.h:274
double getLocalGndSpeed_kn() const
[kn] Approximate ground speed based on local coordinates
Definition LTAPI.h:319
void resetUpdated()
Helper in update loop, resets bUpdated flag.
Definition LTAPI.h:243
std::string getOpIcao() const
ICAO-code of operator like "DLH".
Definition LTAPI.h:263
const char * getTrspModeTxt() const
Transponder mode text, like "off", "Mode C", "Mode S TARA".
float getTrack() const
[°] track over ground
Definition LTAPI.h:283
LTAPIBulkInfoTexts info
textual plane's data
Definition LTAPI.h:218
void getLocalCoord(double &x, double &y, double &z) const
Local coordinates (coverted from lat/lon/alt in older versions)
LTLights getLights() const
all plane's lights
Definition LTAPI.h:298
void setCameraAc()
Declare the aircraft the one under the camera (e.g. if your plugin is a camera plugin and now views t...
std::string getOrigin() const
origin airport (IATA or ICAO) like "MAD" or "LEMD"
Definition LTAPI.h:273
std::string getMan() const
human-readable manufacturer like "Airbus"
Definition LTAPI.h:264
double getLon() const
[°] longitude
Definition LTAPI.h:280
float getTerrainFt() const
[ft] terrain altitude beneath plane
Definition LTAPI.h:288
bool isVisible() const
aircraft visible?
Definition LTAPI.h:293
std::string getTrackedBy() const
name of channel deliverying the underlying tracking data
Definition LTAPI.h:275
std::string getModel() const
human-readable a/c model like "A321-231"
Definition LTAPI.h:265
virtual void toggleCamera(bool bCameraActive, SPtrLTAPIAircraft spPrevAc)
Called when LiveTraffic toggles its aircraft camera, override in your class to handle event.
Definition LTAPI.h:248
std::string getFlightNumber() const
flight number like "LH1113"
Definition LTAPI.h:272
virtual bool updateAircraft(const LTAPIBulkData &__bulk, size_t __inSize)
Updates the aircraft with fresh numerical values, called from LTAPIConnect::UpdateAcList()
std::string getSquawk() const
squawk code (as text) like "1000"
Definition LTAPI.h:271
float getReversers() const
reversers position: 0.0 closed, 1.0 fully opened
Definition LTAPI.h:297
LTFlightPhase
Flight phase, definition copied from LiveTraffic.
Definition LTAPI.h:68
@ FPH_TAXI
Taxiing.
Definition LTAPI.h:71
@ FPH_LIFT_OFF
Lift-off, until "gear-up" height.
Definition LTAPI.h:75
@ FPH_STOPPED_ON_RWY
Stopped on runway because ran out of tracking data, plane will disappear soon.
Definition LTAPI.h:86
@ FPH_DESCEND
Descend, more then 100ft/min descend.
Definition LTAPI.h:79
@ FPH_FLARE
Flare, when reaching "flare " height.
Definition LTAPI.h:83
@ 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:84
@ FPH_ROTATE
Rotating.
Definition LTAPI.h:74
@ FPH_FINAL
Final, below "gear-down" height.
Definition LTAPI.h:81
@ FPH_CRUISE
Cruising, no altitude change.
Definition LTAPI.h:78
@ FPH_UNKNOWN
used for initializations
Definition LTAPI.h:69
@ FPH_ROLL_OUT
Roll-out after touch-down until reaching taxi speed or stopping.
Definition LTAPI.h:85
@ FPH_APPROACH
Approach, below "flaps-down" height.
Definition LTAPI.h:80
@ FPH_INITIAL_CLIMB
Initial climb, until "flaps-up" height.
Definition LTAPI.h:76
@ FPH_TAKE_OFF
Group of status for take-off:
Definition LTAPI.h:72
@ FPH_CLIMB
Regular climbout.
Definition LTAPI.h:77
@ FPH_PARKED
Parked at startup position.
Definition LTAPI.h:70
@ FPH_TO_ROLL
Take-off roll.
Definition LTAPI.h:73
@ FPH_LANDING
Group of status for landing:
Definition LTAPI.h:82
float getHeightFt() const
[ft] height AGL
Definition LTAPI.h:289
std::string getModelIcao() const
ICAO aircraft type like "A321".
Definition LTAPI.h:260
float getGear() const
gear position: 0.0 retracted, 1.0 fully extended
Definition LTAPI.h:296
bool isUpdated() const
Helper in update loop to detected removed aircrafts.
Definition LTAPI.h:241
std::string getCslModel() const
name of CSL model used for actual rendering of plane
Definition LTAPI.h:268
std::string getCatDescr() const
human-readable category description
Definition LTAPI.h:266
double getLocalGndSpeed_ms() const
[m/s] Approximate ground speed based on local coordinates
Definition LTAPI.h:317
int getMultiIdx() const
multiplayer index if plane reported via sim/multiplayer/position dataRefs, 0 if not
Definition LTAPI.h:303
std::string getAcClass() const
a/c class like "L2J"
Definition LTAPI.h:261
std::string getDescription() const
some reasonable descriptive string formed from the above, like an identifier, type,...
virtual bool updateAircraft(const LTAPIBulkInfoTexts &__info, size_t __inSize)
Updates the aircraft with fresh textual information, called from LTAPIConnect::UpdateAcList()
LTAPIBulkData bulk
numerical plane's data
Definition LTAPI.h:217
double getLat() const
[°] latitude
Definition LTAPI.h:279
XPMPTransponderMode getTrspMode() const
< Transponder mode, like off, Mode_C, Mode_S_TARA
Definition LTAPI.h:304
bool bUpdated
update helper, gets reset before updates, set during updates, stays false if not updated
Definition LTAPI.h:221
static LTAPIAircraft * CreateNewObject()
Standard object creation callback.
Definition LTAPI.h:333
std::string getCallSign() const
call sign like "DLH56C"
Definition LTAPI.h:270
XPMPTransponderMode
These enumerations define the way the transponder of a given plane is operating.
Definition LTAPI.h:92
@ xpmpTransponderMode_ModeC
transponder is on, Mode C (Alt)
Definition LTAPI.h:96
@ xpmpTransponderMode_ModeS_Gnd
transponder is on, Mode S (Gnd)
Definition LTAPI.h:98
@ xpmpTransponderMode_ModeA
transponder is on, Mode A
Definition LTAPI.h:95
@ xpmpTransponderMode_Standby
transponder is in standby, not currently sending -> aircraft not visible on TCAS
Definition LTAPI.h:94
@ xpmpTransponderMode_ModeS_TARA
transponder is on, Mode S (TA/RA)
Definition LTAPI.h:100
@ xpmpTransponderMode_ModeS_TAOnly
transponder is on, Mode S (TA-Only)
Definition LTAPI.h:99
@ xpmpTransponderMode_Test
transponder is on, Test
Definition LTAPI.h:97
@ xpmpTransponderMode_Off
transponder is off not currently sending -> aircraft not visible on TCAS
Definition LTAPI.h:93
std::string getRegistration() const
tail number like "D-AISD"
Definition LTAPI.h:258
float getVSIft() const
[ft/minute] vertical speed, positive up
Definition LTAPI.h:287
void getLocalVelocities(double &v_x, double &v_y, double &v_z) const
lat/lon/alt converted to local coordinates
Definition LTAPI.h:313
float getBearing() const
[°] to current camera position
Definition LTAPI.h:301
float getDistNm() const
[nm] distance to current camera
Definition LTAPI.h:302
float getRoll() const
[°] roll: positive right
Definition LTAPI.h:284
std::string getWtc() const
wake turbulence category like H,M,L/M,L
Definition LTAPI.h:262
double getAltFt() const
[ft] altitude
Definition LTAPI.h:281
bool isOnCamera() const
is currently seen on LiveTraffic's internal camera view?
Definition LTAPI.h:299
float getSpeedKn() const
[kt] ground speed
Definition LTAPI.h:286
std::string getOp() const
human-readable operator like "Lufthansa"
Definition LTAPI.h:267
float getHeading() const
[°] heading
Definition LTAPI.h:282
Connects to LiveTraffic's dataRefs and returns aircraft information.
Definition LTAPI.h:362
fCreateAcObject * pfCreateAcObject
Pointer to callback function returning new aircraft objects.
Definition LTAPI.h:390
const MapLTAPIAircraft & getAcMap() const
Returns the map of aircraft as it currently stands.
Definition LTAPI.h:464
static int getLTNumAc()
How many aircraft does LiveTraffic display right now?
bool DoBulkFetch(int numAc, LTDataRef &DR, int &outSizeLT, std::unique_ptr< T[]> &vBulk)
fetch bulk data and create/update aircraft objects
std::unique_ptr< LTAPIAircraft::LTAPIBulkInfoTexts[]> vInfoTexts
bulk info text array for communication with LT
Definition LTAPI.h:386
std::chrono::seconds sPeriodExpsv
Definition LTAPI.h:378
MapLTAPIAircraft mapAc
THE map of aircrafts.
Definition LTAPI.h:393
static int getLTVerDate()
LiveTraffic's version date.
SPtrLTAPIAircraft getAcInCameraView() const
Returns the aircraft being viewed in LiveTraffic's camera view, if any.
static void CameraSharedDataCB(LTAPIConnect *me)
shared DataRef event notification
std::unique_ptr< LTAPIAircraft::LTAPIBulkData[]> vBulkNum
bulk data array for communication with LT
Definition LTAPI.h:384
LTAPIAircraft * fCreateAcObject()
Callback function type passed in to LTAPIConnect()
Definition LTAPI.h:373
static bool doesLTControlAI()
Does LiveTaffic control AI planes?
static bool doesLTDisplayAc()
Does LiveTraffic display aircrafts? (Is it activated?)
static std::chrono::system_clock::time_point getLTSimTimePoint()
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)?
static int getLTVerNr()
LiveTraffic's version number.
static time_t getLTSimTime()
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)?
static bool isLTAvail()
Is LiveTraffic available? (checks via XPLMFindPluginBySignature)
LTAPIConnect(fCreateAcObject *_pfCreateAcObject=LTAPIAircraft::CreateNewObject, int numBulkAc=50)
Constructor.
const int iBulkAc
Number of aircraft to fetch in one bulk operation.
Definition LTAPI.h:382
SPtrLTAPIAircraft getAcByMultIdx(int multiIdx) const
Finds an aircraft for a given multiplayer slot.
void clearCameraInfo()
Clear camera information, ie. delcare that no aircraft is currently being viewed.
std::chrono::time_point< std::chrono::steady_clock > lastExpsvFetch
Last fetching of expensive data.
Definition LTAPI.h:396
const MapLTAPIAircraft & UpdateAcList(ListLTAPIAircraft *plistRemovedAc=nullptr)
Main function: updates map of aircrafts and returns reference to it.
Represents a dataRef and covers late binding.
Definition LTAPI.h:504
XPLMDataTypeID dataTypes
supported data types
Definition LTAPI.h:508
int getData(void *pOut, int inOffset, int inMaxBytes)
Gets dataRef's binary data.
bool hasFloat() const
Is float a supported dataRef type?
Definition LTAPI.h:524
static constexpr XPLMDataTypeID usefulTypes
Defines which types to work with to become valid
Definition LTAPI.h:526
void set(float f)
Writes a float vlue to the dataRef.
LTDataRef(std::string _sDataRef)
Constructor, set the dataRef's name.
bool hasInt() const
Is int a supported dataRef type?
Definition LTAPI.h:522
bool FindDataRef()
Finds the dataRef (and would try again and again, no matter what bValid says)
XPLMDataRef dataRef
dataRef identifier returned by X-Plane
Definition LTAPI.h:507
bool bValid
does this object have a valid binding to a dataRef already?
Definition LTAPI.h:509
XPLMDataTypeID getDataRefTypes() const
Get types supported by the dataRef.
Definition LTAPI.h:520
void set(int i)
Writes an integer value to the dataRef.
bool needsInit() const
Definition LTAPI.h:512
int getInt()
Get dataRef's integer value. Silently returns 0 if dataRef doesn't exist.
std::string sDataRef
dataRef name, passed in via constructor
Definition LTAPI.h:506
bool isValid()
Found the dataRef and it contains formats we can work with?
bool getBool()
Gets dataRef's integer value and returns if it is not zero.
Definition LTAPI.h:536
float getFloat()
Get dataRef's float value. Silently returns 0.0f if dataRef doesn't exist.
Bulk data transfer structur for communication with LTAPI.
Definition LTAPI.h:107
LTFlightPhase phase
flight phase, see LTAircraft::FlightPhase
Definition LTAPI.h:132
unsigned hidden
aircraft not visible? (remains an 'unsigned' for backward compatibility)
Definition LTAPI.h:140
float alt_ft_f
deprecated: [ft] altitude
Definition LTAPI.h:114
float track
[°] track over ground
Definition LTAPI.h:116
float gear
gear position: 0.0 retracted, 1.0 fully extended
Definition LTAPI.h:125
float terrainAlt_ft
[ft] terrain altitude beneath plane
Definition LTAPI.h:121
float pitch
[°] pitch: positive up
Definition LTAPI.h:118
float lat_f
deprecated: [°] latitude
Definition LTAPI.h:112
double lat
[°] latitude
Definition LTAPI.h:152
double v_z
[m/s] Cartesian velocity in Z direction
Definition LTAPI.h:164
double x
local Cartesian X coordinate (NAN indicates to delivered by master, e.g. because older version)
Definition LTAPI.h:158
float reversers
reversers position: 0.0 closed, 1.0 fully opened
Definition LTAPI.h:126
unsigned filler2
Definition LTAPI.h:147
float height_ft
[ft] height AGL
Definition LTAPI.h:122
double z
local Cartesian Z coordinate
Definition LTAPI.h:160
uint64_t keyNum
a/c id, usually transp hex code, or any other unique id (FLARM etc.)
Definition LTAPI.h:110
float speed_kt
[kt] ground speed
Definition LTAPI.h:119
float flaps
flap position: 0.0 retracted, 1.0 fully extended
Definition LTAPI.h:124
LTAPIBulkData()
Constructor initializes some data without defaults.
Definition LTAPI.h:167
float heading
[°] heading
Definition LTAPI.h:115
bool camera
is LiveTraffic's camera on this aircraft?
Definition LTAPI.h:141
double v_x
[m/s] Cartesian velocity in X direction
Definition LTAPI.h:162
bool strb
strobe light
Definition LTAPI.h:138
unsigned trspMode
Transponder mode, see enum XPMPTransponderMode (filled only as of LT 4.4.0)
Definition LTAPI.h:145
float vsi_ft
[ft/minute] vertical speed, positive up
Definition LTAPI.h:120
double alt_ft
[ft] altitude
Definition LTAPI.h:154
float lon_f
deprecated: [°] longitude
Definition LTAPI.h:113
bool taxi
taxi lights
Definition LTAPI.h:135
struct LTAPIAircraft::LTAPIBulkData::BulkBitsTy bits
Flights phase, on-ground status, lights.
bool land
landing lights
Definition LTAPI.h:136
bool nav
navigaton lights
Definition LTAPI.h:139
int multiIdx
multiplayer index if plane reported via sim/multiplayer/position dataRefs, 0 if not
Definition LTAPI.h:143
double v_y
[m/s] Cartesian velocity in Y direction
Definition LTAPI.h:163
float bearing
[°] to current camera position
Definition LTAPI.h:128
float dist_nm
[nm] distance to current camera
Definition LTAPI.h:129
unsigned filler3
Definition LTAPI.h:148
float roll
[°] roll: positive right
Definition LTAPI.h:117
bool bcn
beacon light
Definition LTAPI.h:137
bool onGnd
Is plane on ground?
Definition LTAPI.h:133
double y
local Cartesian Y coordinate
Definition LTAPI.h:159
double lon
[°] longitude
Definition LTAPI.h:153
Bulk text transfer structur for communication with LTAPI.
Definition LTAPI.h:173
char wtc[4]
wake turbulence category like H,M,L/M,L
Definition LTAPI.h:181
char catDescr[40]
human-readable category description
Definition LTAPI.h:185
char callSign[8]
call sign like "DLH56C"
Definition LTAPI.h:188
char squawk[8]
squawk code (as text) like "1000"
Definition LTAPI.h:189
LTAPIBulkInfoTexts()
Constructor initializes all data with zeroes.
Definition LTAPI.h:199
uint64_t keyNum
a/c id, usually transp hex code, or any other unique id (FLARM etc.)
Definition LTAPI.h:176
char opIcao[8]
ICAO-code of operator like "DLH".
Definition LTAPI.h:182
char op[40]
human-readable operator like "Lufthansa"
Definition LTAPI.h:186
char modelIcao[8]
ICAO aircraft type like "A321".
Definition LTAPI.h:179
char flightNumber[8]
flight number like "LH1113"
Definition LTAPI.h:190
char origin[8]
origin airport (IATA or ICAO) like "MAD" or "LEMD"
Definition LTAPI.h:191
char registration[8]
tail number like "D-AISD"
Definition LTAPI.h:177
char cslModel[40]
name of CSL model used for actual rendering of plane
Definition LTAPI.h:196
char man[40]
human-readable manufacturer like "Airbus"
Definition LTAPI.h:183
char trackedBy[24]
name of channel deliverying the underlying tracking data
Definition LTAPI.h:193
char destination[8]
destination airport (IATA or ICAO) like "FRA" or "EDDF"
Definition LTAPI.h:192
char acClass[4]
a/c class like "L2J"
Definition LTAPI.h:180
char model[40]
human-readable a/c model like "A321-231"
Definition LTAPI.h:184
Structure to return plane's lights status.
Definition LTAPI.h:204
bool nav
navigaton lights
Definition LTAPI.h:207
LTLights(const LTAPIBulkData::BulkBitsTy b)
Type conversion constructor.
Definition LTAPI.h:212
bool strobe
strobe light
Definition LTAPI.h:206
bool beacon
beacon light
Definition LTAPI.h:205
bool landing
landing lights
Definition LTAPI.h:208
bool taxi
taxi lights
Definition LTAPI.h:209