40#include "XPLMDataAccess.h"
41#include "XPLMGraphics.h"
174 { memset(
this, 0,
sizeof(*
this)); }
230 std::string
getKey()
const {
return key; }
342 std::unique_ptr<LTAPIAircraft::LTAPIBulkData[]>
vBulkNum;
344 std::unique_ptr<LTAPIAircraft::LTAPIBulkInfoTexts[]>
vInfoTexts;
446 std::unique_ptr<T[]> &vBulk);
485 xplmType_Int | xplmType_Float | xplmType_Data;
496 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:308
constexpr size_t LTAPIBulkData_v122
Size of current bulk structure.
Definition LTAPI.h:513
std::list< SPtrLTAPIAircraft > ListLTAPIAircraft
Simple list of smart pointers to LTAPIAircraft objects.
Definition LTAPI.h:314
constexpr size_t LTAPIBulkInfoTexts_v120
Size of original bulk info structure as per previous versions of LiveTraffic.
Definition LTAPI.h:516
constexpr size_t LTAPIBulkData_v120
Size of original bulk structure as per LiveTraffic v1.20.
Definition LTAPI.h:511
std::shared_ptr< LTAPIAircraft > SPtrLTAPIAircraft
Smart pointer to an LTAPIAircraft object.
Definition LTAPI.h:47
constexpr size_t LTAPIBulkInfoTexts_v240
Size of current bulk info structure.
Definition LTAPI.h:519
constexpr size_t LTAPIBulkInfoTexts_v122
Definition LTAPI.h:517
Represents one aircraft as controlled by LiveTraffic.
Definition LTAPI.h:56
std::string getKey() const
Unique key for this aircraft, usually ICAO transponder hex code.
Definition LTAPI.h:230
float getPitch() const
[°] pitch: positive up
Definition LTAPI.h:259
float getFlaps() const
flap position: 0.0 retracted, 1.0 fully extended
Definition LTAPI.h:269
bool isOnGnd() const
Is plane on ground?
Definition LTAPI.h:264
LTFlightPhase getPhase() const
flight phase
Definition LTAPI.h:265
std::string getPhaseStr() const
flight phase as string
std::string getDestination() const
destination airport (IATA or ICAO) like "FRA" or "EDDF"
Definition LTAPI.h:248
void resetUpdated()
Helper in update loop, resets bUpdated flag.
Definition LTAPI.h:217
std::string getOpIcao() const
ICAO-code of operator like "DLH".
Definition LTAPI.h:237
float getTrack() const
[°] track over ground
Definition LTAPI.h:257
LTAPIBulkInfoTexts info
textual plane's data
Definition LTAPI.h:192
void getLocalCoord(double &x, double &y, double &z) const
lat/lon/alt converted to local coordinates
Definition LTAPI.h:285
LTLights getLights() const
all plane's lights
Definition LTAPI.h:272
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:247
std::string getMan() const
human-readable manufacturer like "Airbus"
Definition LTAPI.h:238
double getLon() const
[°] longitude
Definition LTAPI.h:254
float getTerrainFt() const
[ft] terrain altitude beneath plane
Definition LTAPI.h:262
bool isVisible() const
aircraft visible?
Definition LTAPI.h:267
std::string getTrackedBy() const
name of channel deliverying the underlying tracking data
Definition LTAPI.h:249
std::string getModel() const
human-readable a/c model like "A321-231"
Definition LTAPI.h:239
virtual void toggleCamera(bool bCameraActive, SPtrLTAPIAircraft spPrevAc)
Called when LiveTraffic toggles its aircraft camera, override in your class to handle event.
Definition LTAPI.h:222
std::string getFlightNumber() const
flight number like "LH1113"
Definition LTAPI.h:246
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:245
float getReversers() const
reversers position: 0.0 closed, 1.0 fully opened
Definition LTAPI.h:271
LTFlightPhase
Flight phase, definition copied from LiveTraffic.
Definition LTAPI.h:67
@ FPH_TAXI
Taxiing.
Definition LTAPI.h:70
@ FPH_LIFT_OFF
Lift-off, until "gear-up" height.
Definition LTAPI.h:74
@ FPH_STOPPED_ON_RWY
Stopped on runway because ran out of tracking data, plane will disappear soon.
Definition LTAPI.h:85
@ FPH_DESCEND
Descend, more then 100ft/min descend.
Definition LTAPI.h:78
@ FPH_FLARE
Flare, when reaching "flare " height.
Definition LTAPI.h:82
@ 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:83
@ FPH_ROTATE
Rotating.
Definition LTAPI.h:73
@ FPH_FINAL
Final, below "gear-down" height.
Definition LTAPI.h:80
@ FPH_CRUISE
Cruising, no altitude change.
Definition LTAPI.h:77
@ FPH_UNKNOWN
used for initializations
Definition LTAPI.h:68
@ FPH_ROLL_OUT
Roll-out after touch-down until reaching taxi speed or stopping.
Definition LTAPI.h:84
@ FPH_APPROACH
Approach, below "flaps-down" height.
Definition LTAPI.h:79
@ FPH_INITIAL_CLIMB
Initial climb, until "flaps-up" height.
Definition LTAPI.h:75
@ FPH_TAKE_OFF
Group of status for take-off:
Definition LTAPI.h:71
@ FPH_CLIMB
Regular climbout.
Definition LTAPI.h:76
@ FPH_PARKED
Parked at startup position.
Definition LTAPI.h:69
@ FPH_TO_ROLL
Take-off roll.
Definition LTAPI.h:72
@ FPH_LANDING
Group of status for landing:
Definition LTAPI.h:81
float getHeightFt() const
[ft] height AGL
Definition LTAPI.h:263
std::string getModelIcao() const
ICAO aircraft type like "A321".
Definition LTAPI.h:234
float getGear() const
gear position: 0.0 retracted, 1.0 fully extended
Definition LTAPI.h:270
bool isUpdated() const
Helper in update loop to detected removed aircrafts.
Definition LTAPI.h:215
std::string getCslModel() const
name of CSL model used for actual rendering of plane
Definition LTAPI.h:242
std::string getCatDescr() const
human-readable category description
Definition LTAPI.h:240
int getMultiIdx() const
multiplayer index if plane reported via sim/multiplayer/position dataRefs, 0 if not
Definition LTAPI.h:277
std::string getAcClass() const
a/c class like "L2J"
Definition LTAPI.h:235
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:191
double getLat() const
[°] latitude
Definition LTAPI.h:253
bool bUpdated
update helper, gets reset before updates, set during updates, stays false if not updated
Definition LTAPI.h:195
static LTAPIAircraft * CreateNewObject()
Standard object creation callback.
Definition LTAPI.h:291
std::string getCallSign() const
call sign like "DLH56C"
Definition LTAPI.h:244
std::string getRegistration() const
tail number like "D-AISD"
Definition LTAPI.h:232
float getVSIft() const
[ft/minute] vertical speed, positive up
Definition LTAPI.h:261
float getBearing() const
[°] to current camera position
Definition LTAPI.h:275
float getDistNm() const
[nm] distance to current camera
Definition LTAPI.h:276
float getRoll() const
[°] roll: positive right
Definition LTAPI.h:258
std::string getWtc() const
wake turbulence category like H,M,L/M,L
Definition LTAPI.h:236
double getAltFt() const
[ft] altitude
Definition LTAPI.h:255
bool isOnCamera() const
is currently seen on LiveTraffic's internal camera view?
Definition LTAPI.h:273
float getSpeedKn() const
[kt] ground speed
Definition LTAPI.h:260
std::string getOp() const
human-readable operator like "Lufthansa"
Definition LTAPI.h:241
float getHeading() const
[°] heading
Definition LTAPI.h:256
Connects to LiveTraffic's dataRefs and returns aircraft information.
Definition LTAPI.h:320
fCreateAcObject * pfCreateAcObject
Pointer to callback function returning new aircraft objects.
Definition LTAPI.h:348
const MapLTAPIAircraft & getAcMap() const
Returns the map of aircraft as it currently stands.
Definition LTAPI.h:422
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:344
std::chrono::seconds sPeriodExpsv
Definition LTAPI.h:336
MapLTAPIAircraft mapAc
THE map of aircrafts.
Definition LTAPI.h:351
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:342
LTAPIAircraft * fCreateAcObject()
Callback function type passed in to LTAPIConnect()
Definition LTAPI.h:331
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:340
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:354
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:462
XPLMDataTypeID dataTypes
supported data types
Definition LTAPI.h:466
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:482
static constexpr XPLMDataTypeID usefulTypes
Defines which types to work with to become valid
Definition LTAPI.h:484
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:480
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:465
bool bValid
does this object have a valid binding to a dataRef already?
Definition LTAPI.h:467
XPLMDataTypeID getDataRefTypes() const
Get types supported by the dataRef.
Definition LTAPI.h:478
void set(int i)
Writes an integer value to the dataRef.
bool needsInit() const
Definition LTAPI.h:470
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:464
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:494
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:92
LTFlightPhase phase
flight phase, see LTAircraft::FlightPhase
Definition LTAPI.h:117
unsigned hidden
aircraft not visible? (remains an 'unsigned' for backward compatibility)
Definition LTAPI.h:125
float alt_ft_f
deprecated: [ft] altitude
Definition LTAPI.h:99
float track
[°] track over ground
Definition LTAPI.h:101
float gear
gear position: 0.0 retracted, 1.0 fully extended
Definition LTAPI.h:110
float terrainAlt_ft
[ft] terrain altitude beneath plane
Definition LTAPI.h:106
float pitch
[°] pitch: positive up
Definition LTAPI.h:103
float lat_f
deprecated: [°] latitude
Definition LTAPI.h:97
double lat
[°] latitude
Definition LTAPI.h:135
float reversers
reversers position: 0.0 closed, 1.0 fully opened
Definition LTAPI.h:111
unsigned filler2
Definition LTAPI.h:130
float height_ft
[ft] height AGL
Definition LTAPI.h:107
uint64_t keyNum
a/c id, usually transp hex code, or any other unique id (FLARM etc.)
Definition LTAPI.h:95
float speed_kt
[kt] ground speed
Definition LTAPI.h:104
float flaps
flap position: 0.0 retracted, 1.0 fully extended
Definition LTAPI.h:109
LTAPIBulkData()
Constructor initializes some data without defaults.
Definition LTAPI.h:141
float heading
[°] heading
Definition LTAPI.h:100
bool camera
is LiveTraffic's camera on this aircraft?
Definition LTAPI.h:126
bool strb
strobe light
Definition LTAPI.h:123
float vsi_ft
[ft/minute] vertical speed, positive up
Definition LTAPI.h:105
double alt_ft
[ft] altitude
Definition LTAPI.h:137
float lon_f
deprecated: [°] longitude
Definition LTAPI.h:98
bool taxi
taxi lights
Definition LTAPI.h:120
struct LTAPIAircraft::LTAPIBulkData::BulkBitsTy bits
Flights phase, on-ground status, lights.
bool land
landing lights
Definition LTAPI.h:121
bool nav
navigaton lights
Definition LTAPI.h:124
int multiIdx
multiplayer index if plane reported via sim/multiplayer/position dataRefs, 0 if not
Definition LTAPI.h:128
float bearing
[°] to current camera position
Definition LTAPI.h:113
float dist_nm
[nm] distance to current camera
Definition LTAPI.h:114
unsigned filler3
Definition LTAPI.h:131
float roll
[°] roll: positive right
Definition LTAPI.h:102
bool bcn
beacon light
Definition LTAPI.h:122
bool onGnd
Is plane on ground?
Definition LTAPI.h:118
double lon
[°] longitude
Definition LTAPI.h:136
Bulk text transfer structur for communication with LTAPI.
Definition LTAPI.h:147
char wtc[4]
wake turbulence category like H,M,L/M,L
Definition LTAPI.h:155
char catDescr[40]
human-readable category description
Definition LTAPI.h:159
char callSign[8]
call sign like "DLH56C"
Definition LTAPI.h:162
char squawk[8]
squawk code (as text) like "1000"
Definition LTAPI.h:163
LTAPIBulkInfoTexts()
Constructor initializes all data with zeroes.
Definition LTAPI.h:173
uint64_t keyNum
a/c id, usually transp hex code, or any other unique id (FLARM etc.)
Definition LTAPI.h:150
char opIcao[8]
ICAO-code of operator like "DLH".
Definition LTAPI.h:156
char op[40]
human-readable operator like "Lufthansa"
Definition LTAPI.h:160
char modelIcao[8]
ICAO aircraft type like "A321".
Definition LTAPI.h:153
char flightNumber[8]
flight number like "LH1113"
Definition LTAPI.h:164
char origin[8]
origin airport (IATA or ICAO) like "MAD" or "LEMD"
Definition LTAPI.h:165
char registration[8]
tail number like "D-AISD"
Definition LTAPI.h:151
char cslModel[40]
name of CSL model used for actual rendering of plane
Definition LTAPI.h:170
char man[40]
human-readable manufacturer like "Airbus"
Definition LTAPI.h:157
char trackedBy[24]
name of channel deliverying the underlying tracking data
Definition LTAPI.h:167
char destination[8]
destination airport (IATA or ICAO) like "FRA" or "EDDF"
Definition LTAPI.h:166
char acClass[4]
a/c class like "L2J"
Definition LTAPI.h:154
char model[40]
human-readable a/c model like "A321-231"
Definition LTAPI.h:158
Structure to return plane's lights status.
Definition LTAPI.h:178
bool nav
navigaton lights
Definition LTAPI.h:181
LTLights(const LTAPIBulkData::BulkBitsTy b)
Type conversion constructor.
Definition LTAPI.h:186
bool strobe
strobe light
Definition LTAPI.h:180
bool beacon
beacon light
Definition LTAPI.h:179
bool landing
landing lights
Definition LTAPI.h:182
bool taxi
taxi lights
Definition LTAPI.h:183