Skip to content

Commit

Permalink
fix(brakes): Instinctive disconnect only when AB active (flybywiresim…
Browse files Browse the repository at this point in the history
…#9085)

* Instinctive disconnect only when AB active

* test margins

* naming

* remove debug test

---------

Co-authored-by: flogross89 <[email protected]>
  • Loading branch information
crocket63 and flogross89 authored Oct 18, 2024
1 parent 1f09fdd commit 5f899e5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub struct A380AutobrakeController {
active_id: VariableIdentifier,
rto_mode_armed_id: VariableIdentifier,

external_disarm_event_id: VariableIdentifier,
external_deactivation_event_id: VariableIdentifier,

deceleration_governor: AutobrakeDecelerationGovernor,
decelerating_light: bool,
Expand All @@ -191,7 +191,7 @@ pub struct A380AutobrakeController {
autobrake_knob: A380AutobrakeKnobSelectorSolenoid,
selection_knob_should_return_disarm: DelayedTrueLogicGate,

external_disarm_event: bool,
external_deactivation_event: bool,

placeholder_ground_spoilers_out: bool,

Expand Down Expand Up @@ -229,7 +229,8 @@ impl A380AutobrakeController {
active_id: context.get_identifier("AUTOBRAKES_ACTIVE".to_owned()),
rto_mode_armed_id: context.get_identifier("AUTOBRAKES_RTO_ARMED".to_owned()),

external_disarm_event_id: context.get_identifier("AUTOBRAKE_DISARM".to_owned()),
external_deactivation_event_id: context
.get_identifier("AUTOBRAKE_INSTINCTIVE_DISCONNECT".to_owned()),

deceleration_governor: AutobrakeDecelerationGovernor::new(),
decelerating_light: false,
Expand Down Expand Up @@ -262,7 +263,7 @@ impl A380AutobrakeController {
Self::KNOB_SOLENOID_DISARM_DELAY,
),

external_disarm_event: false,
external_deactivation_event: false,

placeholder_ground_spoilers_out: false,

Expand Down Expand Up @@ -412,10 +413,11 @@ impl A380AutobrakeController {
// when a simulation is started in flight, some values need to be ignored for a certain time to ensure
// an unintended disarm is not happening
(self.deceleration_governor.is_engaged() && self.should_disarm_due_to_pedal_input())
|| (self.deceleration_governor.is_engaged()
&& (self.external_deactivation_event && self.mode != A380AutobrakeMode::RTO))
|| (context.is_sim_ready() && !self.arming_is_allowed_by_bcu)
|| self.spoilers_retracted_during_this_update()
|| self.should_disarm_after_time_in_flight.output()
|| (self.external_disarm_event && self.mode != A380AutobrakeMode::RTO)
|| (self.mode == A380AutobrakeMode::RTO
&& self.should_reject_rto_mode_after_time_in_flight.output())
|| (self.mode == A380AutobrakeMode::BTV && !self.btv_scheduler.is_armed())
Expand Down Expand Up @@ -589,7 +591,7 @@ impl SimulationElement for A380AutobrakeController {
self.last_ground_spoilers_are_deployed = self.ground_spoilers_are_deployed;
self.ground_spoilers_are_deployed = self.placeholder_ground_spoilers_out;

self.external_disarm_event = reader.read(&self.external_disarm_event_id);
self.external_deactivation_event = reader.read(&self.external_deactivation_event_id);

// Reading current mode in sim to initialize correct mode if sim changes it (from .FLT files for example)
let readed_mode = reader.read_f64(&self.armed_mode_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(super) fn autobrakes(builder: &mut MsfsAspectBuilder) -> Result<(), Box<dyn
builder.event_to_variable(
"A32NX.AUTO_THROTTLE_DISCONNECT",
EventToVariableMapping::Value(1.),
Variable::named("AUTOBRAKE_DISARM"),
Variable::named("AUTOBRAKE_INSTINCTIVE_DISCONNECT"),
option_button_press,
)?;

Expand All @@ -54,6 +54,12 @@ pub(super) fn autobrakes(builder: &mut MsfsAspectBuilder) -> Result<(), Box<dyn
Variable::named("AUTOBRAKES_SELECTED_MODE"),
options_set,
)?;
builder.event_to_variable(
"AUTOBRAKE_DISARM",
EventToVariableMapping::Value(0.),
Variable::named("AUTOBRAKES_SELECTED_MODE"),
options_set,
)?;
builder.event_to_variable(
"A32NX.AUTOBRAKE_SET_BTV",
EventToVariableMapping::Value(1.),
Expand Down
4 changes: 2 additions & 2 deletions fbw-common/src/wasm/systems/systems/src/engine/reverser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,11 @@ mod tests {
test_bed.command(|a| a.set_deploy_reverser(true));
test_bed.command(|a| a.set_lock_reverser(false));

test_bed.run_with_delta(Duration::from_millis(1000));
test_bed.run_with_delta(Duration::from_millis(1500));

assert!(test_bed.query(|a| a.reverser_position().get::<ratio>()) >= 0.3);

test_bed.run_with_delta(Duration::from_millis(1500));
test_bed.run_with_delta(Duration::from_millis(2000));

assert!(test_bed.query(|a| a.reverser_position().get::<ratio>()) >= 0.99);
}
Expand Down
6 changes: 3 additions & 3 deletions fbw-common/src/wasm/systems/systems/src/hydraulic/reverser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,14 @@ mod tests {
test_bed.command(|a| a.set_deploy_reverser(true));
test_bed.command(|a| a.set_lock_reverser(false));

test_bed.run_with_delta(Duration::from_millis(1000));
test_bed.run_with_delta(Duration::from_millis(1500));

assert!(test_bed.query(|a| a.reverser_manifold_pressure().get::<psi>()) >= 2800.);
assert!(test_bed.query(|a| a.reverser_position().get::<ratio>()) >= 0.3);

test_bed.run_with_delta(Duration::from_millis(1500));
test_bed.run_with_delta(Duration::from_millis(2000));

assert!(test_bed.query(|a| a.reverser_position().get::<ratio>()) >= 0.99);
assert!(test_bed.query(|a| a.reverser_position().get::<ratio>()) >= 0.98);
}

#[test]
Expand Down

0 comments on commit 5f899e5

Please sign in to comment.