]> git.mxchange.org Git - flightgear.git/commitdiff
Some further work toward adding more AI/ATC messages. This patch provides
authordurk <durk>
Sat, 7 Feb 2009 17:17:07 +0000 (17:17 +0000)
committerTim Moore <timoore@redhat.com>
Mon, 9 Feb 2009 23:22:16 +0000 (00:22 +0100)
some prepratory work for assigning different operations to different
frequencies. It also returns a stub for returning an ATIS message ID.
Currently, the ATIC information ID is hardcoded to "Sierra", which needs
to be replaced by a dynamic ID once ATIS services are fully integrated
with the new trafficcontrol code. At least, it's marginally more realistic
then the previous information XX. :-).

src/ATC/trafficcontrol.cxx
src/ATC/trafficcontrol.hxx
src/Airports/dynamics.cxx
src/Airports/dynamics.hxx

index 0f7b868575ad594f440e8ad4a2df879a5de2ea41..594f4b68b183f6b6cfa01d6a429397f83a1a3547 100644 (file)
@@ -337,18 +337,21 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
 {
     string sender, receiver;
     int stationFreq = 0;
+    int taxiFreq    = 0;
+    string atisInformation;
     //double commFreqD;
     switch (msgDir) {
          case ATC_AIR_TO_GROUND:
              sender = rec->getAircraft()->getTrafficRef()->getCallSign();
              switch (rec->getLeg()) {
                  case 2:
+                 case 3:
                      stationFreq =
-                        rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency();
-                     receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
-                     break;
-                 case 3: 
+                        rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(rec->getLeg());
+                     taxiFreq =
+                        rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(3);
                      receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
+                     atisInformation = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getAtisInformation();
                      break;
                  case 4: 
                      receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Tower";
@@ -359,13 +362,15 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
              receiver = rec->getAircraft()->getTrafficRef()->getCallSign();
              switch (rec->getLeg()) {
                  case 2:
+                 case 3:
                  stationFreq =
-                        rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency();
-                     sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
-                     break;
-                 case 3: 
+                        rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(rec->getLeg());
+                     taxiFreq =
+                        rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(3);
                      sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
+                     atisInformation = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getAtisInformation();
                      break;
+
                  case 4: 
                      sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Tower";
                      break;
@@ -373,26 +378,30 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
              break;
          }
     string text;
+    string taxiFreqStr;
+    char buffer[7];
     switch (msgId) {
           case MSG_ANNOUNCE_ENGINE_START:
                text = sender + ". Ready to Start up";
                break;
           case MSG_REQUEST_ENGINE_START:
                text = receiver + ", This is " + sender + ". Position " +getGateName(rec->getAircraft()) +
-                       ". Information YY." +
+                       ". Information " + atisInformation + ". " +
                        rec->getAircraft()->getTrafficRef()->getFlightRules() + " to " + 
                        rec->getAircraft()->getTrafficRef()->getArrivalAirport()->getName() + ". Request start-up";
                break;
           case MSG_PERMIT_ENGINE_START:
-               text = receiver + ". Start-up approved. YY correct, runway ZZ, AAA departure, squawk BBBB. " +
-                      "For push-back and taxi clearance call CCC.CCC. " + sender + " control.";
+               taxiFreqStr = formatATCFrequency3_2(taxiFreq);
+               text = receiver + ". Start-up approved. " + atisInformation + " correct, runway ZZ, AAA departure, squawk BBBB. " +
+                      "For push-back and taxi clearance call " + taxiFreqStr + ". " + sender + " control.";
                break;
           case MSG_DENY_ENGINE_START:
                text = receiver + ". Standby";
                break;
          case MSG_ACKNOWLEDGE_ENGINE_START:
-               text = receiver + ". Start-up approved. YY correct, runway ZZ, AAA departure, squawk BBBB. " +
-                      "For push-back and taxi clearance call CCC.CCC. " + sender;
+               taxiFreqStr = formatATCFrequency3_2(taxiFreq);
+               text = receiver + ". Start-up approved. " + atisInformation + " correct, runway ZZ, AAA departure, squawk BBBB. " +
+                      "For push-back and taxi clearance call " + taxiFreqStr + ". " + sender;
                break;
            default:
                break;
@@ -406,12 +415,18 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
     // Display ATC message only when one of the radios is tuned
     // the relevant frequency.
     // Note that distance attenuation is currently not yet implemented
+    //cerr << "Transmitting " << text << " at " << stationFreq;
     if ((onBoardRadioFreqI0 == stationFreq) || (onBoardRadioFreqI1 == stationFreq)) {
         fgSetString("/sim/messages/atc", text.c_str());
         //cerr << "Printing Message: " << endl;
     }
 }
 
+string FGATCController::formatATCFrequency3_2(int freq) {
+    char buffer[7];
+    snprintf(buffer, 7, "%3.2f", ( (float) freq / 100.0) );
+    return string(buffer);
+}
 
 /***************************************************************************
  * class FGTowerController
index 66c4803e76fe36b3b76217d745eefba7aa7ceb7d..850a0f930c6fa1c81867b69bc6633a4d04c60da4 100644 (file)
@@ -204,6 +204,10 @@ class FGATCController
 {
 private:
   double dt_count;
+
+
+  string formatATCFrequency3_2(int );
+
 public:
   typedef enum {
       MSG_ANNOUNCE_ENGINE_START,
index 78927c820af39514de5017eae4a169ce4c6bc9f6..bef81ebe60bf228e5862ae039913a07e9be8f781 100644 (file)
@@ -54,11 +54,9 @@ using std::random_shuffle;
 FGAirportDynamics::FGAirportDynamics(FGAirport* ap) :
   _ap(ap), rwyPrefs(ap) {
   lastUpdate = 0;
-  for (int i = 0; i < 10; i++)
-     {
-       //avWindHeading [i] = 0;
-       //avWindSpeed   [i] = 0;
-     }
+
+  // For testing only. This needs to be refined when we move ATIS functionality over.
+  atisInformation = "Sierra";
 }
 
 // Note that the ground network should also be copied
@@ -76,11 +74,7 @@ FGAirportDynamics::FGAirportDynamics(const FGAirportDynamics& other) :
   for (il = other.takeoff.begin(); il != other.takeoff.end(); il++)
     takeoff.push_back(*il);
   lastUpdate = other.lastUpdate;
-  for (int i = 0; i < 10; i++)
-    {
-      //avWindHeading [i] = other.avWindHeading[i];
-      //avWindSpeed   [i] = other.avWindSpeed  [i];
-    }
+  atisInformation = other.atisInformation; 
 }
 
 // Destructor
@@ -515,3 +509,31 @@ double FGAirportDynamics::getElevation() const {
 const string& FGAirportDynamics::getId() const {
   return _ap->getId();
 }
+
+// Experimental: Return a different ground frequency depending on the leg of the
+// Flight. Leg should always have a minimum value of two when this function is called. 
+// Note that in this scheme, the assignment of various frequencies to various ground 
+// operations is completely arbitrary. As such, is a short cut I need to take now,
+// so that at least I can start working on assigning different frequencies to different
+// operations.
+
+int FGAirportDynamics::getGroundFrequency(int leg) { 
+     //return freqGround.size() ? freqGround[0] : 0; };
+     int groundFreq;
+     if (leg < 2) {
+         SG_LOG(SG_ATC, SG_ALERT, "Leg value is smaller than two at " << SG_ORIGIN);
+     }
+     if (freqGround.size() == 0) {
+         return 0;
+     }
+     if ((freqGround.size() >= leg-1) && (leg > 1)) {
+          groundFreq =  freqGround[leg-1];
+     }
+     if ((freqGround.size() < leg-1) && (leg > 1)) {
+          groundFreq = (freqGround.size() < (leg-2)) ? freqGround[freqGround.size()-1] : freqGround[leg-2];
+     }
+     if ((freqGround.size() >= leg-1) && (leg > 1)) {
+          groundFreq = freqGround[leg-2];
+     }
+    return groundFreq;
+}
\ No newline at end of file
index 96d906b88e29253c8a541e9b795ab9645e2fd5fd..9712c5b8059c8be5262f317d3df1e63e5bb919e4 100644 (file)
@@ -64,12 +64,7 @@ private:
   intVec freqTower;    // </TOWER>
   intVec freqApproach; // </APPROACH>
 
-  // Experimental keep a running average of wind dir and speed to prevent
-  // Erratic runway changes. 
-  // Note: I should add these to the copy constructor and assigment operator to be
-  // constistent
-  //double avWindHeading [10];
-  //double avWindSpeed   [10];
+  string atisInformation;
 
   string chooseRunwayFallback();
   bool innerGetActiveRunway(const string &trafficType, int action, string &runway);
@@ -107,13 +102,15 @@ public:
   //FGAirport *getAddress() { return this; };
   //const string &getName() const { return _name;};
   // Returns degrees
-  int getGroundFrequency() { return freqGround.size() ? freqGround[0] : 0; };
 
+
+  // ATC related functions. 
   FGStartupController *getStartupController() { return &startupController; };
   FGGroundNetwork     *getGroundNetwork()     { return &groundNetwork; };
   FGTowerController   *getTowerController()   { return &towerController; };
 
-  
+  const string& getAtisInformation() { return atisInformation; };
+  int getGroundFrequency(int leg); //{ return freqGround.size() ? freqGround[0] : 0; };
 
   void setRwyUse(const FGRunwayPreference& ref);
 };