]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/dme.hxx
Added static port system and a new altimeter model connected to it.
[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/fgfs.hxx>
29 #include <Main/fg_props.hxx>
30
31 #include <simgear/compiler.h>
32
33 // #include <simgear/math/interpolater.hxx>
34 #include <simgear/timing/timestamp.hxx>
35
36 #include <Navaids/ilslist.hxx>
37 #include <Navaids/navlist.hxx>
38 // #include <Sound/beacon.hxx>
39 #include <Sound/morse.hxx>
40
41 // #include "kr_87.hxx"            // ADF
42 // #include "kt_70.hxx"            // Transponder
43 // #include "navcom.hxx"
44
45 class FGDME : public FGSubsystem
46 {
47     SGPropertyNode *lon_node;
48     SGPropertyNode *lat_node;
49     SGPropertyNode *alt_node;
50     SGPropertyNode *bus_power;
51     SGPropertyNode *navcom1_bus_power, *navcom2_bus_power;
52     SGPropertyNode *navcom1_power_btn, *navcom2_power_btn;
53     SGPropertyNode *navcom1_freq, *navcom2_freq;
54
55     bool need_update;
56
57     bool valid;
58     int switch_pos;
59     bool inrange;
60     double freq;
61     double lon;
62     double lat;
63     double elev;
64     double range;
65     double effective_range;
66     double x;
67     double y;
68     double z;
69     double dist;
70     double prev_dist;
71     double spd;
72     double ete;
73     SGTimeStamp last_time;
74
75 public:
76
77     FGDME();
78     ~FGDME();
79
80     void init ();
81     void bind ();
82     void unbind ();
83     void update (double dt);
84
85     // Update dme based on current postition
86     void search ();
87
88     // DME Setters
89     inline void set_freq (double freq) {
90         freq = freq; need_update = true;
91     }
92
93
94     // DME Accessors
95     inline bool has_power() const {
96         return (switch_pos == 1 || switch_pos == 3)
97             && (bus_power->getDoubleValue() > 1.0);
98     }
99     inline bool navcom1_on() const {
100         return (navcom1_bus_power->getDoubleValue() > 1.0)
101             && navcom1_power_btn->getBoolValue();
102     }
103     inline bool navcom2_on() const {
104         return (navcom2_bus_power->getDoubleValue() > 1.0)
105             && navcom2_power_btn->getBoolValue();
106     }
107     inline double get_freq () const { return freq; }
108
109     // Calculated values.
110     inline bool get_inrange () const { return inrange; }
111     inline double get_dist () const { return dist; }
112     inline double get_spd () const { return spd; }
113     inline double get_ete () const { return ete; }
114 };
115
116
117 #endif // _FG_DME_HXX