Skip to content

Commit

Permalink
Added expedited flaps/slates movement for expedited presets
Browse files Browse the repository at this point in the history
  • Loading branch information
frankkopp committed Apr 13, 2024
1 parent fb5e718 commit 460f6c8
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@ class AircraftPresetProcedures_A32NX {
"(L:A32NX_OVHD_PNEU_APU_BLEED_PB_IS_ON) ||", "1 (>L:A32NX_OVHD_PNEU_APU_BLEED_PB_IS_ON)"},

// To allow slats/flaps to retract in expedited mode when engines were running before and slats/flaps were out
// TODO: Check if the flaps are actually out
ProcedureStep{"Yellow Elec Pump On", EXON, 1000, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 0 == "
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 0 == && "
ProcedureStep{"Yellow Elec Pump On", STEP, 200, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 1 <= "
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 1 <= && "
"(L:A32NX_LEFT_SLATS_POSITION_PERCENT) 1 <= && "
"(L:A32NX_RIGHT_SLATS_POSITION_PERCENT) 1 <= && "
"(L:A32NX_OVHD_HYD_EPUMPY_PB_IS_AUTO) 0 == ||", "0 (>L:A32NX_OVHD_HYD_EPUMPY_PB_IS_AUTO)"},
ProcedureStep{"Await Flaps 0", COND, 1000, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 1 <= "
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 1 <= &&", ""},
ProcedureStep{"Await Slats 0", COND, 1000, "(L:A32NX_LEFT_SLATS_POSITION_PERCENT) 1 <= "
"(L:A32NX_RIGHT_SLATS_POSITION_PERCENT) 1 <= &&", ""},
ProcedureStep{"Yellow Elec Pump Off", STEP, 200, "(L:A32NX_OVHD_HYD_EPUMPY_PB_IS_AUTO) 1 ==", "1 (>L:A32NX_OVHD_HYD_EPUMPY_PB_IS_AUTO)"},


//WORKAROUND for intermittent HOT AIR PB Fault when using expedited mode
ProcedureStep{"HOT AIR PB Reset", STEP, 0, "(L:A32NX_OVHD_COND_HOT_AIR_PB_HAS_FAULT) 0 ==", "0 (>L:A32NX_OVHD_COND_HOT_AIR_PB_IS_ON) "},
Expand Down Expand Up @@ -186,6 +193,12 @@ class AircraftPresetProcedures_A32NX {
ProcedureStep{"TCAS TRAFFIC Abv", STEP, 2000, "(L:A32NX_SWITCH_TCAS_TRAFFIC_POSITION) 2 ==", "2 (>L:A32NX_SWITCH_TCAS_TRAFFIC_POSITION)"},
ProcedureStep{"Autobrake Max", STEP, 2000, "(L:A32NX_AUTOBRAKES_ARMED_MODE) 3 ==", "3 (>L:A32NX_AUTOBRAKES_ARMED_MODE_SET)"},
ProcedureStep{"TERR ON ND Capt. On", STEP, 2000, "(L:A32NX_EFIS_TERR_L_ACTIVE) 1 ==", "1 (>L:A32NX_EFIS_TERR_L_ACTIVE)"},

ProcedureStep{"Await Flaps 1+F", COND, 1000, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 24 >= "
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 24 >= &&", ""},
ProcedureStep{"Await Slats 1+F", COND, 1000, "(L:A32NX_LEFT_SLATS_POSITION_PERCENT) 66 >= "
"(L:A32NX_RIGHT_SLATS_POSITION_PERCENT) 66 >= &&", ""},

ProcedureStep{"T.O Config", STEP, 200, "", "1 (>L:A32NX_BTN_TOCONFIG)"},
ProcedureStep{"T.O Config", STEP, 2000, "", "0 (>L:A32NX_BTN_TOCONFIG)"},
},
Expand All @@ -203,10 +216,11 @@ class AircraftPresetProcedures_A32NX {
ProcedureStep{"Flaps 0", STEP, 2000, "(L:A32NX_FLAPS_HANDLE_INDEX) 0 ==", "0 (>L:A32NX_FLAPS_HANDLE_INDEX)"},
ProcedureStep{"Rudder Trim Reset", STEP, 2000, "(A:RUDDER TRIM, Radians) 0 ==", "0 (>K:RUDDER_TRIM_SET)"},
ProcedureStep{"Spoiler Disarm", STEP, 2000, "(L:A32NX_SPOILERS_ARMED) 0 ==", "0 (>K:SPOILERS_ARM_SET)"},
ProcedureStep{"Await Flaps 0", NCON, 1000, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 0 =="
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 0 == &&", ""},
ProcedureStep{"Await Slats 0", NCON, 1000, "(L:A32NX_LEFT_SLATS_POSITION_PERCENT) 0 == "
"(L:A32NX_RIGHT_SLATS_POSITION_PERCENT) 0 == &&", ""},

ProcedureStep{"Await Flaps 0", COND, 1000, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 1 <="
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 1 <= &&", ""},
ProcedureStep{"Await Slats 0", COND, 1000, "(L:A32NX_LEFT_SLATS_POSITION_PERCENT) 1 <= "
"(L:A32NX_RIGHT_SLATS_POSITION_PERCENT) 1 <= &&", ""},

ProcedureStep{"ENG 1 Off", STEP, 2000, "(A:FUELSYSTEM VALVE OPEN:1, Bool) !", "1 (>K:FUELSYSTEM_VALVE_CLOSE)"},
ProcedureStep{"ENG 2 Off", STEP, 2000, "(A:FUELSYSTEM VALVE OPEN:2, Bool) !", "2 (>K:FUELSYSTEM_VALVE_CLOSE)"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ class AircraftPresetProcedures_A380X {
ProcedureStep{"Autobrake RTO", STEP, 200, "(L:A32NX_AUTOBRAKES_RTO_ARMED) 1 ==", "1 (>L:A32NX_OVHD_AUTOBRK_RTO_ARM_IS_PRESSED)"},
ProcedureStep{"TERR ON ND Capt. On", STEP, 2000, "(L:A32NX_EFIS_TERR_L_ACTIVE) 1 ==", "1 (>L:A32NX_EFIS_TERR_L_ACTIVE)"},

ProcedureStep{"Await Flaps 1+F", COND, 1000, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 24 >= "
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 24 >= &&", ""},
ProcedureStep{"Await Slats 1+F", COND, 1000, "(L:A32NX_LEFT_SLATS_POSITION_PERCENT) 66 >= "
"(L:A32NX_RIGHT_SLATS_POSITION_PERCENT) 66 >= &&", ""},

ProcedureStep{"T.O. Config", STEP, 2000, "", "1 (>L:A32NX_TO_CONFIG_NORMAL)"},
},

Expand All @@ -241,10 +246,11 @@ class AircraftPresetProcedures_A380X {
ProcedureStep{"Flaps 0", STEP, 2000, "(L:A32NX_FLAPS_HANDLE_INDEX) 0 ==", "0 (>L:A32NX_FLAPS_HANDLE_INDEX)"},
ProcedureStep{"Rudder Trim Reset", STEP, 2000, "(A:RUDDER TRIM, Radians) 0 ==", "0 (>K:RUDDER_TRIM_SET)"},
ProcedureStep{"Spoiler Disarm", STEP, 2000, "(L:A32NX_SPOILERS_ARMED) 0 ==", "0 (>K:SPOILERS_ARM_SET)"},
ProcedureStep{"Await Flaps 0", NCON, 1000, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 0 =="
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 0 == &&", ""},
ProcedureStep{"Await Slats 0", NCON, 1000, "(L:A32NX_LEFT_SLATS_POSITION_PERCENT) 0 == "
"(L:A32NX_RIGHT_SLATS_POSITION_PERCENT) 0 == &&", ""},

ProcedureStep{"Await Flaps 0", COND, 1000, "(L:A32NX_LEFT_FLAPS_POSITION_PERCENT) 1 <= "
"(L:A32NX_RIGHT_FLAPS_POSITION_PERCENT) 1 <= &&", ""},
ProcedureStep{"Await Slats 0", COND, 1000, "(L:A32NX_LEFT_SLATS_POSITION_PERCENT) 1 <= "
"(L:A32NX_RIGHT_SLATS_POSITION_PERCENT) 1 <= &&", ""},

ProcedureStep{"ENG 4 Off", STEP, 2000, "(A:FUELSYSTEM VALVE OPEN:4, Bool) !", "4 (>K:FUELSYSTEM_VALVE_CLOSE)"},
ProcedureStep{"ENG 3 Off", STEP, 2000, "(A:FUELSYSTEM VALVE OPEN:3, Bool) !", "3 (>K:FUELSYSTEM_VALVE_CLOSE)"},
Expand Down
52 changes: 41 additions & 11 deletions fbw-common/src/wasm/systems/systems/src/hydraulic/flap_slat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use uom::si::{
};

use std::time::Duration;
use uom::si::time::second;

/// Simple hydraulic motor directly driven with a speed.
/// Speed is smoothly rising or lowering to simulate transients states
Expand Down Expand Up @@ -53,7 +54,12 @@ impl FlapSlatHydraulicMotor {

fn update_speed(&mut self, context: &UpdateContext, speed: AngularVelocity) {
// Low pass filter to simulate motors spool up and down. Will ease pressure impact on transients
self.speed.update(context.delta(), speed);
if !context.aircraft_preset_quick_mode() {
self.speed.update(context.delta(), speed);
} else {
// This is for the Aircraft Presets to expedite the setting of a preset.
self.speed.update(Duration::from_secs(2), speed);
}

// Forcing 0 speed at low speed to avoid endless spool down due to low pass filter
if self.speed.output().get::<revolution_per_minute>() < Self::MIN_MOTOR_RPM
Expand All @@ -71,8 +77,14 @@ impl FlapSlatHydraulicMotor {
/ 231.,
);

self.total_volume_to_actuator += self.current_flow * context.delta_as_time();
self.total_volume_returned_to_reservoir += self.current_flow * context.delta_as_time();
if !context.aircraft_preset_quick_mode() {
self.total_volume_to_actuator += self.current_flow * context.delta_as_time();
self.total_volume_returned_to_reservoir += self.current_flow * context.delta_as_time();
} else {
// This is for the Aircraft Presets to expedite the setting of a preset.
self.total_volume_to_actuator += self.current_flow * Time::new::<second>(2.);
self.total_volume_returned_to_reservoir += self.current_flow * Time::new::<second>(2.);
}
}

fn torque(&self, pressure: Pressure) -> Torque {
Expand Down Expand Up @@ -234,14 +246,26 @@ impl FlapSlatAssembly {

fn update_speed_and_position(&mut self, context: &UpdateContext) {
if self.final_requested_synchro_gear_position > self.position_feedback() {
self.surface_control_arm_position += Angle::new::<radian>(
self.max_speed().get::<radian_per_second>() * context.delta_as_secs_f64(),
);
if !context.aircraft_preset_quick_mode() {
self.surface_control_arm_position += Angle::new::<radian>(
self.max_speed().get::<radian_per_second>() * context.delta_as_secs_f64(),
);
} else {
// This is for the Aircraft Presets to expedite the setting of a preset.
self.surface_control_arm_position +=
Angle::new::<radian>(self.max_speed().get::<radian_per_second>() * 2.);
}
self.speed = self.max_speed();
} else if self.final_requested_synchro_gear_position < self.position_feedback() {
self.surface_control_arm_position -= Angle::new::<radian>(
self.max_speed().get::<radian_per_second>() * context.delta_as_secs_f64(),
);
if !context.aircraft_preset_quick_mode() {
self.surface_control_arm_position -= Angle::new::<radian>(
self.max_speed().get::<radian_per_second>() * context.delta_as_secs_f64(),
);
} else {
// This is for the Aircraft Presets to expedite the setting of a preset.
self.surface_control_arm_position -=
Angle::new::<radian>(self.max_speed().get::<radian_per_second>() * 2.);
}
self.speed = -self.max_speed();
} else {
self.speed = AngularVelocity::new::<radian_per_second>(0.);
Expand Down Expand Up @@ -318,8 +342,14 @@ impl FlapSlatAssembly {
}

// Final max speed filtered to simulate smooth movements
self.current_max_speed
.update(context.delta(), new_theoretical_max_speed);
if !context.aircraft_preset_quick_mode() {
self.current_max_speed
.update(context.delta(), new_theoretical_max_speed);
} else {
// This is for the Aircraft Presets to expedite the setting of a preset.
self.current_max_speed
.update(Duration::from_secs(2), new_theoretical_max_speed);
}
}

fn max_speed_factor_from_pressure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,27 +704,15 @@ impl UpdateContext {
}

pub fn delta(&self) -> Duration {
if !self.aircraft_preset_quick_mode {
self.delta.into()
} else {
Duration::from_secs(1).into()
}
self.delta.into()
}

pub fn delta_as_secs_f64(&self) -> f64 {
if !self.aircraft_preset_quick_mode {
self.delta.into()
} else {
1.
}
self.delta.into()
}

pub fn delta_as_time(&self) -> Time {
if !self.aircraft_preset_quick_mode {
self.delta.into()
} else {
Time::new::<second>(1.)
}
self.delta.into()
}

pub fn simulation_time(&self) -> f64 {
Expand Down

0 comments on commit 460f6c8

Please sign in to comment.