]> git.mxchange.org Git - flightgear.git/blob - src/Airports/dynamics.hxx
Expose more things to Nasal for FMSs in particular - still work in progress.
[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 #include "sidstar.hxx"
30
31 // forward decls
32 class FGAirport;
33 class FGEnvironment;
34
35 class FGAirportDynamics {
36
37 private:
38     FGAirport* _ap;
39
40     FGParkingVec         parkings;
41     FGRunwayPreference   rwyPrefs;
42     FGSidStar            SIDs;
43     FGStartupController  startupController;
44     FGGroundNetwork      groundNetwork;
45     FGTowerController    towerController;
46     FGApproachController approachController;
47
48     time_t lastUpdate;
49     std::string prevTrafficType;
50     stringVec landing;
51     stringVec takeoff;
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>
60
61     int atisSequenceIndex;
62     double atisSequenceTimeStamp;
63
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);
67
68     double elevation;
69
70 public:
71     FGAirportDynamics(FGAirport* ap);
72     ~FGAirportDynamics();
73
74     void addAwosFreq     (int val) {
75         freqAwos.push_back(val);
76     };
77     void addUnicomFreq   (int val) {
78         freqUnicom.push_back(val);
79     };
80     void addClearanceFreq(int val) {
81         freqClearance.push_back(val);
82     };
83     void addGroundFreq   (int val) {
84         freqGround.push_back(val);
85     };
86     void addTowerFreq    (int val) {
87         freqTower.push_back(val);
88     };
89     void addApproachFreq (int val) {
90         freqApproach.push_back(val);
91     };
92
93     void init();
94     double getLongitude() const;
95     // Returns degrees
96     double getLatitude()  const;
97     // Returns ft
98     double getElevation() const;
99     const string& getId() const;
100
101     void getActiveRunway(const string& trafficType, int action, string& runway, double heading);
102
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();
113     };
114     //FGAirport *getAddress() { return this; };
115     //const string &getName() const { return _name;};
116     // Returns degrees
117
118     // Departure / Arrival procedures
119     FGSidStar * getSIDs() {
120         return &SIDs;
121     };
122     FGAIFlightPlan * getSID(string activeRunway, double heading);
123
124
125     // ATC related functions.
126     FGStartupController    *getStartupController()    {
127         return &startupController;
128     };
129     FGGroundNetwork        *getGroundNetwork()        {
130         return &groundNetwork;
131     };
132     FGTowerController      *getTowerController()      {
133         return &towerController;
134     };
135     FGApproachController   *getApproachController()   {
136         return &approachController;
137     };
138
139     int getGroundFrequency(unsigned leg);
140     int getTowerFrequency  (unsigned nr);
141
142     /// get current ATIS sequence letter
143     const std::string getAtisSequence();
144
145     /// get the current ATIS sequence number, updating it if necessary
146     int updateAtisSequence(int interval, bool forceUpdate);
147
148     void setRwyUse(const FGRunwayPreference& ref);
149 };
150
151
152
153 #endif