]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/kr_87.hxx
Make adf volume and adf on/off seperate properties.
[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/morse.hxx>
38
39
40 class FGKR_87 : public FGSubsystem
41 {
42     FGMorse morse;
43
44     SGInterpTable *term_tbl;
45     SGInterpTable *low_tbl;
46     SGInterpTable *high_tbl;
47
48     SGPropertyNode *lon_node;
49     SGPropertyNode *lat_node;
50     SGPropertyNode *alt_node;
51
52     bool need_update;
53
54     // internal values
55     string ident;
56     string trans_ident;
57     bool valid;
58     bool inrange;
59     double stn_lon;
60     double stn_lat;
61     double stn_elev;
62     double range;
63     double effective_range;
64     double dist;
65     double heading;
66     double x;
67     double y;
68     double z;
69     double goal_needle_deg;
70     double et_flash_time;
71
72     // modes
73     int ant_mode;               // 0 = ADF mode (needle active), 1 = ANT mode
74                                 // (needle turned to 90, improved audio rcpt)
75     int stby_mode;              // 0 = show stby freq, 1 = show timer
76     int timer_mode;             // 0 = flt, 1 = et
77     int count_mode;             // 0 = count up, 1 = count down, 2 = set et
78                                 // count down
79
80     // input and buttons
81     double rotation;            // compass faceplace rotation
82     bool power_btn;             // 0 = off, 1 = powered
83     double vol_btn;
84     bool adf_btn;               // 0 = normal, 1 = depressed
85     bool bfo_btn;               // 0 = normal, 1 = depressed
86     bool frq_btn;               // 0 = normal, 1 = depressed
87     bool last_frq_btn;
88     bool flt_et_btn;            // 0 = normal, 1 = depressed
89     bool last_flt_et_btn;
90     bool set_rst_btn;           // 0 = normal, 1 = depressed
91     bool last_set_rst_btn;      // 0 = normal, 1 = depressed
92     bool ident_btn;             // turn audio morse code on/off
93
94     // outputs
95     double freq;
96     double stby_freq;
97     double needle_deg;
98     double flight_timer;
99     double elapsed_timer;
100     double tmp_timer;
101
102     // annunciators
103     bool ant_ann;
104     bool adf_ann;
105     bool bfo_ann;
106     bool frq_ann;
107     bool flt_ann;
108     bool et_ann;
109
110 public:
111
112     FGKR_87();
113     ~FGKR_87();
114
115     void init ();
116     void bind ();
117     void unbind ();
118     void update (double dt);
119
120     // Update nav/adf radios based on current postition
121     void search ();
122
123     // internal values
124     inline string get_ident() const { return ident; }
125     inline bool get_valid() const { return valid; }
126     inline bool get_inrange() const { return inrange; }
127     inline double get_stn_lon() const { return stn_lon; }
128     inline double get_stn_lat() const { return stn_lat; }
129     inline double get_dist() const { return dist; }
130     inline double get_heading() const { return heading; }
131
132     // modes
133     inline int get_ant_mode() const { return ant_mode; }
134     inline int get_stby_mode() const { return stby_mode; }
135     inline int get_timer_mode() const { return timer_mode; }
136     inline int get_count_mode() const { return count_mode; }
137
138     // input and buttons
139     inline double get_rotation () const { return rotation; }
140     inline void set_rotation( double rot ) { rotation = rot; }
141     inline bool get_power_btn() const { return power_btn; }
142     inline void set_power_btn( bool val ) {
143         power_btn = val;
144     }
145     inline double get_vol_btn() const { return vol_btn; }
146     inline void set_vol_btn( double val ) {
147         if ( val < 0.0 ) val = 0.0;
148         if ( val > 1.0 ) val = 1.0;
149         vol_btn = val;
150     }
151     inline bool get_adf_btn() const { return adf_btn; }
152     inline void set_adf_btn( bool val ) { adf_btn = val; }
153     inline bool get_bfo_btn() const { return bfo_btn; }
154     inline void set_bfo_btn( bool val ) { bfo_btn = val; }
155     inline bool get_frq_btn() const { return frq_btn; }
156     inline void set_frq_btn( bool val ) { frq_btn = val; }
157     inline bool get_flt_et_btn() const { return flt_et_btn; }
158     inline void set_flt_et_btn( bool val ) { flt_et_btn = val; }
159     inline bool get_set_rst_btn() const { return set_rst_btn; }
160     inline void set_set_rst_btn( bool val ) { set_rst_btn = val; }
161     inline bool get_ident_btn() const { return ident_btn; }
162     inline void set_ident_btn( bool val ) { ident_btn = val; }
163
164     // outputs
165     inline double get_freq () const { return freq; }
166     inline void set_freq( double f ) {
167         freq = f;
168         need_update = true;
169     }
170     double get_stby_freq () const;
171     inline void set_stby_freq( double freq ) { stby_freq = freq; }
172     inline double get_needle_deg() const { return needle_deg; }
173     inline double get_flight_timer() const { return flight_timer; }
174     inline double get_elapsed_timer() const { return elapsed_timer; }
175     inline void set_elapsed_timer( double val ) { elapsed_timer = val; }
176
177     // annunciators
178     inline bool get_ant_ann() const { return ant_ann; }
179     inline bool get_adf_ann() const { return adf_ann; }
180     inline bool get_bfo_ann() const { return bfo_ann; }
181     inline bool get_frq_ann() const { return frq_ann; }
182     inline bool get_flt_ann() const { return flt_ann; }
183     inline bool get_et_ann() const { return et_ann; }
184 };
185
186
187 #endif // _FG_KR_87_HXX