]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/atc_mgr.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / ATC / atc_mgr.cxx
index 828431674e46eaf46c83d5078619921090e0f3fe..88f527f32347d9b261578bb3efdb46b2d31856e2 100644 (file)
@@ -29,7 +29,6 @@
 #include <simgear/math/SGMath.hxx>
 #include <Airports/dynamics.hxx>
 #include <Airports/simple.hxx>
-
 #include "atc_mgr.hxx"
 
 
@@ -69,7 +68,6 @@ void FGATCManager::init() {
     double speed     = fgGetDouble("/velocities/groundspeed-kt");
     double aircraftRadius = 40; // note that this is currently hardcoded to a one-size-fits all JumboJet value. Should change later;
 
-    // Next, 
 
     ai_ac.setCallSign ( callsign  );
     ai_ac.setLongitude( longitude );
@@ -77,7 +75,20 @@ void FGATCManager::init() {
     ai_ac.setAltitude ( altitude  );
     ai_ac.setPerformance("jet_transport");
 
+    // NEXT UP: Create a traffic Schedule and fill that with appropriate information. This we can use to flight plannign.
+    FGAISchedule *trafficRef = new FGAISchedule;
+    trafficRef->setFlightType("gate");
+
+    FGScheduledFlight *flight =  new FGScheduledFlight;
+    flight->setDepartureAirport(airport);
+    flight->setArrivalAirport(airport);
+    flight->initializeAirports();
+    flight->setFlightRules("IFR");
+    flight->setCallSign(callsign);
+    
+    trafficRef->assign(flight);
     FGAIFlightPlan *fp = new FGAIFlightPlan;
+    ai_ac.setTrafficRef(trafficRef);
     
     string flightPlanName = airport + "-" + airport + ".xml";
     double cruiseAlt = 100; // Doesn't really matter right now.
@@ -105,7 +116,7 @@ void FGATCManager::init() {
             string fltType = "ga";
             fp->createTakeOff(&ai_ac, false, apt, 0, fltType);
         } else {
-            controller = apt->getDynamics()->getGroundNetwork();
+            controller = apt->getDynamics()->getStartupController();
             int stationFreq = apt->getDynamics()->getGroundFrequency(2);
             cerr << "Setting radio frequency to : " << stationFreq << endl;
             fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
@@ -151,11 +162,22 @@ void FGATCManager::addController(FGATCController *controller) {
     activeStations.push_back(controller);
 }
 
-
-
 void FGATCManager::update ( double time ) {
     //cerr << "ATC update code is running at time: " << time << endl;
-   currentATCDialog->update(time);
-
-
+    currentATCDialog->update(time);
+    if (controller) {
+        double longitude = fgGetDouble("/position/longitude-deg");
+        double latitude  = fgGetDouble("/position/latitude-deg");
+        double heading   = fgGetDouble("/orientation/heading-deg");
+        double speed     = fgGetDouble("/velocities/groundspeed-kt");
+        double altitude  = fgGetDouble("/position/altitude-ft");
+
+        cerr << "Running FGATCManager::update()" << endl;
+        controller->updateAircraftInformation(ai_ac.getID(),
+                                              latitude,
+                                              longitude,
+                                              heading,
+                                              speed,
+                                              altitude, time);
+    }
 }