]> git.mxchange.org Git - flightgear.git/blob - src/ATC/ground.hxx
A bunch of reorg and clean up of the KR 87 (adf) code including some
[flightgear.git] / src / ATC / ground.hxx
1 // FGGround - a class to provide ground control at larger airports.
2 //
3 // Written by David Luff, started March 2002.
4 //
5 // Copyright (C) 2002  David C. Luff - david.luff@nottingham.ac.uk
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 #ifndef _FG_GROUND_HXX
22 #define _FG_GROUND_HXX
23
24 #include <vector>
25 #include <list>
26 //#include <map>
27
28 SG_USING_STD(vector);
29 SG_USING_STD(list);
30 //SG_USING_STD(map);
31
32 //////////////////////////////////////////////////////
33 // Types for the logical network data structure
34 typedef enum arc_type {
35     RUNWAY,
36     TAXIWAY
37 };
38
39 typedef enum node_type {
40     GATE,
41     APRON,
42     HOLD
43 };
44
45 typedef struct arc {
46     int distance;
47     char* name;
48     arc_type type;
49 };
50
51 typedef list<arc> arc_list_type;
52 typedef arc_list_type::iterator arc_list_itr;
53 typedef arc_list_type::const_iterator arc_list_const_itr; 
54
55 typedef struct node {
56     point pos;
57     char* name;
58     node_type node;
59     arc_list arcs;
60 };
61
62 typedef vector<node> node_array_type;
63 typedef node_array_type::iterator node_array_itr;
64 typedef node_array_type::const_iterator node_array_const_itr;
65 // end logical network types
66 ///////////////////////////////////////////////////////
67
68 // somewhere in the ATC/AI system we are going to have defined something like
69 // typedef struct plane_rec
70 // list <PlaneRec> plane_rec_list_type
71
72 // A more specialist plane rec to include ground information
73 typedef struct ground_rec {
74     plane_rec plane;
75     point current_pos;
76     node destination;
77     node last_clearance;
78     bool cleared;  // set true when the plane has been cleared to somewhere
79     bool incoming; //true for arrivals, false for departures
80     // status?
81     // Almost certainly need to add more here
82 };
83
84 typedef list<ground_rec*> ground_rec_list;
85 typedef ground_rec_list::iterator ground_rec_list_itr;
86 typedef ground_rec_list::const_iterator ground_rec_list_const_itr;
87
88 ///////////////////////////////////////////////////////////////////////////////
89 //
90 // FGGround
91 //
92 ///////////////////////////////////////////////////////////////////////////////
93 class FGGround : public FGATC {
94
95 private:
96
97     // Need a data structure to hold details of the various active planes
98     // Need a data structure to hold details of the logical network
99     // including which gates are filled - or possibly another data structure
100     // with the positions of the inactive planes.
101     // Need a data structure to hold outstanding communications from aircraft.
102     // Possibly need a data structure to hold outstanding communications to aircraft.
103
104     // logical network
105     node_array_type network;
106
107     // Planes currently active
108     ground_rec_list ground_traffic;
109
110 public:
111
112     void Init();
113
114     void Update();
115
116     inline void SetDisplay() {display = true;}
117     inline void SetNoDisplay() {display = false;}
118
119     // Its possible that NewArrival and NewDeparture should simply be rolled into Request.
120
121     // Contact ground control on arrival, assumed to request any gate
122     void NewArrival(plane_rec plane);
123
124     // Contact ground control on departure, assumed to request currently active runway.
125     void NewDeparture(plane_rec plane);
126
127     // Contact ground control when the calling routine doesn't know if arrival
128     // or departure is appropriate.
129     void NewContact(plane_rec plane);
130
131     // Make a request of ground control.
132     void Request(ground_request request);
133
134 private:
135
136     // Find the shortest route through the logical network between two points.
137     FindShortestRoute(point a, point b);
138
139     // Project a point in WGS84 lat/lon onto the local gnomonic.
140     ConvertWGS84ToXY(sgVec3 wgs84, point xy);
141
142     // Assign a gate or parking location to a new arrival
143     AssignGate(ground_rec &g);
144
145     // Generate the next clearance for an airplane
146     NextClearance(ground_rec &g);
147
148 };
149
150 #endif  //_FG_GROUND_HXX