]> git.mxchange.org Git - flightgear.git/commitdiff
Added some interface function to traffic manager related classes and added a traffic...
authorDurk Talsma <durk@localhost.(none)>
Tue, 12 Apr 2011 21:28:48 +0000 (23:28 +0200)
committerDurk Talsma <durk@localhost.(none)>
Tue, 12 Apr 2011 21:28:48 +0000 (23:28 +0200)
src/AIModel/AIAircraft.hxx
src/ATC/atc_mgr.cxx
src/ATC/trafficcontrol.cxx
src/Traffic/SchedFlight.cxx
src/Traffic/SchedFlight.hxx
src/Traffic/Schedule.cxx
src/Traffic/Schedule.hxx

index ea99462d8b5ff1b7984338f0501366e7f352acd4..ff7afad3ef8270572bff66aa13ea1e1608dd887c 100644 (file)
@@ -76,6 +76,7 @@ public:
     void setTaxiClearanceRequest(bool arg) { needsTaxiClearance = arg; };
     bool getTaxiClearanceRequest() { return needsTaxiClearance; };
     FGAISchedule * getTrafficRef() { return trafficRef; };
+    void setTrafficRef(FGAISchedule *ref) { trafficRef = ref; };
 
     virtual const char* getTypeString(void) const { return "aircraft"; }
 
index d8203552a550e17ab3eceb953252f1f1aaac8928..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 );
@@ -78,8 +76,19 @@ void FGATCManager::init() {
     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.
index aab81538f35830ff01314ebb0474b6dc341cec85..e24444d1317b2b49f94e9133fc9b96ed3c8e41ca 100644 (file)
@@ -1034,14 +1034,7 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l
 
     // The user controlled aircraft should have crased here, because it doesn't have a traffic reference. 
     // NOTE: if we create a traffic schedule for the user aircraft, we can use this to plan a flight.
-    time_t startTime = 0;
-    if (isUserAircraft(i->getAircraft())) {
-       cerr << i->getAircraft->getCallSign() << " is user aircraft " << endl;
-    } else {
-        time_t startTime =
-            i->getAircraft()->getTrafficRef()->getDepartureTime();
-
-    }
+    time_t startTime = i->getAircraft()->getTrafficRef()->getDepartureTime();
     time_t now = time(NULL) + fgGetLong("/sim/time/warp");
     //cerr << i->getAircraft()->getTrafficRef()->getCallSign() 
     //     << " is scheduled to depart in " << startTime-now << " seconds. Available = " << available
index 5575f6ee090f924b0f5aace94b140bced3cb5c17..e4d491b4a72d9ebfa2bb470ab8f652b346b55d09 100644 (file)
 
 FGScheduledFlight::FGScheduledFlight()
 {
-   initialized = false;
-   available = true;
+    departureTime  = 0;
+    arrivalTime    = 0;
+    cruiseAltitude = 0;
+    repeatPeriod   = 0;
+    initialized = false;
+    available = true;
 }
   
 FGScheduledFlight::FGScheduledFlight(const FGScheduledFlight &other)
index 0ee3eb6bd1f9c5b3056daa27b0488810ec53c59b..0567102fb89930307b107ca4a2a5ccfb269f4c0d 100644 (file)
@@ -90,6 +90,8 @@ public:
   time_t getDepartureTime() { return departureTime; };
   time_t getArrivalTime  () { return arrivalTime;   };
   
+  void setDepartureAirport(string port) { depId = port; };
+  void setArrivalAirport  (string port) { arrId = port; };
   FGAirport *getDepartureAirport();
   FGAirport *getArrivalAirport  ();
 
@@ -109,6 +111,9 @@ public:
   void release() { available = true; };
 
   bool isAvailable() { return available; };
+
+  void setCallSign(string val)    { callsign = val; };
+  void setFlightRules(string val) { fltRules = val; };
 };
 
 typedef vector<FGScheduledFlight*>           FGScheduledFlightVec;
index cb7fafb3d73918cd6cae455d220bd2600c786fe0..11d8d0abee3055a0fa84d460639c16242e8b080a 100644 (file)
@@ -344,6 +344,12 @@ bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots
   return true;
 }
 
+// Create an initial heading for user controlled aircraft.
+void FGAISchedule::setHeading()  
+{ 
+    courseToDest = SGGeodesy::courseDeg((*flights.begin())->getDepartureAirport()->geod(), (*flights.begin())->getArrivalAirport()->geod());
+}
+
 void FGAISchedule::scheduleFlights()
 {
   if (!flights.empty()) {
index cc80e40805a2a9d9878525302d514b4f37b6bd11..92b7e78aa0efb8ea55c4221b612bd653935e99c6 100644 (file)
@@ -117,6 +117,9 @@ class FGAISchedule
   void         setHits    (unsigned int count) { hits     = count; };
   void         setScore   ();
   double       getScore   () { return score; };
+  void         setHeading (); 
+  void         assign         (FGScheduledFlight *ref) { flights.push_back(ref); };
+  void         setFlightType  (string val            ) { flightType = val; };
   FGScheduledFlight*findAvailableFlight (const string &currentDestination, const string &req);
   // used to sort in decending order of score: I've probably found a better way to
   // decending order sorting, but still need to test that.