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.
21 #include <Main/fgfs.hxx>
22 #include <Main/fg_props.hxx>
23 #include <Sound/soundmgr.hxx>
26 #include "ATCdisplay.hxx"
31 void FGATC::Update(double dt) {
34 void FGATC::AddPlane(string pid) {
37 int FGATC::RemovePlane() {
41 void FGATC::SetDisplay() {
44 void FGATC::SetNoDisplay() {
47 atc_type FGATC::GetType() {
51 void FGATC::SetData(ATCData* d) {
64 // Render a transmission
65 // Outputs the transmission either on screen or as audio depending on user preference
66 // The refname is a string to identify this sample to the sound manager
67 // The repeating flag indicates whether the message should be repeated continuously or played once.
68 void FGATC::Render(string msg, string refname, bool repeating) {
69 #ifdef ENABLE_AUDIO_SUPPORT
70 voice = (voiceOK && fgGetBool("/sim/sound/audible")
71 && fgGetBool("/sim/sound/voice"));
74 unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, voice);
76 FGSimpleSound* simple = new FGSimpleSound(buf, len);
77 // TODO - at the moment the volume is always set off comm1
78 // and can't be changed after the transmission has started.
79 simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
80 globals->get_soundmgr()->add(simple, refname);
82 globals->get_soundmgr()->play_looped(refname);
84 globals->get_soundmgr()->play_once(refname);
89 #endif // ENABLE_AUDIO_SUPPORT
91 // first rip the underscores and the pause hints out of the string - these are for the convienience of the voice parser
92 for(unsigned int i = 0; i < msg.length(); ++i) {
93 if((msg.substr(i,1) == "_") || (msg.substr(i,1) == "/")) {
97 globals->get_ATC_display()->RegisterRepeatingMessage(msg);
103 // Cease rendering a transmission.
104 void FGATC::NoRender(string refname) {
107 #ifdef ENABLE_AUDIO_SUPPORT
108 globals->get_soundmgr()->stop(refname);
109 globals->get_soundmgr()->remove(refname);
112 globals->get_ATC_display()->CancelRepeatingMessage();
118 ostream& operator << (ostream& os, atc_type atc) {
121 return(os << "INVALID");
123 return(os << "ATIS");
125 return(os << "GROUND");
127 return(os << "TOWER");
129 return(os << "APPROACH");
131 return(os << "DEPARTURE");
133 return(os << "ENROUTE");
135 return(os << "ERROR - Unknown switch in atc_type operator << ");