]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/dynamics.hxx
commradio: improvements for atis speech
[flightgear.git] / src / Airports / dynamics.hxx
index 3c787a9345fb186657ed11aab8ec1d5b12e48a8e..1368570da6ab77dd7d6aa6edd8030179ba9a1271 100644 (file)
@@ -14,7 +14,7 @@
 //
 // 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
 #ifndef _AIRPORT_DYNAMICS_HXX_
 #define _AIRPORT_DYNAMICS_HXX_
 
+#include <set>
 
-#ifndef __cplusplus                                                          
-# error This library requires C++
-#endif                        
+#include <ATC/trafficcontrol.hxx>
+#include "airports_fwd.hxx"
+#include "parking.hxx"
+#include "groundnetwork.hxx"
+#include "runwayprefs.hxx"
 
+class ParkingAssignment
+{
+public:
+  ParkingAssignment();
+  ~ParkingAssignment();
   
-
-class FGAirportDynamics : public XMLVisitor {
+// create a parking assignment (and mark it as unavailable)
+  ParkingAssignment(FGParking* pk, FGAirport* apt);
+  
+  ParkingAssignment(const ParkingAssignment& aOther);
+  void operator=(const ParkingAssignment& aOther);
+  
+  bool isValid() const;
+  FGParking* parking() const;
   
+  void release();
 private:
-  double _longitude;    // degrees
-  double _latitude;     // degrees
-  double _elevation;    // ft
-  string _id;
+  void clear();
 
-  FGParkingVec parkings;
-  FGRunwayPreference rwyPrefs;
-  FGGroundNetwork groundNetwork;
-
-  time_t lastUpdate;
-  string prevTrafficType;
-  stringVec landing;
-  stringVec takeoff;
-
-  // Experimental keep a running average of wind dir and speed to prevent
-  // Erratic runway changes. 
-  // Note: I should add these to the copy constructor and assigment operator to be
-  // constistent
-  double avWindHeading [10];
-  double avWindSpeed   [10];
+  class ParkingAssignmentPrivate;
+  ParkingAssignmentPrivate* _sharedData;
+};
 
-  string chooseRunwayFallback();
+class FGAirportDynamics {
 
+private:
+    FGAirport* _ap;
+
+    typedef std::set<PositionedID> ParkingSet;
+    // if a parking item is in this set, it is occupied
+    ParkingSet occupiedParkings;
+
+    FGRunwayPreference   rwyPrefs;
+    FGStartupController  startupController;
+    FGGroundNetwork      groundNetwork;
+    FGTowerController    towerController;
+    FGApproachController approachController;
+
+    time_t lastUpdate;
+    std::string prevTrafficType;
+    stringVec landing;
+    stringVec takeoff;
+    stringVec milActive, comActive, genActive, ulActive;
+    stringVec *currentlyActive;
+    intVec freqAwos;     // </AWOS>
+    intVec freqUnicom;   // </UNICOM>
+    intVec freqClearance;// </CLEARANCE>
+    intVec freqGround;   // </GROUND>
+    intVec freqTower;    // </TOWER>
+    intVec freqApproach; // </APPROACH>
+
+    int atisSequenceIndex;
+    double atisSequenceTimeStamp;
+
+    std::string chooseRunwayFallback();
+    bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
+    std::string chooseRwyByHeading(stringVec rwys, double heading);
+
+    FGParking* innerGetAvailableParking(double radius, const std::string & flType,
+                               const std::string & airline,
+                               bool skipEmptyAirlineCode);
 public:
-  FGAirportDynamics(double, double, double, string);
-  FGAirportDynamics(const FGAirportDynamics &other);
-  ~FGAirportDynamics();
-
-
-  void init();
-  double getLongitude() const { return _longitude;};
-  // Returns degrees
-  double getLatitude()  const { return _latitude; };
-  // Returns ft
-  double getElevation() const { return _elevation;};
+    FGAirportDynamics(FGAirport* ap);
+    ~FGAirportDynamics();
+
+    void addAwosFreq     (int val) {
+        freqAwos.push_back(val);
+    };
+    void addUnicomFreq   (int val) {
+        freqUnicom.push_back(val);
+    };
+    void addClearanceFreq(int val) {
+        freqClearance.push_back(val);
+    };
+    void addGroundFreq   (int val) {
+        freqGround.push_back(val);
+    };
+    void addTowerFreq    (int val) {
+        freqTower.push_back(val);
+    };
+    void addApproachFreq (int val) {
+        freqApproach.push_back(val);
+    };
+
+    void init();
   
-  void getActiveRunway(const string& trafficType, int action, string& runway);
-  bool getAvailableParking(double *lat, double *lon, 
-                          double *heading, int *gate, double rad, const string& fltype, 
-                          const string& acType, const string& airline);
-  void getParking         (int id, double *lat, double* lon, double *heading);
-  FGParking *getParking(int i);
-  void releaseParking(int id);
-  string getParkingName(int i); 
-  //FGAirport *getAddress() { return this; };
-  //const string &getName() const { return _name;};
-  // Returns degrees
-
- FGGroundNetwork* getGroundNetwork() { return &groundNetwork; };
+    double getElevation() const;
+    const std::string getId() const;
   
-
-  void setRwyUse(const FGRunwayPreference& ref);
-
- // Some overloaded virtual XMLVisitor members
-  virtual void startXML (); 
-  virtual void endXML   ();
-  virtual void startElement (const char * name, const XMLAttributes &atts);
-  virtual void endElement (const char * name);
-  virtual void data (const char * s, int len);
-  virtual void pi (const char * target, const char * data);
-  virtual void warning (const char * message, int line, int column);
-  virtual void error (const char * message, int line, int column);
+    FGAirport* parent() const
+    { return _ap; }
+  
+    void getActiveRunway( const std::string& trafficType,
+                          int action,
+                          std::string& runway,
+                          double heading );
+    
+    /**
+     * retrieve an available parking by GateID, or -1 if no suitable
+     * parking location could be found.
+     */
+    ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
+                          const std::string& acType, const std::string& airline);
+
+    void setParkingAvailable(PositionedID guid, bool available);
+  
+    bool isParkingAvailable(PositionedID parking) const;
+  
+    FGParkingRef getParking(PositionedID i) const;
+    void releaseParking(PositionedID id);
+    std::string getParkingName(PositionedID i) const;
+
+    /**
+     * Find a parking gate index by name. Note names are often not unique
+     * in our data, so will return the first match. If the parking is found,
+     * it will be marked as in-use (unavailable)
+     */
+    ParkingAssignment getParkingByName(const std::string& name) const;
+
+    // ATC related functions.
+    FGStartupController    *getStartupController()    {
+        return &startupController;
+    };
+    FGGroundNetwork        *getGroundNetwork()        {
+        return &groundNetwork;
+    };
+    FGTowerController      *getTowerController()      {
+        return &towerController;
+    };
+    FGApproachController   *getApproachController()   {
+        return &approachController;
+    };
+
+    int getGroundFrequency(unsigned leg);
+    int getTowerFrequency  (unsigned nr);
+
+    /// get current ATIS sequence letter
+    const std::string getAtisSequence();
+
+    /// get the current ATIS sequence number, updating it if necessary
+    int updateAtisSequence(int interval, bool forceUpdate);
+
+    void setRwyUse(const FGRunwayPreference& ref);
 };