217 SGGeod acft =
globals->get_aircraft_position();
224 _time_before_search_sec -= dt_sec;
225 if ( _time_before_search_sec < 0 ) {
233 if (
has_power() && serviceable->getBoolValue() ) {
235 if ( adf_btn == 0 ) {
242 if ( frq_btn && frq_btn != last_frq_btn && stby_mode == 0 ) {
246 }
else if ( frq_btn ) {
250 last_frq_btn = frq_btn;
252 if ( flt_et_btn && flt_et_btn != last_flt_et_btn ) {
253 if ( stby_mode == 0 ) {
256 timer_mode = !timer_mode;
260 last_flt_et_btn = flt_et_btn;
262 if ( set_rst_btn == 1 && set_rst_btn != last_set_rst_btn ) {
266 if ( set_rst_btn == 1 && set_rst_btn == last_set_rst_btn ) {
270 if ( tmp_timer > 2.0 ) {
278 if ( set_rst_btn == 0 && set_rst_btn != last_set_rst_btn ) {
280 if ( tmp_timer > 2.0 ) {
283 }
else if ( count_mode == 2 ) {
290 last_set_rst_btn = set_rst_btn;
293 flight_timer += dt_sec;
295 if ( set_rst_btn == 0 ) {
297 if ( count_mode == 0 ) {
298 elapsed_timer += dt_sec;
299 }
else if ( count_mode == 1 ) {
300 elapsed_timer -= dt_sec;
301 if ( elapsed_timer < 1.0 ) {
312 frq_ann = !stby_mode;
313 flt_ann = stby_mode && !timer_mode;
314 if ( count_mode < 2 ) {
315 et_ann = stby_mode && timer_mode;
317 et_flash_time += dt_sec;
318 if ( et_ann && et_flash_time > 0.5 ) {
320 et_flash_time -= 0.5;
321 }
else if ( !et_ann && et_flash_time > 0.2 ) {
323 et_flash_time -= 0.2;
331 dist = sqrt(distSqr(SGVec3d::fromGeod(acft), xyz));
334 geo_inverse_wgs_84( acft, SGGeod::fromDeg(stn_lon, stn_lat),
340 effective_range =
kludgeRange(stn_elev, acft.getElevationFt(), range);
341 if ( dist < effective_range * SG_NM_TO_METER ) {
343 }
else if ( dist < 2 * effective_range * SG_NM_TO_METER ) {
344 inrange = sg_random() <
345 ( 2 * effective_range * SG_NM_TO_METER - dist ) /
346 (effective_range * SG_NM_TO_METER);
354 goal_needle_deg = heading
362 goal_needle_deg = 90.0;
366 goal_needle_deg = 0.0;
380 if ( timer_mode == 0 ) {
383 time = elapsed_timer;
386 hours = (int)(time / 3600.0);
387 time -= hours * 3600.00;
388 min = (int)(time / 60.0);
406 char formatted_timer[24];
408 snprintf(formatted_timer, 24,
"%02d:%02d", big, little);
409 fgSetString(
"/instrumentation/kr-87/outputs/timer-string",
412 while ( goal_needle_deg < 0.0 ) { goal_needle_deg += 360.0; }
413 while ( goal_needle_deg >= 360.0 ) { goal_needle_deg -= 360.0; }
415 double diff = goal_needle_deg - needle_deg;
416 while ( diff < -180.0 ) { diff += 360.0; }
417 while ( diff > 180.0 ) { diff -= 360.0; }
419 needle_deg += diff * dt_sec * 4;
420 while ( needle_deg < 0.0 ) { needle_deg += 360.0; }
421 while ( needle_deg >= 360.0 ) { needle_deg -= 360.0; }
428 if ( valid && inrange && serviceable->getBoolValue() ) {
431 if ( vol_btn >= 0.01 && audio_btn ) {
432 SGSoundSample *sound;
433 sound = _sgr->find(
"adf-ident" );
434 if ( sound != NULL ) {
436 sound->set_volume( vol_btn );
438 sound->set_volume( vol_btn / 4.0 );
441 SG_LOG( SG_COCKPIT, SG_ALERT,
"Can't find adf-ident sound" );
444 globals->get_time_params()->get_cur_time() - 30 ) {
450 if ( !_sgr->is_playing(
"adf-ident") && (vol_btn > 0.05) ) {
451 _sgr->play_once(
"adf-ident" );
456 _sgr->stop(
"adf-ident" );