]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/kr_87.hxx
A little prepratory code reorganization before modeling the King KR 87
[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 adf_ident;
57     string adf_trans_ident;
58     bool adf_valid;
59     bool adf_inrange;
60     double adf_freq;
61     double adf_alt_freq;
62     double adf_rotation;
63     double adf_lon;
64     double adf_lat;
65     double adf_elev;
66     double adf_range;
67     double adf_effective_range;
68     double adf_dist;
69     double adf_heading;
70     double adf_x;
71     double adf_y;
72     double adf_z;
73     double adf_vol_btn;
74     bool adf_ident_btn;
75
76 public:
77
78     FGKR_87();
79     ~FGKR_87();
80
81     void init ();
82     void bind ();
83     void unbind ();
84     void update (double dt);
85
86     // Update nav/adf radios based on current postition
87     void search ();
88
89     // ADF Setters
90     inline void set_adf_freq( double freq ) {
91         adf_freq = freq; need_update = true;
92     }
93     inline void set_adf_alt_freq( double freq ) { adf_alt_freq = freq; }
94     inline void set_adf_rotation( double rot ) { adf_rotation = rot; }
95     inline void set_adf_vol_btn( double val ) {
96         if ( val < 0.0 ) val = 0.0;
97         if ( val > 1.0 ) val = 1.0;
98         adf_vol_btn = val;
99     }
100     inline void set_adf_ident_btn( bool val ) { adf_ident_btn = val; }
101
102     // ADF Accessors
103     inline double get_adf_freq () const { return adf_freq; }
104     inline double get_adf_alt_freq () const { return adf_alt_freq; }
105     inline double get_adf_rotation () const { return adf_rotation; }
106
107     // Calculated values
108     inline bool get_adf_inrange() const { return adf_inrange; }
109     inline double get_adf_lon() const { return adf_lon; }
110     inline double get_adf_lat() const { return adf_lat; }
111     inline double get_adf_heading() const { return adf_heading; }
112     inline double get_adf_vol_btn() const { return adf_vol_btn; }
113     inline bool get_adf_ident_btn() const { return adf_ident_btn; }
114 };
115
116
117 #endif // _FG_KR_87_HXX