XPPlanes
X-Plane plugin to display additional planes based on network data
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
FlightData Class Reference

Transports flight data for location, attitude, configuration between the network and the main thread. More...

#include <FlightData.h>

Classes

struct  lightsTy
 Aircraft lights. More...
 
struct  wakeTy
 Wake turbulence calculation data: wing span, wing area, aircraft mass. More...
 

Public Member Functions

 FlightData (const std::string &csv)
 Constructor: Creates a FlightData object from single record CSV-style data. More...
 
 FlightData (const JSON_Object *obj)
 Constructor: Creates a FlightData object from a JSON object. More...
 
void SetTimestamp (double tsIn)
 Set timestamp from input value. More...
 
bool operator< (const FlightData &o) const
 Order is solely by timestamp. More...
 
bool IsUsable () const
 Has usable data? (Has at least position information) More...
 
 operator XPLMDrawInfo_t () const
 Convert to XP's drawInfo. More...
 
void NANtoZero ()
 Replace any remaining NANs with 0.0 More...
 
void NANtoCopy (const FlightData &o)
 Replace any remaining NANs with values from the other object. More...
 

Static Public Member Functions

static bool ProcessNetworkData (const std::string &s)
 Main function to interpret network data. More...
 

Public Attributes

XPMPPlaneID _modeS_id = 0
 key More...
 
std::string icaoType
 ICAO aircraft type according to doc8643. More...
 
std::string icaoAirline
 ICAO airline code (for model matching) More...
 
std::string tailNum
 tail number / registration, also used as special livery code (optional, for model matching) More...
 
std::string callSign
 call sign More...
 
std::string label
 label text More...
 
tsTy ts
 timestamp More...
 
double lat = NAN
 latitude More...
 
double lon = NAN
 longitude More...
 
double alt_m = NAN
 altitude in meter above ground More...
 
bool bGnd = false
 on the ground? More...
 
float pitch = NAN
 Pitch in degres to rotate the object, positive is up. More...
 
float heading = NAN
 Heading in local coordinates to rotate the object, clockwise. More...
 
float roll = NAN
 Roll to rotate the object. More...
 
FlightData::wakeTy wake
 
float gear = NAN
 gear down = 1.0, gear up = 0.0 More...
 
float nws = NAN
 nose wheel steering degree, 0.0 = straight ahead, negative = left More...
 
float flaps = NAN
 flaps deployed = 1.0, flaps up = 0.0 More...
 
float spoilers = NAN
 spoilers (speedbrakes) up = 1.0, down = 0.0 More...
 
float reversers = NAN
 deployment of reversers, 1.0 = fully open More...
 
float thrust = NAN
 thrust ratio, -1.0 .. 0.0 .. 1.0 More...
 
float engineRpm = NAN
 revolutions per minute of engine/rotor/prop More...
 
bool bVisDefined = false
 Has visibility been set in the data? More...
 
bool bVisible = true
 Shall plane be drawn? More...
 
struct FlightData::lightsTy lights = { false, false, false, false, false, false }
 

Protected Member Functions

bool FillFromRTTFC (const std::string &csv)
 RTTFC: Interprets the data as an RTTFC line. More...
 
bool FillFromXPPTraffic (const JSON_Object *obj)
 Converts the purpose-desgined XPPTraffic JSON format. More...
 

Static Protected Member Functions

static bool AddNew (std::shared_ptr< FlightData > &&pFD)
 Add a just created object to the internal list. More...
 

Detailed Description

Transports flight data for location, attitude, configuration between the network and the main thread.


Class Documentation

◆ FlightData::lightsTy

struct FlightData::lightsTy

Aircraft lights.

Class Members
bool beacon: 1 beacon lights
bool defined: 1 are lights values valid, ie. defined?
bool landing: 1 landing lights
bool nav: 1 navigation lights
bool strobe: 1 strobe lights
bool taxi: 1 taxi lights

Constructor & Destructor Documentation

◆ FlightData() [1/2]

FlightData::FlightData ( const std::string &  csv)

Constructor: Creates a FlightData object from single record CSV-style data.

◆ FlightData() [2/2]

FlightData::FlightData ( const JSON_Object *  obj)

Constructor: Creates a FlightData object from a JSON object.

Member Function Documentation

