]> git.mxchange.org Git - flightgear.git/blob - src/Network/fgcom.hxx
10533fd14e759e10aeec95377a1c6e71152a5317
[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 _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 _text_node;                            // sim/fgcom/text
49     SGPropertyNode_ptr _server_node;                          // sim/fgcom/server
50     SGPropertyNode_ptr _enabled_node;                         // sim/fgcom/enabled
51     SGPropertyNode_ptr _version_node;                         // sim/version/flightgear
52     SGPropertyNode_ptr _micBoost_node;                        // sim/fgcom/mic-boost
53     SGPropertyNode_ptr _callsign_node;                        // sim/multiplay/callsign
54     SGPropertyNode_ptr _register_node;                        // sim/fgcom/register/enabled
55     SGPropertyNode_ptr _username_node;                        // sim/fgcom/register/username
56     SGPropertyNode_ptr _password_node;                        // sim/fgcom/register/password
57     SGPropertyNode_ptr _micLevel_node;                        // sim/fgcom/mic-level
58     SGPropertyNode_ptr _speakerLevel_node;                    // sim/fgcom/speaker-level
59     SGPropertyNode_ptr _deviceID_node[4];                     // sim/fgcom/device[n]/id
60     SGPropertyNode_ptr _deviceName_node[4];                   // sim/fgcom/device[n]/name
61     SGPropertyNode_ptr _deviceInput_node[4];                  // sim/fgcom/device[n]/available-input
62     SGPropertyNode_ptr _deviceOutput_node[4];                 // sim/fgcom/device[n]/available-output
63     SGPropertyNode_ptr _selectedInput_node;                   // sim/fgcom/device-input
64     SGPropertyNode_ptr _selectedOutput_node;                  // sim/fgcom/device-output
65     SGPropertyNode_ptr _showMessages_node;                    // sim/fgcom/show-messages
66
67
68
69     double   _maxRange;
70     double   _minRange;
71     double   _currentComm0;
72     double   _currentComm1;
73     bool     _comm0Changed;
74     bool     _comm1Changed;
75     bool     _register;
76     bool     _enabled;
77     bool     _initialized;
78     int      _regId;
79     int      _callComm0;
80     //int      _callComm1;
81     int      _listener_active;
82     int      _currentFreqKhz;
83     int      _selectedComm;
84     std::string   _server;
85     std::string   _callsign;
86     std::string   _username;
87     std::string   _password;
88     SGTimeStamp   _p;
89     SGGeod        _aptPos;
90
91     std::string   computePhoneNumber(const double& freq, const std::string& icao) const;
92     std::string   getAirportCode(const double& freq);
93     SGGeod        getAirportPos(const double& freq) const;
94     bool          isInRange(const double& freq) const;
95     
96     void updateCall(bool& changed, int& callNo, double freqMHz);
97     void testMode(bool testMode);
98
99 };
100
101 #endif // of FG_FGCOM_HXX
102
103