2013-05-19 14:29:49 +00:00
|
|
|
#ifndef FG_FGCOM_HXX
|
|
|
|
#define FG_FGCOM_HXX
|
|
|
|
|
|
|
|
// fgcom.hxx -- FGCom: Voice communication
|
|
|
|
//
|
2013-08-28 16:09:22 +00:00
|
|
|
// Written by Clement de l'Hamaide, started May 2013.
|
2013-05-19 14:29:49 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
|
|
|
#include <simgear/props/props.hxx>
|
|
|
|
#include <simgear/math/sg_geodesy.hxx>
|
|
|
|
|
|
|
|
class FGCom : public SGSubsystem, public SGPropertyChangeListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FGCom();
|
|
|
|
virtual ~FGCom();
|
|
|
|
|
|
|
|
virtual void bind();
|
|
|
|
virtual void unbind();
|
|
|
|
virtual void init();
|
|
|
|
virtual void postinit();
|
|
|
|
virtual void update(double dt);
|
|
|
|
virtual void valueChanged(SGPropertyNode *prop);
|
|
|
|
virtual void shutdown();
|
2013-08-28 16:09:22 +00:00
|
|
|
void iaxTextEvent(struct iaxc_ev_text text);
|
|
|
|
|
2013-05-19 14:29:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2019-03-19 20:20:17 +00:00
|
|
|
SGPropertyNode_ptr _ptt_node; // PTT; nonzero int indicating channel number (instrumentation/comm/[channel-1])
|
|
|
|
SGPropertyNode_ptr _selected_comm_node; // selected channel (fgcom); nonzero channel int indicating channel number (instrumentation/comm/[channel-1])
|
|
|
|
SGPropertyNode_ptr _commFrequencyNode; // current comm node in use; e.g. /instrumentation/comm[0]
|
2019-03-21 16:56:38 +00:00
|
|
|
SGPropertyNode_ptr _commVolumeNode; // current volume node in use; e.g. /instrumentation/comm[0]/volume
|
2013-05-19 14:29:49 +00:00
|
|
|
SGPropertyNode_ptr _test_node; // sim/fgcom/test
|
2013-08-28 16:09:22 +00:00
|
|
|
SGPropertyNode_ptr _text_node; // sim/fgcom/text
|
2013-05-19 14:29:49 +00:00
|
|
|
SGPropertyNode_ptr _server_node; // sim/fgcom/server
|
|
|
|
SGPropertyNode_ptr _enabled_node; // sim/fgcom/enabled
|
2013-09-22 15:34:51 +00:00
|
|
|
SGPropertyNode_ptr _version_node; // sim/version/flightgear
|
2013-05-19 14:29:49 +00:00
|
|
|
SGPropertyNode_ptr _micBoost_node; // sim/fgcom/mic-boost
|
|
|
|
SGPropertyNode_ptr _callsign_node; // sim/multiplay/callsign
|
|
|
|
SGPropertyNode_ptr _register_node; // sim/fgcom/register/enabled
|
|
|
|
SGPropertyNode_ptr _username_node; // sim/fgcom/register/username
|
|
|
|
SGPropertyNode_ptr _password_node; // sim/fgcom/register/password
|
|
|
|
SGPropertyNode_ptr _micLevel_node; // sim/fgcom/mic-level
|
2014-01-26 15:38:23 +00:00
|
|
|
SGPropertyNode_ptr _silenceThd_node; // sim/fgcom/silence-threshold
|
2013-05-19 14:29:49 +00:00
|
|
|
SGPropertyNode_ptr _speakerLevel_node; // sim/fgcom/speaker-level
|
|
|
|
SGPropertyNode_ptr _deviceID_node[4]; // sim/fgcom/device[n]/id
|
|
|
|
SGPropertyNode_ptr _deviceName_node[4]; // sim/fgcom/device[n]/name
|
|
|
|
SGPropertyNode_ptr _deviceInput_node[4]; // sim/fgcom/device[n]/available-input
|
|
|
|
SGPropertyNode_ptr _deviceOutput_node[4]; // sim/fgcom/device[n]/available-output
|
|
|
|
SGPropertyNode_ptr _selectedInput_node; // sim/fgcom/device-input
|
|
|
|
SGPropertyNode_ptr _selectedOutput_node; // sim/fgcom/device-output
|
2013-08-28 16:09:22 +00:00
|
|
|
SGPropertyNode_ptr _showMessages_node; // sim/fgcom/show-messages
|
2019-03-19 20:20:17 +00:00
|
|
|
SGPropertyNode_ptr _mpTransmitFrequencyNode; // sim/multiplay/comm-transmit-frequency-mhz
|
|
|
|
SGPropertyNode_ptr _mpTransmitPowerNode; // sim/multiplay/comm-transmit-power-norm
|
2013-05-19 14:29:49 +00:00
|
|
|
|
|
|
|
|
2013-08-27 18:23:14 +00:00
|
|
|
double _maxRange;
|
|
|
|
double _minRange;
|
2019-03-19 20:20:17 +00:00
|
|
|
double _currentCommFrequency;
|
|
|
|
double _currentCallFrequency;
|
2013-05-19 14:29:49 +00:00
|
|
|
bool _register;
|
|
|
|
bool _enabled;
|
2013-08-22 12:12:06 +00:00
|
|
|
bool _initialized;
|
2013-05-19 14:29:49 +00:00
|
|
|
int _regId;
|
2019-03-19 20:20:17 +00:00
|
|
|
int _currentCallIdent;
|
2013-05-19 14:29:49 +00:00
|
|
|
//int _callComm1;
|
|
|
|
int _listener_active;
|
|
|
|
std::string _server;
|
|
|
|
std::string _callsign;
|
|
|
|
std::string _username;
|
|
|
|
std::string _password;
|
2019-03-19 20:20:17 +00:00
|
|
|
SGTimeStamp _processingTimer;
|
2013-05-19 14:29:49 +00:00
|
|
|
SGGeod _aptPos;
|
|
|
|
|
|
|
|
std::string computePhoneNumber(const double& freq, const std::string& icao) const;
|
|
|
|
std::string getAirportCode(const double& freq);
|
2019-03-19 20:20:17 +00:00
|
|
|
// SGGeod getAirportPos(const double& freq) const;
|
|
|
|
void setupCommFrequency(int channel = -1);
|
|
|
|
double getCurrentFrequencyKhz() const;
|
2019-03-21 16:56:38 +00:00
|
|
|
double getCurrentCommVolume() const;
|
2013-05-19 14:29:49 +00:00
|
|
|
bool isInRange(const double& freq) const;
|
2019-03-19 20:20:17 +00:00
|
|
|
|
|
|
|
void updateCall();
|
|
|
|
void connectToCommFrequency();
|
2013-05-19 14:29:49 +00:00
|
|
|
void testMode(bool testMode);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // of FG_FGCOM_HXX
|
|
|
|
|
|
|
|
|