]> git.mxchange.org Git - flightgear.git/blob - src/Autopilot/route_mgr.hxx
only activate heading & altitude lock when in air (and even then it should
[flightgear.git] / src / Autopilot / route_mgr.hxx
1 // route_mgr.hxx - manage a route (i.e. a collection of waypoints)
2 //
3 // Written by Curtis Olson, started January 2004.
4 //
5 // Copyright (C) 2004  Curtis L. Olson  - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _ROUTE_MGR_HXX
25 #define _ROUTE_MGR_HXX 1
26
27 #ifndef __cplusplus
28 # error This library requires C++
29 #endif
30
31 #ifdef HAVE_CONFIG_H
32 #  include <config.h>
33 #endif
34
35 #include <simgear/compiler.h>
36
37 #include STL_STRING
38 #include <vector>
39
40 SG_USING_STD(string);
41 SG_USING_STD(vector);
42
43 #include <simgear/props/props.hxx>
44 #include <simgear/route/route.hxx>
45 #include <simgear/structure/subsystem_mgr.hxx>
46
47
48 /**
49  * Top level route manager class
50  * 
51  */
52
53 class FGRouteMgr : public SGSubsystem
54 {
55
56 private:
57
58     SGRoute *route;
59
60     // automatic inputs
61     SGPropertyNode_ptr lon;
62     SGPropertyNode_ptr lat;
63     SGPropertyNode_ptr alt;
64
65     // automatic outputs
66     SGPropertyNode_ptr true_hdg_deg;
67     SGPropertyNode_ptr target_altitude_ft;
68     SGPropertyNode_ptr altitude_lock;
69
70     SGPropertyNode_ptr wp0_id;
71     SGPropertyNode_ptr wp0_dist;
72     SGPropertyNode_ptr wp0_eta;
73
74     SGPropertyNode_ptr wp1_id;
75     SGPropertyNode_ptr wp1_dist;
76     SGPropertyNode_ptr wp1_eta;
77
78     SGPropertyNode_ptr wpn_id;
79     SGPropertyNode_ptr wpn_dist;
80     SGPropertyNode_ptr wpn_eta;
81
82
83     class Listener : public SGPropertyChangeListener {
84     public:
85         Listener(FGRouteMgr *m) : mgr(m) {}
86         virtual void valueChanged (SGPropertyNode * prop);
87     private:
88         FGRouteMgr *mgr;
89     };
90
91     SGPropertyNode_ptr input;
92     Listener *listener;
93     SGPropertyNode_ptr mirror;
94     bool altitude_set;
95
96     int make_waypoint( SGWayPoint **wp, string& target );
97     void update_mirror();
98     bool on_ground();
99
100 public:
101
102     FGRouteMgr();
103     ~FGRouteMgr();
104
105     void init ();
106     void postinit ();
107     void bind ();
108     void unbind ();
109     void update (double dt);
110
111     bool build ();
112
113     int new_waypoint( const string& tgt_alt, int n = -1 );
114     void add_waypoint( const SGWayPoint& wp, int n = -1 );
115     SGWayPoint pop_waypoint( int i = 0 );
116
117     SGWayPoint get_waypoint( int i ) const {
118         return route->get_waypoint(i);
119     }
120
121     int size() const {
122         return route->size();
123     }
124
125 };
126
127
128 #endif // _ROUTE_MGR_HXX