1
0
Fork 0

GPWS: clean up white-space (TAB vs space) and indentation mess

This commit is contained in:
ThorstenB 2018-01-28 21:13:01 +01:00
parent 4497df4ecd
commit f37715f334
2 changed files with 4079 additions and 4021 deletions

View file

@ -206,8 +206,7 @@ MK_VIII::PowerHandler::handle_abnormal_voltage (bool abnormal,
{ {
if (timer->start_or_elapsed() >= max_duration) if (timer->start_or_elapsed() >= max_duration)
return true; // power loss return true; // power loss
} } else
else
timer->stop(); timer->stop();
return false; return false;
@ -227,7 +226,8 @@ MK_VIII::PowerHandler::update ()
now_powered = false; now_powered = false;
if (handle_abnormal_voltage(voltage < 20.5, &low_surge_timer, 0.03)) if (handle_abnormal_voltage(voltage < 20.5, &low_surge_timer, 0.03))
now_powered = false; now_powered = false;
if (handle_abnormal_voltage(voltage < 22.0 || voltage > 30.3, &abnormal_timer, 300)) if (handle_abnormal_voltage(voltage < 22.0 || voltage > 30.3,
&abnormal_timer, 300))
now_powered = false; now_powered = false;
if (handle_abnormal_voltage(voltage > 32.2, &high_surge_timer, 1)) if (handle_abnormal_voltage(voltage > 32.2, &high_surge_timer, 1))
now_powered = false; now_powered = false;
@ -242,13 +242,11 @@ MK_VIII::PowerHandler::update ()
if (now_powered) if (now_powered)
power_loss_timer.stop(); power_loss_timer.stop();
else else {
{
if (power_loss_timer.start_or_elapsed() >= 0.2) if (power_loss_timer.start_or_elapsed() >= 0.2)
power_off(); power_off();
} }
} } else
else
{ {
if (now_powered) if (now_powered)
power_on(); power_on();
@ -524,6 +522,7 @@ MK_VIII::ConfigurationModule::read_aircraft_mode_type_select (int value)
}; };
for (size_t i = 0; i < n_elements(aircraft_types); i++) for (size_t i = 0; i < n_elements(aircraft_types); i++)
{
if (aircraft_types[i].type == value) if (aircraft_types[i].type == value)
{ {
mk->mode1_handler.conf.envelopes = aircraft_types[i].m1; mk->mode1_handler.conf.envelopes = aircraft_types[i].m1;
@ -535,6 +534,7 @@ MK_VIII::ConfigurationModule::read_aircraft_mode_type_select (int value)
mk->conf.runway_database = aircraft_types[i].runway_database; mk->conf.runway_database = aircraft_types[i].runway_database;
return true; return true;
} }
}
state = STATE_INVALID_AIRCRAFT_TYPE; state = STATE_INVALID_AIRCRAFT_TYPE;
return false; return false;
@ -614,9 +614,11 @@ MK_VIII::ConfigurationModule::read_altitude_callouts (int value)
mk->mode6_handler.conf.altitude_callouts_enabled = 0; mk->mode6_handler.conf.altitude_callouts_enabled = 0;
for (unsigned int i = 0; i < n_elements(values); i++) for (unsigned int i = 0; i < n_elements(values); i++)
{
if (values[i].id == value) if (values[i].id == value)
{ {
for (int j = 0; values[i].callouts[j] != 0; j++) for (int j = 0; values[i].callouts[j] != 0; j++)
{
switch (values[i].callouts[j]) switch (values[i].callouts[j])
{ {
case RETARD: case RETARD:
@ -649,10 +651,11 @@ MK_VIII::ConfigurationModule::read_altitude_callouts (int value)
mk->mode6_handler.conf.altitude_callouts_enabled |= 1 << k; mk->mode6_handler.conf.altitude_callouts_enabled |= 1 << k;
break; break;
} }
}
return true; return true;
} }
}
return false; return false;
} }
@ -693,7 +696,7 @@ MK_VIII::ConfigurationModule::read_options_select_group_1 (int value)
mk->io_handler.conf.steep_approach_enabled = test_bits(value, 1 << 6); mk->io_handler.conf.steep_approach_enabled = test_bits(value, 1 << 6);
return true; return true;
} }
else
return false; return false;
} }
@ -765,6 +768,7 @@ MK_VIII::ConfigurationModule::read_input_output_discrete_type_select (int value)
}; };
for (size_t i = 0; i < n_elements(io_types); i++) for (size_t i = 0; i < n_elements(io_types); i++)
{
if (io_types[i].type == value) if (io_types[i].type == value)
{ {
mk->io_handler.conf.lamp = &io_types[i].lamp_conf; mk->io_handler.conf.lamp = &io_types[i].lamp_conf;
@ -773,6 +777,7 @@ MK_VIII::ConfigurationModule::read_input_output_discrete_type_select (int value)
mk->io_handler.conf.alternate_steep_approach = io_types[i].alternate_steep_approach; mk->io_handler.conf.alternate_steep_approach = io_types[i].alternate_steep_approach;
return true; return true;
} }
}
return false; return false;
} }
@ -793,11 +798,13 @@ MK_VIII::ConfigurationModule::read_audio_output_level (int value)
}; };
for (size_t i = 0; i < n_elements(values); i++) for (size_t i = 0; i < n_elements(values); i++)
{
if (values[i].id == value) if (values[i].id == value)
{ {
mk->voice_player.set_volume(mk->voice_player.conf.volume = modify_amplitude(1.0, values[i].relative_dB)); mk->voice_player.set_volume(mk->voice_player.conf.volume = modify_amplitude(1.0, values[i].relative_dB));
return true; return true;
} }
}
// The self test needs the voice player even when the configuration // The self test needs the voice player even when the configuration
// is invalid, so set a default value. // is invalid, so set a default value.
@ -839,6 +846,7 @@ MK_VIII::ConfigurationModule::boot ()
state = STATE_OK; state = STATE_OK;
for (int i = 0; i < N_CATEGORIES; i++) for (int i = 0; i < N_CATEGORIES; i++)
{
if (! (this->*readers[i])(effective_categories[i])) if (! (this->*readers[i])(effective_categories[i]))
{ {
SG_LOG(SG_INSTR, SG_ALERT, "MK VIII EGPWS configuration category " << i + 1 << ": invalid value " << effective_categories[i]); SG_LOG(SG_INSTR, SG_ALERT, "MK VIII EGPWS configuration category " << i + 1 << ": invalid value " << effective_categories[i]);
@ -851,6 +859,7 @@ MK_VIII::ConfigurationModule::boot ()
return; return;
} }
}
// handle conflicts // handle conflicts
@ -912,8 +921,10 @@ MK_VIII::FaultHandler::has_faults (unsigned int inop)
return false; return false;
for (int i = 0; i < N_FAULTS; i++) for (int i = 0; i < N_FAULTS; i++)
{
if ((faults & (1<<i)) && test_bits(fault_inops[i], inop)) if ((faults & (1<<i)) && test_bits(fault_inops[i], inop))
return true; return true;
}
return false; return false;
} }
@ -1100,8 +1111,8 @@ MK_VIII::IOHandler::enter_takeoff ()
{ {
reset_terrain_clearance(); reset_terrain_clearance();
if (momentary_steep_approach_enabled())
// landing or go-around, disable steep approach as per [SPEC] 6.2.1 // landing or go-around, disable steep approach as per [SPEC] 6.2.1
if (momentary_steep_approach_enabled())
mk_doutput(steep_approach) = false; mk_doutput(steep_approach) = false;
} }
@ -1262,10 +1273,12 @@ MK_VIII::IOHandler::update_inputs ()
altitude_samples_type::iterator iter; altitude_samples_type::iterator iter;
for (iter = altitude_samples.begin(); iter != altitude_samples.end(); iter++) for (iter = altitude_samples.begin(); iter != altitude_samples.end(); iter++)
{
if (globals->get_sim_time_sec() - (*iter).timestamp >= 1) if (globals->get_sim_time_sec() - (*iter).timestamp >= 1)
erase_last = iter; erase_last = iter;
else else
break; break;
}
if (erase_last != altitude_samples.begin()) if (erase_last != altitude_samples.begin())
altitude_samples.erase(altitude_samples.begin(), erase_last); altitude_samples.erase(altitude_samples.begin(), erase_last);
@ -1288,7 +1301,6 @@ MK_VIII::IOHandler::update_inputs ()
} }
// update glideslope and localizer // update glideslope and localizer
mk_data(glideslope_deviation_dots).set(&mk_ainput(glideslope_deviation), GLIDESLOPE_DDM_TO_DOTS); mk_data(glideslope_deviation_dots).set(&mk_ainput(glideslope_deviation), GLIDESLOPE_DDM_TO_DOTS);
mk_data(localizer_deviation_dots).set(&mk_ainput(localizer_deviation), LOCALIZER_DDM_TO_DOTS); mk_data(localizer_deviation_dots).set(&mk_ainput(localizer_deviation), LOCALIZER_DDM_TO_DOTS);
@ -1296,7 +1308,6 @@ MK_VIII::IOHandler::update_inputs ()
// complex algorithm which combines several input sources to // complex algorithm which combines several input sources to
// calculate the geometric altitude. Since the exact algorithm is // calculate the geometric altitude. Since the exact algorithm is
// not given, we fallback to a much simpler method. // not given, we fallback to a much simpler method.
if (! mk_data(gps_altitude).ncd) if (! mk_data(gps_altitude).ncd)
mk_data(geometric_altitude).set(mk_data(gps_altitude).get()); mk_data(geometric_altitude).set(mk_data(gps_altitude).get());
else if (! mk_ainput(uncorrected_barometric_altitude).ncd) else if (! mk_ainput(uncorrected_barometric_altitude).ncd)
@ -1305,11 +1316,9 @@ MK_VIII::IOHandler::update_inputs ()
mk_data(geometric_altitude).unset(); mk_data(geometric_altitude).unset();
// update terrain clearance // update terrain clearance
update_terrain_clearance(); update_terrain_clearance();
// 3. perform sanity checks // 3. perform sanity checks
if (! mk_data(radio_altitude).ncd && mk_data(radio_altitude).get() < 0) if (! mk_data(radio_altitude).ncd && mk_data(radio_altitude).get() < 0)
mk_data(radio_altitude).unset(); mk_data(radio_altitude).unset();
@ -1332,7 +1341,6 @@ MK_VIII::IOHandler::update_inputs ()
mk_data(roll_angle).unset(); mk_data(roll_angle).unset();
// 4. process input feeders requiring data computed above // 4. process input feeders requiring data computed above
if (mk_dinput_feed(decision_height)) if (mk_dinput_feed(decision_height))
{ {
mk_dinput(decision_height_100) = ! mk_data(radio_altitude).ncd mk_dinput(decision_height_100) = ! mk_data(radio_altitude).ncd
@ -1543,8 +1551,10 @@ MK_VIII::IOHandler::update_internal_latches ()
&& ! mk->state_handler.takeoff && ! mk->state_handler.takeoff
&& ((last_landing_gear && ! mk_dinput(landing_gear)) && ((last_landing_gear && ! mk_dinput(landing_gear))
|| (last_real_flaps_down && ! real_flaps_down()))) || (last_real_flaps_down && ! real_flaps_down())))
{
// gear or flaps raised during approach: it's a go-around // gear or flaps raised during approach: it's a go-around
mk_doutput(steep_approach) = false; mk_doutput(steep_approach) = false;
}
last_landing_gear = mk_dinput(landing_gear); last_landing_gear = mk_dinput(landing_gear);
last_real_flaps_down = real_flaps_down(); last_real_flaps_down = real_flaps_down();
@ -1583,12 +1593,14 @@ MK_VIII::IOHandler::update_egpws_alert_discrete_1 ()
}; };
for (size_t i = 0; i < n_elements(voices); i++) for (size_t i = 0; i < n_elements(voices); i++)
{
if (voices[i].voice == mk->voice_player.voice) if (voices[i].voice == mk->voice_player.voice)
{ {
mk_aoutput(egpws_alert_discrete_1) = 1 << voices[i].bit; mk_aoutput(egpws_alert_discrete_1) = 1 << voices[i].bit;
return; return;
} }
} }
}
mk_aoutput(egpws_alert_discrete_1) = 0; mk_aoutput(egpws_alert_discrete_1) = 0;
} }
@ -1617,9 +1629,11 @@ MK_VIII::IOHandler::update_egpwc_logic_discretes ()
}; };
for (size_t i = 0; i < n_elements(logic); i++) for (size_t i = 0; i < n_elements(logic); i++)
{
if (mk_test_alerts(logic[i].alerts)) if (mk_test_alerts(logic[i].alerts))
mk_aoutput(egpwc_logic_discretes) |= 1 << logic[i].bit; mk_aoutput(egpwc_logic_discretes) |= 1 << logic[i].bit;
} }
}
void void
MK_VIII::IOHandler::update_mode6_callouts_discrete_1 () MK_VIII::IOHandler::update_mode6_callouts_discrete_1 ()
@ -1643,13 +1657,14 @@ MK_VIII::IOHandler::update_mode6_callouts_discrete_1 ()
}; };
for (size_t i = 0; i < n_elements(voices); i++) for (size_t i = 0; i < n_elements(voices); i++)
{
if (voices[i].voice == mk->voice_player.voice) if (voices[i].voice == mk->voice_player.voice)
{ {
mk_aoutput(mode6_callouts_discrete_1) = 1 << voices[i].bit; mk_aoutput(mode6_callouts_discrete_1) = 1 << voices[i].bit;
return; return;
} }
} }
}
mk_aoutput(mode6_callouts_discrete_1) = 0; mk_aoutput(mode6_callouts_discrete_1) = 0;
} }
@ -1673,12 +1688,14 @@ MK_VIII::IOHandler::update_mode6_callouts_discrete_2 ()
}; };
for (size_t i = 0; i < n_elements(voices); i++) for (size_t i = 0; i < n_elements(voices); i++)
{
if (voices[i].voice == mk->voice_player.voice) if (voices[i].voice == mk->voice_player.voice)
{ {
mk_aoutput(mode6_callouts_discrete_2) = 1 << voices[i].bit; mk_aoutput(mode6_callouts_discrete_2) = 1 << voices[i].bit;
return; return;
} }
} }
}
mk_aoutput(mode6_callouts_discrete_2) = 0; mk_aoutput(mode6_callouts_discrete_2) = 0;
} }
@ -2084,10 +2101,12 @@ MK_VIII::IOHandler::present_status ()
}; };
for (size_t i = 0; i < n_elements(fault_names); i++) for (size_t i = 0; i < n_elements(fault_names); i++)
{
if (mk->fault_handler.faults & (1<<i)) if (mk->fault_handler.faults & (1<<i))
present_status_subitem(fault_names[i]); present_status_subitem(fault_names[i]);
} }
} }
}
printf("\n"); printf("\n");
present_status_section("CONFIGURATION:"); present_status_section("CONFIGURATION:");
@ -2126,7 +2145,8 @@ MK_VIII::IOHandler::get_present_status () const
void void
MK_VIII::IOHandler::set_present_status (bool value) MK_VIII::IOHandler::set_present_status (bool value)
{ {
if (value) present_status(); if (value)
present_status();
} }
@ -2191,7 +2211,7 @@ MK_VIII::SelfTestHandler::_was_here (int position)
current = position; current = position;
return false; return false;
} }
else
return true; return true;
} }
@ -2302,11 +2322,12 @@ MK_VIII::SelfTestHandler::run ()
if (! was_here()) if (! was_here())
return discrete_on_off(&mk_doutput(glideslope_cancel), 0.7); return discrete_on_off(&mk_doutput(glideslope_cancel), 0.7);
goto glideslope_end; goto glideslope_end;
glideslope_inop: glideslope_inop:
if (! was_here()) if (! was_here())
return play(mk_voice(glideslope_inop)); return play(mk_voice(glideslope_inop));
glideslope_end:
glideslope_end:
if (! was_here()) if (! was_here())
{ {
if (mk->fault_handler.faults & (1<<FaultHandler::FAULT_MODES14_INPUTS_INVALID)) if (mk->fault_handler.faults & (1<<FaultHandler::FAULT_MODES14_INPUTS_INVALID))
@ -2315,11 +2336,12 @@ MK_VIII::SelfTestHandler::run ()
if (! was_here()) if (! was_here())
return discrete_on_off(&mk_doutput(gpws_warning), mk_voice(pull_up)); return discrete_on_off(&mk_doutput(gpws_warning), mk_voice(pull_up));
goto gpws_end; goto gpws_end;
gpws_inop: gpws_inop:
if (! was_here()) if (! was_here())
return play(mk_voice(gpws_inop)); return play(mk_voice(gpws_inop));
gpws_end:
gpws_end:
if (! was_here()) if (! was_here())
{ {
if (mk_dinput(self_test)) // proceed to long self test if (mk_dinput(self_test)) // proceed to long self test
@ -2394,11 +2416,13 @@ MK_VIII::SelfTestHandler::run ()
return play(mk->mode6_handler.conf.above_field_voice); return play(mk->mode6_handler.conf.above_field_voice);
} }
for (unsigned i = 0; i < n_altitude_callouts; i++) for (unsigned i = 0; i < n_altitude_callouts; i++)
{
if (! was_here_offset(i)) if (! was_here_offset(i))
{ {
if (mk->mode6_handler.conf.altitude_callouts_enabled & (1<<i)) if (mk->mode6_handler.conf.altitude_callouts_enabled & (1<<i))
return play(mk_altitude_voice(i)); return play(mk_altitude_voice(i));
} }
}
if (! was_here()) if (! was_here())
{ {
@ -2406,11 +2430,12 @@ MK_VIII::SelfTestHandler::run ()
return play(mk_altitude_voice(Mode6Handler::ALTITUDE_CALLOUT_500)); return play(mk_altitude_voice(Mode6Handler::ALTITUDE_CALLOUT_500));
} }
goto callouts_end; goto callouts_end;
callouts_disabled: callouts_disabled:
if (! was_here()) if (! was_here())
return play(mk_voice(minimums_minimums)); return play(mk_voice(minimums_minimums));
callouts_end:
callouts_end:
if (! was_here()) if (! was_here())
{ {
if (mk->tcf_handler.conf.enabled) if (mk->tcf_handler.conf.enabled)
@ -3428,8 +3453,10 @@ MK_VIII::Mode3Handler::get_bias (double initial_bias, double alt_loss)
// mk-viii spec: repeat alerts whenever losing 20% of initial altitude // mk-viii spec: repeat alerts whenever losing 20% of initial altitude
while ((alt_loss > max_alt_loss(initial_bias))&& while ((alt_loss > max_alt_loss(initial_bias))&&
(initial_bias < 1.0)) (initial_bias < 1.0))
{
initial_bias += 0.2; initial_bias += 0.2;
} }
}
return initial_bias; return initial_bias;
} }
@ -3669,7 +3696,9 @@ MK_VIII::Mode4Handler::update_c ()
&& (! mk_dinput(landing_gear) || ! mk->io_handler.flaps_down()) && (! mk_dinput(landing_gear) || ! mk->io_handler.flaps_down())
&& mk_data(radio_altitude).get() < get_upper_agl(conf.modes->ac) && mk_data(radio_altitude).get() < get_upper_agl(conf.modes->ac)
&& mk_data(radio_altitude).get() < mk_data(terrain_clearance).get()) && mk_data(radio_altitude).get() < mk_data(terrain_clearance).get())
{
handle_alert(mk_alert(MODE4C_TOO_LOW_TERRAIN), mk_data(terrain_clearance).get(), &c_bias); handle_alert(mk_alert(MODE4C_TOO_LOW_TERRAIN), mk_data(terrain_clearance).get(), &c_bias);
}
else else
{ {
mk_unset_alerts(mk_alert(MODE4C_TOO_LOW_TERRAIN)); mk_unset_alerts(mk_alert(MODE4C_TOO_LOW_TERRAIN));
@ -3755,9 +3784,12 @@ MK_VIII::Mode5Handler::get_soft_bias (double initial_bias)
{ {
if (initial_bias < 0.0) // sanity check if (initial_bias < 0.0) // sanity check
initial_bias = 0.0; initial_bias = 0.0;
while ((is_soft(initial_bias))&& while ((is_soft(initial_bias))&&
(initial_bias < 1.0)) (initial_bias < 1.0))
{
initial_bias += 0.2; initial_bias += 0.2;
}
return initial_bias; return initial_bias;
} }
@ -3866,10 +3898,11 @@ bool
MK_VIII::Mode6Handler::is_playing_altitude_callout () MK_VIII::Mode6Handler::is_playing_altitude_callout ()
{ {
for (unsigned i = 0; i < n_altitude_callouts; i++) for (unsigned i = 0; i < n_altitude_callouts; i++)
{
if (mk->voice_player.voice == mk_altitude_voice(i) if (mk->voice_player.voice == mk_altitude_voice(i)
|| mk->voice_player.next_voice == mk_altitude_voice(i)) || mk->voice_player.next_voice == mk_altitude_voice(i))
return true; return true;
}
return false; return false;
} }
@ -4000,7 +4033,9 @@ MK_VIII::Mode6Handler::update_minimums ()
if (! mk->io_handler.gpws_inhibit() if (! mk->io_handler.gpws_inhibit()
&& (mk->voice_player.voice == mk_voice(minimums_minimums) && (mk->voice_player.voice == mk_voice(minimums_minimums)
|| mk->voice_player.next_voice == mk_voice(minimums_minimums))) || mk->voice_player.next_voice == mk_voice(minimums_minimums)))
{
goto end; goto end;
}
if (! mk->io_handler.gpws_inhibit() if (! mk->io_handler.gpws_inhibit()
&& ! mk->state_handler.ground // [1] && ! mk->state_handler.ground // [1]
@ -4074,7 +4109,9 @@ MK_VIII::Mode6Handler::update_altitude_callouts ()
if (! mk->state_handler.ground // [1] if (! mk->state_handler.ground // [1]
&& ! mk_data(radio_altitude).ncd) && ! mk_data(radio_altitude).ncd)
{
for (unsigned i = 0; i < n_altitude_callouts && mk_data(radio_altitude).get() <= altitude_callout_definitions[i]; i++) for (unsigned i = 0; i < n_altitude_callouts && mk_data(radio_altitude).get() <= altitude_callout_definitions[i]; i++)
{
if (((conf.altitude_callouts_enabled & (1<<i)) if (((conf.altitude_callouts_enabled & (1<<i))
|| (altitude_callout_definitions[i] == 500 || (altitude_callout_definitions[i] == 500
&& conf.smart_500_enabled)) && conf.smart_500_enabled))
@ -4098,6 +4135,8 @@ MK_VIII::Mode6Handler::update_altitude_callouts ()
} }
} }
} }
}
}
mk_unset_alerts(mk_alert(MODE6_ALTITUDE_CALLOUT)); mk_unset_alerts(mk_alert(MODE6_ALTITUDE_CALLOUT));
@ -4121,10 +4160,12 @@ MK_VIII::Mode6Handler::test_runway (const FGRunway *_runway)
bool bool
MK_VIII::Mode6Handler::test_airport (const FGAirport *airport) MK_VIII::Mode6Handler::test_airport (const FGAirport *airport)
{ {
for (unsigned int r=0; r<airport->numRunways(); ++r) { for (unsigned int r=0; r<airport->numRunways(); ++r)
{
FGRunway* rwy(airport->getRunwayByIndex(r)); FGRunway* rwy(airport->getRunwayByIndex(r));
if (test_runway(rwy)) return true; if (test_runway(rwy))
return true;
} }
return false; return false;
@ -4139,8 +4180,8 @@ bool MK_VIII::Mode6Handler::AirportFilter::passAirport(FGAirport* a) const
void void
MK_VIII::Mode6Handler::update_runway () MK_VIII::Mode6Handler::update_runway ()
{ {
if (mk_data(gps_latitude).ncd || mk_data(gps_longitude).ncd)
if (mk_data(gps_latitude).ncd || mk_data(gps_longitude).ncd) { {
has_runway.unset(); has_runway.unset();
return; return;
} }
@ -4154,7 +4195,8 @@ MK_VIII::Mode6Handler::update_runway ()
FGPositionedRef apt = FGPositioned::findClosest( FGPositionedRef apt = FGPositioned::findClosest(
SGGeod::fromDeg(mk_data(gps_longitude).get(), mk_data(gps_latitude).get()), SGGeod::fromDeg(mk_data(gps_longitude).get(), mk_data(gps_latitude).get()),
30.0, &filter); 30.0, &filter);
if (apt) { if (apt)
{
runway.elevation = apt->elevation(); runway.elevation = apt->elevation();
} }
@ -4324,7 +4366,8 @@ void
MK_VIII::TCFHandler::update_runway () MK_VIII::TCFHandler::update_runway ()
{ {
has_runway = false; has_runway = false;
if (mk_data(gps_latitude).ncd || mk_data(gps_longitude).ncd) { if (mk_data(gps_latitude).ncd || mk_data(gps_longitude).ncd)
{
return; return;
} }
@ -4336,12 +4379,16 @@ MK_VIII::TCFHandler::update_runway ()
AirportFilter filter(mk); AirportFilter filter(mk);
SGGeod apos = SGGeod::fromDeg(mk_data(gps_longitude).get(), mk_data(gps_latitude).get()); SGGeod apos = SGGeod::fromDeg(mk_data(gps_longitude).get(), mk_data(gps_latitude).get());
FGAirport* apt = FGAirport::findClosest(apos, 30.0, &filter); FGAirport* apt = FGAirport::findClosest(apos, 30.0, &filter);
if (!apt)
if (!apt) return; {
return;
}
FGRunway* _runway = apt->findBestRunwayForPos(apos).get(); FGRunway* _runway = apt->findBestRunwayForPos(apos).get();
if (!_runway)
if (!_runway) return; {
return;
}
has_runway = true; has_runway = true;
@ -4417,33 +4464,39 @@ MK_VIII::TCFHandler::is_tcf ()
if (mk_data(radio_altitude).get() < 700) if (mk_data(radio_altitude).get() < 700)
return true; return true;
} }
else if (edge_distance > 12) else
if (edge_distance > 12)
{ {
if (mk_data(radio_altitude).get() < 100 * edge_distance - 800) if (mk_data(radio_altitude).get() < 100 * edge_distance - 800)
return true; return true;
} }
else if (edge_distance > 4) else
if (edge_distance > 4)
{ {
if (mk_data(radio_altitude).get() < 400) if (mk_data(radio_altitude).get() < 400)
return true; return true;
} }
else if (edge_distance > 2.45) else
if (edge_distance > 2.45)
{ {
if (mk_data(radio_altitude).get() < 100 * edge_distance) if (mk_data(radio_altitude).get() < 100 * edge_distance)
return true; return true;
} }
else if ( is_inside_edge_triangle(&runway.edge) && (edge_distance > 0.01) ) else
if ( is_inside_edge_triangle(&runway.edge) && (edge_distance > 0.01) )
{ {
if (mk_data(radio_altitude).get() < 100 * edge_distance) if (mk_data(radio_altitude).get() < 100 * edge_distance)
return true; return true;
} }
else if (! is_inside_bias_area()) else
if (! is_inside_bias_area())
{ {
if (mk_data(radio_altitude).get() < 245) if (mk_data(radio_altitude).get() < 245)
return true; return true;
} }
} }
else if (mk_data(radio_altitude).get() < 700) else
if (mk_data(radio_altitude).get() < 700)
{ {
return true; return true;
} }
@ -4522,8 +4575,10 @@ MK_VIII::TCFHandler::update ()
new_bias = 0.0; new_bias = 0.0;
while ((*reference < initial_value - initial_value * new_bias)&& while ((*reference < initial_value - initial_value * new_bias)&&
(new_bias < 1.0)) (new_bias < 1.0))
{
new_bias += 0.2; new_bias += 0.2;
} }
}
if (new_bias > bias) if (new_bias > bias)
{ {

View file

@ -18,7 +18,6 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __INSTRUMENTS_MK_VIII_HXX #ifndef __INSTRUMENTS_MK_VIII_HXX
#define __INSTRUMENTS_MK_VIII_HXX #define __INSTRUMENTS_MK_VIII_HXX
@ -251,7 +250,7 @@ private:
State state; State state;
inline SystemHandler (MK_VIII *device) inline SystemHandler (MK_VIII *device)
: mk(device), state(STATE_OFF) {} : mk(device), boot_delay(0.0), last_replay_state(0), state(STATE_OFF) {}
void power_on (); void power_on ();
void power_off (); void power_off ();
@ -294,6 +293,7 @@ private:
STATE_INVALID_DATABASE, STATE_INVALID_DATABASE,
STATE_INVALID_AIRCRAFT_TYPE STATE_INVALID_AIRCRAFT_TYPE
} State; } State;
State state; State state;
int effective_categories[N_CATEGORIES]; int effective_categories[N_CATEGORIES];
@ -352,6 +352,7 @@ private:
public: public:
// keep in sync with IOHandler::present_status() // keep in sync with IOHandler::present_status()
typedef enum typedef enum
{ {
FAULT_ALL_MODES_INHIBIT, FAULT_ALL_MODES_INHIBIT,
@ -373,8 +374,9 @@ private:
unsigned int faults; unsigned int faults;
inline FaultHandler (MK_VIII *device) inline FaultHandler(MK_VIII *device) :
: mk(device), faults(0) {} mk(device), faults(0) {
}
void boot(); void boot();
@ -384,11 +386,11 @@ private:
bool has_faults() const; bool has_faults() const;
}; };
public:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// MK_VIII::IOHandler /////////////////////////////////////////////////////// // MK_VIII::IOHandler ///////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
public:
class IOHandler class IOHandler
{ {
public: public:
@ -1327,6 +1329,7 @@ private:
private: private:
MK_VIII* mk; MK_VIII* mk;
}; };
public: public:
struct struct
{ {