]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/adf.hxx
Melchior FRANZ:
[flightgear.git] / src / Instrumentation / adf.hxx
1 // adf.hxx - automatic direction finder.
2 // Written by David Megginson, started 2003.
3 //
4 // This file is in the Public Domain and comes with no warranty.
5
6
7 #ifndef __INSTRUMENTS_ADF_HXX
8 #define __INSTRUMENTS_ADF_HXX 1
9
10 #ifndef __cplusplus
11 # error This library requires C++
12 #endif
13
14 #include <string>
15
16 #include <simgear/math/point3d.hxx>
17 #include <simgear/props/props.hxx>
18
19 #include <simgear/structure/subsystem_mgr.hxx>
20 #include <Sound/morse.hxx>
21
22 SG_USING_STD(string);
23
24
25 /**
26  * Model an ADF radio.
27  *
28  * Input properties:
29  *
30  * /position/longitude-deg
31  * /position/latitude-deg
32  * /position/altitude-ft
33  * /orientation/heading-deg
34  * /systems/electrical/outputs/adf
35  * /instrumentation/adf/serviceable
36  * /instrumentation/adf/error-deg
37  * /instrumentation/adf/frequencies/selected-khz
38  * /instrumentation/adf/mode
39  * /instrumentation/adf/ident-audible
40  * /instrumentation/adf/volume-norm
41  *
42  * Output properties:
43  *
44  * /instrumentation/adf/in-range
45  * /instrumentation/adf/indicated-bearing-deg
46  * /instrumentation/adf/ident
47  */
48 class ADF : public SGSubsystem
49 {
50
51 public:
52
53     ADF ();
54     virtual ~ADF ();
55
56     virtual void init ();
57     virtual void update (double delta_time_sec);
58
59 private:
60
61     void set_bearing (double delta_time_sec, double bearing);
62
63     void search (double frequency, double longitude_rad,
64                  double latitude_rad, double altitude_m);
65
66     SGPropertyNode_ptr _longitude_node;
67     SGPropertyNode_ptr _latitude_node;
68     SGPropertyNode_ptr _altitude_node;
69     SGPropertyNode_ptr _heading_node;
70     SGPropertyNode_ptr _serviceable_node;
71     SGPropertyNode_ptr _error_node;
72     SGPropertyNode_ptr _electrical_node;
73     SGPropertyNode_ptr _frequency_node;
74     SGPropertyNode_ptr _mode_node;
75
76     SGPropertyNode_ptr _in_range_node;
77     SGPropertyNode_ptr _bearing_node;
78     SGPropertyNode_ptr _ident_node;
79     SGPropertyNode_ptr _ident_audible_node;
80     SGPropertyNode_ptr _volume_node;
81
82     double _time_before_search_sec;
83
84     int _last_frequency_khz;
85     bool _transmitter_valid;
86     string _last_ident;
87     Point3D _transmitter;
88     double _transmitter_lon_deg;
89     double _transmitter_lat_deg;
90     double _transmitter_elevation_ft;
91     double _transmitter_range_nm;
92
93     FGMorse morse;
94     int _ident_count;
95     time_t _last_ident_time;
96     double _last_volume;
97 };
98
99
100 #endif // __INSTRUMENTS_ADF_HXX