]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/tower.hxx
Fix the nmea and garmin output to a) fake a GSA sentence, b) fix a y2k bug
[flightgear.git] / src / ATC / tower.hxx
index c8eef6a43864f08cde7d49315307972ef0a894e5..f06faeb56455c0eeab74e4844c4ae750bea3647b 100644 (file)
@@ -53,6 +53,16 @@ enum tower_traffic_type {
 
 ostream& operator << (ostream& os, tower_traffic_type ttt);
 
+enum tower_callback_type {
+       USER_REQUEST_VFR_DEPARTURE = 1,
+       USER_REQUEST_VFR_ARRIVAL = 2,
+       USER_REQUEST_VFR_ARRIVAL_FULL_STOP = 3,
+       USER_REQUEST_VFR_ARRIVAL_TOUCH_AND_GO = 4,
+       USER_REPORT_3_MILE_FINAL = 5,
+       USER_REPORT_DOWNWIND = 6,
+       USER_REPORT_RWY_VACATED = 7
+};
+
 // TODO - need some differentiation of IFR and VFR traffic in order to give the former priority.
 
 // Structure for holding details of a plane under tower control.
@@ -77,15 +87,20 @@ public:
        bool clearedToTakeOff;
        // ought to add time cleared to depart so we can nag if necessary
        bool holdShortReported;
+       bool downwindReported;
        bool longFinalReported;
        bool longFinalAcknowledged;
        bool finalReported;
        bool finalAcknowledged;
+       bool rwyVacatedReported;
+       bool rwyVacatedAcknowledged;
+       bool instructedToGoAround;      // set true if told by tower to go around
        bool onRwy;             // is physically on the runway
        bool nextOnRwy;         // currently projected by tower to be the next on the runway
-
-       double clearanceCounter;                // Hack for communication timing - counter since clearance requested in seconds 
        
+       bool vfrArrivalReported;
+       bool vfrArrivalAcknowledged;
+
        // Type of operation the plane is doing
        tower_traffic_type opType;
        
@@ -113,8 +128,14 @@ public:
        void Init();
        
        void Update(double dt);
+       
+       void ReceiveUserCallback(int code);
 
-       void RequestLandingClearance(string ID);
+       // 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(string ID, LandingType opt = AIP_LT_UNKNOWN);
+       
        void RequestDepartureClearance(string ID);      
        void ReportFinal(string ID);
        void ReportLongFinal(string ID);
@@ -124,14 +145,21 @@ public:
        void ReportGoingAround(string ID);
        void ReportRunwayVacated(string ID);
        void ReportReadyForDeparture(string ID);
+       void ReportDownwind(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(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(PlaneRec plane, FGAIPlane* ai, tower_traffic_type op, PatternLeg lg = LEG_UNKNOWN);
+       
        // 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; }
+       // Get the pattern direction of the active rwy.
+       inline int GetPatternDirection() { return rwy.patternDirection; }
        
        inline void SetDisplay() { display = true; }
        inline void SetNoDisplay() { display = false; }
@@ -147,19 +175,30 @@ public:
        bool GetDownwindConstraint(double& dpos);
        bool GetBaseConstraint(double& bpos);
        
-       // Returns true if OK to transmit on this frequency
-       inline bool FreqClear() { return freqClear; }
-       // Indicate that the frequency is in use
-       inline void FreqInUse() { freqClear = false; }
-       // The idea is that AI traffic or the user ATC dialog box calls FreqInUse() when they begin transmitting,
-       // and that the tower control sets freqClear back to true following a reply.
-       // AI traffic should check FreqClear() is true prior to transmitting.
-       // The user will just have to wait for a gap in dialog as in real life.
+       string GenText(const string& m, int c);
 
 private:
        FGATCMgr* ATCmgr;       
        // This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code!
+       
+       // Respond to a transmission
+       void Respond();
+       
+       void CheckHoldList(double dt);
 
+       void CheckCircuitList(double dt);
+       
+       void CheckRunwayList(double dt);
+
+       void CheckApproachList(double dt);
+       
+       // Currently this assumes we *are* next on the runway and doesn't check for planes about to land - 
+       // this should be done prior to calling this function.
+       void ClearHoldingPlane(TowerPlaneRec* t);
+       
+       // Find a pointer to plane of callsign ID within the internal data structures
+       TowerPlaneRec* FindPlane(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(Point3D pt);
@@ -198,8 +237,6 @@ private:
        bool display;           // Flag to indicate whether we should be outputting to the ATC display.
        bool displaying;                // Flag to indicate whether we are outputting to the ATC display.
        
-       bool freqClear;         // Flag to indicate if the frequency is clear of ongoing dialog
-       
        double timeSinceLastDeparture;  // Time in seconds since last departure from active rwy.
        bool departed;  // set true when the above needs incrementing with time, false when it doesn't.
        
@@ -265,6 +302,8 @@ private:
        // Add a tower plane rec with ETA to the traffic list in the correct position ETA-wise.
        // Returns true if this could cause a threshold ETA conflict with other traffic, false otherwise.
        bool AddToTrafficList(TowerPlaneRec* t, bool holding = false);
+       
+       bool AddToCircuitList(TowerPlaneRec* t);
 
        // Ground can be separate or handled by tower in real life.
        // In the program we will always use a separate FGGround class, but we need to know
@@ -288,6 +327,10 @@ private:
        // 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.
        
+       double nominal_crosswind_leg_pos;
+       double nominal_downwind_leg_pos;
+       double nominal_base_leg_pos;
+       
        friend istream& operator>> ( istream&, FGTower& );
 };