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) { freqAwos.push_back(val); };
75 void addUnicomFreq (int val) { freqUnicom.push_back(val); };
76 void addClearanceFreq(int val) { freqClearance.push_back(val); };
77 void addGroundFreq (int val) { freqGround.push_back(val); };
78 void addTowerFreq (int val) { freqTower.push_back(val); };
79 void addApproachFreq (int val) { freqApproach.push_back(val); };
82 double getLongitude() const;
84 double getLatitude() const;
86 double getElevation() const;
87 const string& getId() const;
89 void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
91 void addParking(FGParking& park);
92 bool getAvailableParking(double *lat, double *lon,
93 double *heading, int *gate, double rad, const string& fltype,
94 const string& acType, const string& airline);
95 void getParking (int id, double *lat, double* lon, double *heading);
96 FGParking *getParking(int i);
97 void releaseParking(int id);
98 string getParkingName(int i);
99 int getNrOfParkings() { return parkings.size(); };
100 //FGAirport *getAddress() { return this; };
101 //const string &getName() const { return _name;};
104 // Departure / Arrival procedures
105 FGSidStar * getSIDs() { return &SIDs; };
106 FGAIFlightPlan * getSID(string activeRunway, double heading);
109 // ATC related functions.
110 FGStartupController *getStartupController() { return &startupController; };
111 FGGroundNetwork *getGroundNetwork() { return &groundNetwork; };
112 FGTowerController *getTowerController() { return &towerController; };
113 FGApproachController *getApproachController() { return &approachController; };
115 int getGroundFrequency(unsigned leg);
116 int getTowerFrequency (unsigned nr);
118 /// get current ATIS sequence letter
119 const std::string getAtisSequence();
121 /// get the current ATIS sequence number, updating it if necessary
122 int updateAtisSequence(int interval, bool forceUpdate);
124 void setRwyUse(const FGRunwayPreference& ref);