Skip to content

Commit

Permalink
fix(pfd): true flag flashes at slat extension
Browse files Browse the repository at this point in the history
  • Loading branch information
tracernz committed Dec 6, 2022
1 parent 057ae25 commit 31567c1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/instruments/src/PFD/HeadingIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,34 @@ interface TrueFlagProps {
}

class TrueFlag extends DisplayComponent<TrueFlagProps> {
private trueRefActive = Subject.create(false);
private readonly trueRefActive = Subject.create(false);

private readonly slatsExtended = Subject.create(false);

private readonly slatsExtendedWithTrue = Subject.create(false);

private readonly trueFlagRef = FSComponent.createRef<SVGGElement>();

/** @inheritdoc */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
onAfterRender(node: VNode): void {
this.props.bus.getSubscriber<DisplayManagementComputerEvents>().on('trueRefActive').whenChanged().handle((v) => this.trueRefActive.set(v));
// FIXME this should be 127-11 from FWC
this.props.bus.getSubscriber<PFDSimvars>().on('slatPosLeft').withPrecision(0.25).handle((v) => this.slatsExtended.set(v > 0.4));

this.trueRefActive.sub(this.handleSlatsTrue.bind(this));
this.slatsExtended.sub(this.handleSlatsTrue.bind(this));
this.slatsExtendedWithTrue.sub((flash) => this.trueFlagRef.instance.classList.toggle('Blink10Seconds', flash));
}

private handleSlatsTrue(): void {
this.slatsExtendedWithTrue.set(this.trueRefActive.get() && this.slatsExtended.get());
}

/** @inheritdoc */
render(): VNode {
return (
<g id="TrueRefFlag" visibility={this.trueRefActive ? 'visible' : 'hidden'}>
<g id="TrueRefFlag" ref={this.trueFlagRef} visibility={this.trueRefActive ? 'visible' : 'hidden'}>
<rect x="62.439" y="134.468" width="12.935" height="4.575" class="Cyan NormalStroke" />
<text x="68.9065" y="137.008" text-anchor="middle" alignment-baseline="middle" class="FontSmallest Cyan">TRUE</text>
</g>
Expand Down
6 changes: 6 additions & 0 deletions src/instruments/src/PFD/animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
animation-iteration-count: 9;
}

.Blink10Seconds {
animation-name: blinking;
animation-duration: 1s;
animation-iteration-count: 10;
}

.OuterMarkerBlink {
animation-name: OuterMarkerAnim;
animation-duration: 460ms;
Expand Down
1 change: 1 addition & 0 deletions src/instruments/src/PFD/instrument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class A32NX_PFD extends BaseInstrument {
this.simVarPublisher.subscribe('irMaintWordRaw');
this.simVarPublisher.subscribe('trueHeadingRaw');
this.simVarPublisher.subscribe('trueTrackRaw');
this.simVarPublisher.subscribe('slatPosLeft');

FSComponent.render(<PFDComponent bus={this.bus} instrument={this} />, document.getElementById('PFD_CONTENT'));
}
Expand Down
3 changes: 3 additions & 0 deletions src/instruments/src/PFD/shared/PFDSimvarPublisher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export interface PFDSimvars {
irMaintWordRaw: number;
trueHeadingRaw: number;
trueTrackRaw: number;
slatPosLeft: number;
}

export enum PFDVars {
Expand Down Expand Up @@ -293,6 +294,7 @@ export enum PFDVars {
irMaintWordRaw = 'L:A32NX_ADIRS_IR_1_MAINT_WORD',
trueHeadingRaw = 'L:A32NX_ADIRS_IR_1_TRUE_HEADING',
trueTrackRaw = 'L:A32NX_ADIRS_IR_1_TRUE_TRACK',
slatPosLeft = 'L:A32NX_LEFT_SLATS_ANGLE',
}

/** A publisher to poll and publish nav/com simvars. */
Expand Down Expand Up @@ -442,6 +444,7 @@ export class PFDSimvarPublisher extends SimVarPublisher<PFDSimvars> {
['irMaintWordRaw', { name: PFDVars.irMaintWordRaw, type: SimVarValueType.Number }],
['trueHeadingRaw', { name: PFDVars.trueHeadingRaw, type: SimVarValueType.Number }],
['trueTrackRaw', { name: PFDVars.trueTrackRaw, type: SimVarValueType.Number }],
['slatPosLeft', { name: PFDVars.slatPosLeft, type: SimVarValueType.Number }],
])

public constructor(bus: EventBus) {
Expand Down

0 comments on commit 31567c1

Please sign in to comment.