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

Transition Altitude Logic #317

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .ace/canvas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"elements":[]}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<script type="text/html" import-script="/Pages/VCockpit/Instruments/Airliners/B747_8/FMC/B747_8_FMC_NavRadioPage.js"></script>
<script type="text/html" import-script="/Pages/VCockpit/Instruments/Airliners/B747_8/FMC/B747_8_FMC_SelectWptPage.js"></script>
<script type="text/html" import-script="/Pages/VCockpit/Instruments/Airliners/B747_8/FMC/B747_8_FMC_VNAVPage.js"></script>
<script type="text/html" import-script="/Pages/VCockpit/Instruments/Airliners/B747_8/FMC/B747_8_FMC_ForecastPage.js"></script>
<script type="text/html" import-script="/Pages/VCockpit/Instruments/Airliners/B747_8/FMC/B747_8_FMC_ArrivalsPage.js"></script>
<script type="text/html" import-script="/Pages/VCockpit/Instruments/Airliners/B747_8/FMC/B747_8_FMC_DeparturesPage.js"></script>
<script type="text/html" import-script="/Pages/VCockpit/Instruments/Airliners/B747_8/FMC/B747_8_FMC_LegsPage.js"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
class B747_8_FMC_ForecastPage {

static ShowPage(fmc) {
let transAltCell = "□□□□□";
transAltCell = "FL" + (fmc.perfApprTransAlt / 100).toString();
let altCell1 = "-----";
let altCell2 = "-----";
let altCell3 = "-----";
let altCell4 = "-----";
let spdCell1 = "-----";
let spdCell2 = "-----";
let spdCell3 = "-----";
let spdCell4 = "-----";
let dirCell1 = "-----";
let dirCell2 = "-----";
let dirCell3 = "-----";
let dirCell4 = "-----";
if (fmc.desForWindAlt.unit1 != "") {
altCell1 = fmc.desForWindAlt.unit1
}
if (fmc.desForWindAlt.unit2 != "") {
altCell2 = fmc.desForWindAlt.unit2
}

/* Climb Page Refresh Timer */
fmc.clearDisplay();
fmc.setTemplate([
["DESCENT FORECAST"],
["\xa0TRANS LVL", "TAI ON/OFF"],
[transAltCell, "-----/-----"],
["\xa0ALT", "WIND DIR/SPD"],
[altCell1, dirCell1 + "°/" + spdCell1 + "KT"],
[""],
[altCell2, dirCell2 + "°/" + spdCell2 + "KT"],
[""],
[altCell3, dirCell3 + "°/" + spdCell3 + "KT"],
[""],
[altCell4, dirCell4 + "°/" + spdCell4 + "KT"],
[""],
[""]
]);

/* LSK 1L - Trans Level */
fmc.onLeftInput[0] = () => {
let value = fmc.inOut;
if (fmc.setPerfApprTransAlt(value)) {
fmc.clearUserInput();
B747_8_FMC_ForecastPage.ShowPage(fmc);
}
};
}
}
//# sourceMappingURL=B747_8_FMC_VNAVPage.js.map
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ class B747_8_FMC_MainDisplay extends Boeing_FMC {
this._pageRefreshTimer = null;

/* SALTY 747 VARS */
this.desForWindSpd = {
unit1: "",
unit2: "",
unit3: "",
unit4: ""
}
this.desForWindDir = {
unit1: "",
unit2: "",
unit3: "",
unit4: ""
}
this.desForWindAlt = {
unit1: "",
unit2: "",
unit3: "",
unit4: ""
}
this._TORwyWindHdg = "";
this._TORwyWindSpd = "";
this.messages = [];
Expand Down Expand Up @@ -380,6 +398,20 @@ class B747_8_FMC_MainDisplay extends Boeing_FMC {
this.showErrorMessage(value);
}
}
}
trySetTransAltitude(s) {
if (!/^\d+$/.test(s)) {
this.showErrorMessage("FORMAT ERROR");
return false;
}
let v = parseInt(s);
if (isFinite(v) && v > 0) {
this.transitionAltitude = v;
SimVar.SetSimVarValue("L:AIRLINER_TRANS_ALT", "Number", this.transitionAltitude);
return true;
}
this.showErrorMessage(this.defaultInputErrorMessage);
return false;
}
_getIndexFromTemp(temp) {
if (temp < -10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class B747_8_FMC_VNAVPage {
break;
}

/* Transition altitude */
let transAltCell = "□□□□□";
if (fmc.transitionAltitude) {
transAltCell = fmc.transitionAltitude.toString();
}

/* LSK 1L - Cruise Level */
let crzAltCell = "□□□□□";
if (fmc.cruiseFlightLevel) {
Expand Down Expand Up @@ -136,15 +142,14 @@ class B747_8_FMC_VNAVPage {
spdTransCell += "/10000";
}

/* LSK 3R - Transition Altitude */
let transAltCell = "";
let origin = fmc.flightPlanManager.getOrigin();
if (origin) {
if (origin.infos.transitionAltitude) {
let transitionAltitude = origin.infos.transitionAltitude;
transAltCell = transitionAltitude.toFixed(0);
/* RSK 3R - Transition Altitude */
fmc.onRightInput[2] = () => {
let value = fmc.inOut;
if (fmc.trySetTransAltitude(value)) {
fmc.clearUserInput();
B747_8_FMC_VNAVPage.ShowPage1(fmc);
}
}
};

/* LSK 4L - Speed Restriction */
let spdRestrCell = "---/-----";
Expand Down Expand Up @@ -549,6 +554,15 @@ class B747_8_FMC_VNAVPage {
}
};

fmc.onRightInput[4] = () => {
setTimeout(
function() {
B747_8_FMC_ForecastPage.ShowPage(fmc);
}, 500
);
};
B747_8_FMC_ForecastPage

fmc.setTemplate([
[desPageTitle, "3", "3"],
["\xa0E/D AT"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ class FMC_MAINT_Sensors {
fmc.clearDisplay();
const oat = SimVar.GetSimVarValue("AMBIENT TEMPERATURE", "celsius").toFixed(0);
const tat = SimVar.GetSimVarValue("TOTAL AIR TEMPERATURE", "celsius").toFixed(0);
const pressAlt = SimVar.GetSimVarValue("PRESSURE ALTITUDE", "meters").toFixed(0);
const pressAlt = SimVar.GetSimVarValue("PRESSURE ALTITUDE", "feet").toFixed(0);
const indAlt = SimVar.GetSimVarValue("INDICATED ALTITUDE", "feet").toFixed(0);
const spIndAlt = Simplane.getAltitude();




Expand All @@ -15,10 +18,10 @@ class FMC_MAINT_Sensors {
["", ""],
["\xa0OAT", "SAT"],
[`${oat}°C`, `${tat}°C`],
["\xa0PRESS ALT", ""],
[`${pressAlt} M`, ``],
["", ""],
["\xa0PRESS ALT", "IND ALT"],
[`${pressAlt} M`, `${indAlt}`],
["", ""],
["", `${spIndAlt}`],
["", ""],
["", ""],
["\xa0MAINT", "", "__FMCSEPARATOR"],
Expand Down Expand Up @@ -90,7 +93,7 @@ class FMC_MAINT_Sensors {
["", ""],
["\xa0FLIGHT PHASE", ""],
[`${fmc.currentFlightPhase}`, ""],
["", ""],
["\xa0BARO MODE", ""],
["", ""],
["", ""],
["", ""],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,26 @@ class Jet_PFD_AltimeterIndicator extends HTMLElement {
if (selectedAltitude === 0) {
selectedAltitude = Math.max(0, Simplane.getAutoPilotDisplayedAltitudeLockValue());
}
}
/* Transition Logic */
const transAlt = SimVar.GetSimVarValue("L:AIRLINER_TRANS_ALT", "Number");
const transLvl = SimVar.GetSimVarValue("L:AIRLINER_APPR_TRANS_ALT", "Number");
const fltPhase = SimVar.GetSimVarValue("L:AIRLINER_FLIGHT_PHASE", "Number");
if (fltPhase > 1 && fltPhase <= 3) {
if (transAlt < selectedAltitude && transAlt < (indicatedAltitude - 300) && baroMode !== "STD") {
console.log(baroMode + "BARO MODE");
this.pressureSVG.setAttribute("fill", "#f9dd02");
} else {
console.log("BELOW TRANS ALT");
this.pressureSVG.setAttribute("fill", "#24F000");
}
}
if (fltPhase >= 4 && fltPhase <= 7) {
if (transLvl > selectedAltitude && transLvl > (indicatedAltitude + 300) && baroMode === "STD") {
this.pressureSVG.setAttribute("fill", "#f9dd02");
} else {
this.pressureSVG.setAttribute("fill", "#24F000");
}
}
this.updateGraduationScrolling(indicatedAltitude);
this.updateCursorScrolling(indicatedAltitude);
Expand Down