From f801b6542bb897a0a0d738b1953e62e8dd11efe7 Mon Sep 17 00:00:00 2001 From: Julian Sebline Date: Sun, 12 Jun 2022 01:06:55 +0200 Subject: [PATCH] Display of M/R if manual/rmp tuned --- docs/a320-simvars.md | 8 ++++++ .../FMC/A32NX_FMCMainDisplay.js | 11 +++++++- src/fmgc/src/radionav/NavRadioManager.ts | 27 +++++++++++++------ .../src/ND/elements/RadioNavInfo.tsx | 10 +++---- src/instruments/src/ND/pages/RoseMode.tsx | 8 +++--- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/docs/a320-simvars.md b/docs/a320-simvars.md index a7be7d4c38f..4f78ee3b91d 100644 --- a/docs/a320-simvars.md +++ b/docs/a320-simvars.md @@ -1030,6 +1030,14 @@ GOAROUND | 6 DONE | 7 +- A32NX_FMGC_RADIONAV_TUNING_MODE + - Enum + - Hold the FMGCs current tuning mode + Value | Meaning + 0 | AUTO + 1 | MANUAL + 2 | REMOTE VIA RMPs + - A32NX_FLAPS_HANDLE_INDEX - Number - Indicates the physical flaps handle position diff --git a/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/Airliners/FlyByWire_A320_Neo/FMC/A32NX_FMCMainDisplay.js b/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/Airliners/FlyByWire_A320_Neo/FMC/A32NX_FMCMainDisplay.js index 8a7c3aaa4cb..9f7097d76dc 100644 --- a/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/Airliners/FlyByWire_A320_Neo/FMC/A32NX_FMCMainDisplay.js +++ b/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/Airliners/FlyByWire_A320_Neo/FMC/A32NX_FMCMainDisplay.js @@ -180,7 +180,8 @@ class FMCMainDisplay extends BaseAirliners { this.efisSymbols = undefined; this.groundTempAuto = undefined; this.groundTempPilot = undefined; - this.backupNavTuning = undefined; + this.backupNavTuning = false; + this.manualNavTuning = false; // ATSU data this.atsu = undefined; @@ -555,6 +556,8 @@ class FMCMainDisplay extends BaseAirliners { onUpdate(_deltaTime) { super.onUpdate(_deltaTime); + this.navRadioManager.update(_deltaTime, this.manualNavTuning, this.backupNavTuning); + this.flightPlanManager.update(_deltaTime); const flightPlanChanged = this.flightPlanManager.currentFlightPlanVersion !== this.lastFlightPlanVersion; if (flightPlanChanged) { @@ -1242,6 +1245,12 @@ class FMCMainDisplay extends BaseAirliners { this.backupNavTuning = SimVar.GetSimVarValue("L:A32NX_RMP_L_NAV_BUTTON_SELECTED", "Bool") || SimVar.GetSimVarValue("L:A32NX_RMP_R_NAV_BUTTON_SELECTED", "Bool"); + + this.manualNavTuning = this.vor1IdIsPilotEntered || this.vor1FreqIsPilotEntered || + this.vor2IdIsPilotEntered || this.vor2FreqIsPilotEntered || + this._ilsFrequencyPilotEntered || this._ilsIdentPilotEntered || + this.adf1IdIsPilotEntered || this.adf1FreqIsPilotEntered || + this.adf2IdIsPilotEntered || this.adf2FreqIsPilotEntered; } updateAutopilot() { diff --git a/src/fmgc/src/radionav/NavRadioManager.ts b/src/fmgc/src/radionav/NavRadioManager.ts index f3cc3cc22f0..7ad656d5791 100644 --- a/src/fmgc/src/radionav/NavRadioManager.ts +++ b/src/fmgc/src/radionav/NavRadioManager.ts @@ -8,19 +8,30 @@ export enum TuningMode { * This is a placeholder for the new radio nav tuning logic... coming soon to an A32NX near you */ export class NavRadioManager { - tuningMode1: TuningMode = TuningMode.Auto; + tuningMode: TuningMode = TuningMode.Auto; - tuningMode2: TuningMode = TuningMode.Auto; + manualTuned: boolean; - tuningMode3: TuningMode = TuningMode.Auto; + rmpTuned: boolean; constructor(public _parentInstrument: BaseInstrument) { - SimVar.SetSimVarValue('L:A32NX_FMGC_RADIONAV_1_TUNING_MODE', 'Enum', TuningMode.Manual); - SimVar.SetSimVarValue('L:A32NX_FMGC_RADIONAV_2_TUNING_MODE', 'Enum', TuningMode.Manual); - SimVar.SetSimVarValue('L:A32NX_FMGC_RADIONAV_3_TUNING_MODE', 'Enum', TuningMode.Manual); + SimVar.SetSimVarValue('L:A32NX_FMGC_RADIONAV_TUNING_MODE', 'Enum', TuningMode.Auto); } - update(_: number): void { - // Do nothing + public update(deltaTime: number, manualTuned: boolean, rmpTuned: boolean): void { + if (this.manualTuned !== manualTuned || this.rmpTuned !== rmpTuned) { + // too avoid SetSimVar too often + this.manualTuned = manualTuned; + this.rmpTuned = rmpTuned; + + if (manualTuned) { + this.tuningMode = TuningMode.Manual; + } else if (rmpTuned) { + this.tuningMode = TuningMode.Remote; + } else { + this.tuningMode = TuningMode.Auto; + } + SimVar.SetSimVarValue('L:A32NX_FMGC_RADIONAV_TUNING_MODE', 'Enum', this.tuningMode); + } } } diff --git a/src/instruments/src/ND/elements/RadioNavInfo.tsx b/src/instruments/src/ND/elements/RadioNavInfo.tsx index 31439bcd2bc..96ad962fb95 100644 --- a/src/instruments/src/ND/elements/RadioNavInfo.tsx +++ b/src/instruments/src/ND/elements/RadioNavInfo.tsx @@ -11,11 +11,11 @@ export enum NavAidMode { export type RadioNavInfoProps = { index: 1 | 2, side: EfisSide } -const TuningModeIndicator: React.FC<{ index: 1 | 2, frequency: number }> = ({ index, frequency }) => { - const [tuningMode] = useSimVar(`L:A32NX_FMGC_RADIONAV_${index}_TUNING_MODE`, 'enum'); +const TuningModeIndicator: React.FC<{ index: 1 | 2 }> = ({ index }) => { + const [tuningMode] = useSimVar('L:A32NX_FMGC_RADIONAV_TUNING_MODE', 'enum'); return ( - frequency > 1 && tuningMode !== TuningMode.Auto && ( + tuningMode !== TuningMode.Auto && ( {tuningMode === TuningMode.Manual ? 'M' : 'R'} ) || null ); @@ -81,7 +81,7 @@ const VorInfo: React.FC<{index: 1 | 2}> = ({ index }) => { 20 ? x + 46 : x + 58} y={759} fontSize={24} fill="#00ff00" textAnchor="end">{dmeText} NM - + ); }; @@ -115,7 +115,7 @@ const AdfInfo: React.FC<{index: 1 | 2}> = ({ index }) => { {!adfAvailable && ( {Math.floor(adfFrequency).toFixed(0)} )} - + ); }; diff --git a/src/instruments/src/ND/pages/RoseMode.tsx b/src/instruments/src/ND/pages/RoseMode.tsx index 7e43fc2fd4d..7344cc64403 100644 --- a/src/instruments/src/ND/pages/RoseMode.tsx +++ b/src/instruments/src/ND/pages/RoseMode.tsx @@ -776,7 +776,7 @@ const VorInfo: FC<{side: EfisSide}> = memo(({ side }) => { const [vorIdent] = useSimVar(`NAV IDENT:${index}`, 'string'); const [vorFrequency] = useSimVar(`NAV ACTIVE FREQUENCY:${index}`, 'megahertz'); const [vorCourse] = useSimVar(`NAV OBS:${index}`, 'degrees'); - const [tuningMode] = useSimVar(`L:A32NX_FMGC_RADIONAV_${index}_TUNING_MODE`, 'enum'); + const [tuningMode] = useSimVar('L:A32NX_FMGC_RADIONAV_TUNING_MODE', 'enum'); const [vorAvailable] = useSimVar(`NAV HAS NAV:${index}`, 'boolean'); const [freqInt, freqDecimal] = vorFrequency.toFixed(2).split('.', 2); @@ -806,7 +806,7 @@ const VorInfo: FC<{side: EfisSide}> = memo(({ side }) => { {vorCourse >= 0 ? (`${Math.round(vorCourse)}`).padStart(3, '0') : '---'} ° - { vorFrequency > 0 && {tuningModeLabel} } + {tuningModeLabel} {vorIdent} ); @@ -816,7 +816,7 @@ const IlsInfo: FC = memo(() => { const [ilsIdent] = useSimVar('NAV IDENT:3', 'string'); const [ilsFrequency] = useSimVar('NAV ACTIVE FREQUENCY:3', 'megahertz'); const [ilsCourse] = useSimVar('NAV LOCALIZER:3', 'degrees'); - const [tuningMode] = useSimVar('L:A32NX_FMGC_RADIONAV_3_TUNING_MODE', 'enum'); + const [tuningMode] = useSimVar('L:A32NX_FMGC_RADIONAV_TUNING_MODE', 'enum'); const [locAvailable] = useSimVar('L:A32NX_RADIO_RECEIVER_LOC_IS_VALID', 'number'); const [freqInt, freqDecimal] = ilsFrequency.toFixed(2).split('.', 2); @@ -843,7 +843,7 @@ const IlsInfo: FC = memo(() => { {locAvailable ? (`${Math.round(ilsCourse)}`).padStart(3, '0') : '---'} ° - { ilsFrequency > 0 && {tuningModeLabel} } + {tuningModeLabel} {ilsIdent} );