count_mode(0),
rotation(0),
power_btn(true),
+ audio_btn(true),
vol_btn(0.5),
adf_btn(true),
bfo_btn(false),
last_flt_et_btn(false),
set_rst_btn(false),
last_set_rst_btn(false),
- ident_btn(false),
freq(0.0),
stby_freq(0.0),
needle_deg(0.0),
&FGKR_87::get_power_btn,
&FGKR_87::set_power_btn);
fgSetArchivable("/radios/kr-87/inputs/power-btn");
+ fgTie("/radios/kr-87/inputs/audio-btn", this,
+ &FGKR_87::get_audio_btn,
+ &FGKR_87::set_audio_btn);
+ fgSetArchivable("/radios/kr-87/inputs/audio-btn");
fgTie("/radios/kr-87/inputs/volume", this,
&FGKR_87::get_vol_btn,
&FGKR_87::set_vol_btn);
fgTie("/radios/kr-87/inputs/set-rst-btn", this,
&FGKR_87::get_set_rst_btn,
&FGKR_87::set_set_rst_btn);
- fgTie("/radios/kr-87/inputs/ident-btn", this,
- &FGKR_87::get_ident_btn, &FGKR_87::set_ident_btn);
// outputs
fgTie("/radios/kr-87/outputs/selected-khz", this,
// cout << "flt = " << flight_timer << " et = " << elapsed_timer
// << " needle = " << needle_deg << endl;
-#ifdef ENABLE_AUDIO_SUPPORT
if ( valid && inrange && servicable->getBoolValue() ) {
- // play station ident via audio system if on + ident_btn,
+ // play station ident via audio system if on + ant mode,
// otherwise turn it off
- if ( vol_btn >= 0.01 && ident_btn ) {
+ if ( vol_btn >= 0.01 && audio_btn ) {
FGSimpleSound *sound;
sound = globals->get_soundmgr()->find( "adf-ident" );
if ( sound != NULL ) {
- sound->set_volume( vol_btn );
+ if ( !adf_btn ) {
+ sound->set_volume( vol_btn );
+ } else {
+ sound->set_volume( vol_btn / 4.0 );
+ }
} else {
SG_LOG( SG_COCKPIT, SG_ALERT, "Can't find adf-ident sound" );
}
globals->get_soundmgr()->stop( "adf-ident" );
}
}
-#endif
}
y = nav.get_y();
z = nav.get_z();
-#ifdef ENABLE_AUDIO_SUPPORT
if ( globals->get_soundmgr()->exists( "adf-ident" ) ) {
globals->get_soundmgr()->remove( "adf-ident" );
}
// << play_count << " last_time = "
// << last_time << " current time = "
// << globals->get_time_params()->get_cur_time() << endl;
-#endif
// cout << "Found an adf station in range" << endl;
// cout << " id = " << nav.get_ident() << endl;
valid = false;
ident = "";
trans_ident = "";
-#ifdef ENABLE_AUDIO_SUPPORT
globals->get_soundmgr()->remove( "adf-ident" );
-#endif
last_ident = "";
// cout << "not picking up adf. :-(" << endl;
}
// input and buttons
double rotation; // compass faceplace rotation
bool power_btn; // 0 = off, 1 = powered
+ bool audio_btn; // 0 = off, 1 = on
double vol_btn;
bool adf_btn; // 0 = normal, 1 = depressed
bool bfo_btn; // 0 = normal, 1 = depressed
bool last_flt_et_btn;
bool set_rst_btn; // 0 = normal, 1 = depressed
bool last_set_rst_btn; // 0 = normal, 1 = depressed
- bool ident_btn; // turn audio morse code on/off
// outputs
double freq;
inline void set_power_btn( bool val ) {
power_btn = val;
}
+ inline bool get_audio_btn() const { return audio_btn; }
+ inline void set_audio_btn( bool val ) {
+ audio_btn = val;
+ }
inline double get_vol_btn() const { return vol_btn; }
inline void set_vol_btn( double val ) {
if ( val < 0.0 ) val = 0.0;
inline void set_flt_et_btn( bool val ) { flt_et_btn = val; }
inline bool get_set_rst_btn() const { return set_rst_btn; }
inline void set_set_rst_btn( bool val ) { set_rst_btn = val; }
- inline bool get_ident_btn() const { return ident_btn; }
- inline void set_ident_btn( bool val ) { ident_btn = val; }
// outputs
inline double get_freq () const { return freq; }
lon_node(fgGetNode("/position/longitude-deg", true)),
lat_node(fgGetNode("/position/latitude-deg", true)),
alt_node(fgGetNode("/position/altitude-ft", true)),
+ bus_power(fgGetNode("/systems/electrical/outputs/navcom[0]", true)),
+ power_btn(fgGetNode("/radios/marker-beacon/power-btn", true)),
+ audio_btn(fgGetNode("/radios/marker-beacon/audio-btn", true)),
+ servicable(fgGetNode("/instrumentation/marker-beacons/servicable", true)),
+
need_update(true),
outer_blink(false),
middle_blink(false),
term_tbl = new SGInterpTable( term.str() );
low_tbl = new SGInterpTable( low.str() );
high_tbl = new SGInterpTable( high.str() );
+
+ power_btn->setBoolValue( true );
+ audio_btn->setBoolValue( true );
+ servicable->setBoolValue( true );
}
{
need_update = false;
- // marker beacon blinking
- bool light_on = ( outer_blink || middle_blink || inner_blink );
- SGTimeStamp current;
- current.stamp();
-
- if ( light_on && (current - blink > 400000) ) {
- light_on = false;
- blink.stamp();
- } else if ( !light_on && (current - blink > 100000) ) {
- light_on = true;
- blink.stamp();
- }
-
- if ( outer_marker ) {
- outer_blink = light_on;
- } else {
- outer_blink = false;
- }
-
- if ( middle_marker ) {
- middle_blink = light_on;
- } else {
- middle_blink = false;
- }
-
- if ( inner_marker ) {
- inner_blink = light_on;
+ if ( has_power() && servicable->getBoolValue() ) {
+ // marker beacon blinking
+ bool light_on = ( outer_blink || middle_blink || inner_blink );
+ SGTimeStamp current;
+ current.stamp();
+
+ if ( light_on && (current - blink > 400000) ) {
+ light_on = false;
+ blink.stamp();
+ } else if ( !light_on && (current - blink > 100000) ) {
+ light_on = true;
+ blink.stamp();
+ }
+
+ if ( outer_marker ) {
+ outer_blink = light_on;
+ } else {
+ outer_blink = false;
+ }
+
+ if ( middle_marker ) {
+ middle_blink = light_on;
+ } else {
+ middle_blink = false;
+ }
+
+ if ( inner_marker ) {
+ inner_blink = light_on;
+ } else {
+ inner_blink = false;
+ }
+
+ // cout << outer_blink << " " << middle_blink << " "
+ // << inner_blink << endl;
} else {
- inner_blink = false;
+ inner_blink = middle_blink = outer_blink = false;
}
-
- // cout << outer_blink << " " << middle_blink << " " << inner_blink << endl;
}
outer_marker = middle_marker = inner_marker = false;
- if ( beacon_type == FGMkrBeacon::OUTER ) {
+ if ( beacon_type == FGMkrBeacon::NOBEACON
+ || !has_power() || !servicable->getBoolValue() )
+ {
+ // cout << "no marker" << endl;
+ beacon_type = FGMkrBeacon::NOBEACON;
+ globals->get_soundmgr()->stop( "outer-marker" );
+ globals->get_soundmgr()->stop( "middle-marker" );
+ globals->get_soundmgr()->stop( "inner-marker" );
+ } else if ( beacon_type == FGMkrBeacon::OUTER ) {
outer_marker = true;
// cout << "OUTER MARKER" << endl;
-#ifdef ENABLE_AUDIO_SUPPORT
- if ( last_beacon != FGMkrBeacon::OUTER ) {
- if ( ! globals->get_soundmgr()->exists( "outer-marker" ) ) {
- FGSimpleSound *sound = beacon.get_outer();
- sound->set_volume( 0.3 );
- globals->get_soundmgr()->add( sound, "outer-marker" );
- }
- if ( !globals->get_soundmgr()->is_playing("outer-marker") ) {
- globals->get_soundmgr()->play_looped( "outer-marker" );
- }
- }
-#endif
+ if ( last_beacon != FGMkrBeacon::OUTER ) {
+ if ( ! globals->get_soundmgr()->exists( "outer-marker" ) ) {
+ FGSimpleSound *sound = beacon.get_outer();
+ sound->set_volume( 0.3 );
+ globals->get_soundmgr()->add( sound, "outer-marker" );
+ }
+ }
+ if ( audio_btn->getBoolValue()
+ && !globals->get_soundmgr()->is_playing("outer-marker") )
+ {
+ globals->get_soundmgr()->play_looped( "outer-marker" );
+ } else {
+ globals->get_soundmgr()->stop( "outer-marker" );
+ }
} else if ( beacon_type == FGMkrBeacon::MIDDLE ) {
middle_marker = true;
// cout << "MIDDLE MARKER" << endl;
-#ifdef ENABLE_AUDIO_SUPPORT
if ( last_beacon != FGMkrBeacon::MIDDLE ) {
if ( ! globals->get_soundmgr()->exists( "middle-marker" ) ) {
FGSimpleSound *sound = beacon.get_middle();
sound->set_volume( 0.3 );
globals->get_soundmgr()->add( sound, "middle-marker" );
}
- if ( !globals->get_soundmgr()->is_playing("middle-marker") ) {
- globals->get_soundmgr()->play_looped( "middle-marker" );
- }
- }
-#endif
+ }
+ if ( audio_btn->getBoolValue()
+ && !globals->get_soundmgr()->is_playing("middle-marker") )
+ {
+ globals->get_soundmgr()->play_looped( "middle-marker" );
+ } else {
+ globals->get_soundmgr()->stop( "middle-marker" );
+ }
} else if ( beacon_type == FGMkrBeacon::INNER ) {
inner_marker = true;
// cout << "INNER MARKER" << endl;
-#ifdef ENABLE_AUDIO_SUPPORT
if ( last_beacon != FGMkrBeacon::INNER ) {
if ( ! globals->get_soundmgr()->exists( "inner-marker" ) ) {
FGSimpleSound *sound = beacon.get_inner();
sound->set_volume( 0.3 );
globals->get_soundmgr()->add( sound, "inner-marker" );
}
- if ( !globals->get_soundmgr()->is_playing("inner-marker") ) {
- globals->get_soundmgr()->play_looped( "inner-marker" );
- }
- }
-#endif
- } else {
- // cout << "no marker" << endl;
-#ifdef ENABLE_AUDIO_SUPPORT
- globals->get_soundmgr()->stop( "outer-marker" );
- globals->get_soundmgr()->stop( "middle-marker" );
- globals->get_soundmgr()->stop( "inner-marker" );
-#endif
+ }
+ if ( audio_btn->getBoolValue()
+ && !globals->get_soundmgr()->is_playing("inner-marker") )
+ {
+ globals->get_soundmgr()->play_looped( "inner-marker" );
+ } else {
+ globals->get_soundmgr()->stop( "inner-marker" );
+ }
}
last_beacon = beacon_type;
}
SGPropertyNode *lon_node;
SGPropertyNode *lat_node;
SGPropertyNode *alt_node;
+ SGPropertyNode *bus_power;
+ SGPropertyNode *power_btn;
+ SGPropertyNode *audio_btn;
+ SGPropertyNode *servicable;
bool need_update;
inline bool get_inner_blink () const { return inner_blink; }
inline bool get_middle_blink () const { return middle_blink; }
inline bool get_outer_blink () const { return outer_blink; }
+ inline bool has_power() const {
+ return power_btn->getBoolValue() && (bus_power->getDoubleValue() > 1.0);
+ }
};
nav_last_time(0),
need_update(true),
power_btn(true),
+ audio_btn(true),
comm_freq(0.0),
comm_alt_freq(0.0),
comm_vol_btn(0.0),
fgSetArchivable( propname );
// Radio outputs
+ sprintf( propname, "/radios/nav[%d]/audio-btn", index );
+ fgTie( propname, this,
+ &FGNavCom::get_audio_btn, &FGNavCom::set_audio_btn );
+ fgSetArchivable( propname );
+
sprintf( propname, "/radios/nav[%d]/radials/actual-deg", index );
fgTie( propname, this, &FGNavCom::get_nav_radial );
// cout << "not picking up vor. :-(" << endl;
}
-#ifdef ENABLE_AUDIO_SUPPORT
if ( nav_valid && nav_inrange && nav_servicable->getBoolValue() ) {
// play station ident via audio system if on + ident,
// otherwise turn it off
if ( power_btn && (bus_power->getDoubleValue() > 1.0)
- && nav_ident_btn )
+ && nav_ident_btn && audio_btn )
{
FGSimpleSound *sound;
sound = globals->get_soundmgr()->find( nav_fx_name );
globals->get_soundmgr()->stop( dme_fx_name );
}
}
-#endif
-
}
nav_gs_y = ils.get_gs_y();
nav_gs_z = ils.get_gs_z();
-#ifdef ENABLE_AUDIO_SUPPORT
if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
globals->get_soundmgr()->remove( nav_fx_name );
}
// << " nav_last_time = " << nav_last_time
// << " current time = "
// << globals->get_time_params()->get_cur_time() << endl;
-#endif
// cout << "Found an ils station in range" << endl;
// cout << " id = " << ils.get_locident() << endl;
nav_y = nav.get_y();
nav_z = nav.get_z();
-#ifdef ENABLE_AUDIO_SUPPORT
if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
globals->get_soundmgr()->remove( nav_fx_name );
}
// << nav_play_count << " nav_last_time = "
// << nav_last_time << " current time = "
// << globals->get_time_params()->get_cur_time() << endl;
-#endif
// cout << "Found a vor station in range" << endl;
// cout << " id = " << nav.get_ident() << endl;
nav_radial = 0;
nav_trans_ident = "";
last_nav_id = "";
-#ifdef ENABLE_AUDIO_SUPPORT
if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) {
cout << "Failed to remove nav-vor-ident sound" << endl;
}
globals->get_soundmgr()->remove( dme_fx_name );
-#endif
// cout << "not picking up vor1. :-(" << endl;
}
}
bool need_update;
bool power_btn;
+ bool audio_btn;
bool comm_valid;
bool comm_inrange;
}
// NavCom Setters
- inline void set_power_btn( bool val ) {
- power_btn = val;
-
- }
+ inline void set_power_btn( bool val ) { power_btn = val; }
+ inline void set_audio_btn( bool val ) { audio_btn = val; }
// COMM Setters
inline void set_comm_freq( double freq ) {
return power_btn && (bus_power->getDoubleValue() > 1.0);
}
inline bool get_power_btn() const { return power_btn; }
+ inline bool get_audio_btn() const { return audio_btn; }
// COMM Accessors
inline double get_comm_freq () const { return comm_freq; }