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:
parent
6f8cae6b87
commit
3bb349179d
6 changed files with 48 additions and 27 deletions
|
@ -51,6 +51,8 @@ FGATC::FGATC() {
|
||||||
_transmitting = false;
|
_transmitting = false;
|
||||||
_counter = 0.0;
|
_counter = 0.0;
|
||||||
_max_count = 5.0;
|
_max_count = 5.0;
|
||||||
|
|
||||||
|
_voiceOK = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FGATC::~FGATC() {
|
FGATC::~FGATC() {
|
||||||
|
@ -105,8 +107,9 @@ void FGATC::Update(double dt) {
|
||||||
//cout << "Transmission = " << pending_transmission << '\n';
|
//cout << "Transmission = " << pending_transmission << '\n';
|
||||||
if(_display) {
|
if(_display) {
|
||||||
//Render(pending_transmission, ident, false);
|
//Render(pending_transmission, ident, false);
|
||||||
|
Render(pending_transmission);
|
||||||
// At the moment Render only works for ATIS
|
// 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.
|
// Run the callback regardless of whether on same freq as user or not.
|
||||||
//cout << "_callback_code = " << _callback_code << '\n';
|
//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);
|
SG_LOG(SG_ATC, SG_INFO, "Immediate transmit called by " << ident << " " << _type << ", msg = " << pending_transmission);
|
||||||
if(_display) {
|
if(_display) {
|
||||||
//Render(pending_transmission, ident, false);
|
//Render(pending_transmission, ident, false);
|
||||||
|
Render(pending_transmission);
|
||||||
// At the moment Render doesn't work except for ATIS
|
// 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) {
|
if(callback_code) {
|
||||||
ProcessCallback(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.
|
// The repeating flag indicates whether the message should be repeated continuously or played once.
|
||||||
void FGATC::Render(string msg, string refname, bool repeating) {
|
void FGATC::Render(string msg, string refname, bool repeating) {
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
voice = (voiceOK && fgGetBool("/sim/sound/voice"));
|
_voice = (_voiceOK && fgGetBool("/sim/sound/voice"));
|
||||||
if(voice) {
|
if(_voice) {
|
||||||
int len;
|
int len;
|
||||||
unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, voice);
|
unsigned char* buf = _vPtr->WriteMessage((char*)msg.c_str(), len, _voice);
|
||||||
if(voice) {
|
if(_voice) {
|
||||||
SGSoundSample *simple
|
SGSoundSample *simple
|
||||||
= new SGSoundSample(buf, len, 8000, false);
|
= new SGSoundSample(buf, len, 8000, false);
|
||||||
// TODO - at the moment the volume is always set off comm1
|
// 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;
|
delete[] buf;
|
||||||
}
|
}
|
||||||
#endif // ENABLE_AUDIO_SUPPORT
|
#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
|
// 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) {
|
for(unsigned int i = 0; i < msg.length(); ++i) {
|
||||||
if((msg.substr(i,1) == "_") || (msg.substr(i,1) == "/")) {
|
if((msg.substr(i,1) == "_") || (msg.substr(i,1) == "/")) {
|
||||||
msg[i] = ' ';
|
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.
|
// Cease rendering a transmission.
|
||||||
void FGATC::NoRender(string refname) {
|
void FGATC::NoRender(string refname) {
|
||||||
if(playing) {
|
if(_playing) {
|
||||||
if(voice) {
|
if(_voice) {
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
globals->get_soundmgr()->stop(refname);
|
globals->get_soundmgr()->stop(refname);
|
||||||
globals->get_soundmgr()->remove(refname);
|
globals->get_soundmgr()->remove(refname);
|
||||||
|
@ -261,7 +269,7 @@ void FGATC::NoRender(string refname) {
|
||||||
} else {
|
} else {
|
||||||
globals->get_ATC_display()->CancelRepeatingMessage();
|
globals->get_ATC_display()->CancelRepeatingMessage();
|
||||||
}
|
}
|
||||||
playing = false;
|
_playing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,9 +180,9 @@ protected:
|
||||||
// Outputs the transmission either on screen or as audio depending on user preference
|
// 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 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.
|
// 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 "".
|
// Requires the sound manager refname if audio, else "".
|
||||||
void NoRender(string refname);
|
void NoRender(string refname);
|
||||||
|
|
||||||
|
@ -206,10 +206,10 @@ protected:
|
||||||
atc_type _type;
|
atc_type _type;
|
||||||
|
|
||||||
// Rendering related stuff
|
// Rendering related stuff
|
||||||
bool voice; // Flag - true if we are using voice
|
bool _voice; // Flag - true if we are using voice
|
||||||
bool playing; // Indicates a message in progress
|
bool _playing; // Indicates a message in progress
|
||||||
bool voiceOK; // Flag - true if at least one voice has loaded OK
|
bool _voiceOK; // Flag - true if at least one voice has loaded OK
|
||||||
FGATCVoice* vPtr;
|
FGATCVoice* _vPtr;
|
||||||
|
|
||||||
string pending_transmission; // derived classes set this string before calling Transmit(...)
|
string pending_transmission; // derived classes set this string before calling Transmit(...)
|
||||||
bool freqClear; // Flag to indicate if the frequency is clear of ongoing dialog
|
bool freqClear; // Flag to indicate if the frequency is clear of ongoing dialog
|
||||||
|
|
|
@ -404,6 +404,7 @@ void FGATCDialog::PopupCallback() {
|
||||||
//cout << "Doing callback...\n";
|
//cout << "Doing callback...\n";
|
||||||
ATCMenuEntry a = atcmlist[atcDialogCommunicationOptions->getValue()];
|
ATCMenuEntry a = atcmlist[atcDialogCommunicationOptions->getValue()];
|
||||||
atcptr->SetFreqInUse();
|
atcptr->SetFreqInUse();
|
||||||
|
// This is the user's speech getting displayed.
|
||||||
globals->get_ATC_display()->RegisterSingleMessage(atcptr->GenText(a.transmission, a.callback_code));
|
globals->get_ATC_display()->RegisterSingleMessage(atcptr->GenText(a.transmission, a.callback_code));
|
||||||
_callbackPending = true;
|
_callbackPending = true;
|
||||||
_callbackTimer = 0.0;
|
_callbackTimer = 0.0;
|
||||||
|
|
|
@ -56,7 +56,7 @@ private:
|
||||||
bool rep_msg; // Flag to indicate there is a repeating transmission to display
|
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
|
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_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
|
string rep_msg_str; // The repeating transmission to play
|
||||||
atcMessageList msgList;
|
atcMessageList msgList;
|
||||||
atcMessageListIterator msgList_itr;
|
atcMessageListIterator msgList_itr;
|
||||||
|
|
|
@ -56,8 +56,8 @@ FGATIS::FGATIS() :
|
||||||
refname("atis")
|
refname("atis")
|
||||||
//type(ATIS)
|
//type(ATIS)
|
||||||
{
|
{
|
||||||
vPtr = globals->get_ATC_mgr()->GetVoicePointer(ATIS);
|
_vPtr = globals->get_ATC_mgr()->GetVoicePointer(ATIS);
|
||||||
voiceOK = (vPtr == NULL ? false : true);
|
_voiceOK = (_vPtr == NULL ? false : true);
|
||||||
_type = ATIS;
|
_type = ATIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,9 @@ void FGTower::Respond() {
|
||||||
}
|
}
|
||||||
trns += ConvertRwyNumToSpokenString(activeRwy);
|
trns += ConvertRwyNumToSpokenString(activeRwy);
|
||||||
if(_display) {
|
if(_display) {
|
||||||
globals->get_ATC_display()->RegisterSingleMessage(trns, 0);
|
//globals->get_ATC_display()->RegisterSingleMessage(trns, 0);
|
||||||
|
pending_transmission = trns;
|
||||||
|
Transmit();
|
||||||
} else {
|
} else {
|
||||||
//cout << "Not displaying, trns was " << trns << '\n';
|
//cout << "Not displaying, trns was " << trns << '\n';
|
||||||
}
|
}
|
||||||
|
@ -543,7 +545,9 @@ void FGTower::Respond() {
|
||||||
string trns = t->plane.callsign;
|
string trns = t->plane.callsign;
|
||||||
trns += " hold position";
|
trns += " hold position";
|
||||||
if(_display) {
|
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.
|
// TODO - add some idea of what traffic is blocking him.
|
||||||
}
|
}
|
||||||
|
@ -581,7 +585,9 @@ void FGTower::Respond() {
|
||||||
t->clearedToLand = false;
|
t->clearedToLand = false;
|
||||||
}
|
}
|
||||||
if(_display && disp) {
|
if(_display && disp) {
|
||||||
globals->get_ATC_display()->RegisterSingleMessage(trns);
|
//globals->get_ATC_display()->RegisterSingleMessage(trns);
|
||||||
|
pending_transmission = trns;
|
||||||
|
Transmit();
|
||||||
}
|
}
|
||||||
t->finalAcknowledged = true;
|
t->finalAcknowledged = true;
|
||||||
} else if(t->rwyVacatedReported && !(t->rwyVacatedAcknowledged)) {
|
} else if(t->rwyVacatedReported && !(t->rwyVacatedAcknowledged)) {
|
||||||
|
@ -676,7 +682,9 @@ void FGTower::ProcessDownwindReport(TowerPlaneRec* t) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(_display) {
|
if(_display) {
|
||||||
globals->get_ATC_display()->RegisterSingleMessage(trns);
|
//globals->get_ATC_display()->RegisterSingleMessage(trns);
|
||||||
|
pending_transmission = trns;
|
||||||
|
Transmit();
|
||||||
}
|
}
|
||||||
if(t->isUser) {
|
if(t->isUser) {
|
||||||
if(t->opType == TTT_UNKNOWN) t->opType = CIRCUIT;
|
if(t->opType == TTT_UNKNOWN) t->opType = CIRCUIT;
|
||||||
|
@ -708,7 +716,9 @@ void FGTower::ProcessRunwayVacatedReport(TowerPlaneRec* t) {
|
||||||
}
|
}
|
||||||
//cout << "trns = " << trns << '\n';
|
//cout << "trns = " << trns << '\n';
|
||||||
if(_display) {
|
if(_display) {
|
||||||
globals->get_ATC_display()->RegisterSingleMessage(trns);
|
//globals->get_ATC_display()->RegisterSingleMessage(trns);
|
||||||
|
pending_transmission = trns;
|
||||||
|
Transmit();
|
||||||
}
|
}
|
||||||
RemoveFromRwyList(t->plane.callsign);
|
RemoveFromRwyList(t->plane.callsign);
|
||||||
AddToVacatedList(t);
|
AddToVacatedList(t);
|
||||||
|
@ -819,7 +829,9 @@ void FGTower::ClearHoldingPlane(TowerPlaneRec* t) {
|
||||||
timeSinceLastDeparture = 0.0;
|
timeSinceLastDeparture = 0.0;
|
||||||
}
|
}
|
||||||
if(_display) {
|
if(_display) {
|
||||||
globals->get_ATC_display()->RegisterSingleMessage(trns, 0);
|
//globals->get_ATC_display()->RegisterSingleMessage(trns, 0);
|
||||||
|
pending_transmission = trns;
|
||||||
|
Transmit();
|
||||||
}
|
}
|
||||||
//cout << "Done ClearHoldingPlane " << endl;
|
//cout << "Done ClearHoldingPlane " << endl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue