]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/AILocalTraffic.hxx
make attribute strings lowercase with hyphen instead of underscore;
[flightgear.git] / src / ATC / AILocalTraffic.hxx
index eb8343456dced5b5cdf70618f4abac1c5ee6adc0..a4e1505f64495ae15d9de65c99d44b2f44c245a9 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #ifndef _FG_AILocalTraffic_HXX
 #define _FG_AILocalTraffic_HXX
 
-#include <plib/sg.h>
-#include <plib/ssg.h>
 #include <simgear/math/point3d.hxx>
 #include <Main/fg_props.hxx>
 
-#include "tower.hxx"
 #include "AIPlane.hxx"
 #include "ATCProjection.hxx"
 #include "ground.hxx"
 
+class FGGround;
+class FGTower;
+struct Gate;
+
 #include <string>
 SG_USING_STD(string);
 
@@ -45,7 +46,8 @@ enum TaxiState {
 enum OperatingState {
        IN_PATTERN,
        TAXIING,
-       PARKED
+       PARKED,
+       EN_ROUTE
 };
 
 struct StartOfDescent {
@@ -58,11 +60,12 @@ class FGAILocalTraffic : public FGAIPlane {
        
 public:
        
+       // At the moment we expect the expanded short form callsign - eventually we will just want the reg + type.
        FGAILocalTraffic();
        ~FGAILocalTraffic();
        
        // Initialise
-       bool Init(string ICAO, OperatingState initialState = PARKED, PatternLeg initialLeg = DOWNWIND);
+       bool Init(const string& callsign, const string& ICAO, OperatingState initialState = PARKED, PatternLeg initialLeg = DOWNWIND);
        
        // Run the internal calculations
        void Update(double dt);
@@ -70,6 +73,9 @@ public:
        // Go out and practice circuits
        void FlyCircuits(int numCircuits, bool tag);
        
+       // Return what type of landing we're doing on this circuit
+       LandingType GetLandingOption();
+       
        // TODO - this will get more complex and moved into the main class
        // body eventually since the position approved to taxi to will have
        // to be passed.
@@ -77,7 +83,11 @@ public:
        
        inline void DenyTaxiRequest() {taxiRequestCleared = false;}
        
-       void RegisterTransmission(int code); 
+       void RegisterTransmission(int code);
+       
+       // Process callbacks sent by base class
+       // (These codes are not related to the codes above)
+       void ProcessCallback(int code);
        
        // This is a hack and will probably go eventually
        inline bool AtHoldShort() {return holdingShort;}
@@ -87,33 +97,48 @@ protected:
        // Attempt to enter the traffic pattern in a reasonably intelligent manner
        void EnterTrafficPattern(double dt);
        
-       // Do what is necessary to land and parkup at home airport
-       void ReturnToBase(double dt);
+       // Set up the internal state to be consistent for a downwind entry.
+       void DownwindEntry();
        
-private:
-       FGATCMgr* ATC;  
-       // This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code!
-
-       // High-level stuff
-       OperatingState operatingState;
-       int circuitsToFly;      //Number of circuits still to do in this session NOT INCLUDING THE CURRENT ONE
-       bool touchAndGo;        //True if circuits should be flown touch and go, false for full stop
+       // Ditto for straight-in
+       void StraightInEntry(bool des = false);
        
-       // Its possible that this might be moved out to the ground/airport class at some point.
-       FGATCAlignedProjection ortho;   // Orthogonal mapping of the local area with the threshold at the origin
-       // and the runway aligned with the y axis.
+       // Do what is necessary to land and parkup at home airport
+       void ReturnToBase(double dt);
        
        // Airport/runway/pattern details
        string airportID;       // The ICAO code of the airport that we're operating around
        double aptElev;         // Airport elevation
        FGGround* ground;       // A pointer to the ground control.
        FGTower* tower; // A pointer to the tower control.
+       bool _controlled;       // Set true if we find tower control working for the airport, false otherwise.
        RunwayDetails rwy;
        double patternDirection;        // 1 for right, -1 for left (This is double because we multiply/divide turn rates
        // with it to get RH/LH turns - DON'T convert it to int under ANY circumstances!!
        double glideAngle;              // Assumed to be visual glidepath angle for FGAILocalTraffic - can be found at www.airnav.com
        // Its conceivable that patternDirection and glidePath could be moved into the RunwayDetails structure.
        
+       // Its possible that this might be moved out to the ground/airport class at some point.
+       FGATCAlignedProjection ortho;   // Orthogonal mapping of the local area with the threshold at the origin
+       // and the runway aligned with the y axis.
+       
+       void GetAirportDetails(const string& id);
+       
+       void GetRwyDetails(const string& id);
+       
+       double responseCounter;         // timer in seconds to allow response to requests to be a little while after them
+       // Will almost certainly get moved to FGAIPlane.        
+       
+private:
+       FGATCMgr* ATC;  
+       // This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code!
+
+       // High-level stuff
+       OperatingState operatingState;
+       int circuitsToFly;      //Number of circuits still to do in this session NOT INCLUDING THE CURRENT ONE
+       bool touchAndGo;        //True if circuits should be flown touch and go, false for full stop
+       bool transmitted;       // Set true when a position report for the current leg has been transmitted.
+       
        // Performance characteristics of the plane in knots and ft/min - some of this might get moved out into FGAIPlane
        double Vr;
        double best_rate_of_climb_speed;
@@ -135,8 +160,8 @@ private:
        bool inAir;                             // True when off the ground 
        
        // environment - some of this might get moved into FGAIPlane
-       SGPropertyNode* wind_from_hdg;  //degrees
-       SGPropertyNode* wind_speed_knots;               //knots
+       SGPropertyNode_ptr wind_from_hdg;       //degrees
+       SGPropertyNode_ptr wind_speed_knots;            //knots
        
        // Pattern details that (may) change
        int numInPattern;               // Number of planes in the pattern (this might get more complicated if high performance GA aircraft fly a higher pattern eventually)
@@ -168,12 +193,20 @@ private:
        bool reportReadyForDeparture;   // set true when ATC has requested that the plane report when ready for departure
        bool clearedToLineUp;
        bool clearedToTakeOff;
+       bool _clearedToLand;    // also implies cleared for the option.
        bool liningUp;  // Set true when the turn onto the runway heading is commenced when taxiing out
+       bool goAround;  // Set true if need to go-around
+       bool goAroundCalled;    // Set true during go-around only after we have called our go-around on the radio
        bool contactTower;      // we have been told to contact tower
        bool contactGround;     // we have been told to contact ground
        bool changeFreq;        // true when we need to change frequency
+       bool _taxiToGA;         // Temporary mega-hack indicating we are to taxi to the GA parking and disconnect from tower control.
+       bool _removeSelf;       // Indicates that we wish to remove this instance.  The use of a variable is a hack to allow time for messages to purge before removal, due to the fagility of the current dialog system.
        atc_type changeFreqType;        // the service we need to change to
-       double responseCounter;         // timer in seconds to allow response to requests to be a little while after them
+       bool freeTaxi;  // False if the airport has a facilities file with a logical taxi network defined, true if we need to calculate our own taxiing points.
+       
+       // Hack for getting close to the runway when atan can go pear-shaped
+       double _savedSlope;
 
        void FlyTrafficPattern(double dt);
 
@@ -183,7 +216,7 @@ private:
 
        void CalculateSoD(double base_leg_pos, double downwind_leg_pos, bool pattern_direction);
 
-       void ExitRunway(Point3D orthopos);
+       void ExitRunway(const Point3D& orthopos);
 
        void StartTaxi();
 
@@ -193,7 +226,8 @@ private:
        
        void DoGroundElev();
        
-       void GetRwyDetails();
+       // Set when the plane should be invisible *regardless of distance from user*.
+       bool _invisible;
 };
 
 #endif  // _FG_AILocalTraffic_HXX