System: Update ECAM auto page logic to use warningphases, and custom timers
This commit is contained in:
parent
ca5733c4da
commit
466c66eb65
1 changed files with 147 additions and 93 deletions
230
Nasal/ECAM.nas
230
Nasal/ECAM.nas
|
@ -20,6 +20,27 @@ var eprlim = 0;
|
|||
var n1lim = 0;
|
||||
var mode = "XX";
|
||||
var modeI = "XX";
|
||||
var man_sel = 0;
|
||||
var fault_sel = 0;
|
||||
var warnPhase = 1;
|
||||
var page = "door";
|
||||
var aileron = 0;
|
||||
var elevator = 0;
|
||||
var elapsedSec = 0;
|
||||
var fctlCounting = 0;
|
||||
var fctlTime = 0;
|
||||
var showAPUPage = 0;
|
||||
var APUMaster = 0;
|
||||
var APURPM = 0;
|
||||
var APUTime = 0;
|
||||
var APUCounting = 0;
|
||||
var engModeSel = 0;
|
||||
var showENGPage = 0;
|
||||
var ENGTime = 0;
|
||||
var ENGCounting = 0;
|
||||
var flapLever = 0;
|
||||
var CRZTime = 0;
|
||||
var CRZCondition = 0;
|
||||
setprop("/ECAM/left-msg", "NONE");
|
||||
setprop("/position/gear-agl-ft", 0);
|
||||
# w = White, b = Blue, g = Green, a = Amber, r = Red
|
||||
|
@ -223,17 +244,19 @@ var ECAM = {
|
|||
|
||||
ECAM.MSGclr();
|
||||
|
||||
# Lower ECAM Pages
|
||||
|
||||
var LowerECAM = {
|
||||
button: func(b) {
|
||||
var man_sel = getprop("/ECAM/Lower/man-select");
|
||||
man_sel = getprop("/ECAM/Lower/man-select");
|
||||
|
||||
if(!getprop("/ECAM/lower/fault-select")) {
|
||||
if(!man_sel) {
|
||||
if (!getprop("/ECAM/lower/fault-select")) {
|
||||
if (!man_sel) {
|
||||
setprop("/ECAM/Lower/man-select", 1);
|
||||
setprop("/ECAM/Lower/page", b);
|
||||
setprop("/ECAM/Lower/light/" ~ b, 1);
|
||||
} else {
|
||||
if(b == getprop("/ECAM/Lower/page")) {
|
||||
if (b == getprop("/ECAM/Lower/page")) {
|
||||
setprop("/ECAM/Lower/man-select", 0);
|
||||
LowerECAM.loop();
|
||||
setprop("/ECAM/Lower/light/" ~ b, 0);
|
||||
|
@ -246,97 +269,132 @@ var LowerECAM = {
|
|||
}
|
||||
},
|
||||
loop: func() {
|
||||
var man_sel = getprop("/ECAM/Lower/man-select");
|
||||
var fault_sel = getprop("/ECAM/Lower/fault-select");
|
||||
man_sel = getprop("/ECAM/Lower/man-select");
|
||||
fault_sel = getprop("/ECAM/Lower/fault-select");
|
||||
page = getprop("/ECAM/Lower/page");
|
||||
aileron = getprop("/fdm/jsbsim/fbw/aileron-sidestick");
|
||||
elevator = getprop("/fdm/jsbsim/fbw/elevator-sidestick");
|
||||
APUMaster = getprop("/controls/APU/master");
|
||||
APURPM = getprop("/systems/apu/rpm");
|
||||
stateL = getprop("/engines/engine[0]/state");
|
||||
stateR = getprop("/engines/engine[1]/state");
|
||||
engModeSel = getprop("/controls/engines/engine-start-switch");
|
||||
|
||||
if (warnPhase == 2) {
|
||||
if (abs(aileron) > 0.3 or abs(elevator) > 0.3) {
|
||||
fctlTime = elapsedSec;
|
||||
fctlCounting = 1;
|
||||
} else if (fctlCounting) {
|
||||
if (fctlTime + 20 < elapsedSec) {
|
||||
fctlCounting = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fctlCounting = 0;
|
||||
}
|
||||
|
||||
if (APURPM > 95) {
|
||||
if (APUTime + 10 < elapsedSec) {
|
||||
APUCounting = 0;
|
||||
}
|
||||
} else {
|
||||
if (APUMaster) {
|
||||
APUTime = elapsedSec;
|
||||
APUCounting = 1;
|
||||
} else {
|
||||
APUCounting = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((APURPM <= 95 or APUCounting) and APUMaster) {
|
||||
showAPUPage = 1;
|
||||
} else {
|
||||
showAPUPage = 0;
|
||||
}
|
||||
|
||||
if (stateL == 3 and stateR == 3) {
|
||||
if (ENGCounting and ENGTime + 10 < elapsedSec) {
|
||||
ENGCounting = 0;
|
||||
}
|
||||
} else if ((stateL > 0 or stateR > 0) and engModeSel == 2) {
|
||||
ENGTime = elapsedSec;
|
||||
ENGCounting = 1;
|
||||
} else if ((stateL == 0 and stateR == 0) or engModeSel < 2) {
|
||||
ENGCounting = 0;
|
||||
}
|
||||
|
||||
if (ENGCounting or engModeSel != 1) {
|
||||
showENGPage = 1;
|
||||
} else {
|
||||
showENGPage = 0;
|
||||
}
|
||||
|
||||
if (!man_sel) {
|
||||
if (!fault_sel) {
|
||||
var apu_timer = getprop("/ECAM/Lower/apu-timer");
|
||||
var apu_n = getprop("/systems/apu/rpm");
|
||||
var apu_master = getprop("/controls/APU/master");
|
||||
|
||||
var eng_timer = getprop("/ECAM/Lower/eng-timer");
|
||||
var eng_to = getprop("/ECAM/Lower/eng-to");
|
||||
var eng1_state = getprop("/engines/engine[0]/state");
|
||||
var eng2_state = getprop("/engines/engine[1]/state");
|
||||
var eng_mode = getprop("/controls/engines/engine-start-switch");
|
||||
|
||||
var flaps = getprop("/controls/flight/flap-lever");
|
||||
var agl = getprop("/position/gear-agl-ft");
|
||||
|
||||
var phase = getprop("/FMGC/status/phase");
|
||||
var gear0 = getprop("/gear/gear[0]/wow");
|
||||
var n1_left = getprop("/engines/engine[0]/n1-actual");
|
||||
var n1_right = getprop("/engines/engine[1]/n1-actual");
|
||||
var state1 = getprop("/systems/thrust/state1");
|
||||
var state2 = getprop("/systems/thrust/state2");
|
||||
var flx = getprop("/systems/thrust/lim-flex");
|
||||
var thr1 = getprop("/controls/engines/engine[0]/throttle-pos");
|
||||
var thr2 = getprop("/controls/engines/engine[1]/throttle-pos");
|
||||
|
||||
var eng_out = 0;
|
||||
if ((getprop("/engines/engine[0]/state") == 3 and getprop("/engines/engine[1]/state") != 3) or (getprop("/engines/engine[0]/state") != 3 and getprop("/engines/engine[1]/state") == 3)) {
|
||||
eng_out = 1;
|
||||
}
|
||||
|
||||
var to_thr = 0;
|
||||
if (n1_left >= 70 and state1 == "TOGA" or (flx == 1 and state1 == "MCT" and eng_out == 0) or (flx == 1 and (state1 == "MAN THR" and thr1 >= 0.83 and eng_out == 0)) or n1_right >= 70 and state2 == "TOGA" or (flx == 1 and state2 == "MCT"
|
||||
and eng_out == 0) or (flx == 1 and (state2 == "MAN THR" and thr2 >= 0.83 and eng_out == 0))) {
|
||||
to_thr = 1;
|
||||
}
|
||||
|
||||
#TODO auto select page for F/CTL
|
||||
if (eng_mode == 0 or eng1_state == 1 or eng1_state == 2 or eng2_state == 1 or eng2_state == 2 or (to_thr == 1 and agl < 1500) or eng_to == 1 or eng_timer > 0) {
|
||||
if (eng_timer == 0) {
|
||||
setprop("/ECAM/Lower/eng-timer", 1);
|
||||
}
|
||||
|
||||
if (eng_mode == 1 and to_thr == 0) {
|
||||
setprop("/ECAM/Lower/eng-timer", 0);
|
||||
}
|
||||
|
||||
if (to_thr == 1 and agl <= 1500) {
|
||||
setprop("/ECAM/Lower/eng-to", 1);
|
||||
}
|
||||
|
||||
if (eng_to == 1 and flaps == 0 and to_thr == 0 and agl >= 1500) {
|
||||
setprop("/ECAM/Lower/eng-to", 0);
|
||||
}
|
||||
|
||||
if ((eng1_state == 0 or eng1_state == 3) and (eng2_state == 0 or eng2_state == 3) and gear0 == 1 and to_thr == 0) {
|
||||
settimer(func() { setprop("/ECAM/Lower/eng-timer", 0);}, 10);
|
||||
}
|
||||
|
||||
if (eng_to == 1 and agl >= 1500) {
|
||||
settimer(func() { setprop("/ECAM/Lower/eng-to", 0);}, 60);
|
||||
}
|
||||
warnPhase = getprop("/ECAM/warning-phase");
|
||||
|
||||
if (warnPhase == 1 or warnPhase == 10) {
|
||||
if (showENGPage) {
|
||||
if (page != "eng") {
|
||||
setprop("/ECAM/Lower/page", "eng");
|
||||
} else if ((apu_master == 1 and apu_n < 95) or apu_timer > 0) {
|
||||
# apu-timer states:
|
||||
# 0 -> no apu start
|
||||
# 1 -> apu starting/started, will be set back to 0 by timer
|
||||
if (apu_timer == 0) {
|
||||
setprop("/ECAM/Lower/apu-timer", 1);
|
||||
}
|
||||
|
||||
if (apu_master == 0) {
|
||||
setprop("/ECAM/Lower/apu-timer", 0);
|
||||
}
|
||||
|
||||
if (apu_n >= 95) {
|
||||
settimer(func() { setprop("/ECAM/Lower/apu-timer", 0);}, 10);
|
||||
}
|
||||
|
||||
} else if (showAPUPage) {
|
||||
if (page != "apu") {
|
||||
setprop("/ECAM/Lower/page", "apu");
|
||||
} else if (((getprop("/engines/engine[0]/n2-actual") >= 59 or getprop("/engines/engine[1]/n2-actual") >= 59) and getprop("/gear/gear[1]/wow") == 1) or (getprop("/instrumentation/altimeter/indicated-altitude-ft") <= 16000
|
||||
and getprop("/controls/gear/gear-down") == 1 and getprop("/gear/gear[1]/wow") == 0)) {
|
||||
setprop("/ECAM/Lower/page", "wheel");
|
||||
} else if (getprop("/gear/gear[1]/wow") == 1) {
|
||||
}
|
||||
} else if (page != "door") {
|
||||
setprop("/ECAM/Lower/page", "door");
|
||||
}
|
||||
} else if (warnPhase == 2) {
|
||||
elapsedSec = getprop("/sim/time/elapsed-sec");
|
||||
|
||||
if (showENGPage) {
|
||||
if (page != "eng") {
|
||||
setprop("/ECAM/Lower/page", "eng");
|
||||
}
|
||||
} else if (showAPUPage) {
|
||||
if (page != "apu") {
|
||||
setprop("/ECAM/Lower/page", "apu");
|
||||
}
|
||||
} else if (fctlCounting == 1) {
|
||||
if (page != "fctl") {
|
||||
setprop("/ECAM/Lower/page", "fctl");
|
||||
}
|
||||
} else if (page != "wheel") {
|
||||
setprop("/ECAM/Lower/page", "wheel");
|
||||
}
|
||||
} else if (warnPhase >= 3 and warnPhase < 10) {
|
||||
flapLever = getprop("/controls/flight/flap-lever");
|
||||
|
||||
if ((toPowerSet or flapLever > 0) and warnPhase == 6) {
|
||||
if (CRZTime + 60 < elapsedSec) {
|
||||
CRZCondition = 1;
|
||||
} else {
|
||||
CRZCondition = 0;
|
||||
}
|
||||
} else {
|
||||
CRZTime = elapsedSec;
|
||||
CRZCondition = 0;
|
||||
}
|
||||
|
||||
if (CRZCondition or (warnPhase == 6 and flapLever == 0 and !toPowerSet)) {
|
||||
if (page != "crz") {
|
||||
setprop("/ECAM/Lower/page", "crz");
|
||||
}
|
||||
} else {
|
||||
if (showENGPage) {
|
||||
if (page != "eng") {
|
||||
setprop("/ECAM/Lower/page", "eng");
|
||||
}
|
||||
} else if (showAPUPage) {
|
||||
if (page != "apu") {
|
||||
setprop("/ECAM/Lower/page", "apu");
|
||||
}
|
||||
} else if (page != "eng") {
|
||||
setprop("/ECAM/Lower/page", "eng");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -344,10 +402,6 @@ var LowerECAM = {
|
|||
setprop("/ECAM/Lower/page", "door");
|
||||
setprop("/ECAM/Lower/man-select", 0);
|
||||
setprop("/ECAM/Lower/fault-select", 0);
|
||||
setprop("/ECAM/Lower/apu-timer", 0);
|
||||
setprop("/ECAM/Lower/eng-timer", 0);
|
||||
setprop("/ECAM/Lower/eng-to", 0);
|
||||
setprop("/ECAM/Lower/fctl-timer", 0);
|
||||
setprop("/ECAM/Lower/light/apu", 0);
|
||||
setprop("/ECAM/Lower/light/bleed", 0);
|
||||
setprop("/ECAM/Lower/light/cond", 0);
|
||||
|
|
Reference in a new issue