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"
29 #include "sidstar.hxx"
35 class FGAirportDynamics {
40 FGParkingVec parkings;
41 FGRunwayPreference rwyPrefs;
43 FGStartupController startupController;
44 FGGroundNetwork groundNetwork;
45 FGTowerController towerController;
46 FGApproachController approachController;
49 std::string prevTrafficType;
52 stringVec milActive, comActive, genActive, ulActive;
53 stringVec *currentlyActive;
54 intVec freqAwos; // </AWOS>
55 intVec freqUnicom; // </UNICOM>
56 intVec freqClearance;// </CLEARANCE>
57 intVec freqGround; // </GROUND>
58 intVec freqTower; // </TOWER>
59 intVec freqApproach; // </APPROACH>
61 int atisSequenceIndex;
62 double atisSequenceTimeStamp;
64 std::string chooseRunwayFallback();
65 bool innerGetActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading);
66 std::string chooseRwyByHeading(stringVec rwys, double heading);
71 FGAirportDynamics(FGAirport* ap);
74 void addAwosFreq (int val) {
75 freqAwos.push_back(val);
77 void addUnicomFreq (int val) {
78 freqUnicom.push_back(val);
80 void addClearanceFreq(int val) {
81 freqClearance.push_back(val);
83 void addGroundFreq (int val) {
84 freqGround.push_back(val);
86 void addTowerFreq (int val) {
87 freqTower.push_back(val);
89 void addApproachFreq (int val) {
90 freqApproach.push_back(val);
94 double getLongitude() const;
96 double getLatitude() const;
98 double getElevation() const;
99 const string& getId() const;
101 void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
103 void addParking(FGParking& park);
104 bool getAvailableParking(double *lat, double *lon,
105 double *heading, int *gate, double rad, const string& fltype,
106 const string& acType, const string& airline);
107 void getParking (int id, double *lat, double* lon, double *heading);
108 FGParking *getParking(int i);
109 void releaseParking(int id);
110 string getParkingName(int i);
111 int getNrOfParkings() {
112 return parkings.size();
114 //FGAirport *getAddress() { return this; };
115 //const string &getName() const { return _name;};
118 // Departure / Arrival procedures
119 FGSidStar * getSIDs() {
122 FGAIFlightPlan * getSID(string activeRunway, double heading);
125 // ATC related functions.
126 FGStartupController *getStartupController() {
127 return &startupController;
129 FGGroundNetwork *getGroundNetwork() {
130 return &groundNetwork;
132 FGTowerController *getTowerController() {
133 return &towerController;
135 FGApproachController *getApproachController() {
136 return &approachController;
139 int getGroundFrequency(unsigned leg);
140 int getTowerFrequency (unsigned nr);
142 /// get current ATIS sequence letter
143 const std::string getAtisSequence();
145 /// get the current ATIS sequence number, updating it if necessary
146 int updateAtisSequence(int interval, bool forceUpdate);
148 void setRwyUse(const FGRunwayPreference& ref);