Skip to content

Commit

Permalink
feat(tcas): TCAS TA/RA logic and annunciations (ReactJS/TS) #5934
Browse files Browse the repository at this point in the history
Co-authored-by: Will Pine <wpine215@gmail.com>
  • Loading branch information
2 people authored and aguther committed Feb 14, 2022
1 parent 474ef9d commit d163264
Show file tree
Hide file tree
Showing 37 changed files with 2,995 additions and 58 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
1. [ATHR] Fix ATHR Speed Undershoot - @IbrahimK42 (IbrahimK42)
1. [FLIGHTMODEL] Improved pitch stability in turbulence - @aguther (Andreas Guther)
1. [AP] Fix DES not being armed in ALT CST and altitude constraint changing to FCU altitude - @aguther (Andreas Guther)
1. [TCAS] Implemented traffic advisories, resolution advisories, and collision avoidance logic - @wpine215 (Iceman) @2hwk (2Cas#1022)
1. [PFD] Implemented TCAS guidance on vertical speed tape - @wpine215 (Iceman)
1. [SOUNDS] Connected TCAS TA/RA logic to TCAS Wwise events - @wpine215 (Iceman) @2hwk (2Cas#1022)

## 0.7.0

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/flybywire-aircraft-a320-neo/build_info.json
/flybywire-aircraft-a320-neo/html_ui/JS/atsu/
/flybywire-aircraft-a320-neo/html_ui/JS/fmgc/
/flybywire-aircraft-a320-neo/html_ui/JS/tcas/
/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX
/flybywire-aircraft-a320-neo/html_ui/JS/generated/**
/flybywire-aircraft-a320-neo/ModelBehaviorDefs/A32NX/generated
Expand Down Expand Up @@ -38,6 +39,7 @@ node_modules
/src/sound/.cache
/src/instruments/aceBundles
/src/instruments/src/EFB/dist
/src/instruments/buildSrc/custom/*
/src/autothrottle/target
/flybywire-aircraft-a320-neo/SimObjects/AirPlanes/FlyByWire_A320_NEO/model/*.gltf
/flybywire-aircraft-a320-neo/SimObjects/AirPlanes/FlyByWire_A320_NEO/model/*.bin
Expand Down
98 changes: 88 additions & 10 deletions docs/a320-simvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,47 +252,47 @@
- Bool
- True when the FWC decides that flight phase inhibits should be overridden (and ignored)

- A32NX_VSPEEDS_VS
- A32NX_SPEEDS_VS
- Number
- Current config stall speed
- is mach corrected

- A32NX_VSPEEDS_VLS
- A32NX_SPEEDS_VLS
- Number
- Current config minimum selectable speed
- is mach corrected

- A32NX_VSPEEDS_F
- A32NX_SPEEDS_F
- Number
- F-Speed (approach)

- A32NX_VSPEEDS_S
- A32NX_SPEEDS_S
- Number
- S-Speed (approach)

- A32NX_VSPEEDS_GD
- A32NX_SPEEDS_GD
- Number
- Green Dot speed (clean config or O)
- is mach corrected

- A32NX_VSPEEDS_LANDING_CONF3
- A32NX_SPEEDS_LANDING_CONF3
- Bool
- True if FLAPS 3 is selected in perf page

- A32NX_VSPEEDS_TO_CONF
- A32NX_SPEEDS_TO_CONF
- Number
- Flaps config for TakeOff, 1, 2 or 3

- A32NX_VSPEEDS_V2
- A32NX_SPEEDS_V2
- Number
- TakeOff V2 Speed calculated based on A32NX_VSPEEDS_TO_CONF config

- A32NX_VSPEEDS_VLS_APP
- A32NX_SPEEDS_VLS_APP
- Number
- vls calculated for config full whether A32NX_VSPEEDS_LANDING_CONF3 or not
- is mach corrected

- A32NX_VSPEEDS_VAPP
- A32NX_SPEEDS_VAPP
- Number
- vapp calculated for config full whether A32NX_VSPEEDS_LANDING_CONF3 or not
- is mach corrected
Expand Down Expand Up @@ -2368,3 +2368,81 @@ In the variables below, {number} should be replaced with one item in the set: {
- A32NX_OVHD_PNEU_ENG_{number}_BLEED_PB_HAS_FAULT:
- Indicates whether the fault light is on for the engine bleed push button
- Bool

## Traffic Collison Avoidance System

- A32NX_SWITCH_TCAS_Position
- Enum
- Read-Only
- Selected TCAS Mode
Description | Value
--- | ---
STBY | 0
TA | 1
TA/RA | 2

- A32NX_SWITCH_ATC
- Enum
- Read-Only
- Selected active transponder (XPDR1/2)
Description | Value
--- | ---
XPDR1 | 0
XPDR2 | 1

- A32NX_SWITCH_TCAS_Traffic_Position
- Enum
- Read-Only
- Selected TCAS Display Mode
Description | Value
--- | ---
THREAT | 0
ALL | 1
ABV | 2
BELOW | 3

- A32NX_TCAS_MODE
- Enum
- Read-Only
- Whether TCAS has been set to standby, TA Only or TA/RA Mode (see ATC panel)
Description | Value
--- | ---
STBY | 0
TA | 1
TA/RA | 2

- A32NX_TCAS_SENSITIVITY
- Number
- Read-Only
- Current sensitivity level

- A32NX_TCAS_STATE
- Enum
- Read-Only
- Currently active traffic/resolution advisory state
Description | Value
--- | ---
NONE | 0
TA | 1
RA | 2

- A32NX_TCAS_RA_CORRECTIVE
- boolean
- Read-Only
- Active RA is corrective?

- A32NX_TCAS_VSPEED_RED:{number}
- Feet per minute
- Read-Only
- Lower and upper red vertical speed range of current active RA
- {number}
- 0
- 1

- A32NX_TCAS_VSPEED_GREEN:{number}
- Feet per minute
- Read-Only
- Lower and upper green vertical speed range of current active RA
- {number}
- 0
- 1
Original file line number Diff line number Diff line change
Expand Up @@ -4307,6 +4307,15 @@
<NODE_ID>PUSH_ATC_FAIL_SEQ2</NODE_ID>
<EMISSIVE_CODE>(L:A32NX_OVHD_INTLT_ANN) 0 == (L:A32NX_ELEC_AC_ESS_SHED_BUS_IS_POWERED, Bool) and</EMISSIVE_CODE>
</UseTemplate>

<UseTemplate Name="FBW_Anim_Interactions">
<ANIM_TEMPLATE>FBW_Airbus_ATC_Panel_ATC</ANIM_TEMPLATE>
<ANIM_TYPE>KNOB</ANIM_TYPE>
<Node_ID>Knob_ATC_1</Node_ID>
<PART_ID>Knob_ATC_1</PART_ID>
<ANIMTIP_0>Set XPDR to 1</ANIMTIP_0>
<ANIMTIP_1>Set XPDR to 2</ANIMTIP_1>
</UseTemplate>
<!-- TCAS MODE -->
<UseTemplate Name="FBW_Anim_Interactions">
<ANIM_TYPE>KNOB</ANIM_TYPE>
Expand Down Expand Up @@ -4887,9 +4896,6 @@
<UseTemplate Name="ASOBO_GT_Interaction_Tooltip">
<NODE_ID>KNOB_RADAR_TILT</NODE_ID>
</UseTemplate>
<UseTemplate Name="ASOBO_GT_Interaction_Tooltip">
<NODE_ID>KNOB_ATC_1</NODE_ID>
</UseTemplate>
<UseTemplate Name="ASOBO_GT_Interaction_Tooltip">
<NODE_ID>PUSH_HANDLE_LEFT_YOKE</NODE_ID>
</UseTemplate>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions flybywire-aircraft-a320-neo/html_ui/Images/ND/TRAFFIC_RA.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions flybywire-aircraft-a320-neo/html_ui/Images/ND/TRAFFIC_TA.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class A32NX_SoundManager {

let found = false;
this.periodicList.forEach((element) => {
if (element.name === sound.name) {
if (element.sound.name === sound.name) {
found = true;
}
});
Expand All @@ -49,13 +49,22 @@ class A32NX_SoundManager {
}
}

tryPlaySound(sound) {
tryPlaySound(sound, retry = false, repeatOnce = false) {
if (this.playingSound === null) {
this.playingSound = sound;
this.playingSoundRemaining = sound.length;

Coherent.call("PLAY_INSTRUMENT_SOUND", sound.name).catch(console.error);
if (repeatOnce) {
this.soundQueue.push(sound);
}
return true;
} else if (retry) {
this.soundQueue.push(sound);
if (repeatOnce) {
this.soundQueue.push(sound);
}
return false;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ var A320_Neo_UpperECAM;
],
flightPhasesInhib: [3, 4, 5, 7, 8],
isActive: () => {
return !this.isInFlightPhase(1, 10) && !this.anyAdiruAligned();
return !this.isInFlightPhase(1, 10) && this.getCachedSimVar('L:A32NX_TCAS_FAULT', 'bool');
},
},
{
Expand All @@ -1114,8 +1114,7 @@ var A320_Neo_UpperECAM;
flightPhasesInhib: [1, 2, 3, 4, 5, 7, 8, 9, 10],
isActive: () => (
this.fwcFlightPhase === 6 &&
this.getCachedSimVar("L:A32NX_SWITCH_TCAS_Position", "Enum") === 0 &&
this.anyAdiruAligned()
this.getCachedSimVar('L:A32NX_TCAS_MODE', 'Enum') === 0
),
}
]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build:fadec": "cd src/fadec && ./build.sh",
"build:failures": "rollup -c src/failures/rollup.config.js",
"build:fmgc": "rollup -c src/fmgc/rollup.config.js",
"build:tcas": "rollup -c src/tcas/rollup.config.js",
"build:mcdu-client": "rollup -c src/mcdu-server/client/rollup.config.js",
"build:mcdu-server": "pkg src/mcdu-server/index.js --target node12-win-x64 --no-bytecode --public-packages \"*\" --public --output \"flybywire-aircraft-a320-neo/MCDU SERVER/server.exe\""
},
Expand Down
18 changes: 16 additions & 2 deletions src/behavior/src/A32NX_Interior_ATC.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<ModelBehaviors>
<Template Name="FBW_Airbus_ATC_Panel_ATC">
<Component ID="#NODE_ID#" Node="#NODE_ID#">
<UseTemplate Name="ASOBO_GT_Switch_2States">
<PART_ID>knob_atc_1</PART_ID>
<WWISE_EVENT>smallknob</WWISE_EVENT>
<ANIM_NAME>#NODE_ID#</ANIM_NAME>
<SWITCH_DIRECTION>Horizontal</SWITCH_DIRECTION>
<ARROW_TYPE>Curved</ARROW_TYPE>
<SWITCH_POSITION_TYPE>L</SWITCH_POSITION_TYPE>
<SWITCH_POSITION_VAR>A32NX_SWITCH_ATC</SWITCH_POSITION_VAR>
</UseTemplate>
</Component>
</Template>
<Template Name="FBW_Airbus_ATC_Panel_TARA">
<Component ID="#NODE_ID#" Node="#NODE_ID#">
<UseTemplate Name="ASOBO_GT_Switch_3States">
Expand Down Expand Up @@ -177,9 +190,10 @@
</Update>
<UseTemplate Name="FBW_Anim_Interactions">
<ANIM_TYPE>KNOB</ANIM_TYPE>
<ANIM_TEMPLATE>ASOBO_GT_Switch_XStates</ANIM_TEMPLATE>
<NUM_STATES>2</NUM_STATES>
<ANIM_TEMPLATE>ASOBO_GT_Switch_2States</ANIM_TEMPLATE>
<SWITCH_DIRECTION>Horizontal</SWITCH_DIRECTION>
<SWITCH_POSITION_TYPE>L</SWITCH_POSITION_TYPE>
<SWITCH_POSITION_VAR>A32NX_SWITCH_ATC_ALT</SWITCH_POSITION_VAR>
<LEFTARROW>TurnLeft</LEFTARROW>
<RIGHTARROW>TurnRight</RIGHTARROW>
<WWISE_EVENT>smallknob</WWISE_EVENT>
Expand Down
7 changes: 7 additions & 0 deletions src/instruments/src/ATC/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './style.scss';
import React, { useEffect, useState } from 'react';
import { useSimVar, useSplitSimVar } from '@instruments/common/simVars';
import { useInteractionEvent, useUpdate } from '@instruments/common/hooks';
import { TcasComputer } from '@tcas/index';
import { render } from '@instruments/common/index';

const getDigitsFromBco16 = (code: number): number[] => {
Expand All @@ -27,11 +28,17 @@ const PoweredXpdrDisplay = () => {
const [clrPressed, setClrPressed] = useState(false);
const [displayResetTimer, setDisplayResetTimer] = useState(-1);
const [ltsTest] = useSimVar('L:A32NX_OVHD_INTLT_ANN', 'Number', 250);
const [tcas] = useState(() => new TcasComputer());

const [transponderCode, setTransponderCode] = useSplitSimVar('TRANSPONDER CODE:1', 'Bco16', 'K:XPNDR_SET', 'Bco16', 500);
const codeInDisplay = newDigits !== null ? newDigits : getDigitsFromBco16(transponderCode);

useEffect(() => {
tcas.init();
}, []);

useUpdate((deltaTime) => {
tcas.update(deltaTime);
if (displayResetTimer > 0) {
setDisplayResetTimer(Math.max(displayResetTimer - deltaTime / 1000, 0));
}
Expand Down
9 changes: 9 additions & 0 deletions src/instruments/src/EFB/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ const SimOptionsPage = () => {
const [dynamicRegistration, setDynamicRegistration] = usePersistentProperty('DYNAMIC_REGISTRATION_DECAL', '0');
const [defaultBaro, setDefaultBaro] = usePersistentProperty('CONFIG_INIT_BARO_UNIT', 'AUTO');
const [mcduServerPort, setMcduServerPort] = usePersistentProperty('CONFIG_EXTERNAL_MCDU_PORT', '8380');
const [tcasDebug, setTcasDebug] = usePersistentProperty('TCAS_DEBUG', '0');

const fpSyncButtons: ButtonType[] = [
{ name: 'None', setting: 'NONE' },
Expand Down Expand Up @@ -328,6 +329,14 @@ const SimOptionsPage = () => {
/>
</div>

<div className="py-4 flex flex-row justify-between items-center">
<span>
<span className="text-lg text-gray-300">TCAS Debug</span>
<span className="text-lg text-gray-500 ml-2">(testing)</span>
</span>
<Toggle value={tcasDebug === '1'} onToggle={(value) => setTcasDebug(value ? '1' : '0')} />
</div>

</div>
<ControlSettings setShowSettings={setShowThrottleSettings} />
</>
Expand Down
Loading

0 comments on commit d163264

Please sign in to comment.