Skip to content

Commit

Permalink
fix(adirs): fix ADIRS low speed warning discrete logic (#8892)
Browse files Browse the repository at this point in the history
* fix(adirs): fix ADIRS low speed warning discrete logic

* fix(adirs): fix tests

* fix(adirs): remove dead code

* refactor(adirs): use one if block for discretes
  • Loading branch information
lukecologne authored Sep 19, 2024
1 parent 2f658a3 commit c8c6b9f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
4 changes: 2 additions & 2 deletions fbw-a32nx/src/wasm/systems/a320_systems/src/hydraulic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2695,7 +2695,7 @@ impl A320GearHydraulicController {
lgciu2: &impl LgciuWeightOnWheels,
) {
let speed_condition =
!adirs.low_speed_warning_4_260kts(1) || !adirs.low_speed_warning_4_260kts(3);
adirs.low_speed_warning_4_260kts(1) || adirs.low_speed_warning_4_260kts(3);

let on_ground_condition = lgciu1.left_and_right_gear_compressed(true)
|| lgciu2.left_and_right_gear_compressed(true);
Expand Down Expand Up @@ -6062,7 +6062,7 @@ mod tests {
}

fn low_speed_warning_4_260kts(&self, _: usize) -> bool {
self.airspeed.get::<knot>() > 260.
self.airspeed.get::<knot>() < 260.
}
}

Expand Down
4 changes: 2 additions & 2 deletions fbw-a380x/src/wasm/systems/a380_systems/src/hydraulic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3023,7 +3023,7 @@ impl A380GearHydraulicController {
lgciu2: &impl LgciuWeightOnWheels,
) {
let speed_condition =
!adirs.low_speed_warning_4_260kts(1) || !adirs.low_speed_warning_4_260kts(3);
adirs.low_speed_warning_4_260kts(1) || adirs.low_speed_warning_4_260kts(3);

let on_ground_condition = lgciu1.left_and_right_gear_compressed(true)
|| lgciu2.left_and_right_gear_compressed(true);
Expand Down Expand Up @@ -6594,7 +6594,7 @@ mod tests {
}

fn low_speed_warning_4_260kts(&self, _: usize) -> bool {
self.airspeed.get::<knot>() > 260.
self.airspeed.get::<knot>() < 260.
}
}
impl AdirsMeasurementOutputs for A380TestAdirus {
Expand Down
67 changes: 34 additions & 33 deletions fbw-common/src/wasm/systems/systems/src/navigation/adirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,43 +611,44 @@ impl AirDataInertialReferenceUnit {
self.ir.has_fault()
}

fn adr_is_valid(&self) -> bool {
self.adr.is_valid()
}

// If above speed threshold OR if data is unavailable: all discrete are set to TRUE
// When the ADR is unpowered (i.e. knob is set to OFF), all discretes go to open circuit (false).
// Discrete #4 is inverted, so ground when below 260kts, OC otherwise.
// When CAS is invalid but the ADR is otherwise powered (currently only possible when ADR p/b is off),
// 1-3 remain in their previous state, and 4 goes OC.
fn update_discrete_outputs(&mut self) {
let speed_knot = self.adr.computed_airspeed_raw().get::<knot>();

if speed_knot < 100. {
self.low_speed_warning_1_104kts = false;
} else if speed_knot > 104. {
self.low_speed_warning_1_104kts = true;
}
if self.adr.is_on {
if speed_knot < 100. {
self.low_speed_warning_1_104kts = false;
} else if speed_knot > 104. {
self.low_speed_warning_1_104kts = true;
}

if speed_knot < 50. {
self.low_speed_warning_2_54kts = false;
} else if speed_knot > 54. {
self.low_speed_warning_2_54kts = true;
}
if speed_knot < 50. {
self.low_speed_warning_2_54kts = false;
} else if speed_knot > 54. {
self.low_speed_warning_2_54kts = true;
}

if speed_knot < 155. {
self.low_speed_warning_3_159kts = false;
} else if speed_knot > 159. {
self.low_speed_warning_3_159kts = true;
if speed_knot < 155. {
self.low_speed_warning_3_159kts = false;
} else if speed_knot > 159. {
self.low_speed_warning_3_159kts = true;
}
}

if speed_knot < 260. {
self.low_speed_warning_4_260kts = false;
} else if speed_knot > 264. {
if speed_knot < 260. && self.adr.is_on {
self.low_speed_warning_4_260kts = true;
} else if speed_knot > 264. || !self.adr.is_on {
self.low_speed_warning_4_260kts = false;
}

if !self.adr_is_valid() {
self.low_speed_warning_1_104kts = true;
self.low_speed_warning_2_54kts = true;
self.low_speed_warning_3_159kts = true;
self.low_speed_warning_4_260kts = true;
if !self.adr.is_initialised() {
self.low_speed_warning_1_104kts = false;
self.low_speed_warning_2_54kts = false;
self.low_speed_warning_3_159kts = false;
self.low_speed_warning_4_260kts = false;
}
}

Expand Down Expand Up @@ -4610,13 +4611,13 @@ mod tests {
test_bed.run();

assert!(
!test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_4_260kts())
test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_4_260kts())
);

test_bed.set_indicated_airspeed(Velocity::new::<knot>(265.));
test_bed.run();
assert!(
test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_4_260kts())
!test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_4_260kts())
);
}

Expand All @@ -4630,19 +4631,19 @@ mod tests {
test_bed.run();

assert!(
test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_1_104kts())
!test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_1_104kts())
);

assert!(
test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_2_54kts())
!test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_2_54kts())
);

assert!(
test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_3_159kts())
!test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_3_159kts())
);

assert!(
test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_4_260kts())
!test_bed.query(|a| a.adirs.adirus[adiru_number - 1].low_speed_warning_4_260kts())
);
}
}
Expand Down

0 comments on commit c8c6b9f

Please sign in to comment.