1
0
Fork 0
flightgear/src/Instrumentation/adf.hxx

104 lines
2.3 KiB
C++
Raw Normal View History

// 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/math/point3d.hxx>
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
Melchior FRANZ: All necessary elements for an ADF gauge had been migrated from Cockpit/kr_87.cxx to Instrumentation/adf.cxx. Migrating the sound related elements was apparently planned, but not done yet. This intermediate state broke the ident morse sound: it couldn't get turned off and it always indicated "SF", regardless of the tuned-in frequency. The following patches continue the migration: adf-radio.diff => Base/Aircraft/Instruments/adf-radio.xml: --------------------------------------------------------------- * sets maximum volume to 1 (rather than 2); Not only is 1 loud enough (and 2 unpleasantly noisy), it also prevents the knob from being turned to non-existant positions. :-) * fixes wrong use of /instrumentation/adf/ident * the voice/ident selector(?) remains unchanged, but as it's not switched to "IDENT", there'll be no ident sound by default this is consistent with other sounds and DME. radiostack.diff => src/Cockpit/radiostack.[ch]xx: --------------------------------------------------------------- * comment out use of FGKR_87 class. kr_87.[ch]xx is now no longer used. kr-87adf.xml would no longer work, either, but isn't used anywhere, anyway. Future adf radios have to use the adf instrument, using xml/Nasal for specific hardware implementation details. adf.diff => src/Instrumentation/adf.[ch]xx: --------------------------------------------------------------- * adds ident morse sound capability using two new input properties: - /instrumentation/adf/volume-norm (double) - /instrumentation/adf/ident-audible (bool)
2004-08-19 11:54:57 +00:00
#include <Sound/morse.hxx>
SG_USING_STD(string);
/**
* 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
Melchior FRANZ: All necessary elements for an ADF gauge had been migrated from Cockpit/kr_87.cxx to Instrumentation/adf.cxx. Migrating the sound related elements was apparently planned, but not done yet. This intermediate state broke the ident morse sound: it couldn't get turned off and it always indicated "SF", regardless of the tuned-in frequency. The following patches continue the migration: adf-radio.diff => Base/Aircraft/Instruments/adf-radio.xml: --------------------------------------------------------------- * sets maximum volume to 1 (rather than 2); Not only is 1 loud enough (and 2 unpleasantly noisy), it also prevents the knob from being turned to non-existant positions. :-) * fixes wrong use of /instrumentation/adf/ident * the voice/ident selector(?) remains unchanged, but as it's not switched to "IDENT", there'll be no ident sound by default this is consistent with other sounds and DME. radiostack.diff => src/Cockpit/radiostack.[ch]xx: --------------------------------------------------------------- * comment out use of FGKR_87 class. kr_87.[ch]xx is now no longer used. kr-87adf.xml would no longer work, either, but isn't used anywhere, anyway. Future adf radios have to use the adf instrument, using xml/Nasal for specific hardware implementation details. adf.diff => src/Instrumentation/adf.[ch]xx: --------------------------------------------------------------- * adds ident morse sound capability using two new input properties: - /instrumentation/adf/volume-norm (double) - /instrumentation/adf/ident-audible (bool)
2004-08-19 11:54:57 +00:00
* /instrumentation/adf/ident-audible
* /instrumentation/adf/volume-norm
*
* Output properties:
*
* /instrumentation/adf/in-range
* /instrumentation/adf/indicated-bearing-deg
* /instrumentation/adf/ident
*/
class ADF : public SGSubsystem
{
public:
ADF ( SGPropertyNode *node );
ADF ();
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);
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;
SGPropertyNode_ptr _ident_audible_node;
Melchior FRANZ: All necessary elements for an ADF gauge had been migrated from Cockpit/kr_87.cxx to Instrumentation/adf.cxx. Migrating the sound related elements was apparently planned, but not done yet. This intermediate state broke the ident morse sound: it couldn't get turned off and it always indicated "SF", regardless of the tuned-in frequency. The following patches continue the migration: adf-radio.diff => Base/Aircraft/Instruments/adf-radio.xml: --------------------------------------------------------------- * sets maximum volume to 1 (rather than 2); Not only is 1 loud enough (and 2 unpleasantly noisy), it also prevents the knob from being turned to non-existant positions. :-) * fixes wrong use of /instrumentation/adf/ident * the voice/ident selector(?) remains unchanged, but as it's not switched to "IDENT", there'll be no ident sound by default this is consistent with other sounds and DME. radiostack.diff => src/Cockpit/radiostack.[ch]xx: --------------------------------------------------------------- * comment out use of FGKR_87 class. kr_87.[ch]xx is now no longer used. kr-87adf.xml would no longer work, either, but isn't used anywhere, anyway. Future adf radios have to use the adf instrument, using xml/Nasal for specific hardware implementation details. adf.diff => src/Instrumentation/adf.[ch]xx: --------------------------------------------------------------- * adds ident morse sound capability using two new input properties: - /instrumentation/adf/volume-norm (double) - /instrumentation/adf/ident-audible (bool)
2004-08-19 11:54:57 +00:00
SGPropertyNode_ptr _volume_node;
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;
double _transmitter_range_nm;
FGMorse morse;
int _ident_count;
time_t _last_ident_time;
double _last_volume;
string name;
int num;
string adf_ident;
};
#endif // __INSTRUMENTS_ADF_HXX