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>
29 #include <ATC/trafficcontrol.hxx>
30 #include <ATC/GroundController.hxx>
32 #include "airports_fwd.hxx"
33 #include "parking.hxx"
34 #include "runwayprefs.hxx"
36 class ParkingAssignment
42 // create a parking assignment (and mark it as unavailable)
43 ParkingAssignment(FGParking* pk, FGAirportDynamics* apt);
45 ParkingAssignment(const ParkingAssignment& aOther);
46 void operator=(const ParkingAssignment& aOther);
49 FGParking* parking() const;
55 class ParkingAssignmentPrivate;
56 ParkingAssignmentPrivate* _sharedData;
59 class FGAirportDynamics : public SGReferenced
65 typedef std::set<FGParkingRef> ParkingSet;
66 // if a parking item is in this set, it is occupied
67 ParkingSet occupiedParkings;
70 std::auto_ptr<FGGroundNetwork> groundNetwork;
72 FGRunwayPreference rwyPrefs;
73 FGStartupController startupController;
74 FGTowerController towerController;
75 FGApproachController approachController;
76 FGGroundController groundController;
79 std::string prevTrafficType;
82 stringVec milActive, comActive, genActive, ulActive;
83 stringVec *currentlyActive;
84 intVec freqAwos; // </AWOS>
85 intVec freqUnicom; // </UNICOM>
86 intVec freqClearance;// </CLEARANCE>
87 intVec freqGround; // </GROUND>
88 intVec freqTower; // </TOWER>
89 intVec freqApproach; // </APPROACH>
91 int atisSequenceIndex;
92 double atisSequenceTimeStamp;
94 std::string chooseRunwayFallback();
95 bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
96 std::string chooseRwyByHeading(stringVec rwys, double heading);
98 FGParking* innerGetAvailableParking(double radius, const std::string & flType,
99 const std::string & airline,
100 bool skipEmptyAirlineCode);
102 FGAirportDynamics(FGAirport* ap);
103 virtual ~FGAirportDynamics();
105 void addAwosFreq (int val) {
106 freqAwos.push_back(val);
108 void addUnicomFreq (int val) {
109 freqUnicom.push_back(val);
111 void addClearanceFreq(int val) {
112 freqClearance.push_back(val);
114 void addGroundFreq (int val) {
115 freqGround.push_back(val);
117 void addTowerFreq (int val) {
118 freqTower.push_back(val);
120 void addApproachFreq (int val) {
121 freqApproach.push_back(val);
126 double getElevation() const;
127 const std::string getId() const;
129 FGAirport* parent() const
132 void getActiveRunway( const std::string& trafficType,
138 * retrieve an available parking by GateID, or -1 if no suitable
139 * parking location could be found.
141 ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
142 const std::string& acType, const std::string& airline);
144 void setParkingAvailable(FGParking* park, bool available);
146 bool isParkingAvailable(FGParking* parking) const;
148 void releaseParking(FGParking* id);
150 FGParkingList getParkings(bool onlyAvailable, const std::string& type) const;
153 * Find a parking gate index by name. Note names are often not unique
154 * in our data, so will return the first match. If the parking is found,
155 * it will be marked as in-use (unavailable)
157 ParkingAssignment getParkingByName(const std::string& name) const;
159 // ATC related functions.
160 FGStartupController *getStartupController() {
161 return &startupController;
163 FGGroundController *getGroundController() {
164 return &groundController;
166 FGTowerController *getTowerController() {
167 return &towerController;
169 FGApproachController *getApproachController() {
170 return &approachController;
173 FGGroundNetwork* getGroundNetwork() const
175 return groundNetwork.get();
178 int getGroundFrequency(unsigned leg);
179 int getTowerFrequency (unsigned nr);
181 /// get current ATIS sequence letter
182 const std::string getAtisSequence();
184 /// get the current ATIS sequence number, updating it if necessary
185 int updateAtisSequence(int interval, bool forceUpdate);
187 void setRwyUse(const FGRunwayPreference& ref);