Skip to content

Commit

Permalink
Display of M/R if manual/rmp tuned
Browse files Browse the repository at this point in the history
  • Loading branch information
juliansebline committed Jun 11, 2022
1 parent 06c3c2c commit f801b65
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 18 deletions.
8 changes: 8 additions & 0 deletions docs/a320-simvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
27 changes: 19 additions & 8 deletions src/fmgc/src/radionav/NavRadioManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
10 changes: 5 additions & 5 deletions src/instruments/src/ND/elements/RadioNavInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (
<text x={index === 1 ? 138 : 616} y={720} fontSize={20} textDecoration="underline" fill="#ffffff">{tuningMode === TuningMode.Manual ? 'M' : 'R'}</text>
) || null
);
Expand Down Expand Up @@ -81,7 +81,7 @@ const VorInfo: React.FC<{index: 1 | 2}> = ({ index }) => {
<text x={dmeDistance > 20 ? x + 46 : x + 58} y={759} fontSize={24} fill="#00ff00" textAnchor="end">{dmeText}</text>
<text x={x + 66} y={759} fontSize={20} fill="#00ffff">NM</text>
</g>
<TuningModeIndicator index={index} frequency={vorFrequency} />
<TuningModeIndicator index={index} />
</g>
);
};
Expand Down Expand Up @@ -115,7 +115,7 @@ const AdfInfo: React.FC<{index: 1 | 2}> = ({ index }) => {
{!adfAvailable && (
<text x={x} y={722} fontSize={24} className="Green">{Math.floor(adfFrequency).toFixed(0)}</text>
)}
<TuningModeIndicator index={index} frequency={adfFrequency} />
<TuningModeIndicator index={index} />
</g>
);
};
Expand Down
8 changes: 4 additions & 4 deletions src/instruments/src/ND/pages/RoseMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -806,7 +806,7 @@ const VorInfo: FC<{side: EfisSide}> = memo(({ side }) => {
{vorCourse >= 0 ? (`${Math.round(vorCourse)}`).padStart(3, '0') : '---'}
&deg;
</text>
{ vorFrequency > 0 && <text x={-80} y={58} fontSize={20} className="White" textAnchor="end" textDecoration="underline">{tuningModeLabel}</text> }
<text x={-80} y={58} fontSize={20} className="White" textAnchor="end" textDecoration="underline">{tuningModeLabel}</text>
<text x={0} y={60} fontSize={25} className="White" textAnchor="end">{vorIdent}</text>
</Layer>
);
Expand All @@ -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);
Expand All @@ -843,7 +843,7 @@ const IlsInfo: FC = memo(() => {
{locAvailable ? (`${Math.round(ilsCourse)}`).padStart(3, '0') : '---'}
&deg;
</text>
{ ilsFrequency > 0 && <text x={-80} y={58} fontSize={20} className="White" textAnchor="end" textDecoration="underline">{tuningModeLabel}</text> }
<text x={-80} y={58} fontSize={20} className="White" textAnchor="end" textDecoration="underline">{tuningModeLabel}</text>
<text x={0} y={60} fontSize={25} className="Magenta" textAnchor="end">{ilsIdent}</text>
</Layer>
);
Expand Down

0 comments on commit f801b65

Please sign in to comment.