1
0
Fork 0
A320-family/Nasal/Systems/FADEC/fadec-cfm.nas

141 lines
4.6 KiB
Text
Raw Normal View History

2019-10-14 16:48:35 +00:00
# A3XX CFM FADEC by Joshua Davidson (Octal450)
2020-04-18 05:36:46 +00:00
# Copyright (c) 2020 Josh Davidson (Octal450)
2019-10-14 16:48:35 +00:00
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/n1mode1", 0); # Doesn't do anything, just here for other logic #
setprop("systems/fadec/n1mode2", 0); # Doesn't do anything, just here for other logic #
setprop("systems/fadec/eng1/egt", 1);
setprop("systems/fadec/eng1/n1", 1);
setprop("systems/fadec/eng1/n2", 1);
setprop("systems/fadec/eng1/ff", 1);
setprop("systems/fadec/eng2/egt", 1);
setprop("systems/fadec/eng2/n1", 1);
setprop("systems/fadec/eng2/n2", 1);
setprop("systems/fadec/eng2/ff", 1);
setprop("systems/fadec/power-avail", 0);
setprop("systems/fadec/powered1", 0);
setprop("systems/fadec/powered2", 0);
setprop("systems/fadec/powered-time", -300);
setprop("systems/fadec/powerup", 0);
setprop("systems/fadec/eng1-master-count", 0);
setprop("systems/fadec/eng1-master-time", -300);
setprop("systems/fadec/eng1-off-power", 0);
setprop("systems/fadec/eng2-master-count", 0);
setprop("systems/fadec/eng2-master-time", -300);
setprop("systems/fadec/eng2-off-power", 0);
2019-10-14 16:48:35 +00:00
var FADEC = {
init: func() {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/powered-time", 0);
setprop("systems/fadec/eng1-master-time", -300);
setprop("systems/fadec/eng2-master-time", -300);
2019-10-14 16:48:35 +00:00
},
loop: func() {
2020-02-07 16:10:54 +00:00
var ac1 = getprop("systems/electrical/bus/ac-1");
var ac2 = getprop("systems/electrical/bus/ac-2");
var acess = getprop("systems/electrical/bus/ac-ess");
var state1 = getprop("engines/engine[0]/state");
var state2 = getprop("engines/engine[1]/state");
var master1 = getprop("controls/engines/engine[0]/cutoff-switch");
var master2 = getprop("controls/engines/engine[1]/cutoff-switch");
var modeSel = getprop("controls/engines/engine-start-switch");
var elapsedSec = getprop("sim/time/elapsed-sec");
2019-10-14 16:48:35 +00:00
if (ac1 >= 110 or ac2 >= 110 or acess >= 110) {
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/power-avail") != 1) {
setprop("systems/fadec/powered-time", elapsedSec);
setprop("systems/fadec/power-avail", 1);
2019-10-14 16:48:35 +00:00
}
} else {
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/power-avail") != 0) {
setprop("systems/fadec/power-avail", 0);
2019-10-14 16:48:35 +00:00
}
}
2020-02-07 16:10:54 +00:00
var powerAvail = getprop("systems/fadec/power-avail");
2019-10-14 16:48:35 +00:00
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/powered-time") + 300 >= elapsedSec) {
setprop("systems/fadec/powerup", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/powerup", 0);
2019-10-14 16:48:35 +00:00
}
if (master1 == 1) {
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/eng1-master-count") != 1) {
setprop("systems/fadec/eng1-master-time", elapsedSec);
setprop("systems/fadec/eng1-master-count", 1);
2019-10-14 16:48:35 +00:00
}
} else {
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/eng1-master-count") != 0) {
setprop("systems/fadec/eng1-master-count", 0);
2019-10-14 16:48:35 +00:00
}
}
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/eng1-master-time") + 300 >= elapsedSec) {
setprop("systems/fadec/eng1-off-power", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/eng1-off-power", 0);
2019-10-14 16:48:35 +00:00
}
if (master2 == 1) {
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/eng2-master-count") != 1) {
setprop("systems/fadec/eng2-master-time", elapsedSec);
setprop("systems/fadec/eng2-master-count", 1);
2019-10-14 16:48:35 +00:00
}
} else {
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/eng2-master-count") != 0) {
setprop("systems/fadec/eng2-master-count", 0);
2019-10-14 16:48:35 +00:00
}
}
2020-02-07 16:10:54 +00:00
if (getprop("systems/fadec/eng2-master-time") + 300 >= elapsedSec) {
setprop("systems/fadec/eng2-off-power", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/eng2-off-power", 0);
2019-10-14 16:48:35 +00:00
}
if (state1 == 3) {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/powered1", 1);
2019-10-14 16:48:35 +00:00
} else if (powerAvail and modeSel == 2) {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/powered1", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/powered1", 0);
2019-10-14 16:48:35 +00:00
}
if (state2 == 3) {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/powered2", 1);
2019-10-14 16:48:35 +00:00
} else if (powerAvail and modeSel == 2) {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/powered2", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/powered2", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
var powered1 = getprop("systems/fadec/powered1");
var powered2 = getprop("systems/fadec/powered2");
2019-10-14 16:48:35 +00:00
2020-02-07 16:10:54 +00:00
if (powered1 or getprop("systems/fadec/powerup") or getprop("systems/fadec/eng1-off-power")) {
setprop("systems/fadec/eng1/n1", 1);
setprop("systems/fadec/eng1/egt", 1);
setprop("systems/fadec/eng1/n2", 1);
setprop("systems/fadec/eng1/ff", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/eng1/n1", 0);
setprop("systems/fadec/eng1/egt", 0);
setprop("systems/fadec/eng1/n2", 0);
setprop("systems/fadec/eng1/ff", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (powered2 or getprop("systems/fadec/powerup") or getprop("systems/fadec/eng2-off-power")) {
setprop("systems/fadec/eng2/n1", 1);
setprop("systems/fadec/eng2/egt", 1);
setprop("systems/fadec/eng2/n2", 1);
setprop("systems/fadec/eng2/ff", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("systems/fadec/eng2/n1", 0);
setprop("systems/fadec/eng2/egt", 0);
setprop("systems/fadec/eng2/n2", 0);
setprop("systems/fadec/eng2/ff", 0);
2019-10-14 16:48:35 +00:00
}
},
};