]> git.mxchange.org Git - flightgear.git/blob - src/Airports/dynamics.hxx
cb489bfa3db458163ef71ac3cb01d0d91eedb8f3
[flightgear.git] / src / Airports / dynamics.hxx
1 // dynamics.hxx - a class to manage the higher order airport ground activities
2 // Written by Durk Talsma, started December 2004.
3 //
4 //
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.
9 //
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.
14 //
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.
18 //
19 // $Id$
20
21
22 #ifndef _AIRPORT_DYNAMICS_HXX_
23 #define _AIRPORT_DYNAMICS_HXX_
24
25 #include <ATC/trafficcontrol.hxx>
26 #include "parking.hxx"
27 #include "groundnetwork.hxx"
28 #include "runwayprefs.hxx"
29
30 // forward decls
31 class FGAirport;
32 class FGEnvironment;
33
34 class FGAirportDynamics {
35
36 private:
37     FGAirport* _ap;
38
39     FGParkingVec         parkings;
40     FGRunwayPreference   rwyPrefs;
41     FGStartupController  startupController;
42     FGGroundNetwork      groundNetwork;
43     FGTowerController    towerController;
44     FGApproachController approachController;
45
46     time_t lastUpdate;
47     std::string prevTrafficType;
48     stringVec landing;
49     stringVec takeoff;
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>
58
59     int atisSequenceIndex;
60     double atisSequenceTimeStamp;
61
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);
65
66   int innerGetAvailableParking(double radius, const std::string & flType,
67                                const std::string & acType, const std::string & airline,
68                                bool skipEmptyAirlineCode);
69 public:
70     FGAirportDynamics(FGAirport* ap);
71     ~FGAirportDynamics();
72
73     void addAwosFreq     (int val) {
74         freqAwos.push_back(val);
75     };
76     void addUnicomFreq   (int val) {
77         freqUnicom.push_back(val);
78     };
79     void addClearanceFreq(int val) {
80         freqClearance.push_back(val);
81     };
82     void addGroundFreq   (int val) {
83         freqGround.push_back(val);
84     };
85     void addTowerFreq    (int val) {
86         freqTower.push_back(val);
87     };
88     void addApproachFreq (int val) {
89         freqApproach.push_back(val);
90     };
91
92     void init();
93   
94     double getElevation() const;
95     const std::string getId() const;
96   
97     FGAirport* parent() const
98     { return _ap; }
99   
100     void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
101
102     void addParking(FGParking& park);
103     
104     /**
105      * retrieve an available parking by GateID, or -1 if no suitable
106      * parking location could be found.
107      */
108     int getAvailableParking(double radius, const std::string& fltype,
109                           const std::string& acType, const std::string& airline);
110
111     FGParking *getParking(int i);
112     void releaseParking(int id);
113     std::string getParkingName(int i);
114     int getNrOfParkings() {
115         return parkings.size();
116     };
117
118     /**
119      * Find a parking gate index by name. Note names are often not unique
120      * in our data, so will return the first match.
121      */
122     int findParkingByName(const std::string& name) const;
123
124     // ATC related functions.
125     FGStartupController    *getStartupController()    {
126         return &startupController;
127     };
128     FGGroundNetwork        *getGroundNetwork()        {
129         return &groundNetwork;
130     };
131     FGTowerController      *getTowerController()      {
132         return &towerController;
133     };
134     FGApproachController   *getApproachController()   {
135         return &approachController;
136     };
137
138     int getGroundFrequency(unsigned leg);
139     int getTowerFrequency  (unsigned nr);
140
141     /// get current ATIS sequence letter
142     const std::string getAtisSequence();
143
144     /// get the current ATIS sequence number, updating it if necessary
145     int updateAtisSequence(int interval, bool forceUpdate);
146
147     void setRwyUse(const FGRunwayPreference& ref);
148 };
149
150
151
152 #endif