XPPlanes
X-Plane plugin to display additional planes based on network data
Plane.h
Go to the documentation of this file.
1 
21 #pragma once
22 
23 //
24 // MARK: Plane class
25 //
26 
27 class Plane : public XPMP2::Aircraft
28 {
29 public:
31  Plane (ptrFlightDataTy&& from, ptrFlightDataTy&& to);
32 
34  ~Plane() override;
35 
37  void UpdatePosition (float _elapsedSinceLastCall, int _flCounter) override;
38 
40  float GetLift() const override;
41 
42 protected:
45  XPLMDrawInfo_t diFrom;
46  XPLMDrawInfo_t diTo;
49  float f = 0.5f;
50 
51  float tTouchDown = NAN;
52 
56  void TakeOverData (bool bFrom, ptrFlightDataTy&& source);
57 
58 public:
61  const tsTy& now);
62 
65 
70  bool ShallBeRemoved (const tsTy& cutOff) const;
71 
72  // This data is updated once per cycle, then reused by other Update... calls
73 protected:
74  static int flCounter;
75  static tsTy::rep ticksNow;
77  static void OncePerCycle (int _flCounter);
78 };
79 
81 typedef std::map<XPMPPlaneID,Plane> mapPlanesTy;
82 
83 //
84 // MARK: Global Functions
85 //
86 
88 bool PlaneStartup();
89 
91 void PlaneShutdown();
92 
94 void PlaneMaintenance ();
std::list< ptrFlightDataTy > listFlightDataTy
List of flight data elements.
Definition: FlightData.h:146
std::shared_ptr< FlightData > ptrFlightDataTy
Smart pointer to flight data objects.
Definition: FlightData.h:143
std::chrono::time_point< std::chrono::system_clock > tsTy
Timestamp format is a system clock's timepoint.
Definition: FlightData.h:29
void PlaneShutdown()
Shutdown the plane module.
Definition: Plane.cpp:444
void PlaneMaintenance()
Regular updates from flight data.
Definition: Plane.cpp:27
std::map< XPMPPlaneID, Plane > mapPlanesTy
Type of the map that stores and owns the plane objects.
Definition: Plane.h:81
bool PlaneStartup()
Initialie the Plane module.
Definition: Plane.cpp:437
Definition: Plane.h:28
ptrFlightDataTy fdTo
the to-position for interpolation
Definition: Plane.h:44
ptrFlightDataTy fdFrom
the from-position for interpolation
Definition: Plane.h:43
XPLMDrawInfo_t diTo
Definition: Plane.h:46
bool ShallBeRemoved(const tsTy &cutOff) const
Determines if this plane shall be removed, sets bToBeRemoved if so.
Definition: Plane.cpp:275
void UpdateFromFlightData(listFlightDataTy &listFD, const tsTy &now)
Regularly called to update from/to positions from the list of available flight data.
Definition: Plane.cpp:143
void DetermineGndAlt(ptrFlightDataTy &fd)
Determine ground altitude of a given location.
Definition: Plane.cpp:239
Plane(ptrFlightDataTy &&from, ptrFlightDataTy &&to)
Create a new plane from two flight data objects.
Definition: Plane.cpp:302
static tsTy::rep ticksNow
'now' timestamp
Definition: Plane.h:75
~Plane() override
Destructor cleans up all resources acquired.
Definition: Plane.cpp:312
float tTouchDown
time since touch down
Definition: Plane.h:51
float f
Definition: Plane.h:49
XPLMDrawInfo_t diFrom
the from-position in XP speak
Definition: Plane.h:45
void UpdatePosition(float _elapsedSinceLastCall, int _flCounter) override
Called by XPMP2 right before updating the aircraft's placement in the world.
Definition: Plane.cpp:324
static int flCounter
flight loop counter of last update
Definition: Plane.h:74
static void OncePerCycle(int _flCounter)
perform once-per-cycle activities
Definition: Plane.cpp:291
void TakeOverData(bool bFrom, ptrFlightDataTy &&source)
Prepare given position for usage after taking over from passed-in smart pointer.
Definition: Plane.cpp:191
float GetLift() const override
Lift produced. Either given in wake.lift or simple defaults apply.
Definition: Plane.cpp:419