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 1345327 commit afbae42
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 77 deletions.
124 changes: 108 additions & 16 deletions fbw-a380x/src/systems/instruments/src/PFD/AltitudeIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@ import { DigitalAltitudeReadout } from './DigitalAltitudeReadout';
import { SimplaneValues } from './shared/SimplaneValueProvider';
import { VerticalTape } from './VerticalTape';
import { Arinc429Values } from './shared/ArincValueProvider';
import { Arinc429Word, 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 @@ -106,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 @@ -218,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 @@ -468,7 +560,7 @@ class SelectedAltIndicator extends DisplayComponent<SelectedAltIndicatorProps> {

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

class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {
Expand All @@ -480,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 @@ -495,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 @@ -528,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 @@ -559,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
Expand Up @@ -11,7 +11,7 @@ import { Arinc429Values } from './shared/ArincValueProvider';
import { HorizontalTape } from './HorizontalTape';
import { SimplaneValues } from './shared/SimplaneValueProvider';
import { getDisplayIndex } from './PFD';
import { Arinc429Word, ArincEventBus } from "@flybywiresim/fbw-sdk";
import { Arinc429Register, Arinc429Word, ArincEventBus } from "@flybywiresim/fbw-sdk";

const DisplayRange = 35;
const DistanceSpacing = 15;
Expand Down Expand Up @@ -299,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 @@ -310,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 @@ -339,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 @@ -362,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 @@ -240,7 +240,7 @@ class Drum extends DisplayComponent<DrumProperties> {
} 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" />);
} 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.8" y="8.9133" />);
}
this.digitRefElements.push(digitRef);
}
Expand Down
Loading

0 comments on commit afbae42

Please sign in to comment.