Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Saschl committed Sep 8, 2022
1 parent 328b774 commit aab0cb2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
27 changes: 15 additions & 12 deletions src/instruments/src/PFD/AltitudeIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ClockEvents, DisplayComponent, EventBus, FSComponent, Subject, Subscrib
import { Arinc429Word } from '@shared/arinc429';
import { VerticalMode } from '@shared/autopilot';
import { BaroPressureMode } from 'instruments/src/PFD/shared/BaroPressureMode';
import { PressureUnit } from 'instruments/src/PFD/shared/PressureUnit';
import { PFDSimvars } from './shared/PFDSimvarPublisher';
import { DigitalAltitudeReadout } from './DigitalAltitudeReadout';
import { VerticalTape } from './VerticalTape';
Expand Down Expand Up @@ -122,7 +123,7 @@ class MinimumDescentAltitudeIndicator extends DisplayComponent<{ bus: EventBus }

private inLandingPhases = false;

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

private mda = new Arinc429Word(0);

Expand All @@ -132,10 +133,10 @@ class MinimumDescentAltitudeIndicator extends DisplayComponent<{ bus: EventBus }
this.qnhLandingAltValid = !this.landingElevation.isFailureWarning()
&& !this.landingElevation.isNoComputedData()
&& this.inLandingPhases
&& this.altMode === 'QNH';
&& this.altMode === BaroPressureMode.QNH;

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

const altDelta = this.mda.value - this.altitude;

Expand All @@ -157,7 +158,7 @@ class MinimumDescentAltitudeIndicator extends DisplayComponent<{ bus: EventBus }
onAfterRender(node: VNode): void {
super.onAfterRender(node);

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

sub.on('chosenRa').whenArinc429SsmChanged().handle((ra) => {
this.radioAltitudeValid = !ra.isFailureWarning() && !ra.isNoComputedData();
Expand Down Expand Up @@ -570,7 +571,7 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {

private pressure = 0;

private unit = 0;
private unit = PressureUnit.InHG;

private transAlt = 0;

Expand All @@ -590,17 +591,17 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {
const sub = this.props.bus.getSubscriber<PFDSimvars>();

sub.on('baroMode').whenChanged().handle((m) => {
if (m === 0) { // QFE
if (m === 0) {
this.mode.set(BaroPressureMode.QFE);
this.stdGroup.instance.classList.add('HiddenElement');
this.qfeGroup.instance.classList.remove('HiddenElement');
this.qfeBorder.instance.classList.remove('HiddenElement');
} else if (m === 1) { // QNH
} else if (m === 1) {
this.mode.set(BaroPressureMode.QNH);
this.stdGroup.instance.classList.add('HiddenElement');
this.qfeGroup.instance.classList.remove('HiddenElement');
this.qfeBorder.instance.classList.add('HiddenElement');
} else if (m === 2 || m === 3) { // "STD"
} else if (m === 2 || m === 3) {
this.mode.set(BaroPressureMode.STD);
this.stdGroup.instance.classList.remove('HiddenElement');
this.qfeGroup.instance.classList.add('HiddenElement');
Expand Down Expand Up @@ -639,7 +640,7 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {
this.getText();
});

sub.on('baroPressure').whenChanged().handle((p) => {
sub.on('baroPressure').withPrecision(0).whenChanged().handle((p) => {
this.pressure = p;
this.getText();
});
Expand All @@ -665,7 +666,7 @@ class AltimeterIndicator extends DisplayComponent<AltimeterIndicatorProps> {

private getText() {
if (this.pressure !== null) {
if (this.unit === 1) {
if (this.unit === PressureUnit.MB) {
this.text.set(Math.round(this.pressure).toString());
} else {
this.text.set(this.pressure.toFixed(2));
Expand Down Expand Up @@ -747,8 +748,10 @@ class MetricAltIndicator extends DisplayComponent<{ bus: EventBus }> {
});

sub.on('metricAltToggle').whenChanged().handle((m) => {
this.state.metricAltToggle = m;
this.needsUpdate = true;
if (this.state.metricAltToggle) {
this.state.metricAltToggle = m;
this.needsUpdate = true;
}
});

sub.on('realTime').handle(this.updateState.bind(this));
Expand Down
4 changes: 4 additions & 0 deletions src/instruments/src/PFD/shared/PressureUnit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum PressureUnit {
InHG,
MB,
}
5 changes: 4 additions & 1 deletion src/instruments/src/PFD/shared/SimplaneValueProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export class SimplaneValueProvider {
});

sub.on('isAirspeedMach').whenChanged().handle((am) => {
this.pfdSimvar.updateSimVarSource('airspeedHoldValue', { name: am ? "AUTOPILOT MACH HOLD VAR" : "AUTOPILOT AIRSPEED HOLD VAR", type: am ? SimVarValueType.Number : SimVarValueType.Knots });
this.pfdSimvar.updateSimVarSource('airspeedHoldValue', {
name: am ? 'AUTOPILOT MACH HOLD VAR' : 'AUTOPILOT AIRSPEED HOLD VAR',
type: am ? SimVarValueType.Number : SimVarValueType.Knots,
});
});
}
}

0 comments on commit aab0cb2

Please sign in to comment.