1 // FGTower - a class to provide tower control at towered airports.
3 // Written by David Luff, started March 2002.
5 // Copyright (C) 2002 David C. Luff - david.luff@nottingham.ac.uk
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <simgear/compiler.h>
25 #include <simgear/math/point3d.hxx>
26 #include <simgear/misc/sgstream.hxx>
27 #include <simgear/math/sg_geodesy.hxx>
37 //#include "ATCmgr.hxx"
40 //DCL - a complete guess for now.
41 #define FG_TOWER_DEFAULT_RANGE 30
43 enum tower_traffic_type {
48 // Umm - what's the difference between INBOUND and STRAIGHT_IN ?
51 // Structure for holding details of a plane under tower control.
52 // Not fixed yet - may include more stuff later.
58 TowerPlaneRec(string ID);
59 TowerPlaneRec(Point3D pt);
60 TowerPlaneRec(string ID, Point3D pt);
64 double eta; // minutes
65 double dist_out; // miles from theshold
68 // ought to add time cleared to depart so we can nag if necessary
69 bool longFinalReported;
70 bool longFinalAcknowledged;
72 bool finalAcknowledged;
74 // enum type - light, medium, heavy etc - we need someway of approximating the aircraft type and performance.
76 // Type of operation the plane is doing
77 tower_traffic_type opType;
81 typedef list < TowerPlaneRec* > tower_plane_rec_list_type;
82 typedef tower_plane_rec_list_type::iterator tower_plane_rec_list_iterator;
83 typedef tower_plane_rec_list_type::const_iterator tower_plane_rec_list_const_iterator;
86 class FGTower : public FGATC {
97 void RequestLandingClearance(string ID);
98 void RequestDepartureClearance(string ID);
99 void ReportFinal(string ID);
100 void ReportLongFinal(string ID);
101 void ReportOuterMarker(string ID);
102 void ReportMiddleMarker(string ID);
103 void ReportInnerMarker(string ID);
104 void ReportGoingAround(string ID);
105 void ReportRunwayVacated(string ID);
107 inline void SetDisplay() {display = true;}
108 inline void SetNoDisplay() {display = false;}
110 inline string get_trans_ident() { return trans_ident; }
111 inline atc_type GetType() { return TOWER; }
113 inline FGGround* GetGroundPtr() {return ground; }
117 // This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code!
119 // Calculate the eta of each plane to the threshold.
120 // For ground traffic this is the fastest they can get there.
121 // For air traffic this is the middle approximation.
122 void doThresholdETACalc();
124 // Order the list of traffic as per expected threshold use and flag any conflicts
125 bool doThresholdUseOrder();
127 void doCommunication();
129 void IssueLandingClearance(TowerPlaneRec* tpr);
130 void IssueGoAround(TowerPlaneRec* tpr);
131 void IssueDepartureClearance(TowerPlaneRec* tpr);
133 bool display; // Flag to indicate whether we should be outputting to the ATC display.
134 bool displaying; // Flag to indicate whether we are outputting to the ATC display.
136 bool rwyOccupied; // Active runway occupied flag. For now we'll disregard multiple runway and land-and-hold-short operations
138 // Need a data structure to hold details of the various active planes
139 // or possibly another data structure with the positions of the inactive planes.
140 // Need a data structure to hold outstanding communications from aircraft.
142 // Linked-list of planes on approach ordered with nearest first (timewise).
143 // Includes planes that have landed but not yet vacated runway.
144 // Somewhat analagous to the paper strips used (used to be used?) in real life.
145 tower_plane_rec_list_type appList;
147 // List of departed planes
148 tower_plane_rec_list_type depList;
150 // List of planes waiting to depart
151 tower_plane_rec_list_type holdList;
153 // List of planes on rwy
154 tower_plane_rec_list_type rwyList;
157 // Linked list of all planes due to use a given rwy arranged in projected order of rwy use
158 tower_plane_rec_list_type trafficList; // TODO - needs to be expandable to more than one rwy
160 // Ground can be separate or handled by tower in real life.
161 // In the program we will always use a separate FGGround class, but we need to know
162 // whether it is supposed to be separate or not to give the correct instructions.
163 bool separateGround; // true if ground control is separate
164 FGGround* ground; // The ground control associated with this airport.
167 // for failure modeling
168 string trans_ident; // transmitted ident
169 bool tower_failed; // tower failed?
171 friend istream& operator>> ( istream&, FGTower& );
174 #endif //_FG_TOWER_HXX