Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eis): move trans alt/lvl to arinc bus #8214

Merged
merged 12 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 16 additions & 5 deletions fbw-a32nx/src/systems/fmgc/src/components/EfisLabels.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FlightLevel } from '@fmgc/guidance/vnav/verticalFlightPlan/VerticalFlightPlan';
import { FlightPlanManager } from '@fmgc/wtsdk';
import { Arinc429SignStatusMatrix, Arinc429Word } from '@flybywiresim/fbw-sdk';
import { FmgcComponent } from './FmgcComponent';

export class EfisLabels implements FmgcComponent {
private lastTransitionAltitude: Feet;

private lastTransitionLevel: FlightLevel;
private lastTransitionLevel: number;

private flightPlanManager: FlightPlanManager;

Expand All @@ -17,14 +17,25 @@ export class EfisLabels implements FmgcComponent {
const transitionAltitude = this.flightPlanManager.originTransitionAltitude;
const transitionLevel = this.flightPlanManager.destinationTransitionLevel;

// FIXME ARINC429 when the PR adding a TS impl. lands...
if (transitionAltitude !== this.lastTransitionAltitude) {
SimVar.SetSimVarValue('L:AIRLINER_TRANS_ALT', 'Number', transitionAltitude ?? 0);
Arinc429Word.toSimVarValue(
'L:A32NX_FM1_TRANS_ALT', transitionAltitude ?? 0, transitionAltitude !== undefined ? Arinc429SignStatusMatrix.NormalOperation : Arinc429SignStatusMatrix.NoComputedData,
);
Arinc429Word.toSimVarValue(
'L:A32NX_FM2_TRANS_ALT', transitionAltitude ?? 0, transitionAltitude !== undefined ? Arinc429SignStatusMatrix.NormalOperation : Arinc429SignStatusMatrix.NoComputedData,
);

this.lastTransitionAltitude = transitionAltitude;
}

if (transitionLevel !== this.lastTransitionLevel) {
SimVar.SetSimVarValue('L:AIRLINER_APPR_TRANS_ALT', 'Number', (transitionLevel ?? 0) * 100);
Arinc429Word.toSimVarValue(
'L:A32NX_FM1_TRANS_LVL', transitionLevel ?? 0, transitionLevel !== undefined ? Arinc429SignStatusMatrix.NormalOperation : Arinc429SignStatusMatrix.NoComputedData,
);
Arinc429Word.toSimVarValue(
'L:A32NX_FM2_TRANS_LVL', transitionLevel ?? 0, transitionLevel !== undefined ? Arinc429SignStatusMatrix.NormalOperation : Arinc429SignStatusMatrix.NoComputedData,
);

tracernz marked this conversation as resolved.
Show resolved Hide resolved
this.lastTransitionLevel = transitionLevel;
}
}
Expand Down
18 changes: 9 additions & 9 deletions fbw-a32nx/src/systems/instruments/src/PFD/AltitudeIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,9 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {

private unit = '';

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

private transAltAppr = 0;
private transLvlAr = Arinc429Word.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 = new Arinc429Word(ta);
tracernz marked this conversation as resolved.
Show resolved Hide resolved

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

sub.on('transAltAppr').whenChanged().handle((ta) => {
this.transAltAppr = ta;
sub.on('fmTransLvlRaw').whenChanged().handle((tl) => {
this.transLvlAr = new Arinc429Word(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()) {
2hwk marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -309,9 +309,9 @@ class RadioAltAndDH extends DisplayComponent<{ bus: ArincEventBus, filteredRadio

private radioAltitude = new Arinc429Word(0);

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

private transAltAppr = 0;
private transLvlAr = Arinc429Word.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 = new Arinc429Word(ta);
});

sub.on('transAltAppr').whenChanged().handle((ta) => {
this.transAltAppr = ta;
sub.on('fmTransLvlRaw').whenChanged().handle((tl) => {
this.transLvlAr = new Arinc429Word(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.isNoComputedData())
tracernz marked this conversation as resolved.
Show resolved Hide resolved
&& 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
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export type PFDSimvars = AdirsSimVars & SwitchingPanelVSimVars & {
isAltManaged: boolean;
targetSpeedManaged: number;
flapHandleIndex: number;
transAlt: number;
transAltAppr: number;
selectedHeading: number;
showSelectedHeading: number;
altConstraint: number;
Expand Down Expand Up @@ -156,6 +154,10 @@ export type PFDSimvars = AdirsSimVars & SwitchingPanelVSimVars & {
fm2DhRaw: number;
fm1HealthyDiscrete: number;
fm2HealthyDiscrete: number;
fm1TransAltRaw: number;
fm2TransAltRaw: number;
fm1TransLvlRaw: number;
fm2TransLvlRaw: number
}

export enum PFDVars {
Expand Down Expand Up @@ -214,8 +216,6 @@ export enum PFDVars {
targetSpeedManaged = 'L:A32NX_SPEEDS_MANAGED_PFD',
mach = 'L:A32NX_ADIRS_ADR_1_MACH',
flapHandleIndex = 'L:A32NX_FLAPS_HANDLE_INDEX',
transAlt = 'L:AIRLINER_TRANS_ALT',
transAltAppr = 'L:AIRLINER_APPR_TRANS_ALT',
magTrackRaw = 'L:A32NX_ADIRS_IR_1_TRACK',
selectedHeading = 'L:A32NX_FCU_HEADING_SELECTED',
showSelectedHeading = 'L:A320_FCU_SHOW_SELECTED_HEADING',
Expand Down Expand Up @@ -310,6 +310,10 @@ export enum PFDVars {
fm2DhRaw = 'L:A32NX_FM1_DECISION_HEIGHT',
fm1HealthyDiscrete = 'L:A32NX_FM1_HEALTHY_DISCRETE',
fm2HealthyDiscrete = 'L:A32NX_FM2_HEALTHY_DISCRETE',
fm1TransAltRaw = 'L:A32NX_FM1_TRANS_ALT',
fm2TransAltRaw = 'L:A32NX_FM2_TRANS_ALT',
fm1TransLvlRaw = 'L:A32NX_FM1_TRANS_LVL',
fm2TransLvlRaw = 'L:A32NX_FM2_TRANS_LVL',
}

/** A publisher to poll and publish nav/com simvars. */
Expand Down Expand Up @@ -371,8 +375,6 @@ export class PFDSimvarPublisher extends UpdatableSimVarPublisher<PFDSimvars> {
['targetSpeedManaged', { name: PFDVars.targetSpeedManaged, type: SimVarValueType.Knots }],
['mach', { name: PFDVars.mach, type: SimVarValueType.Number }],
['flapHandleIndex', { name: PFDVars.flapHandleIndex, type: SimVarValueType.Number }],
['transAlt', { name: PFDVars.transAlt, type: SimVarValueType.Number }],
['transAltAppr', { name: PFDVars.transAltAppr, type: SimVarValueType.Number }],
['magTrackRaw', { name: PFDVars.magTrackRaw, type: SimVarValueType.Number }],
['selectedHeading', { name: PFDVars.selectedHeading, type: SimVarValueType.Degree }],
['showSelectedHeading', { name: PFDVars.showSelectedHeading, type: SimVarValueType.Number }],
Expand Down Expand Up @@ -465,6 +467,10 @@ export class PFDSimvarPublisher extends UpdatableSimVarPublisher<PFDSimvars> {
['fm2DhRaw', { name: PFDVars.fm2DhRaw, type: SimVarValueType.Number }],
['fm1HealthyDiscrete', { name: PFDVars.fm1HealthyDiscrete, type: SimVarValueType.Number }],
['fm2HealthyDiscrete', { name: PFDVars.fm2HealthyDiscrete, type: SimVarValueType.Number }],
['fm1TransAltRaw', { name: PFDVars.fm1TransAltRaw, type: SimVarValueType.Number }],
['fm2TransAltRaw', { name: PFDVars.fm2TransAltRaw, type: SimVarValueType.Number }],
['fm1TransLvlRaw', { name: PFDVars.fm1TransLvlRaw, type: SimVarValueType.Number }],
['fm2TransLvlRaw', { name: PFDVars.fm2TransLvlRaw, type: SimVarValueType.Number }],
])

public constructor(bus: ArincEventBus) {
Expand Down