◆ AddNew()

bool FlightData::AddNew ( std::shared_ptr< FlightData > &&  pFD)
staticprotected

Add a just created object to the internal list.

Performs some basic timestamp handling and validations before doing so like timestamp within grace period and sorted.

◆ FillFromRTTFC()

bool FlightData::FillFromRTTFC ( const std::string &  csv)
protected

RTTFC: Interprets the data as an RTTFC line.

See also
https://www.flyrealtraffic.com/RTdev2.0.pdf

◆ FillFromXPPTraffic()

bool FlightData::FillFromXPPTraffic ( const JSON_Object *  obj)
protected

Converts the purpose-desgined XPPTraffic JSON format.

◆ IsUsable()

bool FlightData::IsUsable ( ) const

Has usable data? (Has at least position information)

◆ NANtoCopy()

void FlightData::NANtoCopy ( const FlightData o)

Replace any remaining NANs with values from the other object.

◆ NANtoZero()

void FlightData::NANtoZero ( )

Replace any remaining NANs with 0.0

◆ operator XPLMDrawInfo_t()

FlightData::operator XPLMDrawInfo_t ( ) const

Convert to XP's drawInfo.

◆ operator<()

bool FlightData::operator< ( const FlightData o) const
inline

Order is solely by timestamp.

◆ ProcessNetworkData()

bool FlightData::ProcessNetworkData ( const std::string &  s)
static

Main function to interpret network data.

Needs to distinguish between

  1. single record data a) in CSV style like RTTFC b) in JSON style like XPPTraffic single plane
  2. array data in JSON style like XPPTraffic

◆ SetTimestamp()

void FlightData::SetTimestamp ( double  tsIn)

Set timestamp from input value.

Can be one out of three:

  • If larger than 1577836800000 -> absolute Java timestamp in milliseconds
  • If larger than 1577836800.0 -> absolute Unix timestamp in seconds, supports decimals
  • otherwise relative timestamp NAN is handled as 0.0, ie. "now"

Member Data Documentation

◆ _modeS_id

XPMPPlaneID FlightData::_modeS_id = 0

key

◆ alt_m

double FlightData::alt_m = NAN

altitude in meter above ground

◆ bGnd

bool FlightData::bGnd = false

on the ground?

◆ bVisDefined

bool FlightData::bVisDefined = false

Has visibility been set in the data?

◆ bVisible

bool FlightData::bVisible = true

Shall plane be drawn?

◆ callSign

std::string FlightData::callSign

call sign

◆ engineRpm

float FlightData::engineRpm = NAN

revolutions per minute of engine/rotor/prop

◆ flaps

float FlightData::flaps = NAN

flaps deployed = 1.0, flaps up = 0.0

◆ gear

float FlightData::gear = NAN

gear down = 1.0, gear up = 0.0

◆ heading

float FlightData::heading = NAN

Heading in local coordinates to rotate the object, clockwise.

◆ icaoAirline

std::string FlightData::icaoAirline

ICAO airline code (for model matching)

◆ icaoType

std::string FlightData::icaoType

ICAO aircraft type according to doc8643.

◆ label

std::string FlightData::label

label text

◆ lat

double FlightData::lat = NAN

latitude

◆ lights

struct FlightData::lightsTy FlightData::lights = { false, false, false, false, false, false }

◆ lon

double FlightData::lon = NAN

longitude

◆ nws

float FlightData::nws = NAN

nose wheel steering degree, 0.0 = straight ahead, negative = left

◆ pitch

float FlightData::pitch = NAN

Pitch in degres to rotate the object, positive is up.

◆ reversers

float FlightData::reversers = NAN

deployment of reversers, 1.0 = fully open

◆ roll

float FlightData::roll = NAN

Roll to rotate the object.

◆ spoilers

float FlightData::spoilers = NAN

spoilers (speedbrakes) up = 1.0, down = 0.0

◆ tailNum

std::string FlightData::tailNum

tail number / registration, also used as special livery code (optional, for model matching)

◆ thrust

float FlightData::thrust = NAN

thrust ratio, -1.0 .. 0.0 .. 1.0

◆ ts

tsTy FlightData::ts

timestamp

◆ wake

FlightData::wakeTy FlightData::wake

The documentation for this class was generated from the following files: