Skip to content

Commit

Permalink
Merge pull request #49 from Heavy-Division/VNAV_page_switching
Browse files Browse the repository at this point in the history
[FMC] VNAV page improved
  • Loading branch information
kimlada authored Dec 28, 2020
2 parents e738f18 + 8b3bc94 commit ae05f63
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 171 deletions.

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

0 comments on commit ae05f63

Please sign in to comment.