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 #include "ATCVoice.hxx"
35 SG_USING_STD(ostream);
39 // Possible types of ATC type that the radios may be tuned to.
40 // INVALID implies not tuned in to anything.
51 // DCL - new experimental ATC data store
57 unsigned short int freq;
59 unsigned short int range;
64 ostream& operator << (ostream& os, atc_type atc);
72 // Run the internal calculations
73 virtual void Update();
75 // Add plane to a stack
76 virtual void AddPlane(string pid);
78 // Remove plane from stack
79 virtual int RemovePlane();
81 // Indicate that this instance should output to the display if appropriate
82 virtual void SetDisplay();
84 // Indicate that this instance should not output to the display
85 virtual void SetNoDisplay();
87 // Return the type of ATC station that the class represents
88 virtual atc_type GetType();
90 // Set the core ATC data
91 void SetData(ATCData* d);
93 inline double get_lon() const { return lon; }
94 inline void set_lon(const double ln) {lon = ln;}
95 inline double get_lat() const { return lat; }
96 inline void set_lat(const double lt) {lat = lt;}
97 inline double get_elev() const { return elev; }
98 inline void set_elev(const double ev) {elev = ev;}
99 inline double get_x() const { return x; }
100 inline void set_x(const double ecs) {x = ecs;}
101 inline double get_y() const { return y; }
102 inline void set_y(const double why) {y = why;}
103 inline double get_z() const { return z; }
104 inline void set_z(const double zed) {z = zed;}
105 inline int get_freq() const { return freq; }
106 inline void set_freq(const int fq) {freq = fq;}
107 inline int get_range() const { return range; }
108 inline void set_range(const int rg) {range = rg;}
109 inline const char* get_ident() { return ident.c_str(); }
110 inline void set_ident(const string id) {ident = id;}
111 inline const char* get_name() {return name.c_str();}
112 inline void set_name(const string nm) {name = nm;}
116 // Render a transmission
117 // Outputs the transmission either on screen or as audio depending on user preference
118 // The refname is a string to identify this sample to the sound manager
119 // The repeating flag indicates whether the message should be repeated continuously or played once.
120 void Render(string msg, string refname, bool repeating);
122 // Cease rendering a transmission.
123 // Requires the sound manager refname if audio, else "".
124 void NoRender(string refname);
126 double lon, lat, elev;
130 string ident; // Code of the airport its at.
131 string name; // Name transmitted in the broadcast.
133 // Rendering related stuff
134 bool voice; // Flag - true if we are using voice
135 bool playing; // Indicates a message in progress
136 bool voiceOK; // Flag - true if at least one voice has loaded OK
141 operator >> ( istream& fin, ATCData& a )
164 return fin >> skipeol;
166 SG_LOG(SG_GENERAL, SG_ALERT, "Warning - unknown type \'" << tp << "\' found whilst reading ATC frequency data!\n");
168 return fin >> skipeol;
171 fin >> a.lat >> a.lon >> a.elev >> f >> a.range
179 fin.unsetf(ios::skipws);
182 if((ch == '"') || (ch == 0x0A)) {
184 } // we shouldn't need the 0x0A but it makes a nice safely in case someone leaves off the "
186 fin.setf(ios::skipws);
187 //cout << "Comm name = " << a.name << '\n';
189 a.freq = (int)(f*100.0 + 0.5);
191 // cout << a.ident << endl;
193 // generate cartesian coordinates
194 Point3D geod( a.lon * SGD_DEGREES_TO_RADIANS, a.lat * SGD_DEGREES_TO_RADIANS, a.elev );
195 Point3D cart = sgGeodToCart( geod );
200 return fin >> skipeol;
204 #endif // _FG_ATC_HXX