]> git.mxchange.org Git - flightgear.git/blob - src/ATC/ground.cxx
Patch from Julian Foad:
[flightgear.git] / src / ATC / ground.cxx
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 #include "ground.hxx"
22
23 void FGGround::Init() {
24     display = false;
25 }
26
27 void FGGround::Update() {
28     // Each time step, what do we need to do?
29     // We need to go through the list of outstanding requests and acknowedgements
30     // and process at least one of them.
31     // We need to go through the list of planes under our control and check if
32     // any need to be addressed.
33     // We need to check for planes not under our control coming within our 
34     // control area and address if necessary.
35
36     // Lets take the example of a plane which has just contacted ground
37     // following landing - presumably requesting where to go?
38     // First we need to establish the position of the plane within the logical network.
39     // Next we need to decide where its going. 
40 }
41
42 void FGGround::NewArrival(plane_rec plane) {
43     // What are we going to do here?
44     // We need to start a new ground_rec and add the plane_rec to it
45     // We need to decide what gate we are going to clear it to.
46     // Then we need to add clearing it to that gate to the pending transmissions queue? - or simply transmit?
47     // Probably simply transmit for now and think about a transmission queue later if we need one.
48     // We might need one though in order to add a little delay for response time.
49     ground_rec* g = new ground_rec;
50     g->plane_rec = plane;
51     g->current_pos = ConvertWGS84ToXY(plane.pos);
52     g->node = GetNode(g->current_pos);  // TODO - might need to sort out node/arc here
53     AssignGate(g);
54     g->cleared = false;
55     ground_traffic.push_back(g);
56     NextClearance(g);
57 }
58
59 void FGGround::NewContact(plane_rec plane) {
60     // This is a bit of a convienience function at the moment and is likely to change.
61     if(at a gate or apron)
62         NewDeparture(plane);
63     else
64         NewArrival(plane);
65 }
66
67 void FGGround::NextClearance(ground_rec &g) {
68     // Need to work out where we can clear g to.
69     // Assume the pilot doesn't need progressive instructions
70     // We *should* already have a gate or holding point assigned by the time we get here
71     // but it wouldn't do any harm to check.
72
73     // For now though we will hardwire it to clear to the final destination.
74 }
75
76 void FGGround::AssignGate(ground_rec &g) {
77     // We'll cheat for now - since we only have the user's aircraft and a couple of airports implemented
78     // we'll hardwire the gate!
79     // In the long run the logic of which gate or area to send the plane to could be somewhat non-trivial.
80 }