Skip to content

Commit

Permalink
feat(eis): move trans alt/lvl to arinc bus (#8214)
Browse files Browse the repository at this point in the history
* Move trans alt/lvl to FMGC bus

* Document new simvars

* Move transmission to JS

* Use `FlightPlans.Active` instead of `0`

* Use `Arinc429Register` everywhere

* Fix duplicate condition
  • Loading branch information
BlueberryKing authored Oct 20, 2023
1 parent 817cc8c commit 7393f1d
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 67 deletions.
18 changes: 16 additions & 2 deletions fbw-a32nx/docs/a320-simvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ In the variables below, {number} should be replaced with one item in the set: {
- 1 - captain's side FMGC
- 2 - f/o's side FMGC

- A32NX_FM{number}_DECISION_HEIGHT
- A32NX_FM{number}_DECISION_HEIGHT
- ARINC429<number>
- The decision height for an approach in feet, as entered on the PERF page.
- Value | Meaning
Expand All @@ -1961,13 +1961,27 @@ In the variables below, {number} should be replaced with one item in the set: {
- 1 - captain's side FMGC
- 2 - f/o's side FMGC

- A32NX_FM{number}_MINIMUM_DESCENT_ALTITUDE
- A32NX_FM{number}_MINIMUM_DESCENT_ALTITUDE
- ARINC429<number>
- The minimum descent altitude for a non-precision approach in feet, as entered on the PERF page.
- {number}
- 1 - captain's side FMGC
- 2 - f/o's side FMGC

- A32NX_FM{number}_TRANS_ALT
- Arinc429<number>
- The transition altitude at the origin in feet
- {number}
- 1 - captain's side FMGC
- 2 - f/o's side FMGC

- A32NX_FM{number}_TRANS_LVL
- Arinc429<number>
- The transition level the destination as a flight level
- {number}
- 1 - captain's side FMGC
- 2 - f/o's side FMGC

- A32NX_FM_VNAV_TRIGGER_STEP_DELETED
- Bool
- Indicates whether to trigger a step deleted message on the MCDU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class FMCMainDisplay extends BaseAirliners {
this.arincMissedThrustReductionAltitude = FmArinc429OutputWord.empty("MISSED_THR_RED_ALT");
this.arincMissedAccelerationAltitude = FmArinc429OutputWord.empty("MISSED_ACC_ALT");
this.arincMissedEoAccelerationAltitude = FmArinc429OutputWord.empty("MISSED_EO_ACC_ALT");
this.arincTransitionAltitude = FmArinc429OutputWord.empty("TRANS_ALT");
this.arincTransitionLevel = FmArinc429OutputWord.empty("TRANS_LVL");
/** contains fm messages (not yet implemented) and nodh bit */
this.arincEisWord2 = FmArinc429OutputWord.empty("EIS_DISCRETE_WORD_2");

Expand All @@ -204,6 +206,8 @@ class FMCMainDisplay extends BaseAirliners {
this.arincMissedThrustReductionAltitude,
this.arincMissedAccelerationAltitude,
this.arincMissedEoAccelerationAltitude,
this.arincTransitionAltitude,
this.arincTransitionLevel,
this.arincEisWord2,
];
}
Expand Down Expand Up @@ -598,6 +602,7 @@ class FMCMainDisplay extends BaseAirliners {
this.toSpeedsChecks();
this.thrustReductionAccelerationChecks();
this.updateThrustReductionAcceleration();
this.updateTransitionAltitudeLevel();
this.updateMinimums();
this.updateIlsCourse();
}
Expand Down Expand Up @@ -2926,6 +2931,7 @@ class FMCMainDisplay extends BaseAirliners {
if (s === FMCMainDisplay.clrValue) {
// TODO when possible fetch default from database
this.flightPlanManager.setOriginTransitionAltitude();
this.updateTransitionAltitudeLevel();
return true;
}

Expand All @@ -2942,6 +2948,7 @@ class FMCMainDisplay extends BaseAirliners {
}

this.flightPlanManager.setOriginTransitionAltitude(value);
this.updateTransitionAltitudeLevel();
return true;
}

Expand Down Expand Up @@ -3202,6 +3209,22 @@ class FMCMainDisplay extends BaseAirliners {
);
}

updateTransitionAltitudeLevel() {
const originTransitionAltitude = this.flightPlanManager.originTransitionAltitude;
this.arincTransitionAltitude.setBnrValue(
originTransitionAltitude !== undefined ? originTransitionAltitude : 0,
originTransitionAltitude !== undefined ? Arinc429Word.SignStatusMatrix.NormalOperation : Arinc429Word.SignStatusMatrix.NoComputedData,
17, 131072, 0,
)

const destinationTansitionLevel = this.flightPlanManager.destinationTransitionLevel;
this.arincTransitionLevel.setBnrValue(
destinationTansitionLevel !== undefined ? destinationTansitionLevel : 0,
destinationTansitionLevel !== undefined ? Arinc429Word.SignStatusMatrix.NormalOperation : Arinc429Word.SignStatusMatrix.NoComputedData,
9, 512, 0,
)
}

//Needs PR Merge #3082
//TODO: with FADEC no longer needed
setPerfTOFlexTemp(s) {
Expand Down Expand Up @@ -3830,6 +3853,7 @@ class FMCMainDisplay extends BaseAirliners {
setPerfApprTransAlt(s) {
if (s === FMCMainDisplay.clrValue) {
this.flightPlanManager.setDestinationTransitionLevel();
this.updateTransitionAltitudeLevel();
return true;
}

Expand All @@ -3844,6 +3868,7 @@ class FMCMainDisplay extends BaseAirliners {
}

this.flightPlanManager.setDestinationTransitionLevel(Math.round(value / 100));
this.updateTransitionAltitudeLevel();
return true;
}

Expand Down
34 changes: 0 additions & 34 deletions fbw-a32nx/src/systems/fmgc/src/components/EfisLabels.ts

This file was deleted.

2 changes: 0 additions & 2 deletions fbw-a32nx/src/systems/fmgc/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { FcuSync } from '@fmgc/components/FcuSync';
import { ReadySignal } from '@fmgc/components/ReadySignal';
import { FlightPlanManager } from '@fmgc/wtsdk';
import { EfisLabels } from './EfisLabels';
import { FmgcComponent } from './FmgcComponent';
import { FmsMessages } from './fms-messages';

const fmsMessages = new FmsMessages();

const components: FmgcComponent[] = [
fmsMessages,
new EfisLabels(),
new ReadySignal(),
new FcuSync(),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ export class FlightPlanManager {
* The transition altitude for the origin in the *active* flight plan
*/
get originTransitionAltitude(): number | undefined {
return this.getOriginTransitionAltitude(0);
return this.getOriginTransitionAltitude(FlightPlans.Active);
}

public getOriginTransitionAltitudeIsFromDb(flightPlanIndex: number = 0): boolean {
Expand All @@ -1827,7 +1827,7 @@ export class FlightPlanManager {
* Is the transition altitude for the origin in the *active* flight plan from the database?
*/
get originTransitionAltitudeIsFromDb(): boolean {
return this.getOriginTransitionAltitudeIsFromDb(0);
return this.getOriginTransitionAltitudeIsFromDb(FlightPlans.Active);
}

/**
Expand Down Expand Up @@ -1855,7 +1855,7 @@ export class FlightPlanManager {
* The transition level for the destination in the *active* flight plan
*/
get destinationTransitionLevel(): FlightLevel | undefined {
return this.getDestinationTransitionLevel(0);
return this.getDestinationTransitionLevel(FlightPlans.Active);
}

public getDestinationTransitionLevelIsFromDb(flightPlanIndex: number = this._currentFlightPlanIndex): boolean {
Expand All @@ -1867,7 +1867,7 @@ export class FlightPlanManager {
* Is the transition level for the destination in the *active* flight plan from the database?
*/
get destinationTransitionLevelIsFromDb(): boolean {
return this.getDestinationTransitionLevelIsFromDb(0);
return this.getDestinationTransitionLevelIsFromDb(FlightPlans.Active);
}

/**
Expand Down
20 changes: 10 additions & 10 deletions fbw-a32nx/src/systems/instruments/src/PFD/AltitudeIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: GPL-3.0

import { ClockEvents, DisplayComponent, FSComponent, Subject, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Arinc429Word, Arinc429WordData } from '@flybywiresim/fbw-sdk';
import { Arinc429Register, Arinc429Word, Arinc429WordData } from '@flybywiresim/fbw-sdk';
import { VerticalMode } from '@shared/autopilot';
import { Arinc429RegisterSubject } from 'instruments/src/MsfsAvionicsCommon/Arinc429RegisterSubject';
import { PFDSimvars } from './shared/PFDSimvarPublisher';
Expand Down Expand Up @@ -541,9 +541,9 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {

private unit = '';

private transAlt = 0;
private transAltAr = Arinc429Register.empty();

private transAltAppr = 0;
private transLvlAr = Arinc429Register.empty();

private flightPhase = 0;

Expand All @@ -556,7 +556,7 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {
onAfterRender(node: VNode): void {
super.onAfterRender(node);

const sub = this.props.bus.getSubscriber<PFDSimvars & SimplaneValues>();
const sub = this.props.bus.getArincSubscriber<PFDSimvars & SimplaneValues & Arinc429Values>();

sub.on('baroMode').whenChanged().handle((m) => {
if (m === 'QFE') {
Expand Down Expand Up @@ -589,15 +589,15 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {
this.handleBlink();
});

sub.on('transAlt').whenChanged().handle((ta) => {
this.transAlt = ta;
sub.on('fmTransAltRaw').whenChanged().handle((ta) => {
this.transAltAr.set(ta);

this.handleBlink();
this.getText();
});

sub.on('transAltAppr').whenChanged().handle((ta) => {
this.transAltAppr = ta;
sub.on('fmTransLvlRaw').whenChanged().handle((tl) => {
this.transLvlAr.set(tl);

this.handleBlink();
this.getText();
Expand All @@ -620,12 +620,12 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {

private handleBlink() {
if (this.mode.get() === 'STD') {
if (this.flightPhase > 3 && this.transAltAppr > this.props.altitude.get() && this.transAltAppr !== 0) {
if (this.flightPhase > 3 && this.transLvlAr.isNormalOperation() && 100 * this.transLvlAr.value > this.props.altitude.get()) {
this.stdGroup.instance.classList.add('BlinkInfinite');
} else {
this.stdGroup.instance.classList.remove('BlinkInfinite');
}
} else if (this.flightPhase <= 3 && this.transAlt < this.props.altitude.get() && this.transAlt !== 0) {
} else if (this.flightPhase <= 3 && this.transAltAr.isNormalOperation() && this.transAltAr.value < this.props.altitude.get()) {
this.qfeGroup.instance.classList.add('BlinkInfinite');
} else {
this.qfeGroup.instance.classList.remove('BlinkInfinite');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: GPL-3.0

import { ClockEvents, ConsumerSubject, DisplayComponent, FSComponent, MappedSubject, Subject, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Arinc429Word, Arinc429WordData } from '@flybywiresim/fbw-sdk';
import { Arinc429Register, Arinc429Word, Arinc429WordData } from '@flybywiresim/fbw-sdk';

import { Arinc429RegisterSubject } from 'instruments/src/MsfsAvionicsCommon/Arinc429RegisterSubject';
import { DmcLogicEvents } from '../MsfsAvionicsCommon/providers/DmcPublisher';
Expand Down Expand Up @@ -309,9 +309,9 @@ class RadioAltAndDH extends DisplayComponent<{ bus: ArincEventBus, filteredRadio

private radioAltitude = new Arinc429Word(0);

private transAlt = 0;
private transAltAr = Arinc429Register.empty();

private transAltAppr = 0;
private transLvlAr = Arinc429Register.empty();

private fmgcFlightPhase = 0;

Expand All @@ -334,12 +334,12 @@ class RadioAltAndDH extends DisplayComponent<{ bus: ArincEventBus, filteredRadio
this.roll = roll;
});

sub.on('transAlt').whenChanged().handle((ta) => {
this.transAlt = ta;
sub.on('fmTransAltRaw').whenChanged().handle((ta) => {
this.transAltAr.set(ta);
});

sub.on('transAltAppr').whenChanged().handle((ta) => {
this.transAltAppr = ta;
sub.on('fmTransLvlRaw').whenChanged().handle((tl) => {
this.transLvlAr.set(tl);
});

sub.on('fmgcFlightPhase').whenChanged().handle((fp) => {
Expand All @@ -357,8 +357,10 @@ class RadioAltAndDH extends DisplayComponent<{ bus: ArincEventBus, filteredRadio
const raHasData = !this.radioAltitude.isNoComputedData();
const raValue = this.filteredRadioAltitude;
const verticalOffset = calculateVerticalOffsetFromRoll(this.roll.value);
const chosenTransalt = this.fmgcFlightPhase <= 3 ? this.transAlt : this.transAltAppr;
const belowTransitionAltitude = chosenTransalt !== 0 && (!this.altitude.isNoComputedData() && !this.altitude.isNoComputedData()) && this.altitude.value < chosenTransalt;
const useTransAltVsLvl = this.fmgcFlightPhase <= 3;
const chosenTransalt = useTransAltVsLvl ? this.transAltAr : this.transLvlAr;
const belowTransitionAltitude = chosenTransalt.isNormalOperation() && !this.altitude.isNoComputedData()
&& this.altitude.value < (useTransAltVsLvl ? chosenTransalt.value : chosenTransalt.value * 100);
let size = 'FontLarge';
const dh = this.dh.get();
const DHValid = dh.value >= 0 && (!dh.isNoComputedData() && !dh.isFailureWarning());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export interface Arinc429Values {
fmEisDiscreteWord2Raw: number;
fmMdaRaw: number;
fmDhRaw: number;
fmTransAltRaw: number;
fmTransLvlRaw: number;
}
export class ArincValueProvider {
private roll = new Arinc429Word(0);
Expand Down Expand Up @@ -502,6 +504,10 @@ export class ArincValueProvider {
this.fm2Subs.push(subscriber.on('fm2MdaRaw').handle((raw) => publisher.pub('fmMdaRaw', raw), true));
this.fm1Subs.push(subscriber.on('fm1DhRaw').handle((raw) => publisher.pub('fmDhRaw', raw), true));
this.fm2Subs.push(subscriber.on('fm2DhRaw').handle((raw) => publisher.pub('fmDhRaw', raw), true));
this.fm1Subs.push(subscriber.on('fm1TransAltRaw').handle((raw) => publisher.pub('fmTransAltRaw', raw), true));
this.fm2Subs.push(subscriber.on('fm2TransAltRaw').handle((raw) => publisher.pub('fmTransAltRaw', raw), true));
this.fm1Subs.push(subscriber.on('fm1TransLvlRaw').handle((raw) => publisher.pub('fmTransLvlRaw', raw), true));
this.fm2Subs.push(subscriber.on('fm2TransLvlRaw').handle((raw) => publisher.pub('fmTransLvlRaw', raw), true));

this.fm1Healthy.setConsumer(subscriber.on('fm1HealthyDiscrete'));
this.fm2Healthy.setConsumer(subscriber.on('fm2HealthyDiscrete'));
Expand Down
Loading

0 comments on commit 7393f1d

Please sign in to comment.