Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hyd): improve lgciu state machine #7685

Merged
merged 11 commits into from
Jan 13, 2023
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
1. [ADIRU/ND/PFD] Initial support for polar navigation - @tracernz (Mike)
1. [FLIGHTMODEL] Update gear drag - @donstim (donbikes#4084)
1. [FLIGHT MODEL/EFB] Modified empty weight cg and loading station/fuel tank locations - @donstim (donbikes#4084)
1. [HYD] Fix gear sequence starting when failing prox sensor - @Crocket63 (crocket)

## 0.9.0

Expand Down
178 changes: 177 additions & 1 deletion src/systems/a320_systems/src/hydraulic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11087,7 +11087,7 @@ mod tests {
}

#[test]
fn gear_gravity_extension_reverted_has_correct_sequence() {
fn gear_gravity_extension_reverted_has_correct_sequence_if_gear_lever_stays_up() {
let mut test_bed = test_bed_in_flight_with()
.set_cold_dark_inputs()
.with_worst_case_ptu()
Expand All @@ -11103,11 +11103,70 @@ mod tests {
assert!(test_bed.is_all_doors_really_down());
assert!(test_bed.is_all_gears_really_down());

test_bed = test_bed
.stow_emergency_gear_extension()
.run_waiting_for(Duration::from_secs_f64(1.));

// Here expecing LGCIU to be unresponsive: everything stays down until gear lever command
assert!(test_bed.is_all_doors_really_down());
assert!(test_bed.is_all_gears_really_down());

test_bed = test_bed
.set_gear_lever_down()
.run_waiting_for(Duration::from_secs_f64(5.));

assert!(test_bed.is_all_doors_really_up());
assert!(test_bed.is_all_gears_really_down());

// After 5 seconds we expect gear being retracted and doors still down
test_bed = test_bed
.set_gear_lever_up()
.run_waiting_for(Duration::from_secs_f64(5.));
assert!(test_bed.gear_system_state() == GearSystemState::Retracting);
assert!(test_bed.is_all_doors_really_down());
assert!(!test_bed.is_all_gears_really_down());

test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(15.));

assert!(test_bed.gear_system_state() == GearSystemState::AllUpLocked);
assert!(test_bed.is_all_doors_really_up());
assert!(test_bed.is_all_gears_really_up());
}

#[test]
fn gear_gravity_extension_reverted_has_correct_sequence_if_gear_lever_down() {
let mut test_bed = test_bed_in_flight_with()
.set_cold_dark_inputs()
.with_worst_case_ptu()
.in_flight()
.run_one_tick();

assert!(test_bed.gear_system_state() == GearSystemState::AllUpLocked);

test_bed = test_bed
.turn_emergency_gear_extension_n_turns(1)
.set_gear_lever_down()
.run_waiting_for(Duration::from_secs_f64(3.));

test_bed = test_bed
.turn_emergency_gear_extension_n_turns(3)
.run_waiting_for(Duration::from_secs_f64(35.));

assert!(test_bed.is_all_doors_really_down());
assert!(test_bed.is_all_gears_really_down());

test_bed = test_bed
.stow_emergency_gear_extension()
.run_waiting_for(Duration::from_secs_f64(5.));

// Doors expected to close
assert!(test_bed.is_all_doors_really_up());
assert!(test_bed.is_all_gears_really_down());

// After 5 seconds we expect gear being retracted and doors still down
test_bed = test_bed
.set_gear_lever_up()
.run_waiting_for(Duration::from_secs_f64(5.));
assert!(test_bed.gear_system_state() == GearSystemState::Retracting);
assert!(test_bed.is_all_doors_really_down());
assert!(!test_bed.is_all_gears_really_down());
Expand Down Expand Up @@ -11338,5 +11397,122 @@ mod tests {
.run_waiting_for(Duration::from_secs_f64(120.));
assert!(!test_bed.yellow_reservoir_has_overheat_fault());
}

#[test]
fn gear_stays_uplocked_when_door_sensors_fails() {
let mut test_bed = test_bed_in_flight_with()
.set_cold_dark_inputs()
.in_flight()
.run_waiting_for(Duration::from_secs_f64(5.));

assert!(test_bed.gear_system_state() == GearSystemState::AllUpLocked);

test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::UplockDoorNose1,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::UplockDoorNose2,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::DownlockDoorNose1,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::DownlockDoorNose2,
));

test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(2.));

assert!(test_bed.is_all_doors_really_up());
assert!(test_bed.is_all_gears_really_up());
}

#[test]
fn gear_stays_uplocked_when_gear_sensors_fails() {
let mut test_bed = test_bed_in_flight_with()
.set_cold_dark_inputs()
.in_flight()
.run_waiting_for(Duration::from_secs_f64(5.));

assert!(test_bed.gear_system_state() == GearSystemState::AllUpLocked);

test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::UplockGearNose1,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::UplockGearNose2,
));

