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

[FMC] VNAV page improved #49

Merged
merged 1 commit into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ class Heavy_B747_8_FMC_MainDisplay extends B747_8_FMC_MainDisplay {
Heavy_B747_8_FMC_NavRadioPage.ShowPage(this);
};
this.onVNAV = () => {
Heavy_B747_8_FMC_VNAVPage.shouldResolvePage = true;
Heavy_B747_8_FMC_VNAVPage.ShowPage1(this);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,124 +1,146 @@
class Heavy_B747_8_FMC_VNAVPage {
static ShowPage1(fmc) {
fmc.clearDisplay();
let crzAltCell = FMCString.Line.Box['5'];
if (fmc.cruiseFlightLevel) {
crzAltCell = FMCString.Common.FLIGHT_LEVEL + fmc.cruiseFlightLevel;

static get shouldResolvePage(){
return this._shouldResolvePage;
}

static set shouldResolvePage(value){
this._shouldResolvePage = value;
}
static pageResolver(fmc){
Heavy_B747_8_FMC_VNAVPage.shouldResolvePage = false;
if (fmc.currentFlightPhase === FlightPhase.FLIGHT_PHASE_CRUISE){
Heavy_B747_8_FMC_VNAVPage.ShowPage2(fmc);
} else if (fmc.currentFlightPhase >= FlightPhase.FLIGHT_PHASE_DESCENT){
Heavy_B747_8_FMC_VNAVPage.ShowPage3(fmc);
}
fmc.onLeftInput[0] = () => {
let value = fmc.inOut;
fmc.clearUserInput();
if (fmc.setCruiseFlightLevelAndTemperature(value)) {
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
}

static ShowPage1(fmc) {
if(Heavy_B747_8_FMC_VNAVPage.shouldResolvePage){
Heavy_B747_8_FMC_VNAVPage.pageResolver(fmc);
} else {
fmc.clearDisplay();
let crzAltCell = FMCString.Line.Box['5'];
if (fmc.cruiseFlightLevel) {
crzAltCell = FMCString.Common.FLIGHT_LEVEL + fmc.cruiseFlightLevel;
}
};
fmc.onLeftInput[3] = () => {
let value = fmc.inOut;
fmc.clearUserInput();
if (fmc.setSpeedRestriction(value)) {
//SimVar.SetSimVarValue("L:FMC_EXEC_ACTIVE", "number", 1);
if (isFinite(fmc.clbSpeedRestrictionValueModified) && isFinite(fmc.clbSpeedRestrictionAltitudeModified)) {
fmc.executeSpeedRestriction();
fmc.onLeftInput[0] = () => {
let value = fmc.inOut;
fmc.clearUserInput();
if (fmc.setCruiseFlightLevelAndTemperature(value)) {
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
}
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
}
};
};
fmc.onLeftInput[3] = () => {
let value = fmc.inOut;
fmc.clearUserInput();
if (fmc.setSpeedRestriction(value)) {
//SimVar.SetSimVarValue("L:FMC_EXEC_ACTIVE", "number", 1);
if (isFinite(fmc.clbSpeedRestrictionValueModified) && isFinite(fmc.clbSpeedRestrictionAltitudeModified)) {
fmc.executeSpeedRestriction();
}
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
}
};

fmc.onRightInput[2] = () => {
let value = fmc.inOut;
fmc.clearUserInput();
let altitude = HeavyInputUtils.inputToAltitude(value);
if (altitude) {
fmc.trySetTransAltitude(altitude);
}
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
};
/*
fmc.onLeftInput[2] = () => {
let value = fmc.inOut;
fmc.clearUserInput();
if (fmc.setSpeedTransition(value)) {
if (isFinite(fmc.clbSpeedTransitionValueModified) && isFinite(fmc.clbSpeedTransitionAltitudeModified)) {
fmc.executeSpeedTransition();
fmc.onRightInput[2] = () => {
let value = fmc.inOut;
fmc.clearUserInput();
let altitude = HeavyInputUtils.inputToAltitude(value);
if (altitude) {
fmc.trySetTransAltitude(altitude);
}
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
};
/*
fmc.onLeftInput[2] = () => {
let value = fmc.inOut;
fmc.clearUserInput();
if (fmc.setSpeedTransition(value)) {
if (isFinite(fmc.clbSpeedTransitionValueModified) && isFinite(fmc.clbSpeedTransitionAltitudeModified)) {
fmc.executeSpeedTransition();
}
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
}
};
*/
/*
fmc.onExec = () => {
if(isFinite(fmc.clbSpeedRestrictionValueModified) && isFinite(fmc.clbSpeedRestrictionAltitudeModified)){
fmc.executeSpeedRestriction()
}
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
}
};
*/
/*
fmc.onExec = () => {
if(isFinite(fmc.clbSpeedRestrictionValueModified) && isFinite(fmc.clbSpeedRestrictionAltitudeModified)){
fmc.executeSpeedRestriction()
}
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
SimVar.SetSimVarValue("L:FMC_EXEC_ACTIVE", "number", 0);
};
*/
fmc.refreshPageCallback = () => {
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
};
SimVar.SetSimVarValue("L:FMC_EXEC_ACTIVE", "number", 0);
};
*/
fmc.refreshPageCallback = () => {
Heavy_B747_8_FMC_VNAVPage.ShowPage1(fmc);
};

let speedTransCell = FMCString.Line.Dash['3'];
let speedTransCell = FMCString.Line.Dash['3'];

let speed = '';
let altitude = '';
if (isFinite(fmc.clbSpeedTransitionValue) && isFinite(fmc.clbSpeedTransitionAltitude)) {
speed = fmc.clbSpeedTransitionValue.toFixed(0);
altitude = fmc.clbSpeedTransitionAltitude.toFixed(0);
} else if (isFinite(fmc.getCrzManagedSpeed())) {
speed = fmc.getCrzManagedSpeed();
altitude = 10000;
}
speedTransCell = speed + FMCString.Common.SLASH + altitude;
let speed = '';
let altitude = '';
if (isFinite(fmc.clbSpeedTransitionValue) && isFinite(fmc.clbSpeedTransitionAltitude)) {
speed = fmc.clbSpeedTransitionValue.toFixed(0);
altitude = fmc.clbSpeedTransitionAltitude.toFixed(0);
} else if (isFinite(fmc.getCrzManagedSpeed())) {
speed = fmc.getCrzManagedSpeed();
altitude = 10000;
}
speedTransCell = speed + FMCString.Common.SLASH + altitude;

let speedRestrictionCell = FMCString.Line.Dash['3'] + FMCString.Common.SLASH + FMCString.Line.Dash['5'];
let speedRestrictionCell = FMCString.Line.Dash['3'] + FMCString.Common.SLASH + FMCString.Line.Dash['5'];

if (isFinite(fmc.clbSpeedRestrictionValue) && isFinite(fmc.clbSpeedRestrictionAltitude)) {
speedRestrictionCell = fmc.clbSpeedRestrictionValue + FMCString.Common.SLASH + fmc.clbSpeedRestrictionAltitude;
}
if (isFinite(fmc.clbSpeedRestrictionValue) && isFinite(fmc.clbSpeedRestrictionAltitude)) {
speedRestrictionCell = fmc.clbSpeedRestrictionValue + FMCString.Common.SLASH + fmc.clbSpeedRestrictionAltitude;
}

if (isFinite(fmc.clbSpeedRestrictionValueModified) && isFinite(fmc.clbSpeedRestrictionAltitudeModified)) {
speedRestrictionCell = fmc.clbSpeedRestrictionValueModified + FMCString.Common.SLASH + fmc.clbSpeedRestrictionAltitudeModified;
}
if (isFinite(fmc.clbSpeedRestrictionValueModified) && isFinite(fmc.clbSpeedRestrictionAltitudeModified)) {
speedRestrictionCell = fmc.clbSpeedRestrictionValueModified + FMCString.Common.SLASH + fmc.clbSpeedRestrictionAltitudeModified;
}

let pageTitle = '';
let pageTitle = '';

if (isFinite(fmc.clbSpeedRestrictionValueModified) || isFinite(fmc.clbSpeedRestrictionAltitudeModified)) {
pageTitle += FMCString.PageTitle.MOD + ' ';
} else {
if (fmc.currentFlightPhase === FlightPhase.FLIGHT_PHASE_CLIMB) {
pageTitle += FMCString.PageTitle.ACT + ' ';
if (isFinite(fmc.clbSpeedRestrictionValueModified) || isFinite(fmc.clbSpeedRestrictionAltitudeModified)) {
pageTitle += FMCString.PageTitle.MOD + ' ';
} else {
if (fmc.currentFlightPhase === FlightPhase.FLIGHT_PHASE_CLIMB) {
pageTitle += FMCString.PageTitle.ACT + ' ';
}
}
}

if (isFinite(fmc.clbSpeedRestrictionValue) && isFinite(fmc.clbSpeedRestrictionAltitude) && fmc.shouldEngageSpeedRestriction()) {
pageTitle += ' ' + fmc.clbSpeedRestrictionValue + 'KT ';
} else {
pageTitle += ' ' + fmc.getClbManagedSpeed().toFixed(0) + 'KT ';
}
if (isFinite(fmc.clbSpeedRestrictionValue) && isFinite(fmc.clbSpeedRestrictionAltitude) && fmc.shouldEngageSpeedRestriction()) {
pageTitle += ' ' + fmc.clbSpeedRestrictionValue + 'KT ';
} else {
pageTitle += ' ' + fmc.getClbManagedSpeed().toFixed(0) + 'KT ';
}

pageTitle += FMCString.PageTitle.CLB;
pageTitle += FMCString.PageTitle.CLB;

let alt = fmc.transitionAltitude.toFixed(0);
let alt = fmc.transitionAltitude.toFixed(0);

fmc.setTemplate([
[pageTitle, '1', '3'],
[FMCString.LineTitle.CRZ_ALT],
[crzAltCell],
[FMCString.LineTitle.ECON_SPD],
[],
[FMCString.LineTitle.SPD_TRANS, FMCString.LineTitle.TRANS_ALT],
[speedTransCell, alt],
[FMCString.LineTitle.SPD_RESTR],
[speedRestrictionCell],
[],
['', FMCString.Prompt.ENG_OUT_RIGHT],
[],
[]
]);
fmc.onNextPage = () => {
Heavy_B747_8_FMC_VNAVPage.ShowPage2(fmc);
};
}

fmc.setTemplate([
[pageTitle, '1', '3'],
[FMCString.LineTitle.CRZ_ALT],
[crzAltCell],
[FMCString.LineTitle.ECON_SPD],
[],
[FMCString.LineTitle.SPD_TRANS, FMCString.LineTitle.TRANS_ALT],
[speedTransCell, alt],
[FMCString.LineTitle.SPD_RESTR],
[speedRestrictionCell],
[],
['', FMCString.Prompt.ENG_OUT_RIGHT],
[],
[]
]);
fmc.onNextPage = () => {
Heavy_B747_8_FMC_VNAVPage.ShowPage2(fmc);
};
}

static ShowPage2(fmc) {
Expand Down
Loading