]> git.mxchange.org Git - flightgear.git/commitdiff
Add airport dynamics manager
authorJames Turner <zakalawe@mac.com>
Sat, 5 Dec 2015 00:25:29 +0000 (00:25 +0000)
committerJames Turner <zakalawe@mac.com>
Sat, 5 Dec 2015 00:25:29 +0000 (00:25 +0000)
- decouple dynamic airport data from the static (nav-db) data.

18 files changed:
src/ATC/atc_mgr.cxx
src/ATC/atc_mgr.hxx
src/ATC/trafficcontrol.cxx
src/Airports/CMakeLists.txt
src/Airports/airport.cxx
src/Airports/airport.hxx
src/Airports/airportdynamicsmanager.cxx [new file with mode: 0644]
src/Airports/airportdynamicsmanager.hxx [new file with mode: 0644]
src/Airports/airports_fwd.hxx
src/Airports/dynamics.cxx
src/Airports/dynamics.hxx
src/Airports/groundnetwork.cxx
src/Airports/groundnetwork.hxx
src/Airports/xmlloader.cxx
src/Main/fg_init.cxx
src/Main/positioninit.cxx
src/Scripting/NasalPositioned.cxx
src/Scripting/NasalPositioned_cppbind.cxx

index c511b66f6c99ed38f36e9c054d38084935356f82..fc5a06c2aba645ba20d1ee59720781f623dddcda 100644 (file)
@@ -27,6 +27,7 @@
 #include <iostream>
 
 #include <Airports/dynamics.hxx>
+#include <Airports/airportdynamicsmanager.hxx>
 #include <Airports/airport.hxx>
 #include <Scenery/scenery.hxx>
 #include "atc_mgr.hxx"
