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

feat(fws): rebuild flight warning system in Rust #4872

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

beheh
Copy link
Member

@beheh beheh commented May 23, 2021

Fixes #2460
Fixes #4482
Fixes #6503
Fixes #6585
Fixes #6692

Summary of Changes

This PR is the first step on the way to our new flight warning system, written nearly entirely in Rust and using an extremely accurate simulation of the underlying data acquisition and warning logic. The new system is made up two simulated Flight Warning Computers replacing some foundational logic pieces that were previously written in Javascript. The vast majority of warnings on the EWD still have exactly the same conditions as previously and have not been touched, but will be eventually moved over to the new flight warning computers one by one.

The new Flight Warning Computers are also hooked into the electrical and failure system, so the alerts that are now powered by the FWS truly won't work when both FWCs are unpowered or have failed.

Features

  • FWS Developer Documentation
  • Determination of the current Flight Phase to decide when warnings should appear or be inhibited
  • Conditions to show Takeoff and Landing memo
  • Sounds
    • Altitude alert ("C Chord" and flashing window)
    • Altitude call outs
      • Regular call outs ("Fifty", "Forty"...)
      • Intermediates ("Three Hundred And Ten")
    • "Hundred Above" and "Minimum" call out
      • ...when using RADIO
      • ...when using BARO incl. altimeter setting
    • "Retard" call outs
      • ...when doing a manual landing ("Twenty Retard...Retard...")
      • ...when doing an autoland ("Ten Retard...Retard...")
    • Inhibit certain callouts while GPWS or TCAS are playing sounds
    • Per-FWC sounds and cross-inhibition
    • Callout Buffering ("20/Retard Retard")
    • Prepare for attenuation
    • Prepare for audio inhibit (while pressing EMER CANC)
  • Hardware Lifecycle work
    • Add CPU 2 cycle time
    • Add startup delay
    • Detect boolean pulses
    • Skip startup delay when starting in non-cold & dark
    • Merge fix(elec): prevent power loss on runway spawn #7446 to prevent power loss on runway spawn
    • Fix engine running detection for spawn on runway (flight phase 1 vs. 2)
  • Failures (ATA 31)
    • Disable EWD warnings when both FWCs are unpowered or failed
    • Disable legacy sounds (triple click, cavalry charge, chime) when both FWCs are unpowered or failed
  • ECAM Control Panel
  • SimVars
    • Unify FWS/FWC naming scheme (A32NX_FWS_FWC_X_ABC & A32NX_FWS_ABC instead of A32NX_FWC_ABC)
    • Simvars Documentation
  • Tests
    • Flight Phase E2E tests
    • ECP
    • FWC/FWS hardware
    • Auto Callout E2E tests
    • Altitude alert E2E tests
  • Changelog

Screenshots (if necessary)

Alerts

Altitude Alert (video)
Intermediate Callouts (video)

Failures

image

References

Additional context

Discord username (if different from GitHub):

Reviewer Guide

A bulk of the FWC "logic" is implemented in the files in a320_systems/flight_warning/runtime/warnings. This may seem scary because it's so much code, but you don't have to review every single warning: the general pattern is uniform across all of them (struct with logic nodes, an update function with a signals parameter and pointers to other sheets, a trait to return warning/audio activation if necessary).

Testing instructions

This PR contains very few immediately obvious changes, but puts a massive system in place that takes care of all the altitude audio callouts and provides critical data for the warning part of the EWD (ECAM Warnings) to work. Test should be focused on making sure that the ECAM warnings and memos look as usual, and that flight phase appropriate memos or special lines (like TO INHIBIT and LDG INHIBIT) don't appear at unexpected times.

