]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/adf.hxx
fix another crash at the poles
[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/props/props.hxx>
17
18 #include <simgear/structure/subsystem_mgr.hxx>
19 #include <simgear/math/SGMath.hxx>
20
21 class SGSampleGroup;
22
23 /**
24  * Model an ADF radio.
25  *
26  * Input properties:
27  *
28  * /position/longitude-deg
29  * /position/latitude-deg
30  * /position/altitude-ft
31  * /orientation/heading-deg
32  * /systems/electrical/outputs/adf
33  * /instrumentation/adf/serviceable
34  * /instrumentation/adf/error-deg
35  * /instrumentation/adf/frequencies/selected-khz
36  * /instrumentation/adf/mode
37  * /instrumentation/adf/ident-audible
38  * /instrumentation/adf/volume-norm
39  *
40  * Output properties:
41  *
42  * /instrumentation/adf/in-range
43  * /instrumentation/adf/indicated-bearing-deg
44  * /instrumentation/adf/ident
45  */
46 class ADF : public SGSubsystem
47 {
48
49 public:
50
51     ADF ( SGPropertyNode *node );
52     virtual ~ADF ();
53
54     virtual void init ();
55     virtual void update (double delta_time_sec);
56
57 private:
58
59     void set_bearing (double delta_time_sec, double bearing);
60
61     void search (double frequency, const SGGeod& pos);
62
63     std::string _name;
64     unsigned int _num;
65
66     SGPropertyNode_ptr _heading_node;
67     SGPropertyNode_ptr _serviceable_node;
68     SGPropertyNode_ptr _error_node;
69     SGPropertyNode_ptr _electrical_node;
70     SGPropertyNode_ptr _frequency_node;
71     SGPropertyNode_ptr _mode_node;
72
73     SGPropertyNode_ptr _in_range_node;
74     SGPropertyNode_ptr _bearing_node;
75     SGPropertyNode_ptr _ident_node;
76     SGPropertyNode_ptr _ident_audible_node;
77     SGPropertyNode_ptr _volume_node;
78     SGPropertyNode_ptr _power_btn_node;
79     SGPropertyNode_ptr _operable_node;
80
81     double _time_before_search_sec;
82
83     int _last_frequency_khz;
84     bool _transmitter_valid;
85     std::string _last_ident;
86     SGGeod _transmitter_pos;
87     SGVec3d _transmitter_cart;
88     double _transmitter_range_nm;
89
90     int _ident_count;
91     time_t _last_ident_time;
92     float _last_volume;
93     std::string _adf_ident;
94
95     SGSharedPtr<SGSampleGroup> _sgr;
96 };
97
98
99 #endif // __INSTRUMENTS_ADF_HXX