1 // ATCMgr.hxx - definition of FGATCMgr
2 // - a global management class for FlightGear generated ATC
4 // Written by David Luff, started February 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.
22 #ifndef _FG_ATCMGR_HXX
23 #define _FG_ATCMGR_HXX
25 #include <Main/fgfs.hxx>
26 #include <Main/fg_props.hxx>
27 #include <Sound/soundmgr.hxx>
36 #include "approach.hxx"
39 #include "ATCVoice.hxx"
45 const int max_app = 20;
47 // Structure for holding details of the ATC frequencies at a given airport, and whether they are in the active list or not.
48 // These can then be cross referenced with the [atis][tower][etc]lists which are stored by frequency.
49 // Non-available services are denoted by a frequency of zero.
50 // Eventually the whole ATC data structures may have to be rethought if we turn out to be massive memory hogs!!
61 //float approach_freq;
62 //bool approach_active;
63 //float departure_freq;
64 //bool departure_active;
66 // Flags to ensure the stations don't get wrongly deactivated
67 bool set_by_AI; // true when the AI manager has activated this station
68 bool set_by_comm_search; // true when the comm_search has activated this station
71 class FGATCMgr : public FGSubsystem
76 // A map of airport ID vs frequencies and ATC provision
77 typedef map < string, AirportATC* > airport_atc_map_type;
78 typedef airport_atc_map_type::iterator airport_atc_map_iterator;
79 typedef airport_atc_map_type::const_iterator airport_atc_map_const_iterator;
81 airport_atc_map_type airport_atc_map;
82 airport_atc_map_iterator airport_atc_map_itr;
84 // A list of pointers to all currently active ATC classes
85 typedef list <FGATC*> atc_list_type;
86 typedef atc_list_type::iterator atc_list_iterator;
87 typedef atc_list_type::const_iterator atc_list_const_iterator;
89 // Everything put in this list should be created dynamically
90 // on the heap and ***DELETED WHEN REMOVED!!!!!***
91 atc_list_type atc_list;
92 atc_list_iterator atc_list_itr;
93 // Any member function of FGATCMgr is permitted to leave this iterator pointing
94 // at any point in or at the end of the list.
95 // Hence any new access must explicitly first check for atc_list.end() before dereferencing.
97 // Position of the Users Aircraft
102 // Type of ATC control that the user's radios are tuned to.
106 // Pointer to the ATC station that the user is currently tuned into.
107 FGATC* tuned_atc_ptr;
112 // Pointers to users current communication frequencies.
113 SGPropertyNode* comm1_node;
114 SGPropertyNode* comm2_node;
116 // Pointers to current users position
117 SGPropertyNode* lon_node;
118 SGPropertyNode* lat_node;
119 SGPropertyNode* elev_node;
121 // Position of the ATC that the comm radios are tuned to in order to decide whether transmission
123 double comm1_x, comm1_y, comm1_z, comm1_elev;
124 double comm1_range, comm1_effective_range;
126 bool comm1_atis_valid;
127 bool comm1_tower_valid;
128 bool comm1_approach_valid;
129 const char* comm1_ident;
130 const char* comm1_atis_ident;
131 const char* comm1_tower_ident;
132 const char* comm1_approach_ident;
133 const char* last_comm1_ident;
134 const char* last_comm1_atis_ident;
135 const char* last_comm1_tower_ident;
136 const char* last_comm1_approach_ident;
137 const char* approach_ident;
139 double comm2_x, comm2_y, comm2_z, comm2_elev;
140 double comm2_range, comm2_effective_range;
142 const char* comm2_ident;
143 const char* last_comm2_ident;
148 FGApproach approaches[max_app];
150 //FGDeparture departure;
152 // Rendering related stuff
153 bool voice; // Flag - true if we are using voice
154 bool playing; // Indicates a message in progress
155 #ifdef ENABLE_AUDIO_SUPPORT
156 string refname; // FIXME - A hack - assumes only one sound to track.
157 bool voiceOK; // Flag - true if at least one voice has loaded OK
172 void update(double dt);
174 // Returns true if the airport is found in the map
175 bool GetAirportATCDetails(string icao, AirportATC* a);
177 // Return a pointer to a given sort of ATC at a given airport and activate if necessary
178 FGATC* GetATCPointer(string icao, atc_type type);
180 // Render a transmission
181 // Outputs the transmission either on screen or as audio depending on user preference
182 // The repeating flag indicates whether the message should be repeated continuously or played once.
183 void Render(string msg, bool repeating);
185 // Cease rendering a transmission.
186 // At the moment this can handle one transmission active at a time only.
189 // Display a dialog box with options relevant to the currently tuned ATC service.
190 void doStandardDialog();
192 atc_type GetCurrentATCType() { return(comm1_type); }
193 FGATC* GetCurrentATCPointer() { return(tuned_atc_ptr); }
197 // Remove a class from the atc_list and delete it from memory
198 void RemoveFromList(const char* id, atc_type tp);
200 // Return a pointer to a class in the list (external interface to this is through GetATCPointer)
201 FGATC* FGATCMgr::FindInList(const char* id, atc_type tp);
203 // Search a specified freq for matching stations
208 #endif // _FG_ATCMGR_HXX