Detailed testing instructions

  1. Load the aircraft cold and dark, power it up and ensure there are no yellow ECAM warnings
  2. Start up both engines, and ensure the T.O MEMO appears automatically after around 2 minutes (indicating flight phase 2).
  3. Taxi to the runway, and perform a few rejected takeoffs at various speeds above and below 80 knots. You should observe the following:
    • No purple memo at IDLE
    • After 3 seconds of FLEX or TO/GA, a purple TO INHIBIT memo appears
    • No discernible difference on the ECAM for a rejected takeoff below 80 knots and above 85 kots
  4. Perform a takeoff. Observe the following:
    • TO INHIBIT disappears after reaching about 1500ft (indicating flight phase 6)
  5. While flying, test a few warnings that should only appear in flight (e.g. disable NWS to get an ECAM warning)
  6. Test the Altitude Warning. While handflying, with flaps = 0 and with the gear up, diverge from the target altitude. You should be able to mute it by pressing either Master Warning (it is expected they won't light up). Changing the altitude or one of the previously mentioned config items should mute the warning.
  7. Proceed to landing. Observe the following:
    • Upon passing around 200ft, the LDG MEMO should appear
    • Upon passing around 800ft and waiting 3 seconds, a purple LDG INHIBIT memo appears
    • Radio Altimeter callouts occur just before the PFD RA reaches the announced value
  8. Land and roll out with max braking so the brakes overheat (confirm on lower ECAM). Observe no ECAM warning.
  9. Shut down the engines, and wait 5 minutes. Observe the BRAKES HOT ECAM warning appearing (indicating flight phase 10).
  10. At your own discretion, perform one or more full flights (can be local). All ECAM warnings should appear as they did previously, and should not be suppressed at unexpected times.

How to download the PR for QA

Every new commit to this PR will cause a new A32NX artifact to be created, built, and uploaded.

  1. Make sure you are signed in to GitHub
  2. Click on the Checks tab on the PR
  3. On the left side, click on the bottom PR tab
  4. Click on the A32NX download link at the bottom of the page

@beheh

This comment has been minimized.

@beheh beheh changed the title First Rust FWC experiments feat: Rust FWC experiments May 24, 2021
@crocket63

This comment has been minimized.

@beheh

This comment has been minimized.

@beheh beheh changed the title feat: Rust FWC experiments feat: experimental implementation of FWS in Rust Jun 5, 2021
@beheh beheh changed the title feat: experimental implementation of FWS in Rust feat: FWC Flight Phases using new Rust FWS Jun 10, 2021
@beheh beheh force-pushed the rust-fwc branch 4 times, most recently from 95ef097 to 918f6d3 Compare August 6, 2021 08:37
src/systems/a320_systems/src/flight_warning/parameters.rs Outdated Show resolved Hide resolved

/// This struct represents the in-memory representation of the signals used by a Flight Warning
/// Computer to determine it's activations.
pub struct A320FWCParameterTable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I would be curious to know if we can somehow use Rust's procedural macros to greatly reduce the amount of typing needed here. As procedural macros are far more complex than regular macros, you might consider looking into this after this PR is completed.

src/systems/systems/src/flight_warning/logic.rs Outdated Show resolved Hide resolved
src/systems/systems/src/flight_warning/logic.rs Outdated Show resolved Hide resolved
src/systems/systems/src/flight_warning/logic.rs Outdated Show resolved Hide resolved
src/systems/a320_systems/src/flight_warning/mod.rs Outdated Show resolved Hide resolved
src/systems/a320_systems/src/flight_warning/mod.rs Outdated Show resolved Hide resolved
src/systems/a320_systems/src/flight_warning/mod.rs Outdated Show resolved Hide resolved
src/systems/a320_systems/src/flight_warning/mod.rs Outdated Show resolved Hide resolved
src/systems/a320_systems/src/flight_warning/mod.rs Outdated Show resolved Hide resolved
@beheh beheh force-pushed the rust-fwc branch 2 times, most recently from 768ea69 to 243158b Compare September 30, 2021 09:36
@beheh beheh changed the title feat: FWC Flight Phases using new Rust FWS feat: Flight Warning Computer implemented in Rust Dec 9, 2021
@beheh beheh force-pushed the rust-fwc branch 3 times, most recently from 11faf6c to 5c69dc6 Compare January 9, 2022 11:44
@beheh beheh changed the title feat: Flight Warning Computer implemented in Rust feat: Flight Warning Computer Jan 9, 2022
@beheh beheh changed the title feat: Flight Warning Computer feat: Flight Warning System Jan 9, 2022
@beheh beheh force-pushed the rust-fwc branch 3 times, most recently from ce79f18 to 03ac15a Compare January 12, 2022 10:47
@alepouna
Copy link
Member

Quality Assurance Trainee Report

Discord : Alepouna#9824
Object of testing: #4872
Tier of Testing : 2
Date : 23/05/2023

Testing Process:
Performed a full flight from LGAV to EGLL. During testing, followed all testing points.

  • [PASS] 1. Load the aircraft cold and dark, power it up and ensure there are no yellow ECAM warnings
  • [PASS] 2. Start up both engines, and ensure the T.O MEMO appears automatically after around 2 minutes (indicating flight phase 2).
  • [PASS*] 3. Taxi to the runway, and perform a few rejected takeoffs at various speeds above and below 80 knots. You should observe the following:
    • [PASS*] No purple memo at IDLE
    • [PASS*] After 3 seconds of FLEX or TO/GA, a purple TO INHIBIT memo appears
    • [PASS] No discernible difference on the ECAM for a rejected takeoff below 80 knots and above 85 kots
      Note: Performed 3 RTOs (79 Knots, 85 Knots, V1 150 Knots)
  • [PASS] 4. Perform a takeoff. Observe the following:
    • [PASS] * TO INHIBIT disappears after reaching about 1500ft (indicating flight phase 6)
  • [PASS] 5. While flying, test a few warnings that should only appear in flight (e.g. disable NWS to get an ECAM warning)
    * Tested with BRAKE HOT warning, NWS warning
  • [PASS] 6. Test the Altitude Warning. While handflying, with flaps = 0 and with the gear up, diverge from the target altitude. You should be able to mute it by pressing either Master Warning (it is expected they won't light up). Changing the altitude or one of the previously mentioned config items should mute the warning.
  • [PASS**] 7. Proceed to landing. Observe the following:
    • [PASS] * Upon passing around 200ft, the LDG MEMO should appear
    • [PASS] * Upon passing around 800ft and waiting 3 seconds, a purple LDG INHIBIT memo appears
    • [PASS**] * Radio Altimeter callouts occur just before the PFD RA reaches the announced value
  • [PASS] 8. Land and roll out with max braking so the brakes overheat (confirm on lower ECAM). Observe no ECAM warning.
  • [PASS] 9. Shut down the engines, and wait 5 minutes. Observe the BRAKES HOT ECAM warning appearing (indicating flight phase 10).

Negatives:

  • During test number 3, T.O MEMO did not show up after RTO. If this is expected behavior disregard.
  • During testing number 7C, announcement for 1000 was delayed by a second or two - could be sim lag.

Testing Results:
Pass

Notes:

  • After the first RTO the FMA Autothrust did not appear at either FLEX or TO/GA.

igor8518 pushed a commit to igor8518/a32nx that referenced this pull request Jun 3, 2023
@2hwk 2hwk removed the Exp Available on experimental branch (for testing) label Jun 29, 2023
@beheh beheh marked this pull request as draft July 15, 2023 20:32
@MM-coder
Copy link

MM-coder commented Nov 21, 2023

Hello, I'd be interested in working on ROPS/ROW, would this be covered under this PR? Seems futile to me to attempt to implement ROPS/ROW in TS when the FWS has been moved to Rust/will be moved to rust.

@beheh
Copy link
Member Author

beheh commented Nov 21, 2023

@MM-coder Barely, this PR is really just about prioritizing warnings and making them trigger the right sounds in the aircraft. I suspect the majority of the ROW/ROPS logic is elsewhere, e.g. the GPS/map checks and actual length calculations.
It's not in the scope of this PR.

@MM-coder
Copy link

MM-coder commented Nov 21, 2023

@MM-coder Barely, this PR is really just about prioritizing warnings and making them trigger the right sounds in the aircraft. I suspect the majority of the ROW/ROPS logic is elsewhere, e.g. the GPS/map checks and actual length calculations.
It's not in the scope of this PR.

Understood thank you.

I've since checked the AMM, it's calculated in the FAC.

Implementation wise, would a new system preferably be written in rust or TS? Is the current project ethos moving towards Rust?

@beheh
Copy link
Member Author

beheh commented Nov 21, 2023

Implementation wise, would a new system preferably be written in rust or TS? Is the current project ethos moving towards Rust?

Yes, we're generally writing systems in Rust nowadays. TS really just for UI or accessing data that's otherwise not available to Rust APIs. Feel free to join our Discord to ask for further guidance, e.g. in #dev-support!

Copy link
Contributor

@RSickenberg RSickenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not qualified to read Rust but I can fix this :D

Seems interesting, can't wait to have this deployed! 🥳

@@ -3675,6 +3719,12 @@ In the variables below, {number} should be replaced with one item in the set: {
- {number}
- 0
- 1

- A32NX_TCAS_AURAL_ADVISORY_OUTPUT
- boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- boolean
- Bool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet