#define _FG_TOWER_HXX
#include <simgear/compiler.h>
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
#include <simgear/misc/sgstream.hxx>
-#include <plib/sg.h>
-#include STL_IOSTREAM
-#include STL_STRING
-
-SG_USING_STD(string);
-SG_USING_STD(ios);
+#include <iosfwd>
+#include <string>
+#include <list>
#include "ATC.hxx"
#include "ATCProjection.hxx"
-#include "AIPlane.hxx"
class FGATCMgr;
class FGGround;
ostream& operator << (ostream& os, tower_traffic_type ttt);
+enum PatternLeg {
+ TAKEOFF_ROLL,
+ CLIMBOUT,
+ TURN1,
+ CROSSWIND,
+ TURN2,
+ DOWNWIND,
+ TURN3,
+ BASE,
+ TURN4,
+ FINAL,
+ LANDING_ROLL,
+ LEG_UNKNOWN
+};
+
+ostream& operator << (ostream& os, PatternLeg pl);
+
+enum LandingType {
+ FULL_STOP,
+ STOP_AND_GO,
+ TOUCH_AND_GO,
+ AIP_LT_UNKNOWN
+};
+
+ostream& operator << (ostream& os, LandingType lt);
+
enum tower_callback_type {
USER_REQUEST_VFR_DEPARTURE = 1,
USER_REQUEST_VFR_ARRIVAL = 2,
TowerPlaneRec();
TowerPlaneRec(const PlaneRec& p);
- TowerPlaneRec(const Point3D& pt);
- TowerPlaneRec(const PlaneRec& p, const Point3D& pt);
+ TowerPlaneRec(const SGGeod& pt);
+ TowerPlaneRec(const PlaneRec& p, const SGGeod& pt);
- FGAIPlane* planePtr; // This might move to the planeRec eventually
PlaneRec plane;
- Point3D pos;
+ SGGeod pos;
double eta; // seconds
double dist_out; // meters from theshold
bool clearedToLand;
};
-typedef list < TowerPlaneRec* > tower_plane_rec_list_type;
+typedef std::list < TowerPlaneRec* > tower_plane_rec_list_type;
typedef tower_plane_rec_list_type::iterator tower_plane_rec_list_iterator;
typedef tower_plane_rec_list_type::const_iterator tower_plane_rec_list_const_iterator;
// Contact tower for VFR approach
// eg "Cessna Charlie Foxtrot Golf Foxtrot Sierra eight miles South of the airport for full stop with Bravo"
// This function probably only called via user interaction - AI planes will have an overloaded function taking a planerec.
- void VFRArrivalContact(const string& ID, const LandingType& opt = AIP_LT_UNKNOWN);
- // For the AI planes...
- void VFRArrivalContact(const PlaneRec& plane, FGAIPlane* requestee, const LandingType& lt = AIP_LT_UNKNOWN);
-
- void RequestDepartureClearance(const string& ID);
- void RequestTakeOffClearance(const string& ID);
- void ReportFinal(const string& ID);
- void ReportLongFinal(const string& ID);
- void ReportOuterMarker(const string& ID);
- void ReportMiddleMarker(const string& ID);
- void ReportInnerMarker(const string& ID);
- void ReportRunwayVacated(const string& ID);
- void ReportReadyForDeparture(const string& ID);
- void ReportDownwind(const string& ID);
- void ReportGoingAround(const string& ID);
-
- // Contact tower when at a hold short for departure - for now we'll assume plane - maybe vehicles might want to cross runway eventually?
- void ContactAtHoldShort(const PlaneRec& plane, FGAIPlane* requestee, tower_traffic_type operation);
-
- // Register the presence of an AI plane at a point where contact would already have been made in real life
- // CAUTION - currently it is assumed that this plane's callsign is unique - it is up to AIMgr to generate unique callsigns.
- void RegisterAIPlane(const PlaneRec& plane, FGAIPlane* ai, const tower_traffic_type& op, const PatternLeg& lg = LEG_UNKNOWN);
-
- // Deregister and remove an AI plane.
- void DeregisterAIPlane(const string& id);
+ void VFRArrivalContact(const std::string& ID, const LandingType& opt = AIP_LT_UNKNOWN);
+
+ void RequestDepartureClearance(const std::string& ID);
+ void RequestTakeOffClearance(const std::string& ID);
+ void ReportFinal(const std::string& ID);
+ void ReportLongFinal(const std::string& ID);
+ void ReportOuterMarker(const std::string& ID);
+ void ReportMiddleMarker(const std::string& ID);
+ void ReportInnerMarker(const std::string& ID);
+ void ReportRunwayVacated(const std::string& ID);
+ void ReportReadyForDeparture(const std::string& ID);
+ void ReportDownwind(const std::string& ID);
+ void ReportGoingAround(const std::string& ID);
// Public interface to the active runway - this will get more complex
// in the future and consider multi-runway use, airplane weight etc.
- inline const string& GetActiveRunway() const { return activeRwy; }
+ inline const std::string& GetActiveRunway() const { return activeRwy; }
inline const RunwayDetails& GetActiveRunwayDetails() const { return rwy; }
// Get the pattern direction of the active rwy.
inline int GetPatternDirection() const { return rwy.patternDirection; }
- inline const string& get_trans_ident() const { return trans_ident; }
+ inline const std::string& get_trans_ident() const { return trans_ident; }
inline FGGround* const GetGroundPtr() const { return ground; }
bool GetDownwindConstraint(double& dpos);
bool GetBaseConstraint(double& bpos);
- string GenText(const string& m, int c);
- string GetWeather();
- string GetATISID();
+ std::string GenText(const std::string& m, int c);
+ std::string GetWeather();
+ std::string GetATISID();
private:
FGATCMgr* ATCmgr;
void ClearHoldingPlane(TowerPlaneRec* t);
// Find a pointer to plane of callsign ID within the internal data structures
- TowerPlaneRec* FindPlane(const string& ID);
+ TowerPlaneRec* FindPlane(const std::string& ID);
// Remove and delete all instances of a plane with a given ID
- void RemovePlane(const string& ID);
+ void RemovePlane(const std::string& ID);
// Figure out if a given position lies on the active runway
// Might have to change when we consider more than one active rwy.
- bool OnActiveRunway(const Point3D& pt);
+ bool OnActiveRunway(const SGGeod& pt);
// Figure out if a given position lies on a runway or not
- bool OnAnyRunway(const Point3D& pt, bool onGround);
+ bool OnAnyRunway(const SGGeod& pt, bool onGround);
// Calculate the eta of a plane to the threshold.
// For ground traffic this is the fastest they can get there.
// For air traffic this is the middle approximation.
void CalcETA(TowerPlaneRec* tpr, bool printout = false);
- // Iterate through all the lists and call CalcETA for all the planes.
+ // Iterate through all the std::lists and call CalcETA for all the planes.
void doThresholdETACalc();
- // Order the list of traffic as per expected threshold use and flag any conflicts
+ // Order the std::list of traffic as per expected threshold use and flag any conflicts
bool doThresholdUseOrder();
// Calculate the crow-flys distance of a plane to the threshold in meters
SGPropertyNode_ptr wind_speed_knots; //knots
double aptElev; // Airport elevation
- string activeRwy; // Active runway number - For now we'll disregard multiple / alternate runway operation.
+ std::string activeRwy; // Active runway number - For now we'll disregard multiple / alternate runway operation.
RunwayDetails rwy; // Assumed to be the active one for now.
bool rwyOccupied; // Active runway occupied flag. For now we'll disregard land-and-hold-short operations.
FGATCAlignedProjection ortho; // Orthogonal mapping of the local area with the active runway threshold at the origin
tower_plane_rec_list_iterator vacatedListItr;
// Returns true if successful
- bool RemoveFromTrafficList(const string& id);
- bool RemoveFromAppList(const string& id);
- bool RemoveFromRwyList(const string& id);
+ bool RemoveFromTrafficList(const std::string& id);
+ bool RemoveFromAppList(const std::string& id);
+ bool RemoveFromRwyList(const std::string& id);
// Return the ETA of plane no. list_pos (1-based) in the traffic list.
// i.e. list_pos = 1 implies next to use runway.
//FGDeparture* _departure; // The relevant departure control (once we've actually written it!)
// for failure modeling
- string trans_ident; // transmitted ident
+ std::string trans_ident; // transmitted ident
bool tower_failed; // tower failed?
// Pointers to current users position and orientation
double nominal_downwind_leg_pos;
double nominal_base_leg_pos;
- friend istream& operator>> ( istream&, FGTower& );
+ friend std::istream& operator>> ( std::istream&, FGTower& );
};
#endif //_FG_TOWER_HXX