Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(a380/pfd): FMA code cleanup & update possible fmas #9501

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 21 additions & 93 deletions fbw-a380x/src/systems/instruments/src/PFD/FMA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Subscribable,
VNode,
} from '@microsoft/msfs-sdk';
import { ArmedLateralMode, ArmedVerticalMode, isArmed, LateralMode, VerticalMode } from '@shared/autopilot';
import { ArmedLateralMode, isArmed, LateralMode, VerticalMode } from '@shared/autopilot';
import { Arinc429Values } from './shared/ArincValueProvider';
import { PFDSimvars } from './shared/PFDSimvarPublisher';
import { Arinc429Word } from '@flybywiresim/fbw-sdk';
Expand Down Expand Up @@ -784,9 +784,6 @@ class B1Cell extends ShowForSecondsComponent<CellProps> {
case VerticalMode.TCAS:
text = 'TCAS';
break;
/* case 9:
text = 'FINAL';
break; */
case VerticalMode.DES:
text = 'DES';
break;
Expand Down Expand Up @@ -815,17 +812,19 @@ class B1Cell extends ShowForSecondsComponent<CellProps> {
}
break;
case VerticalMode.ALT_CPT:
text = 'ALT*';
if (this.crzAltMode) {
// TODO hook to new FG var if necessary
text = 'ALT CRZ *';
} else {
text = 'ALT*';
}
break;
case VerticalMode.ALT_CST_CPT:
text = 'ALT CST*';
break;
case VerticalMode.ALT_CST:
text = 'ALT CST';
break;
/* case 18:
text = 'ALT CRZ';
break; */
case VerticalMode.FPA: {
const FPAText = `${this.FPA > 0 ? '+' : ''}${(Math.round(this.FPA * 10) / 10).toFixed(1)}°`;

Expand Down Expand Up @@ -1011,10 +1010,16 @@ class B2Cell extends DisplayComponent<CellProps> {
const desArmed = (fmv >> 3) & 1;
const gsArmed = (fmv >> 4) & 1;

// TODO hook to FG once implemented
const openClimbArmed = false;
const altCruiseArmed = false;

let text1: string;
let color1 = 'Cyan';
let vertModeActive = true;
if (clbArmed) {
if (openClimbArmed) {
text1 = ' OP CLB';
} else if (clbArmed) {
text1 = ' CLB';
} else if (desArmed) {
text1 = gsArmed ? 'DES ' : ' DES';
Expand All @@ -1023,6 +1028,8 @@ class B2Cell extends DisplayComponent<CellProps> {
color1 = 'Magenta';
} else if (altArmed) {
text1 = gsArmed ? 'ALT ' : ' ALT';
} else if (altCruiseArmed) {
text1 = ' ALT CRZ';
} else {
text1 = '';
vertModeActive = false;
Expand Down Expand Up @@ -1067,10 +1074,6 @@ class C1Cell extends ShowForSecondsComponent<CellProps> {

private activeLateralMode = 0;

private activeVerticalMode = 0;

private armedVerticalMode = 0;

constructor(props: CellProps) {
super(props, 10);
}
Expand All @@ -1094,41 +1097,9 @@ class C1Cell extends ShowForSecondsComponent<CellProps> {
this.displayModeChangedPath(true);
}
});

sub
.on('activeVerticalMode')
.whenChanged()
.handle((lm) => {
this.activeVerticalMode = lm;

const isShown = this.updateText();

if (isShown) {
this.displayModeChangedPath();
} else {
this.displayModeChangedPath(true);
}
});

sub
.on('fmaVerticalArmed')
.whenChanged()
.handle((va) => {
this.armedVerticalMode = va;

const hasChanged = this.updateText();

if (hasChanged) {
this.displayModeChangedPath();
} else {
this.displayModeChangedPath(true);
}
});
}

private updateText(): boolean {
const finalArmed = (this.armedVerticalMode >> 5) & 1;

let text: string;
this.isShown = true;
if (this.activeLateralMode === LateralMode.GA_TRACK) {
Expand All @@ -1145,18 +1116,8 @@ class C1Cell extends ShowForSecondsComponent<CellProps> {
text = 'TRACK';
} else if (this.activeLateralMode === LateralMode.LOC_TRACK) {
text = 'LOC';
} else if (
this.activeLateralMode === LateralMode.NAV &&
!finalArmed &&
this.activeVerticalMode !== VerticalMode.FINAL
) {
} else if (this.activeLateralMode === LateralMode.NAV) {
text = 'NAV';
} else if (
this.activeLateralMode === LateralMode.NAV &&
finalArmed &&
this.activeVerticalMode !== VerticalMode.FINAL
) {
text = 'APP NAV';
} else {
text = '';
this.isShown = false;
Expand Down Expand Up @@ -1211,17 +1172,12 @@ class C1Cell extends ShowForSecondsComponent<CellProps> {
class C2Cell extends DisplayComponent<CellProps> {
private fmaLateralArmed: number = 0;

private fmaVerticalArmed: number = 0;

private activeVerticalMode: number = 0;

private textSub = Subject.create('');

private getText() {
const navArmed = isArmed(this.fmaLateralArmed, ArmedLateralMode.NAV);
const locArmed = isArmed(this.fmaLateralArmed, ArmedLateralMode.LOC);

const finalArmed = isArmed(this.fmaVerticalArmed, ArmedVerticalMode.FINAL);
const runwayArmed = false;

let text: string = '';
if (locArmed) {
Expand All @@ -1232,8 +1188,8 @@ class C2Cell extends DisplayComponent<CellProps> {
// case 3:
// text = 'F-LOC';
// break;
} else if (navArmed && (finalArmed || this.activeVerticalMode === VerticalMode.FINAL)) {
text = 'APP NAV';
} else if (runwayArmed) {
text = 'RWY' + (navArmed ? ' NAV' : '');
} else if (navArmed) {
text = 'NAV';
}
Expand All @@ -1252,36 +1208,18 @@ class C2Cell extends DisplayComponent<CellProps> {
this.fmaLateralArmed = fla;
this.getText();
});

sub
.on('fmaVerticalArmed')
.whenChanged()
.handle((fva) => {
this.fmaVerticalArmed = fva;
this.getText();
});

sub
.on('activeVerticalMode')
.whenChanged()
.handle((avm) => {
this.activeVerticalMode = avm;
this.getText();
});
}

render(): VNode {
return (
<text class="FontMediumSmaller MiddleAlign Cyan" x="84.234184" y="13.629653">
<text style="white-space: pre" class="FontMediumSmaller MiddleAlign Cyan" x="84.234184" y="13.629653">
{this.textSub}
</text>
);
}
}

class BC1Cell extends ShowForSecondsComponent<CellProps> {
private lastLateralMode = 0;

private lastVerticalMode = 0;

private textSub = Subject.create('');
Expand All @@ -1299,8 +1237,6 @@ class BC1Cell extends ShowForSecondsComponent<CellProps> {
text = 'FLARE';
} else if (this.lastVerticalMode === VerticalMode.LAND) {
text = 'LAND';
} else if (this.lastVerticalMode === VerticalMode.FINAL && this.lastLateralMode === LateralMode.NAV) {
text = 'FINAL APP';
} else {
text = '';
}
Expand All @@ -1325,14 +1261,6 @@ class BC1Cell extends ShowForSecondsComponent<CellProps> {
this.lastVerticalMode = v;
this.setText();
});

sub
.on('activeLateralMode')
.whenChanged()
.handle((l) => {
this.lastLateralMode = l;
this.setText();
});
}

render(): VNode {
Expand Down