From 3bb349179deb08c2772b87aa39c2586f8137dcc7 Mon Sep 17 00:00:00 2001 From: daveluff Date: Thu, 30 Sep 2004 15:43:32 +0000 Subject: [PATCH] Use the Transmit-Render functions for tower output instead of directly calling ATCdisplay. This is part of preparations for optionally handing the strings off to a TTS engine if required. --- src/ATC/ATC.cxx | 32 ++++++++++++++++++++------------ src/ATC/ATC.hxx | 12 ++++++------ src/ATC/ATCDialog.cxx | 1 + src/ATC/ATCdisplay.hxx | 2 +- src/ATC/atis.cxx | 4 ++-- src/ATC/tower.cxx | 24 ++++++++++++++++++------ 6 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/ATC/ATC.cxx b/src/ATC/ATC.cxx index 8634de024..955cb8195 100644 --- a/src/ATC/ATC.cxx +++ b/src/ATC/ATC.cxx @@ -51,6 +51,8 @@ FGATC::FGATC() { _transmitting = false; _counter = 0.0; _max_count = 5.0; + + _voiceOK = false; } FGATC::~FGATC() { @@ -105,8 +107,9 @@ void FGATC::Update(double dt) { //cout << "Transmission = " << pending_transmission << '\n'; if(_display) { //Render(pending_transmission, ident, false); + Render(pending_transmission); // At the moment Render only works for ATIS - globals->get_ATC_display()->RegisterSingleMessage(pending_transmission); + //globals->get_ATC_display()->RegisterSingleMessage(pending_transmission); } // Run the callback regardless of whether on same freq as user or not. //cout << "_callback_code = " << _callback_code << '\n'; @@ -179,8 +182,9 @@ void FGATC::ImmediateTransmit(int callback_code) { SG_LOG(SG_ATC, SG_INFO, "Immediate transmit called by " << ident << " " << _type << ", msg = " << pending_transmission); if(_display) { //Render(pending_transmission, ident, false); + Render(pending_transmission); // At the moment Render doesn't work except for ATIS - globals->get_ATC_display()->RegisterSingleMessage(pending_transmission); + //globals->get_ATC_display()->RegisterSingleMessage(pending_transmission); } if(callback_code) { ProcessCallback(callback_code); @@ -217,11 +221,11 @@ void FGATC::SetData(ATCData* d) { // The repeating flag indicates whether the message should be repeated continuously or played once. void FGATC::Render(string msg, string refname, bool repeating) { #ifdef ENABLE_AUDIO_SUPPORT - voice = (voiceOK && fgGetBool("/sim/sound/voice")); - if(voice) { + _voice = (_voiceOK && fgGetBool("/sim/sound/voice")); + if(_voice) { int len; - unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, voice); - if(voice) { + unsigned char* buf = _vPtr->WriteMessage((char*)msg.c_str(), len, _voice); + if(_voice) { SGSoundSample *simple = new SGSoundSample(buf, len, 8000, false); // TODO - at the moment the volume is always set off comm1 @@ -237,23 +241,27 @@ void FGATC::Render(string msg, string refname, bool repeating) { delete[] buf; } #endif // ENABLE_AUDIO_SUPPORT - if(!voice) { + if(!_voice) { // first rip the underscores and the pause hints out of the string - these are for the convienience of the voice parser for(unsigned int i = 0; i < msg.length(); ++i) { if((msg.substr(i,1) == "_") || (msg.substr(i,1) == "/")) { msg[i] = ' '; } } - globals->get_ATC_display()->RegisterRepeatingMessage(msg); + if(repeating) { + globals->get_ATC_display()->RegisterRepeatingMessage(msg); + } else { + globals->get_ATC_display()->RegisterSingleMessage(msg); + } } - playing = true; + _playing = true; } // Cease rendering a transmission. void FGATC::NoRender(string refname) { - if(playing) { - if(voice) { + if(_playing) { + if(_voice) { #ifdef ENABLE_AUDIO_SUPPORT globals->get_soundmgr()->stop(refname); globals->get_soundmgr()->remove(refname); @@ -261,7 +269,7 @@ void FGATC::NoRender(string refname) { } else { globals->get_ATC_display()->CancelRepeatingMessage(); } - playing = false; + _playing = false; } } diff --git a/src/ATC/ATC.hxx b/src/ATC/ATC.hxx index c6c689a8d..cd4ab84db 100644 --- a/src/ATC/ATC.hxx +++ b/src/ATC/ATC.hxx @@ -180,9 +180,9 @@ protected: // Outputs the transmission either on screen or as audio depending on user preference // The refname is a string to identify this sample to the sound manager // The repeating flag indicates whether the message should be repeated continuously or played once. - void Render(string msg, string refname, bool repeating); + void Render(string msg, string refname = "", bool repeating = false); - // Cease rendering a transmission. + // Cease rendering all transmission from this station. // Requires the sound manager refname if audio, else "". void NoRender(string refname); @@ -206,10 +206,10 @@ protected: atc_type _type; // Rendering related stuff - bool voice; // Flag - true if we are using voice - bool playing; // Indicates a message in progress - bool voiceOK; // Flag - true if at least one voice has loaded OK - FGATCVoice* vPtr; + bool _voice; // Flag - true if we are using voice + bool _playing; // Indicates a message in progress + bool _voiceOK; // Flag - true if at least one voice has loaded OK + FGATCVoice* _vPtr; string pending_transmission; // derived classes set this string before calling Transmit(...) bool freqClear; // Flag to indicate if the frequency is clear of ongoing dialog diff --git a/src/ATC/ATCDialog.cxx b/src/ATC/ATCDialog.cxx index 3946898f6..efcde15eb 100644 --- a/src/ATC/ATCDialog.cxx +++ b/src/ATC/ATCDialog.cxx @@ -404,6 +404,7 @@ void FGATCDialog::PopupCallback() { //cout << "Doing callback...\n"; ATCMenuEntry a = atcmlist[atcDialogCommunicationOptions->getValue()]; atcptr->SetFreqInUse(); + // This is the user's speech getting displayed. globals->get_ATC_display()->RegisterSingleMessage(atcptr->GenText(a.transmission, a.callback_code)); _callbackPending = true; _callbackTimer = 0.0; diff --git a/src/ATC/ATCdisplay.hxx b/src/ATC/ATCdisplay.hxx index 0734e446f..7b3ade925 100644 --- a/src/ATC/ATCdisplay.hxx +++ b/src/ATC/ATCdisplay.hxx @@ -56,7 +56,7 @@ private: bool rep_msg; // Flag to indicate there is a repeating transmission to display bool change_msg_flag; // Flag to indicate that the repeating message has changed double dsp_offset1; // Used to set the correct position of scrolling display - double dsp_offset2; + double dsp_offset2; string rep_msg_str; // The repeating transmission to play atcMessageList msgList; atcMessageListIterator msgList_itr; diff --git a/src/ATC/atis.cxx b/src/ATC/atis.cxx index 5ed6940af..2a8780bbf 100644 --- a/src/ATC/atis.cxx +++ b/src/ATC/atis.cxx @@ -56,8 +56,8 @@ FGATIS::FGATIS() : refname("atis") //type(ATIS) { - vPtr = globals->get_ATC_mgr()->GetVoicePointer(ATIS); - voiceOK = (vPtr == NULL ? false : true); + _vPtr = globals->get_ATC_mgr()->GetVoicePointer(ATIS); + _voiceOK = (_vPtr == NULL ? false : true); _type = ATIS; } diff --git a/src/ATC/tower.cxx b/src/ATC/tower.cxx index 05f09e0b2..e5b632f0b 100644 --- a/src/ATC/tower.cxx +++ b/src/ATC/tower.cxx @@ -508,7 +508,9 @@ void FGTower::Respond() { } trns += ConvertRwyNumToSpokenString(activeRwy); if(_display) { - globals->get_ATC_display()->RegisterSingleMessage(trns, 0); + //globals->get_ATC_display()->RegisterSingleMessage(trns, 0); + pending_transmission = trns; + Transmit(); } else { //cout << "Not displaying, trns was " << trns << '\n'; } @@ -543,7 +545,9 @@ void FGTower::Respond() { string trns = t->plane.callsign; trns += " hold position"; if(_display) { - globals->get_ATC_display()->RegisterSingleMessage(trns, 0); + //globals->get_ATC_display()->RegisterSingleMessage(trns, 0); + pending_transmission = trns; + Transmit(); } // TODO - add some idea of what traffic is blocking him. } @@ -581,7 +585,9 @@ void FGTower::Respond() { t->clearedToLand = false; } if(_display && disp) { - globals->get_ATC_display()->RegisterSingleMessage(trns); + //globals->get_ATC_display()->RegisterSingleMessage(trns); + pending_transmission = trns; + Transmit(); } t->finalAcknowledged = true; } else if(t->rwyVacatedReported && !(t->rwyVacatedAcknowledged)) { @@ -676,7 +682,9 @@ void FGTower::ProcessDownwindReport(TowerPlaneRec* t) { } } if(_display) { - globals->get_ATC_display()->RegisterSingleMessage(trns); + //globals->get_ATC_display()->RegisterSingleMessage(trns); + pending_transmission = trns; + Transmit(); } if(t->isUser) { if(t->opType == TTT_UNKNOWN) t->opType = CIRCUIT; @@ -708,7 +716,9 @@ void FGTower::ProcessRunwayVacatedReport(TowerPlaneRec* t) { } //cout << "trns = " << trns << '\n'; if(_display) { - globals->get_ATC_display()->RegisterSingleMessage(trns); + //globals->get_ATC_display()->RegisterSingleMessage(trns); + pending_transmission = trns; + Transmit(); } RemoveFromRwyList(t->plane.callsign); AddToVacatedList(t); @@ -819,7 +829,9 @@ void FGTower::ClearHoldingPlane(TowerPlaneRec* t) { timeSinceLastDeparture = 0.0; } if(_display) { - globals->get_ATC_display()->RegisterSingleMessage(trns, 0); + //globals->get_ATC_display()->RegisterSingleMessage(trns, 0); + pending_transmission = trns; + Transmit(); } //cout << "Done ClearHoldingPlane " << endl; }