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)
This commit is contained in:
parent
02d721f8c9
commit
5c18572c64
4 changed files with 77 additions and 11 deletions
|
@ -50,7 +50,7 @@ FGRadioStack::FGRadioStack() {
|
|||
// Destructor
|
||||
FGRadioStack::~FGRadioStack()
|
||||
{
|
||||
adf.unbind();
|
||||
//adf.unbind();
|
||||
beacon.unbind();
|
||||
navcom1.unbind();
|
||||
navcom2.unbind();
|
||||
|
@ -67,7 +67,7 @@ FGRadioStack::init ()
|
|||
navcom2.set_bind_index( 1 );
|
||||
navcom2.init();
|
||||
|
||||
adf.init();
|
||||
//adf.init();
|
||||
beacon.init();
|
||||
xponder.init();
|
||||
|
||||
|
@ -83,7 +83,7 @@ FGRadioStack::init ()
|
|||
void
|
||||
FGRadioStack::bind ()
|
||||
{
|
||||
adf.bind();
|
||||
//adf.bind();
|
||||
beacon.bind();
|
||||
dme.bind();
|
||||
navcom1.set_bind_index( 0 );
|
||||
|
@ -97,7 +97,7 @@ FGRadioStack::bind ()
|
|||
void
|
||||
FGRadioStack::unbind ()
|
||||
{
|
||||
adf.unbind();
|
||||
//adf.unbind();
|
||||
beacon.unbind();
|
||||
dme.unbind();
|
||||
navcom1.unbind();
|
||||
|
@ -110,7 +110,7 @@ FGRadioStack::unbind ()
|
|||
void
|
||||
FGRadioStack::update(double dt)
|
||||
{
|
||||
adf.update( dt );
|
||||
//adf.update( dt );
|
||||
beacon.update( dt );
|
||||
navcom1.update( dt );
|
||||
navcom2.update( dt );
|
||||
|
@ -122,7 +122,7 @@ FGRadioStack::update(double dt)
|
|||
// Update current nav/adf radio stations based on current postition
|
||||
void FGRadioStack::search()
|
||||
{
|
||||
adf.search();
|
||||
//adf.search();
|
||||
beacon.search();
|
||||
navcom1.search();
|
||||
navcom2.search();
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
class FGRadioStack : public SGSubsystem
|
||||
{
|
||||
FGDME dme;
|
||||
FGKR_87 adf; // King KR 87 Digital ADF model
|
||||
//FGKR_87 adf; // King KR 87 Digital ADF model
|
||||
FGKT_70 xponder; // Bendix/King KT 70 Panel-Mounted Transponder
|
||||
FGMarkerBeacon beacon;
|
||||
FGNavCom navcom1;
|
||||
|
|
|
@ -53,7 +53,10 @@ ADF::ADF ()
|
|||
_last_frequency_khz(-1),
|
||||
_transmitter_valid(false),
|
||||
_transmitter_elevation_ft(0),
|
||||
_transmitter_range_nm(0)
|
||||
_transmitter_range_nm(0),
|
||||
_ident_count(0),
|
||||
_last_ident_time(0),
|
||||
_last_volume(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -79,6 +82,9 @@ ADF::init ()
|
|||
_bearing_node =
|
||||
fgGetNode("/instrumentation/adf/indicated-bearing-deg", true);
|
||||
_ident_node = fgGetNode("/instrumentation/adf/ident", true);
|
||||
_volume_node = fgGetNode("/instrumentation/adf/volume-norm", true);
|
||||
_ident_audible = fgGetNode("/instrumentation/adf/ident-audible", true);
|
||||
morse.init();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -146,10 +152,42 @@ ADF::update (double delta_time_sec)
|
|||
if (bearing < 0)
|
||||
bearing += 360;
|
||||
set_bearing(delta_time_sec, bearing);
|
||||
|
||||
// adf ident sound
|
||||
double volume;
|
||||
if ( _ident_audible->getBoolValue() )
|
||||
volume = _volume_node->getDoubleValue();
|
||||
else
|
||||
volume = 0.0;
|
||||
|
||||
if ( volume != _last_volume ) {
|
||||
_last_volume = volume;
|
||||
|
||||
SGSoundSample *sound;
|
||||
sound = globals->get_soundmgr()->find( "adf-ident" );
|
||||
if ( sound != NULL )
|
||||
sound->set_volume( volume );
|
||||
else
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Can't find adf-ident sound" );
|
||||
}
|
||||
|
||||
double cur_time = globals->get_time_params()->get_cur_time();
|
||||
if ( _last_ident_time < cur_time - 30 ) {
|
||||
_last_ident_time = cur_time;
|
||||
_ident_count = 0;
|
||||
}
|
||||
|
||||
if ( _ident_count < 4 ) {
|
||||
if ( !globals->get_soundmgr()->is_playing("adf-ident") ) {
|
||||
globals->get_soundmgr()->play_once( "adf-ident" );
|
||||
++_ident_count;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_in_range_node->setBoolValue(false);
|
||||
set_bearing(delta_time_sec, 90);
|
||||
_ident_node->setStringValue("");
|
||||
globals->get_soundmgr()->stop( "adf-ident" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +196,6 @@ ADF::search (double frequency_khz, double longitude_rad,
|
|||
double latitude_rad, double altitude_m)
|
||||
{
|
||||
string ident = "";
|
||||
|
||||
// reset search time
|
||||
_time_before_search_sec = 1.0;
|
||||
|
||||
|
@ -178,8 +215,27 @@ ADF::search (double frequency_khz, double longitude_rad,
|
|||
_transmitter_range_nm = nav->get_range();
|
||||
}
|
||||
}
|
||||
|
||||
if ( _last_ident != ident ) {
|
||||
_last_ident = ident;
|
||||
_ident_node->setStringValue(ident.c_str());
|
||||
|
||||
if ( globals->get_soundmgr()->exists( "adf-ident" ) ) {
|
||||
globals->get_soundmgr()->stop( "adf-ident" );
|
||||
globals->get_soundmgr()->remove( "adf-ident" );
|
||||
}
|
||||
|
||||
SGSoundSample *sound;
|
||||
sound = morse.make_ident( ident, LO_FREQUENCY );
|
||||
sound->set_volume(0);
|
||||
_last_volume = -1;
|
||||
globals->get_soundmgr()->add( sound, "adf-ident" );
|
||||
|
||||
int offset = (int)(sg_random() * 30.0);
|
||||
_ident_count = offset / 4;
|
||||
_last_ident_time = globals->get_time_params()->get_cur_time() -
|
||||
offset;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
#include <Sound/morse.hxx>
|
||||
|
||||
SG_USING_STD(string);
|
||||
|
||||
|
@ -35,6 +36,8 @@ SG_USING_STD(string);
|
|||
* /instrumentation/adf/error-deg
|
||||
* /instrumentation/adf/frequencies/selected-khz
|
||||
* /instrumentation/adf/mode
|
||||
* /instrumentation/adf/ident-audible
|
||||
* /instrumentation/adf/volume-norm
|
||||
*
|
||||
* Output properties:
|
||||
*
|
||||
|
@ -73,6 +76,13 @@ private:
|
|||
SGPropertyNode_ptr _in_range_node;
|
||||
SGPropertyNode_ptr _bearing_node;
|
||||
SGPropertyNode_ptr _ident_node;
|
||||
SGPropertyNode_ptr _ident_audible;
|
||||
SGPropertyNode_ptr _volume_node;
|
||||
|
||||
FGMorse morse;
|
||||
int _ident_count;
|
||||
time_t _last_ident_time;
|
||||
double _last_volume;
|
||||
|
||||
double _time_before_search_sec;
|
||||
|
||||
|
|
Loading…
Reference in a new issue