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 "airports_fwd.hxx"
31 #include "parking.hxx"
32 #include "groundnetwork.hxx"
33 #include "runwayprefs.hxx"
35 class ParkingAssignment
41 // create a parking assignment (and mark it as unavailable)
42 ParkingAssignment(FGParking* pk, FGAirportDynamics* apt);
44 ParkingAssignment(const ParkingAssignment& aOther);
45 void operator=(const ParkingAssignment& aOther);
48 FGParking* parking() const;
54 class ParkingAssignmentPrivate;
55 ParkingAssignmentPrivate* _sharedData;
58 class FGAirportDynamics : public SGReferenced
64 typedef std::set<FGParkingRef> ParkingSet;
65 // if a parking item is in this set, it is occupied
66 ParkingSet occupiedParkings;
70 FGRunwayPreference rwyPrefs;
71 FGStartupController startupController;
72 FGGroundNetwork groundNetwork;
73 FGTowerController towerController;
74 FGApproachController approachController;
77 std::string prevTrafficType;
80 stringVec milActive, comActive, genActive, ulActive;
81 stringVec *currentlyActive;
82 intVec freqAwos; // </AWOS>
83 intVec freqUnicom; // </UNICOM>
84 intVec freqClearance;// </CLEARANCE>
85 intVec freqGround; // </GROUND>
86 intVec freqTower; // </TOWER>
87 intVec freqApproach; // </APPROACH>
89 int atisSequenceIndex;
90 double atisSequenceTimeStamp;
92 std::string chooseRunwayFallback();
93 bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
94 std::string chooseRwyByHeading(stringVec rwys, double heading);
96 FGParking* innerGetAvailableParking(double radius, const std::string & flType,
97 const std::string & airline,
98 bool skipEmptyAirlineCode);
100 FGAirportDynamics(FGAirport* ap);
101 ~FGAirportDynamics();
103 void addAwosFreq (int val) {
104 freqAwos.push_back(val);
106 void addUnicomFreq (int val) {
107 freqUnicom.push_back(val);
109 void addClearanceFreq(int val) {
110 freqClearance.push_back(val);
112 void addGroundFreq (int val) {
113 freqGround.push_back(val);
115 void addTowerFreq (int val) {
116 freqTower.push_back(val);
118 void addApproachFreq (int val) {
119 freqApproach.push_back(val);
124 double getElevation() const;
125 const std::string getId() const;
127 FGAirport* parent() const
130 void getActiveRunway( const std::string& trafficType,
136 * retrieve an available parking by GateID, or -1 if no suitable
137 * parking location could be found.
139 ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
140 const std::string& acType, const std::string& airline);
142 void setParkingAvailable(FGParking* park, bool available);
144 bool isParkingAvailable(FGParking* parking) const;
146 void releaseParking(FGParking* id);
148 FGParkingList getParkings(bool onlyAvailable, const std::string& type) const;
151 * Find a parking gate index by name. Note names are often not unique
152 * in our data, so will return the first match. If the parking is found,
153 * it will be marked as in-use (unavailable)
155 ParkingAssignment getParkingByName(const std::string& name) const;
157 // ATC related functions.
158 FGStartupController *getStartupController() {
159 return &startupController;
161 FGGroundNetwork *getGroundNetwork() {
162 return &groundNetwork;
164 FGTowerController *getTowerController() {
165 return &towerController;
167 FGApproachController *getApproachController() {
168 return &approachController;
171 int getGroundFrequency(unsigned leg);
172 int getTowerFrequency (unsigned nr);
174 /// get current ATIS sequence letter
175 const std::string getAtisSequence();
177 /// get the current ATIS sequence number, updating it if necessary
178 int updateAtisSequence(int interval, bool forceUpdate);
180 void setRwyUse(const FGRunwayPreference& ref);