Skip to content

Commit

Permalink
- import Arinc429Word from fbw-sdk (remove copy from @shared)
Browse files Browse the repository at this point in the history
- match slats+flaps position dots to actual positions
- remove speed tape outline right
- remove spaces in FMA E2 cell (i.e. 1FD2 instead of 1 FD 2)
- fix LS info box position (push a little bit upwards)
- integrate PR flybywiresim#8235 (FMA pos. update) & flybywiresim#8214 (move trans alt/lvl to arinc bus)
- make tens of digital altitude readout font smaller & push to right
- altitude tape now listens to baro corrected altitude
  • Loading branch information
flogross89 committed Feb 3, 2024
1 parent 6f3af7b commit b02ebb0
Show file tree
Hide file tree
Showing 21 changed files with 322 additions and 246 deletions.
2 changes: 1 addition & 1 deletion fbw-a380x/src/systems/instruments/src/Common/arinc429.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Arinc429Word } from '@shared/arinc429';
import { Arinc429Word } from '@flybywiresim/fbw-sdk';
import { useSimVar } from './simVars';

export const useArinc429Var = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { usePersistentProperty } from '@instruments/common/persistence';
import { useUpdate } from '@instruments/common/hooks';
import { NXLogicConfirmNode, NXLogicClockNode, NXLogicMemoryNode } from '@instruments/common/NXLogic';
import { useArinc429Var } from '@instruments/common/arinc429';
import { Arinc429Word } from '@shared/arinc429';
import { Arinc429Word } from '@flybywiresim/fbw-sdk';

