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 <ATC/trafficcontrol.hxx>
28 #include "airports_fwd.hxx"
29 #include "parking.hxx"
30 #include "groundnetwork.hxx"
31 #include "runwayprefs.hxx"
33 class ParkingAssignment
39 // create a parking assignment (and mark it as unavailable)
40 ParkingAssignment(FGParking* pk, FGAirport* apt);
42 ParkingAssignment(const ParkingAssignment& aOther);
43 void operator=(const ParkingAssignment& aOther);
46 FGParking* parking() const;
52 class ParkingAssignmentPrivate;
53 ParkingAssignmentPrivate* _sharedData;
56 class FGAirportDynamics {
61 typedef std::set<FGParkingRef> ParkingSet;
62 // if a parking item is in this set, it is occupied
63 ParkingSet occupiedParkings;
67 FGRunwayPreference rwyPrefs;
68 FGStartupController startupController;
69 FGGroundNetwork groundNetwork;
70 FGTowerController towerController;
71 FGApproachController approachController;
74 std::string prevTrafficType;
77 stringVec milActive, comActive, genActive, ulActive;
78 stringVec *currentlyActive;
79 intVec freqAwos; // </AWOS>
80 intVec freqUnicom; // </UNICOM>
81 intVec freqClearance;// </CLEARANCE>
82 intVec freqGround; // </GROUND>
83 intVec freqTower; // </TOWER>
84 intVec freqApproach; // </APPROACH>
86 int atisSequenceIndex;
87 double atisSequenceTimeStamp;
89 std::string chooseRunwayFallback();
90 bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
91 std::string chooseRwyByHeading(stringVec rwys, double heading);
93 FGParking* innerGetAvailableParking(double radius, const std::string & flType,
94 const std::string & airline,
95 bool skipEmptyAirlineCode);
97 FGAirportDynamics(FGAirport* ap);
100 void addAwosFreq (int val) {
101 freqAwos.push_back(val);
103 void addUnicomFreq (int val) {
104 freqUnicom.push_back(val);
106 void addClearanceFreq(int val) {
107 freqClearance.push_back(val);
109 void addGroundFreq (int val) {
110 freqGround.push_back(val);
112 void addTowerFreq (int val) {
113 freqTower.push_back(val);
115 void addApproachFreq (int val) {
116 freqApproach.push_back(val);
121 double getElevation() const;
122 const std::string getId() const;
124 FGAirport* parent() const
127 void getActiveRunway( const std::string& trafficType,
133 * retrieve an available parking by GateID, or -1 if no suitable
134 * parking location could be found.
136 ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
137 const std::string& acType, const std::string& airline);
139 void setParkingAvailable(FGParking* park, bool available);
141 bool isParkingAvailable(FGParking* parking) const;
143 FGParkingRef getParking(FGParking* i) const;
144 void releaseParking(FGParking* id);
146 FGParkingList getParkings(bool onlyAvailable, const std::string& type) const;
149 * Find a parking gate index by name. Note names are often not unique
150 * in our data, so will return the first match. If the parking is found,
151 * it will be marked as in-use (unavailable)
153 ParkingAssignment getParkingByName(const std::string& name) const;
155 // ATC related functions.
156 FGStartupController *getStartupController() {
157 return &startupController;
159 FGGroundNetwork *getGroundNetwork() {
160 return &groundNetwork;
162 FGTowerController *getTowerController() {
163 return &towerController;
165 FGApproachController *getApproachController() {
166 return &approachController;
169 int getGroundFrequency(unsigned leg);
170 int getTowerFrequency (unsigned nr);
172 /// get current ATIS sequence letter
173 const std::string getAtisSequence();
175 /// get the current ATIS sequence number, updating it if necessary
176 int updateAtisSequence(int interval, bool forceUpdate);
178 void setRwyUse(const FGRunwayPreference& ref);