2017-06-02 00:53:50 +00:00
# A3XX ECAM Messages
# Joshua Davidson (it0uchpods)
2017-11-16 19:29:08 +00:00
##############################################
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
2017-07-13 17:30:33 +00:00
2018-09-29 23:48:17 +00:00
var stateL = 0;
var stateR = 0;
var thrustL = 0;
var thrustR = 0;
var elec = 0;
var speed = 0;
var wow = 0;
var altitude = 0;
2017-12-30 04:44:41 +00:00
setprop("/ECAM/left-msg", "NONE");
2017-06-02 00:53:50 +00:00
setprop("/position/gear-agl-ft", 0);
2017-12-30 04:44:41 +00:00
# w = White, b = Blue, g = Green, a = Amber, r = Red
2017-08-14 15:29:00 +00:00
2017-12-30 04:44:41 +00:00
var ECAM = {
init: func() {
2017-12-30 15:27:24 +00:00
setprop("/ECAM/engine-start-time", 0);
setprop("/ECAM/engine-start-time-switch", 0);
setprop("/ECAM/to-memo-enable", 1);
2017-12-30 15:54:45 +00:00
setprop("/ECAM/to-config", 0);
2018-01-14 16:19:10 +00:00
setprop("/ECAM/ldg-memo-enable", 0);
2018-09-14 09:35:00 +00:00
setprop("/ECAM/Lower/page", "door");
setprop("/ECAM/Lower/man-select", 0);
2018-09-14 13:35:05 +00:00
setprop("/ECAM/Lower/fault-select", 0);
2018-09-14 19:56:30 +00:00
setprop("/ECAM/Lower/apu-timer", 0);
setprop("/ECAM/Lower/eng-timer", 0);
setprop("/ECAM/Lower/fctl-timer", 0);
2018-09-13 22:52:24 +00:00
setprop("/ECAM/Lower/light/apu", 0);
setprop("/ECAM/Lower/light/bleed", 0);
setprop("/ECAM/Lower/light/cond", 0);
setprop("/ECAM/Lower/light/door", 0);
setprop("/ECAM/Lower/light/elec", 0);
setprop("/ECAM/Lower/light/eng", 0);
setprop("/ECAM/Lower/light/fctl", 0);
setprop("/ECAM/Lower/light/fuel", 0);
setprop("/ECAM/Lower/light/hyd", 0);
setprop("/ECAM/Lower/light/press", 0);
setprop("/ECAM/Lower/light/sts", 0);
setprop("/ECAM/Lower/light/wheel", 0);
LowerECAM.reset();
2017-12-30 04:44:41 +00:00
},
MSGclr: func() {
setprop("/ECAM/ecam-checklist-active", 0);
setprop("/ECAM/left-msg", "NONE");
setprop("/ECAM/msg/line1", "");
2017-08-14 15:29:00 +00:00
setprop("/ECAM/msg/line2", "");
setprop("/ECAM/msg/line3", "");
setprop("/ECAM/msg/line4", "");
setprop("/ECAM/msg/line5", "");
setprop("/ECAM/msg/line6", "");
setprop("/ECAM/msg/line7", "");
setprop("/ECAM/msg/line8", "");
2018-07-31 14:11:12 +00:00
setprop("/ECAM/msg/linec1", "w");
setprop("/ECAM/msg/linec2", "w");
setprop("/ECAM/msg/linec3", "w");
setprop("/ECAM/msg/linec4", "w");
setprop("/ECAM/msg/linec5", "w");
setprop("/ECAM/msg/linec6", "w");
setprop("/ECAM/msg/linec7", "w");
setprop("/ECAM/msg/linec8", "w");
2018-07-30 11:53:33 +00:00
setprop("/ECAM/rightmsg/line1", "");
setprop("/ECAM/rightmsg/line2", "");
setprop("/ECAM/rightmsg/line3", "");
setprop("/ECAM/rightmsg/line4", "");
setprop("/ECAM/rightmsg/line5", "");
setprop("/ECAM/rightmsg/line6", "");
setprop("/ECAM/rightmsg/line7", "");
setprop("/ECAM/rightmsg/line8", "");
2018-07-31 14:11:12 +00:00
setprop("/ECAM/rightmsg/linec1", "w");
setprop("/ECAM/rightmsg/linec2", "w");
setprop("/ECAM/rightmsg/linec3", "w");
setprop("/ECAM/rightmsg/linec4", "w");
setprop("/ECAM/rightmsg/linec5", "w");
setprop("/ECAM/rightmsg/linec6", "w");
setprop("/ECAM/rightmsg/linec7", "w");
setprop("/ECAM/rightmsg/linec8", "w");
2017-12-30 04:44:41 +00:00
},
2017-12-30 15:27:24 +00:00
loop: func() {
2017-12-30 04:44:41 +00:00
stateL = getprop("/engines/engine[0]/state");
stateR = getprop("/engines/engine[1]/state");
thrustL = getprop("/systems/thrust/state1");
thrustR = getprop("/systems/thrust/state2");
elec = getprop("/systems/electrical/on");
speed = getprop("/velocities/airspeed-kt");
2018-01-14 16:19:10 +00:00
wow = getprop("/gear/gear[0]/wow");
2017-12-30 04:44:41 +00:00
2017-12-30 15:27:24 +00:00
if (stateL == 3 and stateR == 3 and wow == 1) {
if (getprop("/ECAM/engine-start-time-switch") != 1) {
setprop("/ECAM/engine-start-time", getprop("/sim/time/elapsed-sec"));
setprop("/ECAM/engine-start-time-switch", 1);
}
} else if (wow == 1) {
if (getprop("/ECAM/engine-start-time-switch") != 0) {
setprop("/ECAM/engine-start-time-switch", 0);
}
}
if (wow == 0) {
setprop("/ECAM/to-memo-enable", 0);
} else if ((stateL != 3 or stateR != 3) and wow == 1) {
setprop("/ECAM/to-memo-enable", 1);
}
2018-01-14 16:19:10 +00:00
if (getprop("/position/gear-agl-ft") <= 2000 and (getprop("/FMGC/status/phase") == 3 or getprop("/FMGC/status/phase") == 4 or getprop("/FMGC/status/phase") == 5) and wow == 0) {
setprop("/ECAM/ldg-memo-enable", 1);
} else if (getprop("/ECAM/left-msg") == "LDG-MEMO" and getprop("/instrumentation/airspeed-indicator/indicated-speed-kt") <= 80 and wow == 1) {
setprop("/ECAM/ldg-memo-enable", 0);
} else if (getprop("/ECAM/left-msg") != "LDG-MEMO") {
setprop("/ECAM/ldg-memo-enable", 0);
}
2018-07-30 18:49:35 +00:00
if (ecam.warnings.size() > 0) {
2018-06-05 20:12:28 +00:00
setprop("/ECAM/left-msg", "MSG");
} else if (getprop("/FMGC/status/phase") == 0 and stateL == 3 and stateR == 3 and getprop("/ECAM/engine-start-time") + 120 < getprop("/sim/time/elapsed-sec") and getprop("/ECAM/to-memo-enable") == 1 and wow == 1) {
2017-12-30 04:44:41 +00:00
setprop("/ECAM/left-msg", "TO-MEMO");
2018-01-14 16:19:10 +00:00
} else if (getprop("/ECAM/ldg-memo-enable") == 1) {
setprop("/ECAM/left-msg", "LDG-MEMO");
2017-12-30 04:44:41 +00:00
} else {
setprop("/ECAM/left-msg", "NONE");
}
2017-12-30 15:54:45 +00:00
2018-07-30 18:49:35 +00:00
if (ecam.memos.size() > 0) {
2018-07-30 11:53:33 +00:00
setprop("/ECAM/right-msg", "MSG");
} else {
setprop("/ECAM/right-msg", "NONE");
}
2017-12-30 15:54:45 +00:00
if (getprop("/controls/autobrake/mode") == 3 and getprop("/controls/switches/no-smoking-sign") == 1 and getprop("/controls/switches/seatbelt-sign") == 1 and getprop("/controls/flight/speedbrake-arm") == 1 and getprop("/controls/flight/flap-pos") > 0
and getprop("/controls/flight/flap-pos") < 5) {
# Do nothing
} else {
setprop("/ECAM/to-config", 0);
}
2018-09-13 22:52:24 +00:00
LowerECAM.loop();
2017-12-30 15:54:45 +00:00
},
toConfig: func() {
2018-01-14 03:38:47 +00:00
stateL = getprop("/engines/engine[0]/state");
stateR = getprop("/engines/engine[1]/state");
2018-01-14 16:19:10 +00:00
wow = getprop("/gear/gear[0]/wow");
2018-01-14 03:38:47 +00:00
if (wow == 1 and stateL == 3 and stateR == 3 and getprop("/ECAM/left-msg") != "TO-MEMO") {
setprop("/ECAM/to-memo-enable", 1);
setprop("/ECAM/engine-start-time", getprop("/ECAM/engine-start-time") - 120);
}
2017-12-30 15:54:45 +00:00
if (getprop("/controls/autobrake/mode") == 3 and getprop("/controls/switches/no-smoking-sign") == 1 and getprop("/controls/switches/seatbelt-sign") == 1 and getprop("/controls/flight/speedbrake-arm") == 1 and getprop("/controls/flight/flap-pos") > 0
and getprop("/controls/flight/flap-pos") < 5) {
setprop("/ECAM/to-config", 1);
}
2017-12-30 04:44:41 +00:00
},
};
2017-08-14 15:29:00 +00:00
2017-12-30 04:44:41 +00:00
ECAM.MSGclr();
2018-09-13 22:52:24 +00:00
var LowerECAM = {
button: func(b) {
2018-09-14 09:35:00 +00:00
var man_sel = getprop("/ECAM/Lower/man-select");
2018-09-14 13:35:05 +00:00
if(!getprop("/ECAM/lower/fault-select")) {
if(!man_sel) {
setprop("/ECAM/Lower/man-select", 1);
2018-09-14 09:35:00 +00:00
setprop("/ECAM/Lower/page", b);
setprop("/ECAM/Lower/light/" ~ b, 1);
2018-09-14 13:35:05 +00:00
} else {
if(b == getprop("/ECAM/Lower/page")) {
setprop("/ECAM/Lower/man-select", 0);
LowerECAM.loop();
setprop("/ECAM/Lower/light/" ~ b, 0);
} else {
setprop("/ECAM/Lower/light/" ~ getprop("/ECAM/Lower/page"), 0);
setprop("/ECAM/Lower/page", b);
setprop("/ECAM/Lower/light/" ~ b, 1);
}
2018-09-14 09:35:00 +00:00
}
}
2018-09-13 22:52:24 +00:00
},
loop: func() {
2018-09-14 09:35:00 +00:00
var man_sel = getprop("/ECAM/Lower/man-select");
2018-09-14 13:35:05 +00:00
var fault_sel = getprop("/ECAM/Lower/fault-select");
2018-09-14 09:35:00 +00:00
if(!man_sel) {
2018-09-29 01:21:34 +00:00
2018-09-14 13:35:05 +00:00
if(!fault_sel) {
2018-09-29 01:21:34 +00:00
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
2018-09-14 22:38:12 +00:00
or eng1_state == 1
or eng1_state == 2
or eng2_state == 1
or eng2_state == 2
2018-09-29 01:21:34 +00:00
or (to_thr == 1 and agl < 1500)
or eng_to == 1
2018-09-14 22:38:12 +00:00
or eng_timer > 0) {
2018-09-29 01:21:34 +00:00
if (eng_timer == 0) {
2018-09-14 22:38:12 +00:00
setprop("/ECAM/Lower/eng-timer", 1);
}
2018-09-29 01:21:34 +00:00
if (eng_mode == 1 and to_thr == 0) {
2018-09-14 22:38:12 +00:00
setprop("/ECAM/Lower/eng-timer", 0);
}
2018-09-29 01:21:34 +00:00
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) {
2018-09-14 22:38:12 +00:00
settimer(func() { setprop("/ECAM/Lower/eng-timer", 0);}, 10);
}
2018-09-29 01:21:34 +00:00
if (eng_to == 1 and agl >= 1500) {
settimer(func() { setprop("/ECAM/Lower/eng-to", 0);}, 60);
}
2018-09-14 22:38:12 +00:00
setprop("/ECAM/Lower/page", "eng");
2018-09-29 01:21:34 +00:00
} else if ((apu_master == 1 and apu_n < 95) or apu_timer > 0) {
2018-09-14 19:56:30 +00:00
# apu-timer states:
# 0 -> no apu start
# 1 -> apu starting/started, will be set back to 0 by timer
2018-09-29 01:21:34 +00:00
if (apu_timer == 0) {
2018-09-14 19:56:30 +00:00
setprop("/ECAM/Lower/apu-timer", 1);
}
2018-09-29 01:21:34 +00:00
if (apu_master == 0) {
2018-09-14 19:56:30 +00:00
setprop("/ECAM/Lower/apu-timer", 0);
}
2018-09-29 01:21:34 +00:00
if (apu_n >= 95) {
2018-09-14 19:56:30 +00:00
settimer(func() { setprop("/ECAM/Lower/apu-timer", 0);}, 10);
}
setprop("/ECAM/Lower/page", "apu");
2018-09-14 22:38:12 +00:00
2018-09-29 01:21:34 +00:00
} 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)) {
2018-09-14 13:35:05 +00:00
setprop("/ECAM/Lower/page", "wheel");
2018-09-14 22:38:12 +00:00
2018-09-29 01:21:34 +00:00
} else if (getprop("/gear/gear[1]/wow") == 1) {
2018-09-14 13:35:05 +00:00
setprop("/ECAM/Lower/page", "door");
2018-09-14 22:38:12 +00:00
2018-09-14 13:35:05 +00:00
} else {
setprop("/ECAM/Lower/page", "crz");
}
}
2018-09-14 09:35:00 +00:00
}
2018-09-13 22:52:24 +00:00
},
reset: func() {
2018-09-14 09:35:00 +00:00
setprop("/ECAM/Lower/page", "door");
setprop("/ECAM/Lower/man-select", 0);
2018-09-14 13:35:05 +00:00
setprop("/ECAM/Lower/fault-select", 0);
2018-09-14 19:56:30 +00:00
setprop("/ECAM/Lower/apu-timer", 0);
setprop("/ECAM/Lower/eng-timer", 0);
2018-09-29 01:21:34 +00:00
setprop("/ECAM/Lower/eng-to", 0);
2018-09-14 19:56:30 +00:00
setprop("/ECAM/Lower/fctl-timer", 0);
2018-09-14 09:35:00 +00:00
setprop("/ECAM/Lower/light/apu", 0);
setprop("/ECAM/Lower/light/bleed", 0);
setprop("/ECAM/Lower/light/cond", 0);
setprop("/ECAM/Lower/light/door", 0);
setprop("/ECAM/Lower/light/elec", 0);
setprop("/ECAM/Lower/light/eng", 0);
setprop("/ECAM/Lower/light/fctl", 0);
setprop("/ECAM/Lower/light/fuel", 0);
setprop("/ECAM/Lower/light/hyd", 0);
setprop("/ECAM/Lower/light/press", 0);
setprop("/ECAM/Lower/light/sts", 0);
setprop("/ECAM/Lower/light/wheel", 0);
2018-09-13 22:52:24 +00:00
},
2018-09-30 00:05:47 +00:00
};