1 // kr-87.hxx -- class to impliment the King KR 87 Digital ADF
3 // Written by Curtis Olson, started June 2002.
5 // Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
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.
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.
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.
28 #include <Main/fg_props.hxx>
30 #include <simgear/compiler.h>
31 #include <simgear/structure/subsystem_mgr.hxx>
32 #include <simgear/timing/timestamp.hxx>
34 #include <Navaids/navlist.hxx>
35 #include <Sound/morse.hxx>
38 class FGKR_87 : public SGSubsystem
42 SGPropertyNode *lon_node;
43 SGPropertyNode *lat_node;
44 SGPropertyNode *alt_node;
45 SGPropertyNode *bus_power;
46 SGPropertyNode *serviceable;
59 double effective_range;
65 double goal_needle_deg;
69 int ant_mode; // 0 = ADF mode (needle active), 1 = ANT mode
70 // (needle turned to 90, improved audio rcpt)
71 int stby_mode; // 0 = show stby freq, 1 = show timer
72 int timer_mode; // 0 = flt, 1 = et
73 int count_mode; // 0 = count up, 1 = count down, 2 = set et
77 double rotation; // compass faceplace rotation
78 bool power_btn; // 0 = off, 1 = powered
79 bool audio_btn; // 0 = off, 1 = on
81 bool adf_btn; // 0 = normal, 1 = depressed
82 bool bfo_btn; // 0 = normal, 1 = depressed
83 bool frq_btn; // 0 = normal, 1 = depressed
85 bool flt_et_btn; // 0 = normal, 1 = depressed
87 bool set_rst_btn; // 0 = normal, 1 = depressed
88 bool last_set_rst_btn; // 0 = normal, 1 = depressed
106 // internal periodic station search timer
107 double _time_before_search_sec;
111 FGKR_87( SGPropertyNode *node );
117 void update (double dt_sec);
119 // Update nav/adf radios based on current postition
123 inline string get_ident() const { return ident; }
124 inline bool get_valid() const { return valid; }
125 inline bool get_inrange() const { return inrange; }
126 inline double get_stn_lon() const { return stn_lon; }
127 inline double get_stn_lat() const { return stn_lat; }
128 inline double get_dist() const { return dist; }
129 inline double get_heading() const { return heading; }
130 inline bool has_power() const {
131 return power_btn && (bus_power->getDoubleValue() > 1.0);
135 inline int get_ant_mode() const { return ant_mode; }
136 inline int get_stby_mode() const { return stby_mode; }
137 inline int get_timer_mode() const { return timer_mode; }
138 inline int get_count_mode() const { return count_mode; }
141 inline double get_rotation () const { return rotation; }
142 inline void set_rotation( double rot ) { rotation = rot; }
143 inline bool get_power_btn() const { return power_btn; }
144 inline void set_power_btn( bool val ) {
147 inline bool get_audio_btn() const { return audio_btn; }
148 inline void set_audio_btn( bool val ) {
151 inline double get_vol_btn() const { return vol_btn; }
152 inline void set_vol_btn( double val ) {
153 if ( val < 0.0 ) val = 0.0;
154 if ( val > 1.0 ) val = 1.0;
157 inline bool get_adf_btn() const { return adf_btn; }
158 inline void set_adf_btn( bool val ) { adf_btn = val; }
159 inline bool get_bfo_btn() const { return bfo_btn; }
160 inline void set_bfo_btn( bool val ) { bfo_btn = val; }
161 inline bool get_frq_btn() const { return frq_btn; }
162 inline void set_frq_btn( bool val ) { frq_btn = val; }
163 inline bool get_flt_et_btn() const { return flt_et_btn; }
164 inline void set_flt_et_btn( bool val ) { flt_et_btn = val; }
165 inline bool get_set_rst_btn() const { return set_rst_btn; }
166 inline void set_set_rst_btn( bool val ) { set_rst_btn = val; }
169 inline int get_freq () const { return freq; }
170 inline void set_freq( int f ) {
174 int get_stby_freq () const;
175 inline void set_stby_freq( int f ) { stby_freq = f; }
176 inline double get_needle_deg() const { return needle_deg; }
177 inline double get_flight_timer() const { return flight_timer; }
178 inline double get_elapsed_timer() const { return elapsed_timer; }
179 inline void set_elapsed_timer( double val ) { elapsed_timer = val; }
182 inline bool get_ant_ann() const { return ant_ann; }
183 inline bool get_adf_ann() const { return adf_ann; }
184 inline bool get_bfo_ann() const { return bfo_ann; }
185 inline bool get_frq_ann() const { return frq_ann; }
186 inline bool get_flt_ann() const { return flt_ann; }
187 inline bool get_et_ann() const { return et_ann; }
191 #endif // _FG_KR_87_HXX