]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/tower.hxx
Add an overloaded function
[flightgear.git] / src / ATC / tower.hxx
index 25e0ab91a5e7644925926e10f8b3b540eaa30dba..7e44c4df1e1799c06b7f2d1abf7612bc6fa24d34 100644 (file)
@@ -38,6 +38,7 @@ SG_USING_STD(ios);
 //#include "ATCmgr.hxx"
 #include "ground.hxx"
 #include "ATCProjection.hxx"
+#include "AIPlane.hxx"
 
 //DCL - a complete guess for now.
 #define FG_TOWER_DEFAULT_RANGE 30
@@ -46,34 +47,11 @@ enum tower_traffic_type {
        CIRCUIT,
        INBOUND,
        OUTBOUND,
+       TTT_UNKNOWN,    // departure, but we don't know if for circuits or leaving properly
        STRAIGHT_IN
        // Umm - what's the difference between INBOUND and STRAIGHT_IN ?
 };
 
-// Much simplified compared to AILocalTraffic
-enum TwrPatternLeg {
-       TWR_LANDING_ROLL,
-       TWR_FINAL,
-       TWR_BASE,
-       TWR_DOWNWIND,
-       TWR_CROSSWIND,
-       TWR_CLIMBOUT,
-       TWR_TAKEOFF_ROLL,
-       TWR_UNKNOWN
-};
-
-// perhaps we could use an FGRunway instead of this
-struct RunwayDetails {
-       Point3D threshold_pos;
-       Point3D end1ortho;      // ortho projection end1 (the threshold ATM)
-       Point3D end2ortho;      // ortho projection end2 (the take off end in the current hardwired scheme)
-       //double mag_hdg;
-       //double mag_var;
-       double hdg;             // true runway heading
-       double length;  // In *METERS*
-       string rwyID;
-};
-
 // Structure for holding details of a plane under tower control.
 // Not fixed yet - may include more stuff later.
 class TowerPlaneRec {
@@ -85,7 +63,7 @@ public:
        TowerPlaneRec(Point3D pt);
        TowerPlaneRec(PlaneRec p, Point3D pt);
        
-       FGAIEntity* planePtr;   // This might move to the planeRec eventually
+       FGAIPlane* planePtr;    // This might move to the planeRec eventually
        PlaneRec plane;
        
        Point3D pos;
@@ -109,7 +87,7 @@ public:
        tower_traffic_type opType;
        
        // Whereabouts in circuit if doing circuits
-       TwrPatternLeg leg;
+       PatternLeg leg;
        
        bool isUser;    // true if this plane is the user
 };
@@ -142,13 +120,13 @@ public:
        void ReportRunwayVacated(string ID);
        void ReportReadyForDeparture(string ID);
        
-       // Contact tower when at a hold short for departure
-       void ContactAtHoldShort(PlaneRec plane, FGAIEntity* requestee, tower_traffic_type operation);
+       // 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(PlaneRec plane, FGAIPlane* requestee, tower_traffic_type operation);
        
        // Public interface to the active runway - this will get more complex 
        // in the future and consider multi-runway use, airplane weight etc.
        inline string GetActiveRunway() { return activeRwy; }
-       inline RunwayDetails* GetActiveRunwayDetails() { return &rwy; }
+       inline RunwayDetails GetActiveRunwayDetails() { return rwy; }
        
        inline void SetDisplay() { display = true; }
        inline void SetNoDisplay() { display = false; }
@@ -157,6 +135,12 @@ public:
        inline atc_type GetType() { return TOWER; }
        
        inline FGGround* GetGroundPtr() { return ground; }
+       
+       // Returns true if positions of crosswind/downwind/base leg turns should be constrained by previous traffic
+       // plus the constraint position as a rwy orientated orthopos (meters)
+       bool GetCrosswindConstraint(double& cpos);
+       bool GetDownwindConstraint(double& dpos);
+       bool GetBaseConstraint(double& bpos);
 
 private:
        FGATCMgr* ATCmgr;       
@@ -242,10 +226,17 @@ private:
        string trans_ident;             // transmitted ident
        bool tower_failed;              // tower failed?
        
-    // Pointers to current users position
-    SGPropertyNode* user_lon_node;
-    SGPropertyNode* user_lat_node;
-    SGPropertyNode* user_elev_node;
+       // Pointers to current users position and orientation
+       SGPropertyNode* user_lon_node;
+       SGPropertyNode* user_lat_node;
+       SGPropertyNode* user_elev_node;
+       SGPropertyNode* user_hdg_node;
+       
+       // Details of the general traffic flow etc in the circuit
+       double crosswind_leg_pos;       // Distance from threshold crosswind leg is being turned to in meters (actual operation - *not* ideal circuit)
+       double downwind_leg_pos;        // Actual offset distance in meters from the runway that planes are flying the downwind leg
+       // Currently not sure whether the above should be always +ve or just take the natural orthopos sign (+ve for RH circuit, -ve for LH).
+       double base_leg_pos;            // Actual offset distance from the threshold (-ve) that planes are turning to base leg.
        
        friend istream& operator>> ( istream&, FGTower& );
 };