1 // FGATC - abstract base class for the various actual atc classes
2 // such as FGATIS, FGTower etc.
4 // Written by David Luff, started Feburary 2002.
6 // Copyright (C) 2002 David C. Luff - david.luff@nottingham.ac.uk
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <simgear/compiler.h>
26 #include <simgear/misc/sgstream.hxx>
27 #include <simgear/math/sg_geodesy.hxx>
28 #include <simgear/debug/logstream.hxx>
33 SG_USING_STD(ostream);
37 // Possible types of ATC type that the radios may be tuned to.
38 // INVALID implies not tuned in to anything.
49 // DCL - new experimental ATC data store
55 unsigned short int freq;
57 unsigned short int range;
62 ostream& operator << (ostream& os, atc_type atc);
70 // Run the internal calculations
71 virtual void Update();
73 // Add plane to a stack
74 virtual void AddPlane(string pid);
76 // Remove plane from stack
77 virtual int RemovePlane();
79 // Indicate that this instance should output to the display if appropriate
80 virtual void SetDisplay();
82 // Indicate that this instance should not output to the display
83 virtual void SetNoDisplay();
85 // Return the type of ATC station that the class represents
86 virtual atc_type GetType();
88 // Set the core ATC data
89 void SetData(ATCData* d);
91 inline double get_lon() const { return lon; }
92 inline void set_lon(const double ln) {lon = ln;}
93 inline double get_lat() const { return lat; }
94 inline void set_lat(const double lt) {lat = lt;}
95 inline double get_elev() const { return elev; }
96 inline void set_elev(const double ev) {elev = ev;}
97 inline double get_x() const { return x; }
98 inline void set_x(const double ecs) {x = ecs;}
99 inline double get_y() const { return y; }
100 inline void set_y(const double why) {y = why;}
101 inline double get_z() const { return z; }
102 inline void set_z(const double zed) {z = zed;}
103 inline int get_freq() const { return freq; }
104 inline void set_freq(const int fq) {freq = fq;}
105 inline int get_range() const { return range; }
106 inline void set_range(const int rg) {range = rg;}
107 inline const char* get_ident() { return ident.c_str(); }
108 inline void set_ident(const string id) {ident = id;}
109 inline const char* get_name() {return name.c_str();}
110 inline void set_name(const string nm) {name = nm;}
114 double lon, lat, elev;
118 string ident; // Code of the airport its at.
119 string name; // Name transmitted in the broadcast.
123 operator >> ( istream& fin, ATCData& a )
146 return fin >> skipeol;
148 SG_LOG(SG_GENERAL, SG_ALERT, "Warning - unknown type \'" << tp << "\' found whilst reading ATC frequency data!\n");
150 return fin >> skipeol;
153 fin >> a.lat >> a.lon >> a.elev >> f >> a.range
161 fin.unsetf(ios::skipws);
164 if((ch == '"') || (ch == 0x0A)) {
166 } // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
168 fin.setf(ios::skipws);
169 //cout << "Comm name = " << a.name << '\n';
171 a.freq = (int)(f*100.0 + 0.5);
173 // cout << a.ident << endl;
175 // generate cartesian coordinates
176 Point3D geod( a.lon * SGD_DEGREES_TO_RADIANS, a.lat * SGD_DEGREES_TO_RADIANS, a.elev );
177 Point3D cart = sgGeodToCart( geod );
182 return fin >> skipeol;
186 #endif // _FG_ATC_HXX