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_
27 # error This library requires C++
30 #include <simgear/xml/easyxml.hxx>
32 #include <ATC/trafficcontrol.hxx>
33 #include "parking.hxx"
34 #include "groundnetwork.hxx"
35 #include "runwayprefs.hxx"
37 //typedef vector<float> DoubleVec;
38 //typedef vector<float>::iterator DoubleVecIterator;
43 class FGAirportDynamics {
48 FGParkingVec parkings;
49 FGRunwayPreference rwyPrefs;
50 FGStartupController startupController;
51 FGGroundNetwork groundNetwork;
52 FGTowerController towerController;
55 string prevTrafficType;
58 stringVec milActive, comActive, genActive, ulActive;
59 stringVec *currentlyActive;
60 intVec freqAwos; // </AWOS>
61 intVec freqUnicom; // </UNICOM>
62 intVec freqClearance;// </CLEARANCE>
63 intVec freqGround; // </GROUND>
64 intVec freqTower; // </TOWER>
65 intVec freqApproach; // </APPROACH>
67 // Experimental keep a running average of wind dir and speed to prevent
68 // Erratic runway changes.
69 // Note: I should add these to the copy constructor and assigment operator to be
71 //double avWindHeading [10];
72 //double avWindSpeed [10];
74 string chooseRunwayFallback();
75 bool innerGetActiveRunway(const string &trafficType, int action, string &runway);
77 FGAirportDynamics(FGAirport* ap);
78 FGAirportDynamics(const FGAirportDynamics &other);
81 void addAwosFreq (int val) { freqAwos.push_back(val); };
82 void addUnicomFreq (int val) { freqUnicom.push_back(val); };
83 void addClearanceFreq(int val) { freqClearance.push_back(val); };
84 void addGroundFreq (int val) { freqGround.push_back(val); };
85 void addTowerFreq (int val) { freqTower.push_back(val); };
86 void addApproachFreq (int val) { freqApproach.push_back(val); };
89 double getLongitude() const;
91 double getLatitude() const;
93 double getElevation() const;
94 const string& getId() const;
96 void getActiveRunway(const string& trafficType, int action, string& runway);
98 void addParking(FGParking& park);
99 bool getAvailableParking(double *lat, double *lon,
100 double *heading, int *gate, double rad, const string& fltype,
101 const string& acType, const string& airline);
102 void getParking (int id, double *lat, double* lon, double *heading);
103 FGParking *getParking(int i);
104 void releaseParking(int id);
105 string getParkingName(int i);
106 int getNrOfParkings() { return parkings.size(); };
107 //FGAirport *getAddress() { return this; };
108 //const string &getName() const { return _name;};
110 int getGroundFrequency() { return freqGround.size() ? freqGround[0] : 0; };
112 FGStartupController *getStartupController() { return &startupController; };
113 FGGroundNetwork *getGroundNetwork() { return &groundNetwork; };
114 FGTowerController *getTowerController() { return &towerController; };
118 void setRwyUse(const FGRunwayPreference& ref);