]> git.mxchange.org Git - flightgear.git/blob - src/ATC/ATCmgr.hxx
Patch from Melchior Franz:
[flightgear.git] / src / ATC / ATCmgr.hxx
1 // ATCMgr.hxx - definition of FGATCMgr 
2 // - a global management class for FlightGear generated ATC
3 //
4 // Written by David Luff, started February 2002.
5 //
6 // Copyright (C) 2002  David C Luff - david.luff@nottingham.ac.uk
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 #ifndef _FG_ATCMGR_HXX
23 #define _FG_ATCMGR_HXX
24
25 #include <Main/fgfs.hxx>
26 #include <Main/fg_props.hxx>
27
28 #include <list>
29
30 #include "atis.hxx"
31 #include "ATC.hxx"
32
33 SG_USING_STD(list);
34
35 class FGATCMgr : public FGSubsystem
36 {
37
38 private:
39
40     // A list of pointers to all currently active ATC classes
41     typedef list <FGATC*> atc_list_type;
42     typedef atc_list_type::iterator atc_list_iterator;
43     typedef atc_list_type::const_iterator atc_list_const_iterator;
44
45     // Everything put in this list should be created dynamically
46     // on the heap and ***DELETED WHEN REMOVED!!!!!***
47     atc_list_type atc_list;
48     atc_list_iterator atc_list_itr;
49     // Any member function of FGATCMgr is permitted to leave this iterator pointing
50     // at any point in or at the end of the list.
51     // Hence any new access must explicitly first check for atc_list.end() before dereferencing.
52
53     // Position of the Users Aircraft
54     double lon;
55     double lat;
56     double elev;
57
58     atc_type comm1_type;
59     atc_type comm2_type;
60
61     double comm1_freq;
62     double comm2_freq;
63
64     // Pointers to users current communication frequencies.
65     SGPropertyNode *comm1_node;
66     SGPropertyNode *comm2_node;
67
68     // Pointers to current users position
69     SGPropertyNode *lon_node;
70     SGPropertyNode *lat_node;
71     SGPropertyNode *elev_node;
72
73     // Position of the ATC that the comm radios are tuned to in order to decide whether transmission
74     // will be received
75     double comm1_x, comm1_y, comm1_z, comm1_elev;
76     double comm1_range, comm1_effective_range;
77     bool comm1_valid; 
78     const char* comm1_ident;
79     const char* last_comm1_ident;
80     double comm2_x, comm2_y, comm2_z, comm2_elev;
81     double comm2_range, comm2_effective_range;
82     bool comm2_valid;
83     const char* comm2_ident;
84     const char* last_comm2_ident;
85
86     FGATIS atis;
87     //FGTower tower;
88     //FGGround ground;
89     //FGApproach approach;
90     //FGDeparture departure;
91
92 public:
93
94     FGATCMgr();
95     ~FGATCMgr();
96
97     void init();
98
99     void bind();
100
101     void unbind();
102
103     void update(int dt);
104
105 private:
106
107     // Remove a class from the atc_list and delete it from memory
108     void RemoveFromList(const char* id, atc_type tp);
109
110     // Search a specified freq for matching stations
111     void Search();
112
113 };
114
115 #endif  // _FG_ATCMGR_HXX