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<PositionedID> ParkingSet;
62 // if a parking item is in this set, it is occupied
63 ParkingSet occupiedParkings;
65 FGRunwayPreference rwyPrefs;
66 FGStartupController startupController;
67 FGGroundNetwork groundNetwork;
68 FGTowerController towerController;
69 FGApproachController approachController;
72 std::string prevTrafficType;
75 stringVec milActive, comActive, genActive, ulActive;
76 stringVec *currentlyActive;
77 intVec freqAwos; // </AWOS>
78 intVec freqUnicom; // </UNICOM>
79 intVec freqClearance;// </CLEARANCE>
80 intVec freqGround; // </GROUND>
81 intVec freqTower; // </TOWER>
82 intVec freqApproach; // </APPROACH>
84 int atisSequenceIndex;
85 double atisSequenceTimeStamp;
87 std::string chooseRunwayFallback();
88 bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
89 std::string chooseRwyByHeading(stringVec rwys, double heading);
91 FGParking* innerGetAvailableParking(double radius, const std::string & flType,
92 const std::string & airline,
93 bool skipEmptyAirlineCode);
95 FGAirportDynamics(FGAirport* ap);
98 void addAwosFreq (int val) {
99 freqAwos.push_back(val);
101 void addUnicomFreq (int val) {
102 freqUnicom.push_back(val);
104 void addClearanceFreq(int val) {
105 freqClearance.push_back(val);
107 void addGroundFreq (int val) {
108 freqGround.push_back(val);
110 void addTowerFreq (int val) {
111 freqTower.push_back(val);
113 void addApproachFreq (int val) {
114 freqApproach.push_back(val);
119 double getElevation() const;
120 const std::string getId() const;
122 FGAirport* parent() const
125 void getActiveRunway( const std::string& trafficType,
131 * retrieve an available parking by GateID, or -1 if no suitable
132 * parking location could be found.
134 ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
135 const std::string& acType, const std::string& airline);
137 void setParkingAvailable(PositionedID guid, bool available);
139 bool isParkingAvailable(PositionedID parking) const;
141 FGParkingRef getParking(PositionedID i) const;
142 void releaseParking(PositionedID id);
143 std::string getParkingName(PositionedID i) const;
146 * Find a parking gate index by name. Note names are often not unique
147 * in our data, so will return the first match. If the parking is found,
148 * it will be marked as in-use (unavailable)
150 ParkingAssignment getParkingByName(const std::string& name) const;
152 // ATC related functions.
153 FGStartupController *getStartupController() {
154 return &startupController;
156 FGGroundNetwork *getGroundNetwork() {
157 return &groundNetwork;
159 FGTowerController *getTowerController() {
160 return &towerController;
162 FGApproachController *getApproachController() {
163 return &approachController;
166 int getGroundFrequency(unsigned leg);
167 int getTowerFrequency (unsigned nr);
169 /// get current ATIS sequence letter
170 const std::string getAtisSequence();
172 /// get the current ATIS sequence number, updating it if necessary
173 int updateAtisSequence(int interval, bool forceUpdate);
175 void setRwyUse(const FGRunwayPreference& ref);