]> git.mxchange.org Git - flightgear.git/blob - src/Network/fgcom.hxx
FGCom: Add a different max range for ground and tower frequencies
[flightgear.git] / src / Network / fgcom.hxx
1 #ifndef FG_FGCOM_HXX
2 #define FG_FGCOM_HXX
3
4 // fgcom.hxx -- FGCom: Voice communication
5 //
6 // Written by Clement de l'Hamaide, started Mai 2013.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #include <simgear/structure/subsystem_mgr.hxx>
23 #include <simgear/props/props.hxx>
24 #include <simgear/math/sg_geodesy.hxx>
25
26 class FGCom : public SGSubsystem, public SGPropertyChangeListener
27 {
28   public:
29     FGCom();
30     virtual ~FGCom();
31
32     virtual void bind();
33     virtual void unbind();
34     virtual void init();
35     virtual void postinit();
36     virtual void update(double dt);
37     virtual void valueChanged(SGPropertyNode *prop);
38     virtual void shutdown();
39
40   private:
41
42     SGPropertyNode_ptr _ptt0_node;                            // instrumentation/nav[0]/ptt
43     //SGPropertyNode_ptr _nav0_node;                          // instrumentation/nav[0]/frequencies/selected-mhz
44     //SGPropertyNode_ptr _nav1_node;                          // instrumentation/nav[1]/frequencies/selected-mhz
45     SGPropertyNode_ptr _comm0_node;                           // instrumentation/comm[0]/frequencies/selected-mhz
46     //SGPropertyNode_ptr _comm1_node;                         // instrumentation/comm[1]/frequencies/selected-mhz
47     SGPropertyNode_ptr _test_node;                            // sim/fgcom/test
48     SGPropertyNode_ptr _server_node;                          // sim/fgcom/server
49     SGPropertyNode_ptr _enabled_node;                         // sim/fgcom/enabled
50     SGPropertyNode_ptr _micBoost_node;                        // sim/fgcom/mic-boost
51     SGPropertyNode_ptr _callsign_node;                        // sim/multiplay/callsign
52     SGPropertyNode_ptr _register_node;                        // sim/fgcom/register/enabled
53     SGPropertyNode_ptr _username_node;                        // sim/fgcom/register/username
54     SGPropertyNode_ptr _password_node;                        // sim/fgcom/register/password
55     SGPropertyNode_ptr _micLevel_node;                        // sim/fgcom/mic-level
56     SGPropertyNode_ptr _speakerLevel_node;                    // sim/fgcom/speaker-level
57     SGPropertyNode_ptr _deviceID_node[4];                     // sim/fgcom/device[n]/id
58     SGPropertyNode_ptr _deviceName_node[4];                   // sim/fgcom/device[n]/name
59     SGPropertyNode_ptr _deviceInput_node[4];                  // sim/fgcom/device[n]/available-input
60     SGPropertyNode_ptr _deviceOutput_node[4];                 // sim/fgcom/device[n]/available-output
61     SGPropertyNode_ptr _selectedInput_node;                   // sim/fgcom/device-input
62     SGPropertyNode_ptr _selectedOutput_node;                  // sim/fgcom/device-output
63
64
65
66     double   _maxRange;
67     double   _minRange;
68     double   _currentComm0;
69     //double   _currentComm1;
70     //double   _currentNav0;
71     //double   _currentNav1;
72     //bool     _nav0Changed;
73     //bool     _nav1Changed;
74     bool     _comm0Changed;
75     //bool     _comm1Changed;
76     bool     _register;
77     bool     _enabled;
78     bool     _initialized;
79     int      _regId;
80     //int      _callNav0;
81     //int      _callNav1;
82     int      _callComm0;
83     //int      _callComm1;
84     int      _listener_active;
85     int      _currentFreqKhz;
86     std::string   _server;
87     std::string   _callsign;
88     std::string   _username;
89     std::string   _password;
90     SGTimeStamp   _p;
91     SGGeod        _aptPos;
92
93     std::string   computePhoneNumber(const double& freq, const std::string& icao) const;
94     std::string   getAirportCode(const double& freq);
95     //std::string   getVorCode(const double& freq) const;
96     SGGeod        getAirportPos(const double& freq) const;
97     bool          isInRange(const double& freq) const;
98     
99     void updateCall(bool& changed, int& callNo, double freqMHz);
100     void testMode(bool testMode);
101
102 };
103
104 #endif // of FG_FGCOM_HXX
105
106