]> git.mxchange.org Git - flightgear.git/commitdiff
Some preparory work for enabling the handover from ground to tower controller.
authorDurk Talsma <durk@localhost.(none)>
Wed, 3 Aug 2011 21:09:52 +0000 (23:09 +0200)
committerDurk Talsma <durk@localhost.(none)>
Wed, 3 Aug 2011 21:09:52 +0000 (23:09 +0200)
src/AIModel/AIAircraft.cxx
src/AIModel/AIAircraft.hxx
src/AIModel/AIFlightPlanCreate.cxx
src/ATC/trafficcontrol.cxx
src/Airports/dynamics.cxx
src/Airports/groundnetwork.cxx

index 30b7cf9d3be6f2dbe7781e2f28867b91af66c093..eac6cd4fa59bb8460444a16a9f2b381d5ab87731 100644 (file)
@@ -65,9 +65,10 @@ FGAIAircraft::FGAIAircraft(FGAISchedule *ref) :
     else
         groundOffset = 0;
 
-    fp = 0;
-    controller = 0;
-    prevController = 0;
+    fp              = 0;
+    controller      = 0;
+    prevController  = 0;
+    towerController = 0;
     dt_count = 0;
     dt_elev_count = 0;
     use_perf_vs = true;
@@ -92,6 +93,7 @@ FGAIAircraft::FGAIAircraft(FGAISchedule *ref) :
 
     _performance = 0; //TODO initialize to JET_TRANSPORT from PerformanceDB
     dt = 0;
+    scheduledForTakeoff = false;
 }
 
 
@@ -555,6 +557,25 @@ void FGAIAircraft::announcePositionToController() {
     }
 }
 
