]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/kr_87.hxx
Commented out a cout statement.
[flightgear.git] / src / Cockpit / kr_87.hxx
1 // kr-87.hxx -- class to impliment the King KR 87 Digital ADF
2 //
3 // Written by Curtis Olson, started June 2002.
4 //
5 // Copyright (C) 2002  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_KR_87_HXX
25 #define _FG_KR_87_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/navlist.hxx>
37 #include <Sound/beacon.hxx>
38 #include <Sound/morse.hxx>
39
40
41 class FGKR_87 : public FGSubsystem
42 {
43     FGBeacon beacon;
44     FGMorse morse;
45
46     SGInterpTable *term_tbl;
47     SGInterpTable *low_tbl;
48     SGInterpTable *high_tbl;
49
50     SGPropertyNode *lon_node;
51     SGPropertyNode *lat_node;
52     SGPropertyNode *alt_node;
53
54     bool need_update;
55
56     string ident;
57     string trans_ident;
58     bool valid;
59     bool inrange;
60     double freq;
61     double stby_freq;
62     double rotation;
63     double stn_lon;
64     double stn_lat;
65     double stn_elev;
66     double range;
67     double effective_range;
68     double dist;
69     double heading;
70     double x;
71     double y;
72     double z;
73
74     double on_off_vol_btn;
75     bool adf_btn;               // 0 = normal, 1 = depressed
76     bool bfo_btn;               // 0 = normal, 1 = depressed
77     bool frq_btn;               // 0 = normal, 1 = depressed
78     bool last_frq_btn;
79     bool flt_et_btn;            // 0 = normal, 1 = depressed
80     bool last_flt_et_btn;
81     bool set_rst_btn;           // 0 = normal, 1 = depressed
82     bool last_set_rst_btn;           // 0 = normal, 1 = depressed
83     bool ident_btn;             // ???
84
85     double goal_needle_deg;
86     double needle_deg;
87     double flight_timer;
88     double elapsed_timer;
89     double tmp_timer;
90
91     int ant_mode;               // 0 = ADF mode (needle active), 1 = ANT mode
92                                 // (needle turned to 90, improved audio rcpt)
93     int stby_mode;              // 0 = show stby freq, 1 = show timer
94     int timer_mode;             // 0 = flt, 1 = et
95     int count_mode;             // 0 = count up, 1 = count down, 2 = set et
96                                 // count down
97
98 public:
99
100     FGKR_87();
101     ~FGKR_87();
102
103     void init ();
104     void bind ();
105     void unbind ();
106     void update (double dt);
107
108     // Update nav/adf radios based on current postition
109     void search ();
110
111     // ADF Setters
112     inline void set_freq( double f ) {
113         freq = f; need_update = true;
114     }
115     inline void set_stby_freq( double freq ) { stby_freq = freq; }
116     inline void set_rotation( double rot ) { rotation = rot; }
117     inline void set_on_off_vol_btn( double val ) {
118         if ( val < 0.0 ) val = 0.0;
119         if ( val > 1.0 ) val = 1.0;
120         on_off_vol_btn = val;
121     }
122     inline void set_ident_btn( bool val ) { ident_btn = val; }
123     inline void set_adf_btn( bool val ) { adf_btn = val; }
124     inline void set_bfo_btn( bool val ) { bfo_btn = val; }
125     inline void set_frq_btn( bool val ) { frq_btn = val; }
126     inline void set_flt_et_btn( bool val ) { flt_et_btn = val; }
127     inline void set_set_rst_btn( bool val ) { set_rst_btn = val; }
128     inline void set_elapsed_timer( double val ) { elapsed_timer = val; }
129
130     // ADF Accessors
131     inline double get_freq () const { return freq; }
132     double get_stby_freq () const;
133     inline double get_rotation () const { return rotation; }
134
135     // Calculated values
136     inline bool get_inrange() const { return inrange; }
137     inline double get_stn_lon() const { return stn_lon; }
138     inline double get_stn_lat() const { return stn_lat; }
139     inline double get_heading() const { return heading; }
140     inline double get_needle_deg() const { return needle_deg; }
141     inline double get_flight_timer() const { return flight_timer; }
142     inline double get_elapsed_timer() const { return elapsed_timer; }
143     inline double get_on_off_vol_btn() const { return on_off_vol_btn; }
144     inline int get_stby_mode() const { return stby_mode; }
145     inline int get_timer_mode() const { return timer_mode; }
146     inline int get_count_mode() const { return count_mode; }
147
148     // physical inputs
149     inline bool get_ident_btn() const { return ident_btn; }
150     inline bool get_adf_btn() const { return adf_btn; }
151     inline bool get_bfo_btn() const { return bfo_btn; }
152     inline bool get_frq_btn() const { return frq_btn; }
153     inline bool get_flt_et_btn() const { return flt_et_btn; }
154     inline bool get_set_rst_btn() const { return set_rst_btn; }
155 };
156
157
158 #endif // _FG_KR_87_HXX