]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/dme.hxx
Move FGEventMgr and FGSubsystemMgr over to SimGear, add SGEventMgr to FlightGear...
[flightgear.git] / src / Cockpit / dme.hxx
1 // dme.hxx -- class to manage an instance of the DME
2 //
3 // Written by Curtis Olson, started April 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - curt@flightgear.org
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 // $Id$
22
23
24 #ifndef _FG_DME_HXX
25 #define _FG_DME_HXX
26
27
28 #include <Main/fg_props.hxx>
29
30 #include <simgear/compiler.h>
31 #include <simgear/structure/subsystem_mgr.hxx>
32 // #include <simgear/math/interpolater.hxx>
33 #include <simgear/timing/timestamp.hxx>
34
35 #include <Navaids/ilslist.hxx>
36 #include <Navaids/navlist.hxx>
37 // #include <Sound/beacon.hxx>
38 #include <Sound/morse.hxx>
39
40 // #include "kr_87.hxx"            // ADF
41 // #include "kt_70.hxx"            // Transponder
42 // #include "navcom.hxx"
43
44 class FGDME : public SGSubsystem
45 {
46     SGPropertyNode *lon_node;
47     SGPropertyNode *lat_node;
48     SGPropertyNode *alt_node;
49     SGPropertyNode *bus_power;
50     SGPropertyNode *navcom1_bus_power, *navcom2_bus_power;
51     SGPropertyNode *navcom1_power_btn, *navcom2_power_btn;
52     SGPropertyNode *navcom1_freq, *navcom2_freq;
53
54     bool need_update;
55
56     bool valid;
57     int switch_pos;
58     bool inrange;
59     double freq;
60     double lon;
61     double lat;
62     double elev;
63     double range;
64     double effective_range;
65     double x;
66     double y;
67     double z;
68     double dist;
69     double prev_dist;
70     double spd;
71     double ete;
72     SGTimeStamp last_time;
73
74 public:
75
76     FGDME();
77     ~FGDME();
78
79     void init ();
80     void bind ();
81     void unbind ();
82     void update (double dt);
83
84     // Update dme based on current postition
85     void search ();
86
87     // DME Setters
88     inline void set_freq (double freq) {
89         freq = freq; need_update = true;
90     }
91
92
93     // DME Accessors
94     inline bool has_power() const {
95         return (switch_pos > 0)
96             && (bus_power->getDoubleValue() > 1.0);
97     }
98     inline bool navcom1_on() const {
99         return (navcom1_bus_power->getDoubleValue() > 1.0)
100             && navcom1_power_btn->getBoolValue();
101     }
102     inline bool navcom2_on() const {
103         return (navcom2_bus_power->getDoubleValue() > 1.0)
104             && navcom2_power_btn->getBoolValue();
105     }
106     inline double get_freq () const { return freq; }
107
108     // Calculated values.
109     inline bool get_inrange () const { return inrange; }
110     inline double get_dist () const { return dist; }
111     inline double get_spd () const { return spd; }
112     inline double get_ete () const { return ete; }
113 };
114
115
116 #endif // _FG_DME_HXX