Skip to content

Commit

Permalink
fix(a380/mfd): enter dest data not clearing automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
BravoMike99 committed Mar 8, 2025
1 parent 5a3c3d4 commit c9c41d7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface Fmgc {
getCleanSpeed(): Knots;
getTripWind(): number;
getWinds(): FmcWinds;
getApproachWind(): FmcWindVector;
getApproachWind(): FmcWindVector | null;
getApproachQnh(): number;
getApproachTemperature(): number;
getDestEFOB(useFob: boolean): number; // Metric tons
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2023 FlyByWire Simulations
// Copyright (c) 2021-2025 FlyByWire Simulations
//
// SPDX-License-Identifier: GPL-3.0

Expand All @@ -23,11 +23,12 @@ export class WindForecastInputObserver {
}

update() {
this.inputs.tripWind = new WindComponent(this.fmgc.getTripWind() ?? 0);
this.inputs.tripWind.value = this.fmgc.getTripWind();
this.parseFmcWinds(this.fmgc.getWinds());

const { direction, speed } = this.fmgc.getApproachWind();
this.inputs.destinationWind = new WindVector(direction, speed);
const windVector = this.fmgc.getApproachWind();
this.inputs.destinationWind.direction = windVector?.direction ?? 0;
this.inputs.destinationWind.speed = windVector?.speed ?? 0;
}

get(): WindForecastInputs {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023-2024 FlyByWire Simulations
// Copyright (c) 2023-2025 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import { FlightPlanService } from '@fmgc/flightplanning/FlightPlanService';
Expand Down Expand Up @@ -205,6 +205,15 @@ export class FlightManagementComputer implements FmcInterface {

private wasReset = false;

private readonly destDataEntered = MappedSubject.create(
([qnh, temperature, wind]) => qnh !== null && temperature != null && wind !== null,
this.fmgc.data.approachQnh,
this.fmgc.data.approachTemperature,
this.fmgc.data.approachWind,
);

private destDataChecked = false;

constructor(
private instance: FmcIndex,
operatingMode: FmcOperatingModes,
Expand Down Expand Up @@ -272,6 +281,13 @@ export class FlightManagementComputer implements FmcInterface {
SimVar.SetSimVarValue('L:A32NX_FM1_HEALTHY_DISCRETE', 'boolean', v);
SimVar.SetSimVarValue('L:A32NX_FM2_HEALTHY_DISCRETE', 'boolean', v);
}, true),

this.destDataEntered,
this.destDataEntered.sub((v) => {
if (v) {
this.removeMessageFromQueue(NXSystemMessages.enterDestData.text);
}
}),
);

this.subs.push(this.shouldBePreflightPhase, this.flightPhase, this.activePage);
Expand Down Expand Up @@ -658,8 +674,6 @@ export class FlightManagementComputer implements FmcInterface {
return this.dataManager?.getStoredWaypointsByIdent(ident) ?? [];
}

private destDataChecked = false;

/**
* This method is called by the FlightPhaseManager after a flight phase change
* This method initializes AP States, initiates CDUPerformancePage changes and other set other required states
Expand Down Expand Up @@ -889,21 +903,8 @@ export class FlightManagementComputer implements FmcInterface {
this.flightPhaseManager.phase >= FmgcFlightPhase.Descent ||
(this.flightPhaseManager.phase === FmgcFlightPhase.Cruise && destPred && destPred.distanceFromAircraft < 180)
) {
if (
!Number.isFinite(this.fmgc.data.approachQnh.get()) ||
!Number.isFinite(this.fmgc.data.approachTemperature.get()) ||
!Number.isFinite(this.fmgc.data.approachWind.get()?.direction) ||
!Number.isFinite(this.fmgc.data.approachWind.get()?.speed)
) {
this.addMessageToQueue(
NXSystemMessages.enterDestData,
() =>
Number.isFinite(this.fmgc.data.approachQnh.get()) &&
Number.isFinite(this.fmgc.data.approachTemperature.get()) &&
Number.isFinite(this.fmgc.data.approachWind.get()?.direction) &&
Number.isFinite(this.fmgc.data.approachWind.get()?.speed),
() => {},
);
if (!this.destDataEntered.get()) {
this.addMessageToQueue(NXSystemMessages.enterDestData);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023-2024 FlyByWire Simulations
// Copyright (c) 2023-2025 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import {
Expand Down Expand Up @@ -979,7 +979,7 @@ export class FmcAircraftInterface {
let towerHeadwind = 0;
const appWind = this.fmgc.data.approachWind.get();
const destRwy = this.fmgc.getDestinationRunway();
if (appWind && Number.isFinite(appWind.speed) && Number.isFinite(appWind.direction)) {
if (appWind && appWind.speed !== null && appWind.direction !== null) {
if (destRwy) {
towerHeadwind = A380SpeedsUtils.getHeadwind(appWind.speed, appWind.direction, destRwy.magneticBearing);
}
Expand Down Expand Up @@ -1196,7 +1196,7 @@ export class FmcAircraftInterface {
// if pilot has set approach wind in MCDU we use it, otherwise fall back to current measured wind
const appWind = this.fmgc.data.approachWind.get();
let towerHeadwind = 0;
if (appWind && Number.isFinite(appWind.speed) && Number.isFinite(appWind.direction)) {
if (appWind && appWind.speed !== null && appWind.direction !== null) {
if (this.flightPlanService.active.destinationRunway) {
towerHeadwind = A380SpeedsUtils.getHeadwind(
appWind.speed,
Expand Down
14 changes: 11 additions & 3 deletions fbw-a380x/src/systems/instruments/src/MFD/FMC/fmgc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,15 @@ export class FmgcData {

public readonly approachSpeed = Subject.create<Knots | null>(null);

public readonly approachWind = Subject.create<FmcWindVector | null>(null);
public readonly approachWindDirection = Subject.create<number | null>(null);

public readonly approachWindSpeed = Subject.create<number | null>(null);

public readonly approachWind: MappedSubject<number[], FmcWindVector | null> = MappedSubject.create(
([direction, speed]) => (direction != null && speed !== null ? { direction: direction, speed: speed } : null),
this.approachSpeed,
this.approachWindSpeed,
);

public readonly approachQnh = Subject.create<number | null>(null);

Expand Down Expand Up @@ -565,8 +573,8 @@ export class FmgcDataService implements Fmgc {
};
}

getApproachWind(): FmcWindVector {
return this.data.approachWind.get() ?? { direction: 0, speed: 0 };
getApproachWind(): FmcWindVector | null {
return this.data.approachWind.get();
}

/** in hPa */
Expand Down
31 changes: 4 additions & 27 deletions fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/MfdFmsPerf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { getEtaFromUtcOrPresent as getEtaUtcOrFromPresent, getApproachName } fro
import { ApproachType } from '@flybywiresim/fbw-sdk';
import { FlapConf } from '@fmgc/guidance/vnav/common';
import { MfdFmsFplnVertRev } from 'instruments/src/MFD/pages/FMS/F-PLN/MfdFmsFplnVertRev';
import { FmcWindVector } from '@fmgc/guidance/vnav/wind/types';

interface MfdFmsPerfProps extends AbstractMfdPageProps {}

Expand Down Expand Up @@ -495,14 +494,6 @@ export class MfdFmsPerf extends FmsPage<MfdFmsPerfProps> {

private readonly apprRadioText = this.precisionApproachSelected.map((v) => (v ? 'RADIO' : '-----'));

private readonly apprWindDirectionValue = (
this.props.fmcService.master?.fmgc.data.approachWind ?? Subject.create<FmcWindVector | null>(null)
).map((it) => (it ? it.direction : null));

private readonly apprWindSpeedValue = (
this.props.fmcService.master?.fmgc.data.approachWind ?? Subject.create<FmcWindVector | null>(null)
).map((it) => (it ? it.speed : null));

private missedThrRedAlt = Subject.create<number | null>(null);

private missedThrRedAltIsPilotEntered = Subject.create<boolean>(false);
Expand Down Expand Up @@ -1112,8 +1103,6 @@ export class MfdFmsPerf extends FmsPage<MfdFmsPerfProps> {
this.transFlToAlt,
this.apprLandingWeightFormatted,
this.apprRadioText,
this.apprWindDirectionValue,
this.apprWindSpeedValue,
);
}

Expand Down Expand Up @@ -2504,31 +2493,19 @@ export class MfdFmsPerf extends FmsPage<MfdFmsPerfProps> {
<div style="display: flex; flex-direction: row;">
<span class="mfd-label mfd-spacing-right perf-appr-weather">MAG WIND</span>
<div style="border: 1px solid lightgrey; display: flex; flex-direction: row; padding: 2px;">
<InputField<number, number, false>
<InputField<number>
dataEntryFormat={new WindDirectionFormat()}
mandatory={Subject.create(false)}
readonlyValue={this.apprWindDirectionValue ?? Subject.create(null)}
onModified={(v) =>
this.props.fmcService.master?.fmgc.data.approachWind.set({
direction: v ?? 0,
speed: this.props.fmcService.master.fmgc.data.approachWind.get()?.speed ?? 0,
})
}
value={this.props.fmcService.master?.fmgc.data.approachWindDirection}
alignText="center"
errorHandler={(e) => this.props.fmcService.master?.showFmsErrorMessage(e)}
hEventConsumer={this.props.mfd.hEventConsumer}
interactionMode={this.props.mfd.interactionMode}
/>
<InputField<number, number, false>
<InputField<number>
dataEntryFormat={new WindSpeedFormat()}
mandatory={Subject.create(false)}
readonlyValue={this.apprWindSpeedValue ?? Subject.create(null)}
onModified={(v) =>
this.props.fmcService.master?.fmgc.data.approachWind.set({
direction: this.props.fmcService.master.fmgc.data.approachWind.get()?.direction ?? 0,
speed: v ?? 0,
})
}
value={this.props.fmcService.master.fmgc.data.approachWindSpeed}
containerStyle="margin-left: 10px;"
alignText="center"
errorHandler={(e) => this.props.fmcService.master?.showFmsErrorMessage(e)}
Expand Down

0 comments on commit c9c41d7

Please sign in to comment.