1
0
Fork 0

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.

This commit is contained in:
daveluff 2004-09-30 15:43:32 +00:00
parent 6f8cae6b87
commit 3bb349179d
6 changed files with 48 additions and 27 deletions

View file

@ -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] = ' ';
}
}
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;
}
}

View file

@ -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

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}