]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/ATC.cxx
Fix the nmea and garmin output to a) fake a GSA sentence, b) fix a y2k bug
[flightgear.git] / src / ATC / ATC.cxx
index e5649bbdccb914c6270c8a2846c795a39df85d21..7adb85c4f7d97b00d45f5cd005858ae6d9ba14f4 100644 (file)
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-#include <Main/fgfs.hxx>
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <simgear/sound/soundmgr.hxx>
+
 #include <Main/fg_props.hxx>
-#include <Sound/soundmgr.hxx>
 
 #include "ATC.hxx"
 #include "ATCdisplay.hxx"
 
+FGATC::FGATC() {
+       freqClear = true;
+       receiving = false;
+       respond = false;
+       runResponseCounter = false;
+       responseID = "";
+       responseReqd = false;
+}
+
 FGATC::~FGATC() {
 }
 
+// Derived classes wishing to use the response counter should call this from their own Update(...).
 void FGATC::Update(double dt) {
+       if(runResponseCounter) {
+               //cout << responseCounter << '\t' << responseTime << '\n';
+               if(responseCounter >= responseTime) {
+                       runResponseCounter = false;
+                       respond = true;
+                       //cout << "RESPOND\n";
+               } else {
+                       responseCounter += dt;
+               }
+       }
+}
+
+void FGATC::ReceiveUserCallback(int code) {
+       SG_LOG(SG_ATC, SG_WARN, "WARNING - whichever ATC class was intended to receive callback code " << code << " didn't get it!!!");
+}
+
+void FGATC::SetResponseReqd(string rid) {
+       receiving = false;
+       responseReqd = true;
+       respond = false;        // TODO - this ignores the fact that more than one plane could call this before response
+                                               // Shouldn't happen with AI only, but user could confuse things??
+       responseID = rid;
+       runResponseCounter = true;
+       responseCounter = 0.0;
+       responseTime = 1.8;             // TODO - randomize this slightly.
+}
+
+void FGATC::NotifyTransmissionFinished(string rid) {
+       receiving = false;
+       responseID = rid;
+       if(responseReqd) {
+               runResponseCounter = true;
+               responseCounter = 0.0;
+               responseTime = 1.8;             // TODO - randomize this slightly.
+       } else {
+               freqClear = true;
+       }
 }
 
 void FGATC::AddPlane(string pid) {
 }
 
 int FGATC::RemovePlane() {
-    return 0;
+       return 0;
 }
 
 void FGATC::SetDisplay() {
@@ -45,7 +96,7 @@ void FGATC::SetNoDisplay() {
 }
 
 atc_type FGATC::GetType() {
-    return INVALID;
+       return INVALID;
 }
 
 void FGATC::SetData(ATCData* d) {
@@ -66,14 +117,14 @@ void FGATC::SetData(ATCData* d) {
 // 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 FGATC::Render(string msg, string refname, bool repeating) {
-#ifdef ENABLE_AUDIO_SUPPORT
+       #ifdef ENABLE_AUDIO_SUPPORT
        voice = (voiceOK && fgGetBool("/sim/sound/audible")
-                 && fgGetBool("/sim/sound/voice"));
+       && fgGetBool("/sim/sound/voice"));
        if(voice) {
                int len;
                unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, voice);
                if(voice) {
-                       FGSimpleSound* simple = new FGSimpleSound(buf, len);
+                       SGSimpleSound* simple = new SGSimpleSound(buf, len);
                        // TODO - at the moment the volume is always set off comm1 
                        // and can't be changed after the transmission has started.
                        simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
@@ -86,7 +137,7 @@ void FGATC::Render(string msg, string refname, bool repeating) {
                }
                delete[] buf;
        }
-#endif // ENABLE_AUDIO_SUPPORT
+       #endif  // ENABLE_AUDIO_SUPPORT
        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) {
@@ -104,10 +155,10 @@ void FGATC::Render(string msg, string refname, bool repeating) {
 void FGATC::NoRender(string refname) {
        if(playing) {
                if(voice) {
-#ifdef ENABLE_AUDIO_SUPPORT            
+                       #ifdef ENABLE_AUDIO_SUPPORT             
                        globals->get_soundmgr()->stop(refname);
                        globals->get_soundmgr()->remove(refname);
-#endif
+                       #endif
                } else {
                        globals->get_ATC_display()->CancelRepeatingMessage();
                }
@@ -115,22 +166,20 @@ void FGATC::NoRender(string refname) {
        }
 }
 
+// Generate the text of a message from its parameters and the current context.
+string FGATC::GenText(const string& m, int c) {
+       return("");
+}
+
 ostream& operator << (ostream& os, atc_type atc) {
-    switch(atc) {
-    case(INVALID):
-       return(os << "INVALID");
-    case(ATIS):
-       return(os << "ATIS");
-    case(GROUND):
-       return(os << "GROUND");
-    case(TOWER):
-       return(os << "TOWER");
-    case(APPROACH):
-       return(os << "APPROACH");
-    case(DEPARTURE):
-       return(os << "DEPARTURE");
-    case(ENROUTE):
-       return(os << "ENROUTE");
-    }
-    return(os << "ERROR - Unknown switch in atc_type operator << ");
+       switch(atc) {
+               case(INVALID):    return(os << "INVALID");
+               case(ATIS):       return(os << "ATIS");
+               case(GROUND):     return(os << "GROUND");
+               case(TOWER):      return(os << "TOWER");
+               case(APPROACH):   return(os << "APPROACH");
+               case(DEPARTURE):  return(os << "DEPARTURE");
+               case(ENROUTE):    return(os << "ENROUTE");
+       }
+       return(os << "ERROR - Unknown switch in atc_type operator << ");
 }