2003-10-01 21:10:33 +00:00
|
|
|
// adf.hxx - automatic direction finder.
|
|
|
|
// Written by David Megginson, started 2003.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __INSTRUMENTS_ADF_HXX
|
|
|
|
#define __INSTRUMENTS_ADF_HXX 1
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <simgear/props/props.hxx>
|
|
|
|
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
2004-08-19 11:54:57 +00:00
|
|
|
#include <Sound/morse.hxx>
|
2003-10-01 21:10:33 +00:00
|
|
|
|
2008-07-27 16:25:13 +00:00
|
|
|
using std::string;
|
2003-10-01 21:10:33 +00:00
|
|
|
|
|
|
|
|
2009-10-04 13:52:53 +00:00
|
|
|
class SGSampleGroup;
|
|
|
|
|
2003-10-01 21:10:33 +00:00
|
|
|
/**
|
|
|
|
* Model an ADF radio.
|
|
|
|
*
|
|
|
|
* Input properties:
|
|
|
|
*
|
|
|
|
* /position/longitude-deg
|
|
|
|
* /position/latitude-deg
|
|
|
|
* /position/altitude-ft
|
|
|
|
* /orientation/heading-deg
|
|
|
|
* /systems/electrical/outputs/adf
|
|
|
|
* /instrumentation/adf/serviceable
|
|
|
|
* /instrumentation/adf/error-deg
|
|
|
|
* /instrumentation/adf/frequencies/selected-khz
|
|
|
|
* /instrumentation/adf/mode
|
2004-08-19 11:54:57 +00:00
|
|
|
* /instrumentation/adf/ident-audible
|
|
|
|
* /instrumentation/adf/volume-norm
|
2003-10-01 21:10:33 +00:00
|
|
|
*
|
|
|
|
* Output properties:
|
|
|
|
*
|
|
|
|
* /instrumentation/adf/in-range
|
|
|
|
* /instrumentation/adf/indicated-bearing-deg
|
|
|
|
* /instrumentation/adf/ident
|
|
|
|
*/
|
|
|
|
class ADF : public SGSubsystem
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
ADF ( SGPropertyNode *node );
|
2003-10-01 21:10:33 +00:00
|
|
|
virtual ~ADF ();
|
|
|
|
|
|
|
|
virtual void init ();
|
|
|
|
virtual void update (double delta_time_sec);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void set_bearing (double delta_time_sec, double bearing);
|
|
|
|
|
|
|
|
void search (double frequency, double longitude_rad,
|
|
|
|
double latitude_rad, double altitude_m);
|
|
|
|
|
2006-10-26 14:47:15 +00:00
|
|
|
string _name;
|
|
|
|
unsigned int _num;
|
|
|
|
|
2003-10-01 21:10:33 +00:00
|
|
|
SGPropertyNode_ptr _longitude_node;
|
|
|
|
SGPropertyNode_ptr _latitude_node;
|
|
|
|
SGPropertyNode_ptr _altitude_node;
|
|
|
|
SGPropertyNode_ptr _heading_node;
|
|
|
|
SGPropertyNode_ptr _serviceable_node;
|
|
|
|
SGPropertyNode_ptr _error_node;
|
|
|
|
SGPropertyNode_ptr _electrical_node;
|
|
|
|
SGPropertyNode_ptr _frequency_node;
|
|
|
|
SGPropertyNode_ptr _mode_node;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _in_range_node;
|
|
|
|
SGPropertyNode_ptr _bearing_node;
|
|
|
|
SGPropertyNode_ptr _ident_node;
|
2004-10-06 09:30:36 +00:00
|
|
|
SGPropertyNode_ptr _ident_audible_node;
|
2004-08-19 11:54:57 +00:00
|
|
|
SGPropertyNode_ptr _volume_node;
|
|
|
|
|
2003-10-01 21:10:33 +00:00
|
|
|
double _time_before_search_sec;
|
|
|
|
|
|
|
|
int _last_frequency_khz;
|
|
|
|
bool _transmitter_valid;
|
|
|
|
string _last_ident;
|
2006-06-15 19:16:21 +00:00
|
|
|
SGGeod _transmitter_pos;
|
|
|
|
SGVec3d _transmitter_cart;
|
2003-10-01 21:10:33 +00:00
|
|
|
double _transmitter_range_nm;
|
|
|
|
|
2004-10-06 09:30:36 +00:00
|
|
|
FGMorse morse;
|
|
|
|
int _ident_count;
|
|
|
|
time_t _last_ident_time;
|
2009-10-04 13:52:53 +00:00
|
|
|
float _last_volume;
|
2006-10-26 14:47:15 +00:00
|
|
|
string _adf_ident;
|
2009-10-04 13:52:53 +00:00
|
|
|
|
|
|
|
SGSampleGroup *_sgr;
|
2003-10-01 21:10:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __INSTRUMENTS_ADF_HXX
|