1 // Implementation of FGATC - ATC subsystem base class.
3 // Written by David Luff, started February 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.
25 #include <simgear/sound/soundmgr.hxx>
27 #include <Main/fgfs.hxx>
28 #include <Main/fg_props.hxx>
31 #include "ATCdisplay.hxx"
36 void FGATC::Update(double dt) {
39 void FGATC::AddPlane(string pid) {
42 int FGATC::RemovePlane() {
46 void FGATC::SetDisplay() {
49 void FGATC::SetNoDisplay() {
52 atc_type FGATC::GetType() {
56 void FGATC::SetData(ATCData* d) {
69 // Render a transmission
70 // Outputs the transmission either on screen or as audio depending on user preference
71 // The refname is a string to identify this sample to the sound manager
72 // The repeating flag indicates whether the message should be repeated continuously or played once.
73 void FGATC::Render(string msg, string refname, bool repeating) {
74 #ifdef ENABLE_AUDIO_SUPPORT
75 voice = (voiceOK && fgGetBool("/sim/sound/audible")
76 && fgGetBool("/sim/sound/voice"));
79 unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, voice);
81 SGSimpleSound* simple = new SGSimpleSound(buf, len);
82 // TODO - at the moment the volume is always set off comm1
83 // and can't be changed after the transmission has started.
84 simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
85 globals->get_soundmgr()->add(simple, refname);
87 globals->get_soundmgr()->play_looped(refname);
89 globals->get_soundmgr()->play_once(refname);
94 #endif // ENABLE_AUDIO_SUPPORT
96 // first rip the underscores and the pause hints out of the string - these are for the convienience of the voice parser
97 for(unsigned int i = 0; i < msg.length(); ++i) {
98 if((msg.substr(i,1) == "_") || (msg.substr(i,1) == "/")) {
102 globals->get_ATC_display()->RegisterRepeatingMessage(msg);
108 // Cease rendering a transmission.
109 void FGATC::NoRender(string refname) {
112 #ifdef ENABLE_AUDIO_SUPPORT
113 globals->get_soundmgr()->stop(refname);
114 globals->get_soundmgr()->remove(refname);
117 globals->get_ATC_display()->CancelRepeatingMessage();
123 ostream& operator << (ostream& os, atc_type atc) {
126 return(os << "INVALID");
128 return(os << "ATIS");
130 return(os << "GROUND");
132 return(os << "TOWER");
134 return(os << "APPROACH");
136 return(os << "DEPARTURE");
138 return(os << "ENROUTE");
140 return(os << "ERROR - Unknown switch in atc_type operator << ");