Skip to content

Commit

Permalink
fix(FMA): LVR CLB not showing when preselected speed becomes active (f…
Browse files Browse the repository at this point in the history
…lybywiresim#8644)

* fix(pfd): hide presel msg if brk max active

* fix(pfd): athr mode messages being cleared when out of preselected mode

---------

Co-authored-by: Benjamin Dupont <[email protected]>
Co-authored-by: alepouna <[email protected]>
  • Loading branch information
3 people authored Jul 14, 2024
1 parent 5a5eb07 commit d3e6e98
Showing 1 changed file with 51 additions and 35 deletions.
86 changes: 51 additions & 35 deletions fbw-a32nx/src/systems/instruments/src/PFD/FMA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export class FMA extends DisplayComponent<{ bus: ArincEventBus; isAttExcessive:

private armedVerticalModeSub = Subject.create(0);

private autobrakeMode = 0;

private athrModeMessage = 0;

private machPreselVal = 0;
Expand All @@ -80,8 +82,6 @@ export class FMA extends DisplayComponent<{ bus: ArincEventBus; isAttExcessive:

private secondBorderSub = Subject.create('');

private AB3Message = Subject.create(false);

private handleFMABorders() {
const sharedModeActive =
this.activeLateralMode === 32 ||
Expand All @@ -101,8 +101,11 @@ export class FMA extends DisplayComponent<{ bus: ArincEventBus; isAttExcessive:
this.checkSpeedMode,
)[0] !== null;

const engineMessage = this.athrModeMessage;
const AB3Message = (this.machPreselVal !== -1 || this.speedPreselVal !== -1) && !BC3Message && engineMessage === 0;
const AB3Message =
this.athrModeMessage === 0 &&
this.autobrakeMode !== 3 &&
(this.machPreselVal !== -1 || this.speedPreselVal !== -1) &&
!BC3Message;

let secondBorder: string;
if (sharedModeActive && !this.props.isAttExcessive.get()) {
Expand All @@ -120,7 +123,6 @@ export class FMA extends DisplayComponent<{ bus: ArincEventBus; isAttExcessive:
firstBorder = 'm33.117 0.33732v20.864';
}

this.AB3Message.set(AB3Message);
this.firstBorderSub.set(firstBorder);
this.secondBorderSub.set(secondBorder);
}
Expand Down Expand Up @@ -227,6 +229,22 @@ export class FMA extends DisplayComponent<{ bus: ArincEventBus; isAttExcessive:
this.checkSpeedMode = csm;
this.handleFMABorders();
});

sub
.on('athrModeMessage')
.whenChanged()
.handle((athr) => {
this.athrModeMessage = athr;
this.handleFMABorders();
});

sub
.on('autoBrakeMode')
.whenChanged()
.handle((ab) => {
this.autobrakeMode = ab;
this.handleFMABorders();
});
}

render(): VNode {
Expand All @@ -241,7 +259,7 @@ export class FMA extends DisplayComponent<{ bus: ArincEventBus; isAttExcessive:

<Row1 bus={this.props.bus} isAttExcessive={this.props.isAttExcessive} />
<Row2 bus={this.props.bus} isAttExcessive={this.props.isAttExcessive} />
<Row3 bus={this.props.bus} isAttExcessive={this.props.isAttExcessive} AB3Message={this.AB3Message} />
<Row3 bus={this.props.bus} isAttExcessive={this.props.isAttExcessive} />
</g>
);
}
Expand Down Expand Up @@ -393,7 +411,6 @@ class A2Cell extends DisplayComponent<{ bus: ArincEventBus }> {
class Row3 extends DisplayComponent<{
bus: ArincEventBus;
isAttExcessive: Subscribable<boolean>;
AB3Message: Subscribable<boolean>;
}> {
private cellsToHide = FSComponent.createRef<SVGGElement>();

Expand All @@ -412,7 +429,7 @@ class Row3 extends DisplayComponent<{
render(): VNode {
return (
<g>
<A3Cell bus={this.props.bus} AB3Message={this.props.AB3Message} />
<A3Cell bus={this.props.bus} />
<g ref={this.cellsToHide}>
<AB3Cell bus={this.props.bus} />
<D3Cell bus={this.props.bus} />
Expand Down Expand Up @@ -623,23 +640,19 @@ class A1A2Cell extends ShowForSecondsComponent<CellProps> {
}
}

interface A3CellProps extends CellProps {
AB3Message: Subscribable<boolean>;
}

class A3Cell extends DisplayComponent<A3CellProps> {
class A3Cell extends DisplayComponent<CellProps> {
private classSub = Subject.create('');

private textSub = Subject.create('');

private autobrakeMode = 0;

private AB3Message = false;
private athrMessage = 0;

private onUpdateAthrModeMessage(message: number) {
private handleAthrMessageAndAutobrakeMode() {
let text: string = '';
let className: string = '';
switch (message) {
switch (this.athrMessage) {
case 1:
text = 'THR LK';
className = 'Amber BlinkInfinite';
Expand All @@ -661,22 +674,19 @@ class A3Cell extends DisplayComponent<A3CellProps> {
className = 'Amber';
break;
default:
text = '';
switch (this.autobrakeMode) {
case 3:
text = 'BRK MAX';
className = 'Cyan';
break;
default:
text = '';
}
}

this.textSub.set(text);
this.classSub.set(`FontMedium MiddleAlign ${className}`);
}

private handleAutobrakeMode() {
if (this.autobrakeMode === 3 && !this.AB3Message) {
this.textSub.set('BRK MAX');
this.classSub.set('FontMediumSmaller MiddleAlign Cyan');
} else {
this.textSub.set('');
}
}

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

Expand All @@ -686,22 +696,18 @@ class A3Cell extends DisplayComponent<A3CellProps> {
.on('athrModeMessage')
.whenChanged()
.handle((m) => {
this.onUpdateAthrModeMessage(m);
this.athrMessage = m;
this.handleAthrMessageAndAutobrakeMode();
});

sub
.on('autoBrakeMode')
.whenChanged()
.handle((am) => {
this.autobrakeMode = am;
this.handleAutobrakeMode();
this.handleAthrMessageAndAutobrakeMode();
});

this.props.AB3Message.sub((ab3) => {
this.AB3Message = ab3;
this.handleAutobrakeMode();
});

sub
.on('autoBrakeActive')
.whenChanged()
Expand All @@ -728,14 +734,16 @@ class AB3Cell extends DisplayComponent<CellProps> {

private athrModeMessage = 0;

private autobrakeMode = 0;

private textSub = Subject.create('');

private text2Sub = Subject.create('');

private textXPosSub = Subject.create(0);

private getText() {
if (this.athrModeMessage === 0) {
if (this.athrModeMessage === 0 && this.autobrakeMode !== 3) {
/* use vertical bar instead of : for PRESEL text since : is not aligned to the bottom as the other fonts and the font file is used on ECAM, ND etc.
vertical bar is mapped to ":" aligned to bottom in font file
*/
Expand Down Expand Up @@ -786,6 +794,14 @@ class AB3Cell extends DisplayComponent<CellProps> {
this.athrModeMessage = m;
this.getText();
});

sub
.on('autoBrakeMode')
.whenChanged()
.handle((ab) => {
this.autobrakeMode = ab;
this.getText();
});
}

render(): VNode {
Expand Down

0 comments on commit d3e6e98

Please sign in to comment.