Skip to content

Commit

Permalink
feta(a380x/pfd): add LS reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
BravoMike99 committed Dec 17, 2024
1 parent 75e1692 commit e8f20e0
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Arinc429Word } from '@flybywiresim/fbw-sdk';
import { Arinc429Values } from './shared/ArincValueProvider';
import { PFDSimvars } from './shared/PFDSimvarPublisher';
import { LagFilter } from './PFDUtils';
import { FmgcFlightPhase } from '@shared/flightphase';

export class LandingSystem extends DisplayComponent<{ bus: EventBus; instrument: BaseInstrument }> {
private lsButtonPressedVisibility = false;
Expand Down Expand Up @@ -95,11 +96,14 @@ export class LandingSystem extends DisplayComponent<{ bus: EventBus; instrument:
<LocalizerIndicator bus={this.props.bus} instrument={this.props.instrument} />
<GlideSlopeIndicator bus={this.props.bus} instrument={this.props.instrument} />
<MarkerBeaconIndicator bus={this.props.bus} />
<LsReminder bus={this.props.bus} />
<LsTitle bus={this.props.bus} />
</g>

<path ref={this.gsReferenceLine} class="Yellow Fill" d="m115.52 80.067v1.5119h-8.9706v-1.5119z" />
</g>

<g>
<LsReminderIndicator bus={this.props.bus} />
</g>
<g id="DeviationGroup" ref={this.deviationGroup} style="display: none">
<g id="LateralDeviationGroup" ref={this.ldevRef} style="display: none">
<LDevIndicator bus={this.props.bus} />
Expand Down Expand Up @@ -609,14 +613,14 @@ class MarkerBeaconIndicator extends DisplayComponent<{ bus: EventBus }> {
}
}

class LsReminder extends DisplayComponent<{ bus: EventBus }> {
private readonly lsReminderRef = FSComponent.createRef<SVGTextElement>();
class LsTitle extends DisplayComponent<{ bus: EventBus }> {
private readonly lsTitle = FSComponent.createRef<SVGTextElement>();

private readonly hasLoc = ConsumerSubject.create(null, false);

private readonly lsButton = ConsumerSubject.create(null, false);

private readonly ilsReminderShown = MappedSubject.create(
private readonly ilsTitleShown = MappedSubject.create(
([hasLoc, lsButton]) => hasLoc && lsButton,
this.hasLoc,
this.lsButton,
Expand All @@ -631,20 +635,73 @@ class LsReminder extends DisplayComponent<{ bus: EventBus }> {
this.lsButton.setConsumer(sub.on(getDisplayIndex() === 2 ? 'ls2Button' : 'ls1Button').whenChanged());

// normally the ident and freq should be always displayed when an ILS freq is set, but currently it only show when we have a signal
this.ilsReminderShown.sub((it) => {
this.ilsTitleShown.sub((it) => {
if (it) {
this.lsReminderRef.instance.style.display = 'inline';
this.lsTitle.instance.style.display = 'inline';
} else {
this.lsReminderRef.instance.style.display = 'none';
this.lsTitle.instance.style.display = 'none';
}
});
}

render(): VNode {
return (
<text class="FontLargest Magenta MiddleAlign Blink9Seconds" ref={this.lsReminderRef} x="104" y="126">
<text class="FontLargest Magenta MiddleAlign Blink9Seconds" ref={this.lsTitle} x="104" y="126">
ILS
</text>
);
}
}

class LsReminderIndicator extends DisplayComponent<{ bus: EventBus }> {
private readonly sub = this.props.bus.getSubscriber<PFDSimvars>();

private readonly lsReminder = FSComponent.createRef<SVGTextElement>();

private readonly glsMlsFlsOrLocVnavInstalled = Subject.create(true);

private readonly fwcFlightPhase = ConsumerSubject.create(this.sub.on('fwcFlightPhase'), 0);

private readonly fmgcFlightPhase = ConsumerSubject.create(this.sub.on('fmgcFlightPhase'), FmgcFlightPhase.Preflight);

private readonly approachModePushed = ConsumerSubject.create(this.sub.on('fcuApproachModeActive'), false);

private readonly lsButton = ConsumerSubject.create(null, false);

private readonly lsReminderVisible = MappedSubject.create(
([fwcPhase, fmgcPhase, approachModePushed, lsPushed]) => {
return (
approachModePushed &&
fmgcPhase === FmgcFlightPhase.Approach &&
!lsPushed && // TODO Check if LOC or G/S scales are invalid
fwcPhase !== 10 &&
fwcPhase !== 11 &&
fwcPhase !== 12
);
},
this.fwcFlightPhase,
this.fmgcFlightPhase,
this.approachModePushed,
this.lsButton,
);

onAfterRender(node: VNode): void {
super.onAfterRender(node);
this.lsButton.setConsumer(this.sub.on(getDisplayIndex() === 2 ? 'ls2Button' : 'ls1Button'));
this.lsReminderVisible.sub((v) => {
if (v) {
this.lsReminder.instance.style.display = 'inline';
} else {
this.lsReminder.instance.style.display = 'none';
}
});
}

render(): VNode {
return (
<text class="FontLargest Amber Blink9Seconds" x="104.33" y="124.8" ref={this.lsReminder}>
{this.glsMlsFlsOrLocVnavInstalled.map((v) => (v ? 'LS' : 'ILS'))}
</text>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface PFDSimvars {
spoilersArmed: boolean;
fcuLeftVelocityVectorOn: boolean;
fcuRightVelocityVectorOn: boolean;
fcuApproachModeActive: boolean;
}

export enum PFDVars {
Expand Down Expand Up @@ -334,6 +335,7 @@ export enum PFDVars {
spoilersArmed = 'L:A32NX_SPOILERS_ARMED',
fcuLeftVelocityVectorOn = 'L:A380X_EFIS_L_VV_BUTTON_IS_ON',
fcuRightVelocityVectorOn = 'L:A380X_EFIS_R_VV_BUTTON_IS_ON',
fcuApproachModeActive = 'L:A32NX_FCU_APPR_MODE_ACTIVE',
}

/** A publisher to poll and publish nav/com simvars. */
Expand Down Expand Up @@ -500,6 +502,7 @@ export class PFDSimvarPublisher extends UpdatableSimVarPublisher<PFDSimvars> {
['spoilersArmed', { name: PFDVars.spoilersArmed, type: SimVarValueType.Bool }],
['fcuLeftVelocityVectorOn', { name: PFDVars.fcuLeftVelocityVectorOn, type: SimVarValueType.Bool }],
['fcuRightVelocityVectorOn', { name: PFDVars.fcuRightVelocityVectorOn, type: SimVarValueType.Bool }],
['fcuApproachModeActive', { name: PFDVars.fcuApproachModeActive, type: SimVarValueType.Bool }],
]);

public constructor(bus: EventBus) {
Expand Down

0 comments on commit e8f20e0

Please sign in to comment.