test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::DownlockGearNose1,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::DownlockGearNose2,
));

test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(2.));

assert!(test_bed.is_all_doors_really_up());
assert!(test_bed.is_all_gears_really_up());
}

#[test]
fn gear_stays_downlocked_when_gear_sensors_fails() {
let mut test_bed = test_bed_on_ground_with()
.set_cold_dark_inputs()
.in_flight()
.set_gear_lever_down()
.run_waiting_for(Duration::from_secs_f64(5.));

assert!(test_bed.gear_system_state() == GearSystemState::AllDownLocked);

test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::DownlockGearNose1,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::DownlockGearNose2,
));

test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::UplockGearNose1,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::UplockGearNose2,
));

test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(2.));

assert!(test_bed.is_all_doors_really_up());
assert!(test_bed.is_all_gears_really_down());
}

#[test]
fn gear_stays_downlocked_when_door_sensors_fails() {
let mut test_bed = test_bed_on_ground_with()
.set_cold_dark_inputs()
.in_flight()
.set_gear_lever_down()
.run_waiting_for(Duration::from_secs_f64(5.));

assert!(test_bed.gear_system_state() == GearSystemState::AllDownLocked);

test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::DownlockDoorNose1,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::DownlockDoorNose2,
));

test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::UplockDoorNose1,
));
test_bed.fail(FailureType::GearProxSensorDamage(
systems::shared::ProximityDetectorId::UplockDoorNose2,
));

test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(0.1));

assert!(test_bed.is_all_doors_really_up());
assert!(test_bed.is_all_gears_really_down());
}
}
}
70 changes: 0 additions & 70 deletions src/systems/a380_systems/src/hydraulic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10222,76 +10222,6 @@ mod tests {
assert!(test_bed.gear_system_state() == GearSystemState::AllUpLocked);
}

#[test]
fn gear_gravity_extension_reverted_has_correct_sequence() {
let mut test_bed = test_bed_in_flight_with()
.set_cold_dark_inputs()
.in_flight()
.run_one_tick();

assert!(test_bed.gear_system_state() == GearSystemState::AllUpLocked);

test_bed = test_bed
.turn_emergency_gear_extension_n_turns(3)
.run_waiting_for(Duration::from_secs_f64(35.));

assert!(test_bed.is_all_doors_really_down());
assert!(test_bed.is_all_gears_really_down());

test_bed = test_bed
.stow_emergency_gear_extension()
.run_waiting_for(Duration::from_secs_f64(5.));

// After 5 seconds we expect gear being retracted and doors still down
assert!(test_bed.gear_system_state() == GearSystemState::Retracting);
assert!(test_bed.is_all_doors_really_down());
assert!(!test_bed.is_all_gears_really_down());

test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(15.));

assert!(test_bed.gear_system_state() == GearSystemState::AllUpLocked);
assert!(test_bed.is_all_doors_really_up());
assert!(test_bed.is_all_gears_really_up());
}

// #[test]
// fn aileron_init_centered_if_spawning_in_air() {
// let mut test_bed = test_bed_in_flight_with()
// .set_cold_dark_inputs()
// .in_flight()
// .run_one_tick();

// assert!(test_bed.get_left_aileron_position().get::<ratio>() < 0.55);
// assert!(test_bed.get_right_aileron_position().get::<ratio>() < 0.55);
// assert!(test_bed.get_left_aileron_position().get::<ratio>() > 0.45);
// assert!(test_bed.get_right_aileron_position().get::<ratio>() > 0.45);
// }

// #[test]
// fn rudder_init_centered_if_spawning_in_air() {
// let mut test_bed = test_bed_in_flight_with()
// .set_cold_dark_inputs()
// .in_flight()
// .run_one_tick();

// assert!(test_bed.get_rudder_position().get::<ratio>() > 0.49);
// assert!(test_bed.get_rudder_position().get::<ratio>() < 0.51);
// }

// #[test]
// fn elevator_init_centered_if_spawning_in_air() {
// let mut test_bed = test_bed_in_flight_with()
// .set_cold_dark_inputs()
// .in_flight()
// .run_one_tick();

// // Elevator deflection is assymetrical so middle is below 0.5
// assert!(test_bed.get_left_elevator_position().get::<ratio>() < 0.45);
// assert!(test_bed.get_right_elevator_position().get::<ratio>() < 0.45);
// assert!(test_bed.get_left_elevator_position().get::<ratio>() > 0.35);
// assert!(test_bed.get_right_elevator_position().get::<ratio>() > 0.35);
// }
//
#[test]
fn brakes_on_ground_work_after_emergency_extension() {
let mut test_bed = test_bed_in_flight_with()
Expand Down
Loading