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