]> git.mxchange.org Git - flightgear.git/blob - src/Network/fgcom.hxx
Implement IAX callerID feature
[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 May 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     void iaxTextEvent(struct iaxc_ev_text text);
40
41
42   private:
43
44     SGPropertyNode_ptr _ptt0_node;                            // instrumentation/nav[0]/ptt
45     //SGPropertyNode_ptr _nav0_node;                          // instrumentation/nav[0]/frequencies/selected-mhz
46     //SGPropertyNode_ptr _nav1_node;                          // instrumentation/nav[1]/frequencies/selected-mhz
47     SGPropertyNode_ptr _comm0_node;                           // instrumentation/comm[0]/frequencies/selected-mhz
48     //SGPropertyNode_ptr _comm1_node;                         // instrumentation/comm[1]/frequencies/selected-mhz
49     SGPropertyNode_ptr _test_node;                            // sim/fgcom/test
50     SGPropertyNode_ptr _text_node;                            // sim/fgcom/text
51     SGPropertyNode_ptr _server_node;                          // sim/fgcom/server
52     SGPropertyNode_ptr _enabled_node;                         // sim/fgcom/enabled
53     SGPropertyNode_ptr _version_node;                         // sim/version/flightgear
54     SGPropertyNode_ptr _micBoost_node;                        // sim/fgcom/mic-boost
55     SGPropertyNode_ptr _callsign_node;                        // sim/multiplay/callsign
56     SGPropertyNode_ptr _register_node;                        // sim/fgcom/register/enabled
57     SGPropertyNode_ptr _username_node;                        // sim/fgcom/register/username
58     SGPropertyNode_ptr _password_node;                        // sim/fgcom/register/password
59     SGPropertyNode_ptr _micLevel_node;                        // sim/fgcom/mic-level
60     SGPropertyNode_ptr _speakerLevel_node;                    // sim/fgcom/speaker-level
61     SGPropertyNode_ptr _deviceID_node[4];                     // sim/fgcom/device[n]/id
62     SGPropertyNode_ptr _deviceName_node[4];                   // sim/fgcom/device[n]/name
63     SGPropertyNode_ptr _deviceInput_node[4];                  // sim/fgcom/device[n]/available-input
64     SGPropertyNode_ptr _deviceOutput_node[4];                 // sim/fgcom/device[n]/available-output
65     SGPropertyNode_ptr _selectedInput_node;                   // sim/fgcom/device-input
66     SGPropertyNode_ptr _selectedOutput_node;                  // sim/fgcom/device-output
67     SGPropertyNode_ptr _showMessages_node;                    // sim/fgcom/show-messages
68
69
70
71     double   _maxRange;
72     double   _minRange;
73     double   _currentComm0;
74     //double   _currentComm1;
75     //double   _currentNav0;
76     //double   _currentNav1;
77     //bool     _nav0Changed;
78     //bool     _nav1Changed;
79     bool     _comm0Changed;
80     //bool     _comm1Changed;
81     bool     _register;
82     bool     _enabled;
83     bool     _initialized;
84     int      _regId;
85     //int      _callNav0;
86     //int      _callNav1;
87     int      _callComm0;
88     //int      _callComm1;
89     int      _listener_active;
90     int      _currentFreqKhz;
91     std::string   _server;
92     std::string   _callsign;
93     std::string   _username;
94     std::string   _password;
95     SGTimeStamp   _p;
96     SGGeod        _aptPos;
97
98     std::string   computePhoneNumber(const double& freq, const std::string& icao) const;
99     std::string   getAirportCode(const double& freq);
100     //std::string   getVorCode(const double& freq) const;
101     SGGeod        getAirportPos(const double& freq) const;
102     bool          isInRange(const double& freq) const;
103     
104     void updateCall(bool& changed, int& callNo, double freqMHz);
105     void testMode(bool testMode);
106
107 };
108
109 #endif // of FG_FGCOM_HXX
110
111