@@ -102,17 +103,17 @@ void FGATCManager::init() {
     //time_t deptime = 0;        // just make sure how flightplan processing is affected by this...
 
 
-    FGAirport *apt = FGAirport::findByIdent(airport); 
-    if (apt && onGround) {// && !runway.empty()) {
-        FGAirportDynamics* dcs = apt->getDynamics();
+    FGAirportDynamicsRef dcs(flightgear::AirportDynamicsManager::find(airport));
+    if (dcs && onGround) {// && !runway.empty()) {
+
         ParkingAssignment pk(dcs->getParkingByName(parking));
       
         // No valid parking location, so either at the runway or at a random location.
         if (pk.isValid()) {
             dcs->setParkingAvailable(pk.parking(), false);
             fp = new FGAIFlightPlan;
-            controller = apt->getDynamics()->getStartupController();
-            int stationFreq = apt->getDynamics()->getGroundFrequency(1);
+            controller = dcs->getStartupController();
+            int stationFreq = dcs->getGroundFrequency(1);
             if (stationFreq > 0)
             {
                 //cerr << "Setting radio frequency to : " << stationFreq << endl;
@@ -128,7 +129,7 @@ void FGATCManager::init() {
             fp->setGate(pk);
             if (!(fp->createPushBack(&ai_ac,
                                      false,
-                                     apt,
+                                     dcs->parent(),
                                      aircraftRadius,
                                      fltType,
                                      aircraftType,
@@ -140,8 +141,8 @@ void FGATCManager::init() {
             
             
         } else if (!runway.empty()) {
-            controller = apt->getDynamics()->getTowerController();
-            int stationFreq = apt->getDynamics()->getTowerFrequency(2);
+            controller = dcs->getTowerController();
+            int stationFreq = dcs->getTowerFrequency(2);
             if (stationFreq > 0)
             {
                 //cerr << "Setting radio frequency to in airfrequency: " << stationFreq << endl;
@@ -151,7 +152,7 @@ void FGATCManager::init() {
             leg = 3;
             string fltType = "ga";
             fp->setRunway(runway);
-            fp->createTakeOff(&ai_ac, false, apt, 0, fltType);
+            fp->createTakeOff(&ai_ac, false, dcs->parent(), 0, fltType);
             ai_ac.setTakeOffStatus(2);
         } else {
                 // We're on the ground somewhere. Handle this case later.
@@ -189,6 +190,15 @@ void FGATCManager::addController(FGATCController *controller) {
     activeStations.push_back(controller);
 }
 
+void FGATCManager::removeController(FGATCController *controller)
+{
+    AtcVecIterator it;
+    it = std::find(activeStations.begin(), activeStations.end(), controller);
+    if (it != activeStations.end()) {
+        activeStations.erase(it);
+    }
+}
+
 void FGATCManager::update ( double time ) {
     //cerr << "ATC update code is running at time: " << time << endl;
     // Test code: let my virtual co-pilot handle ATC:
index 09d40197a36a7ec0294562d311a24367898bb6d3..9f9545730e2ba2e1399dfd12a06788706d45f17d 100644 (file)
@@ -59,6 +59,7 @@ public:
   ~FGATCManager();
   void init();
   void addController(FGATCController *controller);
+  void removeController(FGATCController* controller);
   void update(double time);
 };
   
index 065658058b1a3d452bb09767825a5926ec7ea2a6..e86ad1e534f9d16a37d71ce0896f7b3900339a81 100644 (file)
@@ -490,7 +490,8 @@ FGATCController::FGATCController()
 
 FGATCController::~FGATCController()
 {
-    //cerr << "running FGATController destructor" << endl;
+    FGATCManager *mgr = (FGATCManager*) globals->get_subsystem("ATC");
+    mgr->removeController(this);
 }
 
 string FGATCController::getGateName(FGAIAircraft * ref)
index e83261507a65dce36719e1ed1de387e8e1f947e5..48e8cf8245d2de4d7da187b550548c1db8c4a756 100644 (file)
@@ -15,6 +15,7 @@ set(SOURCES
        sidstar.cxx
        airport.cxx
        xmlloader.cxx
+        airportdynamicsmanager.cxx
        )
 
 set(HEADERS
@@ -33,6 +34,7 @@ set(HEADERS
        sidstar.hxx
        airport.hxx
        xmlloader.hxx
+        airportdynamicsmanager.hxx
        )
                
-flightgear_component(Airports "${SOURCES}" "${HEADERS}")
\ No newline at end of file
+flightgear_component(Airports "${SOURCES}" "${HEADERS}")
index 13f7a7a87c89f82310c3fdef3783d2c1a9e8e1c0..f284fb55ad50bc38874416311814665192ba10df 100644 (file)
@@ -46,8 +46,9 @@
 #include <Main/fg_props.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/pavement.hxx>
-#include <Airports/dynamics.hxx>
 #include <Airports/xmlloader.hxx>
+#include <Airports/dynamics.hxx>
+#include <Airports/airportdynamicsmanager.hxx>
 #include <Navaids/procedure.hxx>
 #include <Navaids/waypoint.hxx>
 #include <ATC/CommStation.hxx>
@@ -74,7 +75,6 @@ FGAirport::FGAirport( PositionedID aGuid,
     FGPositioned(aGuid, aType, id, location),
     _name(name),
     _has_metar(has_metar),
-    _dynamics(0),
     mTowerDataLoaded(false),
     mHasTower(false),
     mRunwaysLoaded(false),
@@ -90,8 +90,6 @@ FGAirport::FGAirport( PositionedID aGuid,
 
 FGAirport::~FGAirport()
 {
-    SG_LOG(SG_NAVAID, SG_INFO, "deleting airport:" << ident());
-    delete _dynamics;
 }
 
 bool FGAirport::isAirport() const
@@ -118,23 +116,6 @@ bool FGAirport::isAirportType(FGPositioned* pos)
     return (pos->type() >= AIRPORT) && (pos->type() <= SEAPORT);
 }
 
-FGAirportDynamics * FGAirport::getDynamics()
-{
-    if (_dynamics) {
-        return _dynamics;
-    }
-    
-    _dynamics = new FGAirportDynamics(this);
-    XMLLoader::load(_dynamics);
-    _dynamics->init();
-  
-    FGRunwayPreference rwyPrefs(this);
-    XMLLoader::load(&rwyPrefs);
-    _dynamics->setRwyUse(rwyPrefs);
-    
-    return _dynamics;
-}
-
 //------------------------------------------------------------------------------
 unsigned int FGAirport::numRunways() const
 {
@@ -983,6 +964,11 @@ void FGAirport::sortBySize(FGPositionedList& airportList)
     }
 }
 
+FGAirportDynamicsRef FGAirport::getDynamics() const
+{
+    return flightgear::AirportDynamicsManager::find(const_cast<FGAirport*>(this));
+}
+
 // get airport elevation
 double fgGetAirportElev( const std::string& id )
 {
index 598a1df07931ee2345513733ecb8f9e4c7fd5dd3..d5ad1a0e367dfb75768865cae1873f990777c902 100644 (file)
@@ -89,7 +89,7 @@ class FGAirport : public FGPositioned
 
     FGRunwayRef getActiveRunwayForUsage() const;
 
-    FGAirportDynamics *getDynamics();
+    FGAirportDynamicsRef getDynamics() const;
     
     unsigned int numRunways() const;
     unsigned int numHelipads() const;
@@ -323,7 +323,6 @@ private:
   
     std::string _name;
     bool _has_metar;
-    FGAirportDynamics *_dynamics;
 
     void loadRunways() const;
     void loadHelipads() const;
diff --git a/src/Airports/airportdynamicsmanager.cxx b/src/Airports/airportdynamicsmanager.cxx
new file mode 100644 (file)
index 0000000..99885fb
--- /dev/null
@@ -0,0 +1,107 @@
+// airportdynamicsmanager.cxx - manager for dynamic (changeable)
+// part of airport state
+//
+// Written by James Turner, started December 2015
+//
+// Copyright (C) 2015 James Turner <zakalawe@mac.com>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+#include "airportdynamicsmanager.hxx"
+
+#include <simgear/structure/exception.hxx>
+
+#include "airport.hxx"
+#include "xmlloader.hxx"
+#include "dynamics.hxx"
+#include "runwayprefs.hxx"
+
+#include <Main/globals.hxx>
+
+namespace flightgear
+{
+
+AirportDynamicsManager::AirportDynamicsManager()
+{
+
+}
+
+
+AirportDynamicsManager::~AirportDynamicsManager()
+{
+
+
+}
+
+void AirportDynamicsManager::init()
+{
+
+
+}
+
+void AirportDynamicsManager::shutdown()
+{
+    m_dynamics.clear();
+}
+
+void AirportDynamicsManager::update(double dt)
+{
+    SG_UNUSED(dt);
+}
+
+void AirportDynamicsManager::reinit()
+{
+    shutdown();
+    init();
+}
+
+FGAirportDynamicsRef AirportDynamicsManager::dynamicsForICAO(const std::string &icao)
+{
+    ICAODynamicsDict::iterator it = m_dynamics.find(icao);
+    if (it != m_dynamics.end()) {
+        return it->second;
+    }
+
+    FGAirportRef apt(FGAirport::findByIdent(icao));
+    if (!apt)
+        throw sg_exception("dynamicsForICAO: Invalid ICAO:" + icao);
+    FGAirportDynamicsRef d(new FGAirportDynamics(apt));
+
+    XMLLoader::load(d.ptr());
+    d->init();
+
+    FGRunwayPreference rwyPrefs(apt);
+    XMLLoader::load(&rwyPrefs);
+    d->setRwyUse(rwyPrefs);
+
+    m_dynamics[icao] = d;
+    return d;
+}
+
+FGAirportDynamicsRef AirportDynamicsManager::find(const std::string &icao)
+{
+    AirportDynamicsManager* instance = static_cast<AirportDynamicsManager*>(globals->get_subsystem("airport-dynamics"));
+    if (!instance)
+        return FGAirportDynamicsRef();
+
+    return instance->dynamicsForICAO(icao);
+}
+
+FGAirportDynamicsRef AirportDynamicsManager::find(const FGAirportRef& apt)
+{
+    return find(apt->ident());
+}
+
+} // of namespace flightgear
diff --git a/src/Airports/airportdynamicsmanager.hxx b/src/Airports/airportdynamicsmanager.hxx
new file mode 100644 (file)
index 0000000..26172db
--- /dev/null
@@ -0,0 +1,58 @@
+// airportdynamicsmanager.hxx - manager for dynamic (changeable)
+// part of airport state
+//
+// Written by James Turner, started December 2015
+//
+// Copyright (C) 2015 James Turner <zakalawe@mac.com>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+#ifndef AIRPORTDYNAMICSMANAGER_H
+#define AIRPORTDYNAMICSMANAGER_H
+
+#include <simgear/structure/subsystem_mgr.hxx>
+#include <simgear/structure/SGSharedPtr.hxx>
+
+#include <map>
+
+#include "airports_fwd.hxx"
+
+namespace flightgear
+{
+
+class AirportDynamicsManager : public SGSubsystem
+{
+public:
+    AirportDynamicsManager();
+    virtual ~AirportDynamicsManager();
+
+    virtual void init();
+    virtual void shutdown();
+    virtual void update (double dt);
+    virtual void reinit();
+
+    static FGAirportDynamicsRef find(const std::string& icao);
+
+    static FGAirportDynamicsRef find(const FGAirportRef& apt);
+
+    FGAirportDynamicsRef dynamicsForICAO(const std::string& icao);
+private:
+    typedef std::map<std::string, FGAirportDynamicsRef> ICAODynamicsDict;
+    ICAODynamicsDict m_dynamics;
+};
+
+} // of namespace
+
+#endif // AIRPORTDYNAMICSMANAGER_H
index a596f3db968aaa7337855a90d927424bca7431a7..3918a88346256deb1416bb8e08d6d9bfac5b2ed0 100644 (file)
@@ -79,6 +79,7 @@ typedef SGSharedPtr<FGHelipad> FGHelipadRef;
 typedef SGSharedPtr<FGTaxiway> FGTaxiwayRef;
 typedef SGSharedPtr<FGPavement> FGPavementRef;
 typedef SGSharedPtr<FGParking> FGParkingRef;
+typedef SGSharedPtr<FGAirportDynamics> FGAirportDynamicsRef;
 
 typedef std::vector<FGRunwayRef> FGRunwayList;
 typedef std::map<std::string, FGRunwayRef> FGRunwayMap;
index 9d17f2b3418f3c6fe0d6daac69589ecf8fa2bc4a..ffc4a095923dd6e4335c585869f2b7344bc76e94 100644 (file)
@@ -53,19 +53,19 @@ using std::random_shuffle;
 class ParkingAssignment::ParkingAssignmentPrivate
 {
 public:
-  ParkingAssignmentPrivate(FGParking* pk, FGAirport* apt) :
+  ParkingAssignmentPrivate(FGParking* pk, FGAirportDynamics* dyn) :
     refCount(0),
     parking(pk),
-    airport(apt)
+    dynamics(dyn)
   {
     assert(pk);
-    assert(apt);
+    assert(dyn);
     retain(); // initial count of 1
   }
   
   ~ParkingAssignmentPrivate()
   {
-    airport->getDynamics()->releaseParking(parking);
+    dynamics->releaseParking(parking);
   }
   
   void release()
@@ -82,7 +82,7 @@ public:
   
   unsigned int refCount;
   FGParkingRef parking;
-  FGAirportRef airport;
+  FGAirportDynamicsRef dynamics;
 };
 
 ParkingAssignment::ParkingAssignment() :
@@ -97,11 +97,11 @@ ParkingAssignment::~ParkingAssignment()
   }
 }
   
-ParkingAssignment::ParkingAssignment(FGParking* pk, FGAirport* apt) :
+ParkingAssignment::ParkingAssignment(FGParking* pk, FGAirportDynamics* dyn) :
   _sharedData(NULL)
 {
   if (pk) {
-    _sharedData = new ParkingAssignmentPrivate(pk, apt);
+    _sharedData = new ParkingAssignmentPrivate(pk, dyn);
   }
 }
 
@@ -164,13 +164,14 @@ FGAirportDynamics::FGAirportDynamics(FGAirport * ap):
 // Destructor
 FGAirportDynamics::~FGAirportDynamics()
 {
+    SG_LOG(SG_AI, SG_INFO, "destroyed dynamics for:" << _ap->ident());
 }
 
 
 // Initialization required after XMLRead
 void FGAirportDynamics::init()
 {
-    groundNetwork.init(_ap);
+    groundNetwork.init(this);
     groundNetwork.setTowerController(&towerController);
     
 }
@@ -213,18 +214,18 @@ ParkingAssignment FGAirportDynamics::getAvailableParking(double radius, const st
   // most exact seach - airline codes must be present and match
   FGParking* result = innerGetAvailableParking(radius, flType, airline, true);
   if (result) {
-    return ParkingAssignment(result, _ap);
+    return ParkingAssignment(result, this);
   }
   
   // more tolerant - gates with empty airline codes are permitted
   result = innerGetAvailableParking(radius, flType, airline, false);
   if (result) {
-    return ParkingAssignment(result, _ap);
+    return ParkingAssignment(result, this);
   }
 
   // fallback - ignore the airline code entirely
   result = innerGetAvailableParking(radius, flType, string(), false);
-  return result ? ParkingAssignment(result, _ap) : ParkingAssignment();
+  return result ? ParkingAssignment(result, this) : ParkingAssignment();
 }
 
 ParkingAssignment FGAirportDynamics::getParkingByName(const std::string& name) const
@@ -233,7 +234,7 @@ ParkingAssignment FGAirportDynamics::getParkingByName(const std::string& name) c
     FGParkingList::const_iterator it;
     for (it = parkings.begin(); it != parkings.end(); ++it) {
         if ((*it)->name() == name) {
-            return ParkingAssignment(*it, _ap);
+            return ParkingAssignment(*it, const_cast<FGAirportDynamics*>(this));
         }
     }
 
index 75a97f59873962c1c774e15bead4444cb66a9158..85c98b9d8e054e34214870ae3b7b93fb3f7ada3b 100644 (file)
@@ -24,6 +24,8 @@
 
 #include <set>
 
+#include <simgear/structure/SGReferenced.hxx>
+
 #include <ATC/trafficcontrol.hxx>
 #include "airports_fwd.hxx"
 #include "parking.hxx"
@@ -37,7 +39,7 @@ public:
   ~ParkingAssignment();
   
 // create a parking assignment (and mark it as unavailable)
-  ParkingAssignment(FGParking* pk, FGAirport* apt);
+  ParkingAssignment(FGParking* pk, FGAirportDynamics* apt);
   
   ParkingAssignment(const ParkingAssignment& aOther);
   void operator=(const ParkingAssignment& aOther);
@@ -53,7 +55,8 @@ private:
   ParkingAssignmentPrivate* _sharedData;
 };
 
-class FGAirportDynamics {
+class FGAirportDynamics : public SGReferenced
+{
 
 private:
     FGAirport* _ap;
@@ -140,7 +143,6 @@ public:
   
     bool isParkingAvailable(FGParking* parking) const;
   
-    FGParkingRef getParking(FGParking* i) const;
     void releaseParking(FGParking* id);
 
     FGParkingList getParkings(bool onlyAvailable, const std::string& type) const;
index a2c9b39ae829bd4e5f2cad9e1b01f92363c6f65b..1f337a9574e67ddd531cb43d1fba2639df1bead0 100644 (file)
@@ -175,7 +175,8 @@ bool compare_trafficrecords(FGTrafficRecord a, FGTrafficRecord b)
 }
 
 FGGroundNetwork::FGGroundNetwork() :
-  parent(NULL)
+    dynamics(NULL),
+    parent(NULL)
 {
     hasNetwork = false;
     totalDistance = 0;
@@ -199,7 +200,7 @@ FGGroundNetwork::~FGGroundNetwork()
   // owning references to ground-net nodes will also drop
 }
 
-void FGGroundNetwork::init(FGAirport* pr)
+void FGGroundNetwork::init(FGAirportDynamics* dyn)
 {
     if (networkInitialized) {
         SG_LOG(SG_GENERAL, SG_WARN, "duplicate ground-network init");
@@ -207,7 +208,8 @@ void FGGroundNetwork::init(FGAirport* pr)
         return;
     }
     
-    parent = pr;
+    dynamics = dyn;
+    parent = dyn->parent();
     assert(parent);
     hasNetwork = true;
     nextSave = 0;
@@ -407,8 +409,8 @@ void FGGroundNetwork::announcePosition(int id,
                                        FGAIAircraft * aircraft)
 {
     
-    assert(parent);
-    init(parent);
+    assert(dynamics);
+    init(dynamics);
   
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id alread has an entry
@@ -495,11 +497,11 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic
                 FGATCDialogNew::instance()->removeEntry(1);
             } else {
                 //cerr << "creating message for " << i->getAircraft()->getCallSign() << endl;
-                transmit(&(*i), &(*parent->getDynamics()), msgId, msgDir, false);
+                transmit(&(*i), dynamics, msgId, msgDir, false);
                 return false;
             }
         }
-        transmit(&(*i), &(*parent->getDynamics()), msgId, msgDir, true);
+        transmit(&(*i), dynamics, msgId, msgDir, true);
         i->updateState();
         lastTransmission = now;
         available = false;
@@ -846,11 +848,11 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
         if ((origStatus != currStatus) && available) {
             //cerr << "Issueing hold short instrudtion " << currStatus << " " << available << endl;
             if (currStatus == true) { // No has a hold short instruction
-                transmit(&(*current), &(*parent->getDynamics()), MSG_HOLD_POSITION, ATC_GROUND_TO_AIR, true);
+                transmit(&(*current), dynamics, MSG_HOLD_POSITION, ATC_GROUND_TO_AIR, true);
                 //cerr << "Transmittin hold short instrudtion " << currStatus << " " << available << endl;
                 current->setState(1);
             } else {
-                transmit(&(*current), &(*parent->getDynamics()), MSG_RESUME_TAXI, ATC_GROUND_TO_AIR, true);
+                transmit(&(*current), dynamics, MSG_RESUME_TAXI, ATC_GROUND_TO_AIR, true);
                 //cerr << "Transmittig resume instrudtion " << currStatus << " " << available << endl;
                 current->setState(2);
             }
@@ -1305,8 +1307,8 @@ void FGGroundNetwork::update(double dt)
     //sort(activeTraffic.begin(), activeTraffic.end(), compare_trafficrecords);
     // Handle traffic that is under ground control first; this way we'll prevent clutter at the gate areas.
     // Don't allow an aircraft to pushback when a taxiing aircraft is currently using part of the intended route.
-    for   (TrafficVectorIterator i = parent->getDynamics()->getStartupController()->getActiveTraffic().begin();
-            i != parent->getDynamics()->getStartupController()->getActiveTraffic().end(); i++) {
+    for   (TrafficVectorIterator i = dynamics->getStartupController()->getActiveTraffic().begin();
+            i != dynamics->getStartupController()->getActiveTraffic().end(); i++) {
         i->allowPushBack();
         i->setPriority(priority++);
         // in meters per second;
index 8e9b55cf9e3f23a5cc848706d60e52539af24781..3dd4c1cf043d3bd9bb13856ab26da13d1dd6b303 100644 (file)
@@ -177,6 +177,7 @@ class FGGroundNetwork : public FGATCController
 private:
     friend class FGAirportDynamicsXMLLoader;
 
+    FGAirportDynamics* dynamics; // weak back-pointer to our owner
     bool hasNetwork;
     bool networkInitialized;
     time_t nextSave;
@@ -218,7 +219,7 @@ public:
     void setVersion (int v) { version = v;};
     int getVersion() { return version; };
 
-    void init(FGAirport* pr);
+    void init(FGAirportDynamics* pr);
     bool exists() {
         return hasNetwork;
     };
index bc54e12478573b046ae14dd7fad51cda23ab1211..cdd36271437846b9cff945ead136771715e2a51b 100644 (file)
@@ -49,9 +49,9 @@ void XMLLoader::load(FGAirportDynamics* d)
     return;
   }
 
-
   SG_LOG(SG_NAVAID, SG_INFO, "reading groundnet data from " << path);
   SGTimeStamp t;
+  t.stamp();
   try {
       FGAirportDynamicsXMLLoader visitor(d);
       readXML(path.str(), visitor);
index 6e803d94f05b069bca32b6879d290a88aa670479..56111fbc93e319a1e502055d97c87548859472dd 100644 (file)
@@ -80,6 +80,7 @@
 #include <Airports/runways.hxx>
 #include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
+#include <Airports/airportdynamicsmanager.hxx>
 
 #include <AIModel/AIManager.hxx>
 
@@ -712,6 +713,11 @@ void fgCreateSubsystems(bool duringReset) {
     globals->add_subsystem("properties", new FGProperties);
 
 
+    ////////////////////////////////////////////////////////////////////
+    // Add the FlightGear property utilities.
+    ////////////////////////////////////////////////////////////////////
+    globals->add_subsystem("airport-dynamics", new flightgear::AirportDynamicsManager);
+
     ////////////////////////////////////////////////////////////////////
     // Add the performance monitoring system.
     ////////////////////////////////////////////////////////////////////
index 366f122cb6b1afb8daa2a1c76dd883b5bc0387be..b2221842b75c301b15a387e40578f1e875b9adcf 100644 (file)
@@ -196,7 +196,7 @@ static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& par
     SG_LOG( SG_GENERAL, SG_ALERT, "Failed to find airport " << id );
     return false;
   }
-  FGAirportDynamics* dcs = apt->getDynamics();
+  FGAirportDynamicsRef dcs = apt->getDynamics();
   if (!dcs) {
     SG_LOG( SG_GENERAL, SG_ALERT,
            "Airport " << id << "does not appear to have parking information available");
index 275929de2cf38b62204906126312eb08f861a062..4fe2ef9f76b6c23f9d7588b21bf89b3a105dba1e 100644 (file)
@@ -1351,7 +1351,7 @@ static naRef f_airport_parking(naContext c, naRef me, int argc, naRef* args)
     onlyAvailable = (args[1].num != 0.0);
   }
   
-  FGAirportDynamics* dynamics = apt->getDynamics();
+  FGAirportDynamicsRef dynamics = apt->getDynamics();
   FGParkingList parkings = dynamics->getParkings(onlyAvailable, type);
   FGParkingList::const_iterator it;
   for (it = parkings.begin(); it != parkings.end(); ++it) {
index eef345155f040aa4c78ea64b7d29a5caaa137378..35de1747af04f242a81ea1a07124fbbc541bdf44 100644 (file)
@@ -208,7 +208,7 @@ f_airport_parking(FGAirport& apt, nasal::CallContext ctx)
 {
   std::string type = ctx.getArg<std::string>(0);
   bool only_available = ctx.getArg<bool>(1);
-  FGAirportDynamics* dynamics = apt.getDynamics();
+  FGAirportDynamicsRef dynamics = apt.getDynamics();
   return dynamics->getParkings(only_available, type);
 }