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_
25 #include <ATC/trafficcontrol.hxx>
26 #include "parking.hxx"
27 #include "groundnetwork.hxx"
28 #include "runwayprefs.hxx"
34 class FGAirportDynamics {
39 FGParkingVec parkings;
40 FGRunwayPreference rwyPrefs;
41 FGStartupController startupController;
42 FGGroundNetwork groundNetwork;
43 FGTowerController towerController;
44 FGApproachController approachController;
47 std::string prevTrafficType;
50 stringVec milActive, comActive, genActive, ulActive;
51 stringVec *currentlyActive;
52 intVec freqAwos; // </AWOS>
53 intVec freqUnicom; // </UNICOM>
54 intVec freqClearance;// </CLEARANCE>
55 intVec freqGround; // </GROUND>
56 intVec freqTower; // </TOWER>
57 intVec freqApproach; // </APPROACH>
59 int atisSequenceIndex;
60 double atisSequenceTimeStamp;
62 std::string chooseRunwayFallback();
63 bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
64 std::string chooseRwyByHeading(stringVec rwys, double heading);
66 int innerGetAvailableParking(double radius, const std::string & flType,
67 const std::string & acType, const std::string & airline,
68 bool skipEmptyAirlineCode);
70 FGAirportDynamics(FGAirport* ap);
73 void addAwosFreq (int val) {
74 freqAwos.push_back(val);
76 void addUnicomFreq (int val) {
77 freqUnicom.push_back(val);
79 void addClearanceFreq(int val) {
80 freqClearance.push_back(val);
82 void addGroundFreq (int val) {
83 freqGround.push_back(val);
85 void addTowerFreq (int val) {
86 freqTower.push_back(val);
88 void addApproachFreq (int val) {
89 freqApproach.push_back(val);
94 double getElevation() const;
95 const std::string getId() const;
97 FGAirport* parent() const
100 void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
102 void addParking(FGParking& park);
105 * retrieve an available parking by GateID, or -1 if no suitable
106 * parking location could be found.
108 int getAvailableParking(double radius, const std::string& fltype,
109 const std::string& acType, const std::string& airline);
111 FGParking *getParking(int i);
112 void releaseParking(int id);
113 std::string getParkingName(int i);
114 int getNrOfParkings() {
115 return parkings.size();
119 * Find a parking gate index by name. Note names are often not unique
120 * in our data, so will return the first match.
122 int findParkingByName(const std::string& name) const;
124 // ATC related functions.
125 FGStartupController *getStartupController() {
126 return &startupController;
128 FGGroundNetwork *getGroundNetwork() {
129 return &groundNetwork;
131 FGTowerController *getTowerController() {
132 return &towerController;
134 FGApproachController *getApproachController() {
135 return &approachController;
138 int getGroundFrequency(unsigned leg);
139 int getTowerFrequency (unsigned nr);
141 /// get current ATIS sequence letter
142 const std::string getAtisSequence();
144 /// get the current ATIS sequence number, updating it if necessary
145 int updateAtisSequence(int interval, bool forceUpdate);
147 void setRwyUse(const FGRunwayPreference& ref);