+void FGAIAircraft::scheduleForATCTowerDepartureControl() {
+    if (!scheduledForTakeoff) {
+        int leg = fp->getLeg();
+        if (trafficRef) {
+            if (trafficRef->getDepartureAirport()->getDynamics()) {
+                towerController = trafficRef->getDepartureAirport()->getDynamics()->getTowerController();
+            } else {
+                cerr << "Error: Could not find Dynamics at airport : " << trafficRef->getDepartureAirport()->getId() << endl;
+            }
+            if (towerController) {
+                towerController->announcePosition(getID(), fp, fp->getCurrentWaypoint()->getRouteIndex(),
+                                                   _getLatitude(), _getLongitude(), hdg, speed, altitude_ft,
+                                                    trafficRef->getRadius(), leg, this);
+            }
+        }
+    }
+    scheduledForTakeoff = true;
+}
+
 // Process ATC instructions and report back
 
 void FGAIAircraft::processATC(FGATCInstruction instruction) {
@@ -791,6 +812,9 @@ bool FGAIAircraft::handleAirportEndPoints(FGAIWaypoint* prev, time_t now) {
     if (prev->contains("legend")) {
         fp->incrementLeg();
     }
+    if (prev->contains(string("DepartureHold"))) {
+        scheduleForATCTowerDepartureControl();
+    }
 
     // This is the last taxi waypoint, and marks the the end of the flight plan
     // so, the schedule should update and wait for the next departure time.
index 3921bacc6439d2e92e6a48a0758f8a6a0ae7e378..d8cbe9d604498e18dabf5f8b24a31878dedef7bc 100644 (file)
@@ -77,6 +77,9 @@ public:
     bool getTaxiClearanceRequest() { return needsTaxiClearance; };
     FGAISchedule * getTrafficRef() { return trafficRef; };
     void setTrafficRef(FGAISchedule *ref) { trafficRef = ref; };
+    void scheduleForATCTowerDepartureControl();
+
+    inline bool isScheduledForTakeoff() { return scheduledForTakeoff; };
 
     virtual const char* getTypeString(void) const { return "aircraft"; }
 
@@ -104,7 +107,9 @@ protected:
 
 private:
     FGAISchedule *trafficRef;
-    FGATCController *controller, *prevController; 
+    FGATCController *controller, 
+                    *prevController,
+                    *towerController; // Only needed to make a pre-announcement
 
     bool hdg_lock;
     bool alt_lock;
@@ -147,6 +152,7 @@ private:
     void checkVisibility();
     inline bool isStationary() { return ((fabs(speed)<=0.0001)&&(fabs(tgt_speed)<=0.0001));}
     inline bool needGroundElevation() { if (!isStationary()) _needsGroundElevation=true;return _needsGroundElevation;}
+   
 
     double sign(double x);
 
@@ -167,6 +173,7 @@ private:
     bool reachedWaypoint;
     bool needsTaxiClearance;
     bool _needsGroundElevation;
+    bool scheduledForTakeoff;
     time_t timeElapsed;
 
     PerformanceData* _performance; // the performance data for this aircraft
index 884bf25b6730afeb7caf33b98ceef2bbe9132d17..ddd18078c6130af72f294ba7277ee11be2cb56c1 100644 (file)
@@ -303,6 +303,10 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
             createOnGround(ac, buffer, tn->getGeod(), apt->getElevation(),
                            ac->getPerformance()->vTaxi());
         wpt->setRouteIndex(route);
+        if (taxiRoute->size() == 1) {
+            // Note that we actually have hold points in the ground network, but this is just an initial test.
+            wpt->setName( wpt->getName() + string("DepartureHold"));
+        }
         waypoints.push_back(wpt);
     }
     return true;
index 0e660b87e1ade80b5947269535f49a734b19237b..2690d5a3f7838c2eae61eb53f3bbb171b9269738 100644 (file)
@@ -86,7 +86,7 @@ time_t ActiveRunway::requestTimeSlot(time_t eta)
                 }
             } else {
                 if ((((*j) - (*i)) > (separation * 2))) {       // found a potential slot
-                    // now check whether this slow is usable:
+                    // now check whether this slot is usable:
                     // 1) eta should fall between the two points
                     //    i.e. eta > i AND eta < j
                     //
@@ -755,6 +755,7 @@ void FGTowerController::announcePosition(int id,
         //rec.setCallSign(callsign);
         rec.setAircraft(ref);
         activeTraffic.push_back(rec);
+        cerr << ref->getTrafficRef()->getCallSign() << " You are number " << activeTraffic.size() <<  " for takeoff " << endl;
     } else {
         i->setPositionAndHeading(lat, lon, heading, speed, alt);
     }
index 854b3b4819f5b5c3ecd065fe09118500b272be8c..c42635f4a078d3fb54e921bfa135b4749f72216a 100644 (file)
@@ -496,7 +496,7 @@ const string & FGAirportDynamics::getId() const
 int FGAirportDynamics::getGroundFrequency(unsigned leg)
 {
     //return freqGround.size() ? freqGround[0] : 0; };
-    cerr << "Getting frequency for : " << leg << endl;
+    //cerr << "Getting frequency for : " << leg << endl;
     int groundFreq = 0;
     if (leg < 1) {
         SG_LOG(SG_ATC, SG_ALERT,
index 36fdeeb1797a07bf4b204376a16a5b2b698031d4..a97f8075a00e93dd399a46b4b8f5b3a0bf3f8e02 100644 (file)
@@ -710,6 +710,8 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
             }
         }
         //Check traffic at the tower controller
+        // Note, as of 2011-08-01, this should no longer be necessecary.
+        /*
         if (towerController->hasActiveTraffic()) {
             for (TrafficVectorIterator i =
                  towerController->getActiveTraffic().begin();
@@ -731,6 +733,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
             }
         }
         // Finally, check UserPosition
+        // Note, as of 2011-08-01, this should no longer be necessecary.
         double userLatitude = fgGetDouble("/position/latitude-deg");
         double userLongitude = fgGetDouble("/position/longitude-deg");
         SGGeod user(SGGeod::fromDeg(userLongitude, userLatitude));
@@ -745,7 +748,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
             minbearing = bearing;
             otherReasonToSlowDown = true;
         }
-
+        */
         current->clearSpeedAdjustment();
 
         if (current->checkPositionAndIntentions(*closest)
@@ -761,6 +764,8 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
                 if (closest->getId() != current->getId())
                     current->setSpeedAdjustment(closest->getSpeed() *
                                                 (mindist / 100));
+                    if (closest->getAircraft()->isScheduledForTakeoff())
+                        current->getAircraft()->scheduleForATCTowerDepartureControl();
                 else
                     current->setSpeedAdjustment(0);     // This can only happen when the user aircraft is the one closest
                 if (mindist < maxAllowableDistance) {