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>
34 #ifndef SG_HAVE_NATIVE_SGI_COMPILERS
40 //DCL - a complete guess for now.
41 #define FG_TOWER_DEFAULT_RANGE 30
43 // somewhere in the ATC/AI system we are going to have defined something like
45 // list <PlaneRec> plane_rec_list_type
47 class FGTower : public FGATC {
51 // Need a data structure to hold details of the various active planes
52 // or possibly another data structure with the positions of the inactive planes.
53 // Need a data structure to hold outstanding communications from aircraft.
65 inline void SetDisplay() {display = true;}
66 inline void SetNoDisplay() {display = false;}
68 inline char get_type() const { return type; }
69 inline double get_lon() const { return lon; }
70 inline double get_lat() const { return lat; }
71 inline double get_elev() const { return elev; }
72 inline double get_x() const { return x; }
73 inline double get_y() const { return y; }
74 inline double get_z() const { return z; }
75 inline int get_freq() const { return freq; }
76 inline int get_range() const { return range; }
77 inline const char* GetIdent() { return ident.c_str(); }
78 inline string get_trans_ident() { return trans_ident; }
79 inline atc_type GetType() { return TOWER; }
81 // Make a request of tower control
82 //void Request(tower_request request);
92 bool display; // Flag to indicate whether we should be outputting to the ATC display.
93 bool displaying; // Flag to indicate whether we are outputting to the ATC display.
94 string ident; // Code of the airport its at.
95 string name; // Name generally used in transmissions.
97 // for failure modeling
98 string trans_ident; // transmitted ident
99 bool tower_failed; // tower failed?
101 friend istream& operator>> ( istream&, FGTower& );
106 operator >> ( istream& in, FGTower& t )
114 return in >> skipeol;
116 in >> t.lat >> t.lon >> t.elev >> f >> t.range
124 in.unsetf(ios::skipws);
127 if((ch == '"') || (ch == 0x0A)) {
129 } // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
131 in.setf(ios::skipws);
132 //cout << "tower.name = " << t.name << '\n';
134 t.freq = (int)(f*100.0 + 0.5);
136 // cout << t.ident << endl;
138 // generate cartesian coordinates
139 Point3D geod( t.lon * SGD_DEGREES_TO_RADIANS, t.lat * SGD_DEGREES_TO_RADIANS, t.elev );
140 Point3D cart = sgGeodToCart( geod );
145 t.trans_ident = t.ident;
146 t.tower_failed = false;
148 return in >> skipeol;
152 #endif //_FG_TOWER_HXX