]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/trafficcontrol.cxx
Fix two bugs in the new autopilot code
[flightgear.git] / src / ATC / trafficcontrol.cxx
index f9c2fee4e5fc6ef900774085e07a755e1f5fe533..ba00b60194f2288f4d3c6c1dc927983706867095 100644 (file)
@@ -38,15 +38,16 @@ FGTrafficRecord::FGTrafficRecord() :
   id(0), waitsForId(0),
   currentPos(0),
   leg(0),
+  frequencyId(0),
   state(0),
+   allowTransmission(true),
   latitude(0),
   longitude(0), 
    heading(0), 
    speed(0), 
    altitude(0), 
-   radius(0),
-   frequencyId(0),
-   allowTransmission(true) {
+   radius(0)
+{
 }
 
 void FGTrafficRecord::setPositionAndIntentions(int pos, FGAIFlightPlan *route)
@@ -65,7 +66,6 @@ void FGTrafficRecord::setPositionAndIntentions(int pos, FGAIFlightPlan *route)
      }
      intentions.erase(i);
    } else {
-     //int legNr, routeNr;
      //FGAIFlightPlan::waypoint* const wpt= route->getCurrentWaypoint();
      int size = route->getNrOfWayPoints();
      //cerr << "Setting pos" << pos << " ";
@@ -340,11 +340,27 @@ FGATCInstruction::FGATCInstruction()
   alt     = 0;
 }
 
+
 bool FGATCInstruction::hasInstruction()
 {
   return (holdPattern || holdPosition || changeSpeed || changeHeading || changeAltitude || resolveCircularWait);
 }
 
+/***************************************************************************
+ * FGATCController
+ *
+ **************************************************************************/
+
+
+
+
+FGATCController::FGATCController() 
+{
+     dt_count = 0; 
+     available = true; 
+     lastTransmission = 0;
+}
+
 string FGATCController::getGateName(FGAIAircraft *ref) 
 {
     return ref->atGate();
@@ -370,6 +386,7 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
 
     //double commFreqD;
     sender = rec->getAircraft()->getTrafficRef()->getCallSign();
+    //cerr << "transmitting for: " << sender << "Leg = " << rec->getLeg() << endl;
     switch (rec->getLeg()) {
         case 2:
         case 3:
@@ -449,6 +466,12 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
                taxiFreqStr = formatATCFrequency3_2(taxiFreq);
                text = receiver + ". Switching to " + taxiFreqStr + ". " + sender;
                break;
+           case MSG_INITIATE_CONTACT:
+                text = receiver + ". With you. " + sender;
+                break;
+           case MSG_ACKNOWLEDGE_INITIATE_CONTACT:
+                text = receiver + ". Roger. " + sender;
+                break;
            case MSG_REQUEST_PUSHBACK_CLEARANCE:
                text = receiver + ". Request push-back. " + sender;
                break;
@@ -457,9 +480,30 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
                break;
            case MSG_HOLD_PUSHBACK_CLEARANCE:
                 text = receiver + ". Standby. " + sender;
-                 break;
-            default:
-                 text = sender + ". Transmitting unknown Message";
+                break;
+           case MSG_REQUEST_TAXI_CLEARANCE:
+                text = receiver + ". Ready to Taxi. " + sender;
+                break;
+           case MSG_ISSUE_TAXI_CLEARANCE:
+                text = receiver + ". Cleared to taxi. " + sender;
+                break;
+           case MSG_ACKNOWLEDGE_TAXI_CLEARANCE:
+                text = receiver + ". Cleared to taxi. " + sender;
+                break;
+           case MSG_HOLD_POSITION:
+                text = receiver + ". Hold Position. " + sender;
+                break;
+           case MSG_ACKNOWLEDGE_HOLD_POSITION:
+                text = receiver + ". Holding Position. " + sender;
+                break;
+           case MSG_RESUME_TAXI:
+                text = receiver + ". Resume Taxiing. " + sender;
+                break;
+           case MSG_ACKNOWLEDGE_RESUME_TAXI:
+                text = receiver + ". Continuing Taxi. " + sender;
+                break;
+           default:
+                 text = text + sender + ". Transmitting unknown Message";
                   break;
     }
     double onBoardRadioFreq0 = fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
@@ -691,8 +735,6 @@ FGATCInstruction FGTowerController::getInstruction(int id)
 FGStartupController::FGStartupController() :
   FGATCController()
 {
-    available        = false;
-    lastTransmission = 0;
 }
 
 void FGStartupController::announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentPosition,
@@ -874,7 +916,7 @@ void FGStartupController::update(int id, double lat, double lon, double heading,
              available = false;
         }
      }
-     // Note: The next two stages are only necessesary when Startup control is
+     // Note: The next four stages are only necessesary when Startup control is
      //  on a different frequency, compared to ground control
      if ((state == 4) && available){
         if (now > startTime+130) {
@@ -885,20 +927,36 @@ void FGStartupController::update(int id, double lat, double lon, double heading,
              available = false;
         }
      }
+     if ((state == 5) && available){
+        if (now > startTime+140) {
+            transmit(&(*i), MSG_INITIATE_CONTACT, ATC_AIR_TO_GROUND);
+            i->updateState();
+            lastTransmission = now;
+             available = false;
+        }
+     }
+     if ((state == 6) && available){
+        if (now > startTime+150) {
+            transmit(&(*i), MSG_ACKNOWLEDGE_INITIATE_CONTACT, ATC_GROUND_TO_AIR);
+            i->updateState();
+            lastTransmission = now;
+             available = false;
+        }
+     }
 
 
      // TODO: Switch to APRON control and request pushback Clearance.
      // Get Push back clearance
-     if ((state == 5) && available){
-        if (now > startTime+160) {
+     if ((state == 7) && available){
+        if (now > startTime+180) {
             transmit(&(*i), MSG_REQUEST_PUSHBACK_CLEARANCE, ATC_AIR_TO_GROUND);
             i->updateState();
             lastTransmission = now;
              available = false;
         }
      }
-     if ((state == 6) && available){
-        if (now > startTime+180) {
+     if ((state == 8) && available){
+        if (now > startTime+200) {
             if (i->pushBackAllowed()) {
                  i->allowRepeatedTransmissions();
                  transmit(&(*i), MSG_PERMIT_PUSHBACK_CLEARANCE, ATC_GROUND_TO_AIR);
@@ -911,7 +969,7 @@ void FGStartupController::update(int id, double lat, double lon, double heading,
              available = false;
         }
      }
-     if ((state == 6) && available){
+     if ((state == 9) && available){
           i->setHoldPosition(false);
      }
 }