1 // dynamics.hxx - a class to manage the higher order airport ground activities
2 // Written by Durk Talsma, started December 2004.
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef _AIRPORT_DYNAMICS_HXX_
23 #define _AIRPORT_DYNAMICS_HXX_
27 #include <simgear/structure/SGReferenced.hxx>
28 #include <simgear/timing/timestamp.hxx>
30 #include <ATC/trafficcontrol.hxx>
31 #include <ATC/GroundController.hxx>
33 #include "airports_fwd.hxx"
34 #include "parking.hxx"
35 #include "runwayprefs.hxx"
37 class ParkingAssignment
43 // create a parking assignment (and mark it as unavailable)
44 ParkingAssignment(FGParking* pk, FGAirportDynamics* apt);
46 ParkingAssignment(const ParkingAssignment& aOther);
47 void operator=(const ParkingAssignment& aOther);
50 FGParking* parking() const;
56 class ParkingAssignmentPrivate;
57 ParkingAssignmentPrivate* _sharedData;
60 class FGAirportDynamics : public SGReferenced
66 typedef std::set<FGParkingRef> ParkingSet;
67 // if a parking item is in this set, it is occupied
68 ParkingSet occupiedParkings;
70 FGRunwayPreference rwyPrefs;
71 FGStartupController startupController;
72 FGTowerController towerController;
73 FGApproachController approachController;
74 FGGroundController groundController;
77 std::string prevTrafficType;
80 stringVec milActive, comActive, genActive, ulActive;
81 stringVec *currentlyActive;
83 int atisSequenceIndex;
84 double atisSequenceTimeStamp;
86 std::string chooseRunwayFallback();
87 bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
88 std::string chooseRwyByHeading(stringVec rwys, double heading);
90 FGParking* innerGetAvailableParking(double radius, const std::string & flType,
91 const std::string & airline,
92 bool skipEmptyAirlineCode);
94 std::string fallbackGetActiveRunway(int action, double heading);
96 // runway preference fallback data
97 SGTimeStamp _lastFallbackUpdate;
98 FGRunwayList _fallbackDepartureRunways,
99 _fallbackArrivalRunways;
100 unsigned int _fallbackRunwayCounter;
103 FGAirportDynamics(FGAirport* ap);
104 virtual ~FGAirportDynamics();
108 double getElevation() const;
109 const std::string getId() const;
111 FGAirport* parent() const
114 void getActiveRunway( const std::string& trafficType,
119 bool hasParkings() const;
122 * retrieve an available parking by GateID, or -1 if no suitable
123 * parking location could be found.
125 ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
126 const std::string& acType, const std::string& airline);
128 void setParkingAvailable(FGParking* park, bool available);
130 bool isParkingAvailable(FGParking* parking) const;
132 void releaseParking(FGParking* id);
134 FGParkingList getParkings(bool onlyAvailable, const std::string& type) const;
137 * Find a parking gate index by name. Note names are often not unique
138 * in our data, so will return the first match. If the parking is found,
139 * it will be marked as in-use (unavailable)
141 ParkingAssignment getParkingByName(const std::string& name) const;
143 // ATC related functions.
144 FGStartupController *getStartupController() {
145 return &startupController;
147 FGGroundController *getGroundController() {
148 return &groundController;
150 FGTowerController *getTowerController() {
151 return &towerController;
153 FGApproachController *getApproachController() {
154 return &approachController;
157 FGGroundNetwork* getGroundNetwork() const;
159 int getGroundFrequency(unsigned leg);
160 int getTowerFrequency (unsigned nr);
162 /// get current ATIS sequence letter
163 const std::string getAtisSequence();
165 /// get the current ATIS sequence number, updating it if necessary
166 int updateAtisSequence(int interval, bool forceUpdate);
168 void setRwyUse(const FGRunwayPreference& ref);