Skip to content

Commit

Permalink
refactor(hyd): Flap/slat logic to rust (flybywiresim#6122)
Browse files Browse the repository at this point in the history

Co-authored-by: Omry Ginzburg <[email protected]>
Co-authored-by: omrygin <[email protected]>
Co-authored-by: Benjamin Dupont <[email protected]>
Co-authored-by: Andreas Guther <[email protected]>
Co-authored-by: David Walschots <[email protected]>
Co-authored-by: BBK <[email protected]>
  • Loading branch information
7 people authored Nov 23, 2021
1 parent ef11897 commit 6c72eb6
Show file tree
Hide file tree
Showing 18 changed files with 1,793 additions and 403 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions docs/a320-simvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,70 @@
0 | Retracted
1 | Full extension

- A32NX_LEFT_FLAPS_POSITION_PERCENT
- Percent
- Indicates the angle of the left flaps out of 40 degrees

- A32NX_RIGHT_FLAPS_POSITION_PERCENT
- Percent
- Indicates the angle of the right flaps out of 40 degrees

- A32NX_LEFT_SLATS_POSITION_PERCENT
- Percent
- Indicates the angle of the left slats out of 27 degrees

- A32NX_RIGHT_SLATS_POSITION_PERCENT
- Percent
- Indicates the angle of the right slats out of 27 degrees

- A32NX_LEFT_FLAPS_TARGET_ANGLE
- Degrees
- Indicates the target angle of the left flaps
according to the configuration.

- A32NX_RIGHT_FLAPS_TARGET_ANGLE
- Degrees
- Indicates the target angle of the right flaps
according to the configuration.

- A32NX_LEFT_SLATS_TARGET_ANGLE
- Degrees
- Indicates the target angle of the left slats
according to the configuration.

- A32NX_RIGHT_SLATS_TARGET_ANGLE
- Degrees
- Indicates the target angle of the right slats
according to the configuration.

- A32NX_LEFT_FLAPS_ANGLE
- Degrees
- The actual angle of the left flaps

- A32NX_RIGHT_FLAPS_ANGLE
- Degrees
- The actual angle of the right flaps

- A32NX_LEFT_SLATS_ANGLE
- Degrees
- The actual angle of the left slats

- A32NX_RIGHT_SLATS_ANGLE
- Degrees
- The actual angle of the right slats

- A32NX_FLAPS_CONF_INDEX
- Number
- Indicates the desired flap configuration index according to the table
- Value | Meaning
--- | ---
0 | Conf0
1 | Conf1
2 | Conf1F
3 | Conf2
4 | Conf3
5 | ConfFull

- A32NX_SPOILERS_ARMED
- Bool
- Indicates if the ground spoilers are armed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const FLAPS_IN_MOTION_MIN_DELTA = 0.1;
class A32NX_LocalVarUpdater {
constructor() {
// Initial data for deltas
this.lastFlapsPosition = SimVar.GetSimVarValue("TRAILING EDGE FLAPS LEFT PERCENT", "percent");
this.lastFlapsPosition = SimVar.GetSimVarValue("L:A32NX_LEFT_FLAPS_POSITION_PERCENT", "Percent");
// track which compartment has gotten temperature initialization
this.initializedCabinTemp = {
"CKPT":false,
Expand Down Expand Up @@ -178,7 +178,7 @@ class A32NX_LocalVarUpdater {
}

_flapsInMotionSelector() {
const currentFlapsPosition = SimVar.GetSimVarValue("TRAILING EDGE FLAPS LEFT PERCENT", "percent");
const currentFlapsPosition = SimVar.GetSimVarValue("L:A32NX_LEFT_FLAPS_POSITION_PERCENT", "Percent");
const lastFlapsPosition = this.lastFlapsPosition;

this.lastFlapsPosition = currentFlapsPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class A32NX_Speeds {
/** Using true fhi for comparison */
const isTo = fhi === SimVar.GetSimVarValue("L:A32NX_TO_CONFIG_FLAPS", "number");
/** Change fhi to differentiate between 1 and 1 + F */
if (fhi === 1 && SimVar.GetSimVarValue("FLAPS HANDLE INDEX", "Enum") === 1) {
if (fhi === 1 && SimVar.GetSimVarValue("L:A32NX_FLAPS_CONF_INDEX", "Enum") === 1) {
fhi = 5;
}
const gw = this.round(SimVar.GetSimVarValue("TOTAL WEIGHT", "kg")) / 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1810,10 +1810,10 @@ var A320_Neo_UpperECAM;
}
}
updateTakeoffConfigWarnings(_test) {
const slatsLeft = SimVar.GetSimVarValue("LEADING EDGE FLAPS LEFT ANGLE", "degrees");
const slatsRight = SimVar.GetSimVarValue("LEADING EDGE FLAPS RIGHT ANGLE", "degrees");
const flapsLeft = SimVar.GetSimVarValue("TRAILING EDGE FLAPS LEFT ANGLE", "degrees");
const flapsRight = SimVar.GetSimVarValue("TRAILING EDGE FLAPS RIGHT ANGLE", "degrees");
const slatsLeft = SimVar.GetSimVarValue("L:A32NX_LEFT_SLATS_ANGLE", "degrees");
const slatsRight = SimVar.GetSimVarValue("L:A32NX_RIGHT_SLATS_ANGLE", "degrees");
const flapsLeft = SimVar.GetSimVarValue("L:A32NX_LEFT_FLAPS_ANGLE", "degrees");
const flapsRight = SimVar.GetSimVarValue("L:A32NX_RIGHT_FLAPS_ANGLE", "degrees");
const flapsHandle = SimVar.GetSimVarValue("L:A32NX_FLAPS_HANDLE_INDEX", "Enum");
const flapsMcdu = SimVar.GetSimVarValue("L:A32NX_TO_CONFIG_FLAPS", "number");
const flapsMcduEntered = SimVar.GetSimVarValue("L:A32NX_TO_CONFIG_FLAPS_ENTERED", "bool");
Expand Down Expand Up @@ -2672,9 +2672,9 @@ var A320_Neo_UpperECAM;
}
update(_deltaTime) {
super.update(_deltaTime);
const slatsAngle = (SimVar.GetSimVarValue("LEADING EDGE FLAPS LEFT ANGLE", "degrees") + SimVar.GetSimVarValue("LEADING EDGE FLAPS RIGHT ANGLE", "degrees")) * 0.5;
const flapsAngle = Math.max(0, (SimVar.GetSimVarValue("TRAILING EDGE FLAPS LEFT ANGLE", "degrees") + SimVar.GetSimVarValue("TRAILING EDGE FLAPS RIGHT ANGLE", "degrees")) * 0.5);
const handleIndex = SimVar.GetSimVarValue("FLAPS HANDLE INDEX", "Number");
const slatsAngle = (SimVar.GetSimVarValue("L:A32NX_LEFT_SLATS_ANGLE", "degrees") + SimVar.GetSimVarValue("L:A32NX_LEFT_SLATS_ANGLE", "degrees")) * 0.5;
const flapsAngle = Math.max(0, (SimVar.GetSimVarValue("L:A32NX_LEFT_FLAPS_ANGLE", "degrees") + SimVar.GetSimVarValue("L:A32NX_LEFT_FLAPS_ANGLE", "degrees")) * 0.5);
const handleIndex = SimVar.GetSimVarValue("L:A32NX_FLAPS_CONF_INDEX", "Number");
let slatsTargetIndex = 0;
let flapsTargetIndex = 0;
switch (handleIndex) {
Expand Down
1 change: 0 additions & 1 deletion src/fbw/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ clang++ \
"${DIR}/src/zlib/zfstream.cc" \
"${DIR}/src/AnimationAileronHandler.cpp" \
"${DIR}/src/ElevatorTrimHandler.cpp" \
"${DIR}/src/FlapsHandler.cpp" \
"${DIR}/src/FlyByWireInterface.cpp" \
"${DIR}/src/FlightDataRecorder.cpp" \
"${DIR}/src/LocalVariable.cpp" \
Expand Down
154 changes: 0 additions & 154 deletions src/fbw/src/FlapsHandler.cpp

This file was deleted.

48 changes: 0 additions & 48 deletions src/fbw/src/FlapsHandler.h

This file was deleted.

Loading

0 comments on commit 6c72eb6

Please sign in to comment.