const mapOrder = (array, order) => {
array.sort((a, b) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Arinc429Word } from '@flybywiresim/fbw-sdk';
import { useArinc429Var } from '@instruments/common/arinc429';
import { splitDecimals } from '@instruments/common/gauges';
import { useSimVar } from '@instruments/common/simVars';
import { Arinc429Word } from '@shared/arinc429';
import React from 'react';

type N1LimitProps = {
Expand Down
125 changes: 108 additions & 17 deletions fbw-a380x/src/systems/instruments/src/PFD/AltitudeIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { ClockEvents, DisplayComponent, EventBus, FSComponent, Subject, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Arinc429Word } from '@shared/arinc429';
import { VerticalMode } from '@shared/autopilot';
import { PFDSimvars } from './shared/PFDSimvarPublisher';
import { DigitalAltitudeReadout } from './DigitalAltitudeReadout';
import { SimplaneValues } from './shared/SimplaneValueProvider';
import { VerticalTape } from './VerticalTape';
import { Arinc429Values } from './shared/ArincValueProvider';
import { ArincEventBus } from "@flybywiresim/fbw-sdk";
import { Arinc429Register, Arinc429RegisterSubject, Arinc429Word, ArincEventBus } from "@flybywiresim/fbw-sdk";

const DisplayRange = 600;
const ValueSpacing = 100;
const DistanceSpacing = 7.5;

class LandingElevationIndicator extends DisplayComponent<{bus: EventBus}> {
class LandingElevationIndicator extends DisplayComponent<{bus: ArincEventBus}> {
private landingElevationIndicator = FSComponent.createRef<SVGPathElement>();

private altitude = 0;

private landingElevation = 0;
private landingElevation = new Arinc429Word(0);

private flightPhase = 0;

private delta = 0;

private handleLandingElevation() {
const delta = this.altitude - this.landingElevation;
const landingElevationValid = !this.landingElevation.isFailureWarning() && !this.landingElevation.isNoComputedData();
const delta = this.altitude - this.landingElevation.value;
const offset = (delta - DisplayRange) * DistanceSpacing / ValueSpacing;
this.delta = delta;
if (delta > DisplayRange || (this.flightPhase !== 7 && this.flightPhase !== 8)) {
if (delta > DisplayRange || (this.flightPhase !== 7 && this.flightPhase !== 8) || !landingElevationValid) {
this.landingElevationIndicator.instance.classList.add('HiddenElement');
} else {
this.landingElevationIndicator.instance.classList.remove('HiddenElement');
Expand Down Expand Up @@ -107,9 +107,99 @@ class RadioAltIndicator extends DisplayComponent<{ bus: EventBus, filteredRadioA
}
}

class MinimumDescentAltitudeIndicator extends DisplayComponent<{ bus: ArincEventBus }> {
private visibility = Subject.create('hidden');

private path = Subject.create('');

private altitude = 0;

private radioAltitudeValid = false;

private qnhLandingAltValid = false;

private qfeLandingAltValid = false;

private inLandingPhases = false;

private altMode: 'STD' | 'QNH' | 'QFE' = 'STD';

private readonly mda = Arinc429RegisterSubject.createEmpty();

private landingElevation = new Arinc429Word(0);

private updateIndication(): void {
this.qnhLandingAltValid = !this.landingElevation.isFailureWarning()
&& !this.landingElevation.isNoComputedData()
&& this.inLandingPhases
&& this.altMode === 'QNH';

this.qfeLandingAltValid = this.inLandingPhases
&& this.altMode === 'QFE';

const altDelta = this.mda.get().value - this.altitude;

const showMda = (this.radioAltitudeValid || this.qnhLandingAltValid || this.qfeLandingAltValid)
&& Math.abs(altDelta) <= 570
&& !this.mda.get().isFailureWarning()
&& !this.mda.get().isNoComputedData();

if (!showMda) {
this.visibility.set('hidden');
return;
}

const offset = altDelta * DistanceSpacing / ValueSpacing;
this.path.set(`m 127.9276,${80.249604 - offset} h 5.80948 v 1.124908 h -5.80948 z`);
this.visibility.set('visible');
}

onAfterRender(node: VNode): void {
super.onAfterRender(node);

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

sub.on('chosenRa').whenArinc429SsmChanged().handle((ra) => {
this.radioAltitudeValid = !ra.isFailureWarning() && !ra.isNoComputedData();
this.updateIndication();
});

sub.on('landingElevation').withArinc429Precision(0).handle((landingElevation) => {
this.landingElevation = landingElevation;
this.updateIndication();
});

sub.on('baroMode').whenChanged().handle((m) => {
this.altMode = m;
this.updateIndication();
});

sub.on('altitudeAr').withArinc429Precision(0).handle((a) => {
// TODO filtered alt
this.altitude = a.value;
this.updateIndication();
});

this.mda.sub(this.updateIndication.bind(this));

sub.on('fwcFlightPhase').whenChanged().handle((fp) => {
this.inLandingPhases = fp === 7 || fp === 8;
this.updateIndication();
});

sub.on('fmMdaRaw').handle(this.mda.setWord.bind(this.mda));
}

render(): VNode {
return (
<path visibility={this.visibility} id="AltTapeMdaIndicator" class="Fill Amber" d={this.path} />
);
}
}

interface AltitudeIndicatorProps {

bus: EventBus;
bus: ArincEventBus;
}

export class AltitudeIndicator extends DisplayComponent<AltitudeIndicatorProps> {
Expand Down Expand Up @@ -219,6 +309,7 @@ export class AltitudeIndicatorOfftape extends DisplayComponent<AltitudeIndicator
<g ref={this.normal} style="display: none">
<path id="AltTapeOutlineUpper" class="NormalStroke White" d="m 117.75,38.09 h 13.10 6.73" />
<path id="AltTapeOutlineLower" class="NormalStroke White" d="m 117.75,123.56 h 13.10 6.73" />
<MinimumDescentAltitudeIndicator bus={this.props.bus} />
<SelectedAltIndicator bus={this.props.bus} />
<AltimeterIndicator bus={this.props.bus} altitude={this.altitude} />
<MetricAltIndicator bus={this.props.bus} />
Expand Down Expand Up @@ -469,7 +560,7 @@ class SelectedAltIndicator extends DisplayComponent<SelectedAltIndicatorProps> {

interface AltimeterIndicatorProps {
altitude: Subscribable<number>,
bus: EventBus,
bus: ArincEventBus,
}

class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {
Expand All @@ -481,9 +572,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 @@ -496,7 +587,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 @@ -529,15 +620,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 @@ -560,12 +651,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
@@ -1,10 +1,10 @@
import { DisplayComponent, EventBus, FSComponent, Subject, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Arinc429Word } from '@shared/arinc429';
import { getDisplayIndex } from 'instruments/src/PFD/PFD';
import { FlightPathDirector } from './FlightPathDirector';
import { FlightPathVector } from './FlightPathVector';
import { Arinc429Values } from './shared/ArincValueProvider';
import { PFDSimvars } from './shared/PFDSimvarPublisher';
import { Arinc429Word } from '@flybywiresim/fbw-sdk';

interface AttitudeIndicatorFixedUpperProps {
bus: EventBus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ClockEvents, DisplayComponent, EventBus, FSComponent, Subject, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Arinc429Word } from '@shared/arinc429';

import {
calculateHorizonOffsetFromPitch,
Expand All @@ -12,7 +11,7 @@ import { Arinc429Values } from './shared/ArincValueProvider';
import { HorizontalTape } from './HorizontalTape';
import { SimplaneValues } from './shared/SimplaneValueProvider';
import { getDisplayIndex } from './PFD';
import { ArincEventBus } from "@flybywiresim/fbw-sdk";
import { Arinc429Register, Arinc429Word, ArincEventBus } from "@flybywiresim/fbw-sdk";

const DisplayRange = 35;
const DistanceSpacing = 15;
Expand Down Expand Up @@ -300,7 +299,7 @@ class TailstrikeIndicator extends DisplayComponent<{bus: EventBus}> {
}
}

class RadioAltAndDH extends DisplayComponent<{ bus: EventBus, filteredRadioAltitude: Subscribable<number>, attExcessive: Subscribable<boolean> }> {
class RadioAltAndDH extends DisplayComponent<{ bus: ArincEventBus, filteredRadioAltitude: Subscribable<number>, attExcessive: Subscribable<boolean> }> {
private daRaGroup = FSComponent.createRef<SVGGElement>();

private roll = new Arinc429Word(0);
Expand All @@ -311,9 +310,9 @@ class RadioAltAndDH extends DisplayComponent<{ bus: EventBus, filteredRadioAltit

private radioAltitude = new Arinc429Word(0);

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

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

private fmgcFlightPhase = 0;

Expand All @@ -340,12 +339,12 @@ class RadioAltAndDH extends DisplayComponent<{ bus: EventBus, filteredRadioAltit
this.dh = dh;
});

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 @@ -363,8 +362,10 @@ class RadioAltAndDH extends DisplayComponent<{ bus: EventBus, filteredRadioAltit
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 DHValid = this.dh >= 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class DigitalAltitudeReadout extends DisplayComponent<DigitalAltitudeRead
return (
<g id="AltReadoutGroup">
<g>
<svg x="117.754" y="76.3374" width="13.5" height="8.9706" viewBox="0 0 13.5 8.9706">
<svg x="117.754" y="76.3374" width="14.5" height="8.9706" viewBox="0 0 14.5 8.9706">
<Drum
type="ten-thousands"
position={this.tenThousandsPosition}
Expand Down Expand Up @@ -234,13 +234,13 @@ class Drum extends DisplayComponent<DrumProperties> {
const digitRef = FSComponent.createRef<SVGTextElement>();

if (this.props.type === 'hundreds') {
graduationElements.push(<text ref={digitRef} transform={`translate(0 ${offset})`} class={`FontLargest MiddleAlign ${this.color}`} x="11.631" y="7.1" />);
graduationElements.push(<text ref={digitRef} transform={`translate(0 ${offset})`} class={`FontMedium MiddleAlign ${this.color}`} x="13.1" y="6.8" />);
} else if (this.props.type === 'thousands') {
graduationElements.push(<text ref={digitRef} transform={`translate(0 ${offset})`} class={`FontLargest MiddleAlign ${this.color}`} x="7.18" y="7.1" />);
graduationElements.push(<text ref={digitRef} transform={`translate(0 ${offset})`} class={`FontMedium MiddleAlign ${this.color}`} x="9.2" y="6.8" />);
} else if (this.props.type === 'ten-thousands') {
graduationElements.push(<text ref={digitRef} transform={`translate(0 ${offset})`} class={`FontLargest MiddleAlign ${this.color}`} x="2.498" y="7.1" />);
graduationElements.push(<text ref={digitRef} transform={`translate(0 ${offset})`} class={`FontMedium MiddleAlign ${this.color}`} x="5.9" y="6.8" />);
} else if (this.props.type === 'tens') {
graduationElements.push(<text ref={digitRef} transform={`translate(0 ${offset})`} class={`FontSmallest MiddleAlign ${this.color}`} x="4.5894" y="8.9133" />);
graduationElements.push(<text ref={digitRef} transform={`translate(0 ${offset})`} class={`FontTinyToSmallest MiddleAlign ${this.color}`} x="5.5" y="8.9133" />);
}
this.digitRefElements.push(digitRef);
}
Expand Down
Loading

0 comments on commit b02ebb0

Please sign in to comment.