1
0
Fork 0

FADEC: efficientize the nasal loop

This commit is contained in:
legoboyvdlp R 2020-09-24 20:32:02 +01:00
parent ce6f08bb30
commit 844d604ea1
4 changed files with 303 additions and 261 deletions

View file

@ -145,9 +145,6 @@ var spoiler_R3 = props.globals.getNode("/fdm/jsbsim/hydraulics/spoiler-r3/final-
var spoiler_R4 = props.globals.getNode("/fdm/jsbsim/hydraulics/spoiler-r4/final-deg", 1);
var spoiler_R5 = props.globals.getNode("/fdm/jsbsim/hydraulics/spoiler-r5/final-deg", 1);
var total_fuel_lbs = props.globals.getNode("/consumables/fuel/total-fuel-lbs", 1);
var fadec1 = props.globals.getNode("/systems/fadec/powered1", 1);
var fadec2 = props.globals.getNode("/systems/fadec/powered2", 1);
var fadecPowerUp = props.globals.getNode("/systems/fadec/powerup", 1);
var fuel_flow1 = props.globals.getNode("/engines/engine[0]/fuel-flow_actual", 1);
var fuel_flow2 = props.globals.getNode("/engines/engine[1]/fuel-flow_actual", 1);
var fuel_left_outer_temp = props.globals.getNode("/consumables/fuel/tank[0]/temperature_degC", 1);
@ -2375,7 +2372,7 @@ var canvas_lowerECAM_fuel = {
me["FFlow-weight-unit"].setText("LBS/MIN");
}
if (fadec1.getValue() and fadec2.getValue() or fadecPowerUp.getValue()) {
if (fadec.FADEC.Power.powered1.getValue() and fadec.FADEC.Power.powered2.getValue() or fadec.FADEC.Power.powerup.getValue()) {
me["FUEL-Flow-per-min"].setColor(0.0509,0.7529,0.2941);
if (_weight_kgs == 1) {
me["FUEL-Flow-per-min"].setText(sprintf("%s", math.round(((fuel_flow1.getValue() + fuel_flow2.getValue()) * LBS2KGS) / 60, 10)));

View file

@ -44,12 +44,6 @@ var eng_option = props.globals.getNode("/options/eng", 1);
var du3_lgt = props.globals.getNode("/controls/lighting/DU/du3", 1);
var rev_1 = props.globals.getNode("/engines/engine[0]/reverser-pos-norm", 1);
var rev_2 = props.globals.getNode("/engines/engine[1]/reverser-pos-norm", 1);
var eng1_n1mode = props.globals.getNode("/systems/fadec/eng1/n1", 1);
var eng1_eprmode = props.globals.getNode("/systems/fadec/eng1/epr", 1);
var eng2_n1mode = props.globals.getNode("/systems/fadec/eng2/n1", 1);
var eng2_eprmode = props.globals.getNode("/systems/fadec/eng2/epr", 1);
var eng1_n2mode = props.globals.getNode("/systems/fadec/eng1/n2", 1);
var eng2_n2mode = props.globals.getNode("/systems/fadec/eng2/n2", 1);
var fuel = props.globals.getNode("/consumables/fuel/total-fuel-lbs", 1);
var modeautobrake = props.globals.getNode("/controls/autobrake/mode", 1);
var speedbrakearm = props.globals.getNode("/controls/flight/speedbrake-arm", 1);
@ -67,10 +61,6 @@ var eng1_epr = props.globals.getNode("/engines/engine[0]/epr-actual", 1);
var eng2_epr = props.globals.getNode("/engines/engine[1]/epr-actual", 1);
var eng1_egt = props.globals.getNode("/engines/engine[0]/egt-actual", 1);
var eng2_egt = props.globals.getNode("/engines/engine[1]/egt-actual", 1);
var eng1_egtmode = props.globals.getNode("/systems/fadec/eng1/egt", 1);
var eng2_egtmode = props.globals.getNode("/systems/fadec/eng2/egt", 1);
var eng1_ffmode = props.globals.getNode("/systems/fadec/eng1/ff", 1);
var eng2_ffmode = props.globals.getNode("/systems/fadec/eng2/ff", 1);
var fadecpower_1 = props.globals.getNode("/systems/fadec/powered1", 1);
var fadecpower_2 = props.globals.getNode("/systems/fadec/powered2", 1);
var fadecpowerup = props.globals.getNode("/systems/fadec/powerup", 1);
@ -196,10 +186,10 @@ var canvas_upperECAM_base = {
rev_1_cur = rev_1.getValue();
rev_2_cur = rev_2.getValue();
cur_eng_option = eng_option.getValue();
if (rev_1_cur >= 0.01 and eng1_n1mode.getValue() == 1 and cur_eng_option == "CFM") {
if (rev_1_cur >= 0.01 and fadec.FADEC.Eng1.n1 == 1 and cur_eng_option == "CFM") {
me["REV1"].show();
me["REV1-box"].show();
} else if (rev_1_cur >= 0.01 and eng1_eprmode.getValue() == 1 and cur_eng_option == "IAE") {
} else if (rev_1_cur >= 0.01 and fadec.FADEC.Eng1.epr == 1 and cur_eng_option == "IAE") {
me["REV1"].show();
me["REV1-box"].show();
} else {
@ -213,10 +203,10 @@ var canvas_upperECAM_base = {
me["REV1"].setColor(0.7333,0.3803,0);
}
if (rev_2_cur >= 0.01 and eng2_n1mode.getValue() == 1 and cur_eng_option == "CFM") {
if (rev_2_cur >= 0.01 and fadec.FADEC.Eng2.n1 == 1 and cur_eng_option == "CFM") {
me["REV2"].show();
me["REV2-box"].show();
} else if (rev_2_cur >= 0.01 and eng2_eprmode.getValue() == 1 and cur_eng_option == "IAE") {
} else if (rev_2_cur >= 0.01 and fadec.FADEC.Eng2.epr == 1 and cur_eng_option == "IAE") {
me["REV2"].show();
me["REV2-box"].show();
} else {
@ -654,12 +644,8 @@ var canvas_upperECAM_cfm_eis2 = {
N1_lim_cur = N1_lim.getValue();
N1_thr_1_act = N1_thr_1.getValue();
N1_thr_2_act = N1_thr_2.getValue();
n1mode_1 = eng1_n1mode.getValue();
n1mode_2 = eng2_n1mode.getValue();
rev_1_act = rev_1.getValue();
rev_2_act = rev_2.getValue();
ff_1 = eng1_ffmode.getValue();
ff_2 = eng2_ffmode.getValue();
EGT_1_cur = EGT_1.getValue();
EGT_2_cur = EGT_2.getValue();
n2cur_1 = eng1_n2.getValue();
@ -679,7 +665,7 @@ var canvas_upperECAM_cfm_eis2 = {
me["N12-thr"].setRotation((N1_thr_2_act + 90) * D2R);
me["N12-ylim"].setRotation((N1_lim_cur + 90) * D2R);
if (n1mode_1 == 1) {
if (fadec.FADEC.Eng1.n1 == 1) {
me["N11-scale"].setColor(0.8078,0.8039,0.8078);
me["N11-scale2"].setColor(1,0,0);
me["N11"].show();
@ -709,13 +695,13 @@ var canvas_upperECAM_cfm_eis2 = {
me["N11-XX-box"].show();
}
if (rev_1_act < 0.01 and n1mode_1 == 1) {
if (rev_1_act < 0.01 and fadec.FADEC.Eng1.n1 == 1) {
me["N11-thr"].show();
} else {
me["N11-thr"].hide();
}
if (n1mode_2 == 1) {
if (fadec.FADEC.Eng2.n1 == 1) {
me["N12-scale"].setColor(0.8078,0.8039,0.8078);
me["N12-scale2"].setColor(1,0,0);
me["N12"].show();
@ -745,7 +731,7 @@ var canvas_upperECAM_cfm_eis2 = {
me["N12-XX-box"].show();
}
if (rev_2_act < 0.01 and n1mode_2 == 1) {
if (rev_2_act < 0.01 and fadec.FADEC.Eng2.n1 == 1) {
me["N12-thr"].show();
} else {
me["N12-thr"].hide();
@ -758,7 +744,7 @@ var canvas_upperECAM_cfm_eis2 = {
me["EGT1-needle"].setRotation((EGT_1_cur + 90) * D2R);
me["EGT2-needle"].setRotation((EGT_2_cur + 90) * D2R);
if (eng1_egtmode.getValue() == 1) {
if (fadec.FADEC.Eng1.egt == 1) {
me["EGT1-scale"].setColor(0.8078,0.8039,0.8078);
me["EGT1-scale2"].setColor(1,0,0);
me["EGT1"].show();
@ -776,7 +762,7 @@ var canvas_upperECAM_cfm_eis2 = {
me["EGT1-XX"].show();
}
if (eng2_egtmode.getValue() == 1) {
if (fadec.FADEC.Eng2.egt == 1) {
me["EGT2-scale"].setColor(0.8078,0.8039,0.8078);
me["EGT2-scale2"].setColor(1,0,0);
me["EGT2"].show();
@ -801,7 +787,7 @@ var canvas_upperECAM_cfm_eis2 = {
me["N22"].setText(sprintf("%s", math.floor(n2cur_2 + 0.05)));
me["N22-decimal"].setText(sprintf("%s", int(10 * math.mod(n2cur_2 + 0.05, 1))));
if (eng1_n2mode.getValue() == 1) {
if (fadec.FADEC.Eng1.n2 == 1) {
me["N21"].show();
me["N21-decimal"].show();
me["N21-decpnt"].show();
@ -813,7 +799,7 @@ var canvas_upperECAM_cfm_eis2 = {
me["N21-XX"].show();
}
if (eng2_n2mode.getValue() == 1) {
if (fadec.FADEC.Eng2.n2 == 1) {
me["N22"].show();
me["N22-decimal"].show();
me["N22-decpnt"].show();
@ -836,7 +822,7 @@ var canvas_upperECAM_cfm_eis2 = {
me["FFlow-weight-unit"].setText("LBS/H");
}
if (ff_1 == 1) {
if (fadec.FADEC.Eng1.ff == 1) {
me["FF1"].show();
me["FF1-XX"].hide();
} else {
@ -844,7 +830,7 @@ var canvas_upperECAM_cfm_eis2 = {
me["FF1-XX"].show();
}
if (ff_2 == 1) {
if (fadec.FADEC.Eng2.ff == 1) {
me["FF2"].show();
me["FF2-XX"].hide();
} else {
@ -911,12 +897,8 @@ var canvas_upperECAM_iae_eis2 = {
EPR_lim_cur = EPR_lim.getValue();
EPR_thr_1_act = EPR_thr_1.getValue();
EPR_thr_2_act = EPR_thr_2.getValue();
eprmode1 = eng1_eprmode.getValue();
eprmode2 = eng2_eprmode.getValue();
rev_1_act = rev_1.getValue();
rev_2_act = rev_2.getValue();
ff_1 = eng1_ffmode.getValue();
ff_2 = eng2_ffmode.getValue();
EGT_1_cur = EGT_1.getValue();
EGT_2_cur = EGT_2.getValue();
n2cur_1 = eng1_n2.getValue();
@ -935,7 +917,7 @@ var canvas_upperECAM_iae_eis2 = {
me["EPR2-thr"].setRotation((EPR_thr_2_act + 90) * D2R);
me["EPR2-ylim"].setRotation((EPR_lim_cur + 90) * D2R);
if (eprmode1 == 1) {
if (fadec.FADEC.Eng1.epr == 1) {
me["EPR1-scale"].setColor(0.8078,0.8039,0.8078);
me["EPR1"].show();
me["EPR1-decpnt"].show();
@ -961,13 +943,13 @@ var canvas_upperECAM_iae_eis2 = {
me["EPR1-XX2"].show();
}
if (rev_1_act < 0.01 and eprmode1 == 1) {
if (rev_1_act < 0.01 and fadec.FADEC.Eng1.epr == 1) {
me["EPR1-thr"].show();
} else {
me["EPR1-thr"].hide();
}
if (eprmode2 == 1) {
if (fadec.FADEC.Eng2.epr == 1) {
me["EPR2-scale"].setColor(0.8078,0.8039,0.8078);
me["EPR2"].show();
me["EPR2-decpnt"].show();
@ -993,7 +975,7 @@ var canvas_upperECAM_iae_eis2 = {
me["EPR2-XX2"].show();
}
if (rev_2_act < 0.01 and eprmode2 == 1) {
if (rev_2_act < 0.01 and fadec.FADEC.Eng2.epr == 1) {
me["EPR2-thr"].show();
} else {
me["EPR2-thr"].hide();
@ -1006,7 +988,7 @@ var canvas_upperECAM_iae_eis2 = {
me["EGT1-needle"].setRotation((EGT_1_cur + 90) * D2R);
me["EGT2-needle"].setRotation((EGT_2_cur + 90) * D2R);
if (eng1_egtmode.getValue() == 1) {
if (fadec.FADEC.Eng1.egt == 1) {
me["EGT1-scale"].setColor(0.8078,0.8039,0.8078);
me["EGT1-scale2"].setColor(1,0,0);
me["EGT1"].show();
@ -1024,7 +1006,7 @@ var canvas_upperECAM_iae_eis2 = {
me["EGT1-XX"].show();
}
if (eng2_egtmode.getValue() == 1) {
if (fadec.FADEC.Eng2.egt == 1) {
me["EGT2-scale"].setColor(0.8078,0.8039,0.8078);
me["EGT2-scale2"].setColor(1,0,0);
me["EGT2"].show();
@ -1057,7 +1039,7 @@ var canvas_upperECAM_iae_eis2 = {
me["N12-thr"].setRotation((N1_thr_2.getValue() + 90) * D2R);
me["N12-ylim"].setRotation((N1_lim_cur + 90) * D2R);
if (eng1_n1mode.getValue() == 1) {
if (fadec.FADEC.Eng1.n1 == 1) {
me["N11-scale"].setColor(0.8078,0.8039,0.8078);
me["N11-scale2"].setColor(1,0,0);
me["N11"].show();
@ -1079,7 +1061,7 @@ var canvas_upperECAM_iae_eis2 = {
me["N11-XX"].show();
}
if (eng2_n1mode.getValue() == 1) {
if (fadec.FADEC.Eng2.n1 == 1) {
me["N12-scale"].setColor(0.8078,0.8039,0.8078);
me["N12-scale2"].setColor(1,0,0);
me["N12"].show();
@ -1101,7 +1083,7 @@ var canvas_upperECAM_iae_eis2 = {
me["N12-XX"].show();
}
if (eng1_n1mode.getValue() == 1 and fadec.Fadec.n1Mode[0].getValue() == 1) {
if (fadec.FADEC.Eng1.n1 == 1 and fadec.Fadec.n1Mode[0].getValue() == 1) {
me["N11-thr"].show();
me["N11-ylim"].hide(); # Keep it hidden, since N1 mode limit calculation is not done yet
} else {
@ -1109,7 +1091,7 @@ var canvas_upperECAM_iae_eis2 = {
me["N11-ylim"].hide();
}
if (eng2_n1mode.getValue() == 1 and fadec.Fadec.n1Mode[1].getValue() == 1) {
if (fadec.FADEC.Eng2.n1 == 1 and fadec.Fadec.n1Mode[1].getValue() == 1) {
me["N12-thr"].show();
me["N12-ylim"].hide(); # Keep it hidden, since N1 mode limit calculation is not done yet
} else {
@ -1123,7 +1105,7 @@ var canvas_upperECAM_iae_eis2 = {
me["N22"].setText(sprintf("%s", math.floor(eng2_n2.getValue() + 0.05)));
me["N22-decimal"].setText(sprintf("%s", int(10 * math.mod(eng2_n2.getValue() + 0.05, 1))));
if (eng1_n2mode.getValue() == 1) {
if (fadec.FADEC.Eng1.n2 == 1) {
me["N21"].show();
me["N21-decimal"].show();
me["N21-decpnt"].show();
@ -1135,7 +1117,7 @@ var canvas_upperECAM_iae_eis2 = {
me["N21-XX"].show();
}
if (eng2_n2mode.getValue() == 1) {
if (fadec.FADEC.Eng2.n2 == 1) {
me["N22"].show();
me["N22-decimal"].show();
me["N22-decpnt"].show();
@ -1160,7 +1142,7 @@ var canvas_upperECAM_iae_eis2 = {
me["FFlow2-weight-unit"].setText("LBS/H");
}
if (ff_1 == 1) {
if (fadec.FADEC.Eng1.ff == 1) {
me["FF1"].show();
me["FF1-XX"].hide();
} else {
@ -1168,7 +1150,7 @@ var canvas_upperECAM_iae_eis2 = {
me["FF1-XX"].show();
}
if (ff_2 == 1) {
if (fadec.FADEC.Eng2.ff == 1) {
me["FF2"].show();
me["FF2-XX"].hide();
} else {

View file

@ -2,139 +2,172 @@
# Copyright (c) 2020 Josh Davidson (Octal450)
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);
var powerAvailTemp = nil;
var master1 = nil;
var master2 = nil;
var state1 = nil;
var state2 = nil;
var modeSel = nil;
var powered1 = nil;
var powered2 = nil;
var powerup = nil;
var N11 = nil;
var N12 = nil;
var N21 = nil;
var N22 = nil;
var FADEC = {
Power: {
powered1: props.globals.initNode("/systems/fadec/powered1", 0, "BOOL"),
powered2: props.globals.initNode("/systems/fadec/powered2", 0, "BOOL"),
powerup: props.globals.initNode("/systems/fadec/powerup", 0, "BOOL"),
powerAvail: props.globals.initNode("/systems/fadec/power-avail", 0, "BOOL"),
poweredTime: props.globals.initNode("/systems/fadec/powered-time", 0, "DOUBLE"),
},
Eng1: {
eng1Time: props.globals.initNode("/systems/fadec/eng1-master-time", -300, "DOUBLE"),
eng1Off: props.globals.initNode("/systems/fadec/eng1-off-power", 0, "BOOL"),
eng1Counting: 0,
epr: 0,
egt: 0,
n1: 0,
n2: 0,
ff: 0,
},
Eng2: {
eng2Time: props.globals.initNode("/systems/fadec/eng2-master-time", -300, "DOUBLE"),
eng2Off: props.globals.initNode("/systems/fadec/eng2-off-power", 0, "BOOL"),
eng2Counting: 0,
epr: 0,
egt: 0,
n1: 0,
n2: 0,
ff: 0,
},
Switches: {
n1ModeSwitch1: props.globals.initNode("/controls/fadec/n1mode1", 0, "BOOL"),
n1ModeSwitch2: props.globals.initNode("/controls/fadec/n1mode2", 0, "BOOL"),
},
Modes: {
n1Mode1: props.globals.initNode("/systems/fadec/n1mode1", 0, "BOOL"), # 0 == EPR, 1 == N1 Rated, 2 == N1 Unrated #
n1Mode2: props.globals.initNode("/systems/fadec/n1mode2", 0, "BOOL"),
},
init: func() {
setprop("/systems/fadec/powered-time", 0);
setprop("/systems/fadec/eng1-master-time", -300);
setprop("/systems/fadec/eng2-master-time", -300);
me.Power.poweredTime.setValue(-300);
me.Eng1.eng1Time.setValue(-300);
me.Eng2.eng2Time.setValue(-300);
},
loop: func() {
var ac1 = systems.ELEC.Bus.ac1.getValue();
var ac2 = systems.ELEC.Bus.ac2.getValue();
var acess = systems.ELEC.Bus.acEss.getValue();
var state1 = pts.Engines.Engine.state[0].getValue();
var state2 = pts.Engines.Engine.state[1].getValue();
var master1 = pts.Controls.Engines.Engine.cutoffSw[0].getValue();
var master2 = pts.Controls.Engines.Engine.cutoffSw[1].getValue();
var modeSel = pts.Controls.Engines.startSw.getValue();
var elapsedSec = pts.Sim.Time.elapsedSec.getValue();
powerAvailTemp = me.Power.powerAvail.getValue();
if (ac1 >= 110 or ac2 >= 110 or acess >= 110) {
if (getprop("/systems/fadec/power-avail") != 1) {
setprop("/systems/fadec/powered-time", elapsedSec);
setprop("/systems/fadec/power-avail", 1);
if (systems.ELEC.Bus.ac1.getValue() >= 110 or systems.ELEC.Bus.ac2.getValue() >= 110 or systems.ELEC.Bus.acEss.getValue() >= 110) {
if (powerAvailTemp != 1) {
me.Power.poweredTime.setValue(elapsedSec);
me.Power.powerAvail.setValue(1);
}
} else {
if (getprop("/systems/fadec/power-avail") != 0) {
setprop("/systems/fadec/power-avail", 0);
if (powerAvailTemp != 0) {
me.Power.powerAvail.setValue(0);
}
}
var powerAvail = getprop("/systems/fadec/power-avail");
powerAvailTemp = me.Power.powerAvail.getValue();
if (getprop("/systems/fadec/powered-time") + 300 >= elapsedSec) {
setprop("/systems/fadec/powerup", 1);
if (me.Power.poweredTime.getValue() + 300 >= elapsedSec) {
if (!me.Power.powerup.getValue()) {
me.Power.powerup.setValue(1);
}
} else {
setprop("/systems/fadec/powerup", 0);
if (me.Power.powerup.getValue()) {
me.Power.powerup.setValue(0);
}
}
master1 = pts.Controls.Engines.Engine.cutoffSw[0].getValue();
if (master1 == 1) {
if (getprop("/systems/fadec/eng1-master-count") != 1) {
setprop("/systems/fadec/eng1-master-time", elapsedSec);
setprop("/systems/fadec/eng1-master-count", 1);
if (me.Eng1.eng1Counting != 1) {
me.Eng1.eng1Time.setValue(elapsedSec);
me.Eng1.eng1Counting = 1;
}
} else {
if (getprop("/systems/fadec/eng1-master-count") != 0) {
setprop("/systems/fadec/eng1-master-count", 0);
if (me.Eng1.eng1Counting != 0) {
me.Eng1.eng1Counting = 0;
}
}
if (getprop("/systems/fadec/eng1-master-time") + 300 >= elapsedSec) {
setprop("/systems/fadec/eng1-off-power", 1);
if (me.Eng1.eng1Time.getValue() + 300 >= elapsedSec) {
me.Eng1.eng1Off.setValue(1);
} else {
setprop("/systems/fadec/eng1-off-power", 0);
me.Eng1.eng1Off.setValue(0);
}
master2 = pts.Controls.Engines.Engine.cutoffSw[1].getValue();
if (master2 == 1) {
if (getprop("/systems/fadec/eng2-master-count") != 1) {
setprop("/systems/fadec/eng2-master-time", elapsedSec);
setprop("/systems/fadec/eng2-master-count", 1);
if (me.Eng2.eng2Counting != 1) {
me.Eng2.eng2Time.setValue(elapsedSec);
me.Eng2.eng2Counting = 1;
}
} else {
if (getprop("/systems/fadec/eng2-master-count") != 0) {
setprop("/systems/fadec/eng2-master-count", 0);
if (me.Eng2.eng2Counting != 0) {
me.Eng2.eng2Counting = 0;
}
}
if (getprop("/systems/fadec/eng2-master-time") + 300 >= elapsedSec) {
setprop("/systems/fadec/eng2-off-power", 1);
if (me.Eng2.eng2Time.getValue() + 300 >= elapsedSec) {
me.Eng2.eng2Off.setValue(1);
} else {
setprop("/systems/fadec/eng2-off-power", 0);
me.Eng2.eng2Off.setValue(0);
}
state1 = pts.Engines.Engine.state[0].getValue();
state2 = pts.Engines.Engine.state[1].getValue();
modeSel = pts.Controls.Engines.startSw.getValue();
if (state1 == 3) {
setprop("/systems/fadec/powered1", 1);
} else if (powerAvail and modeSel == 2) {
setprop("/systems/fadec/powered1", 1);
me.Power.powered1.setValue(1);
} else if (powerAvailTemp and modeSel == 2) {
me.Power.powered1.setValue(1);
} else {
setprop("/systems/fadec/powered1", 0);
me.Power.powered1.setValue(0);
}
if (state2 == 3) {
setprop("/systems/fadec/powered2", 1);
} else if (powerAvail and modeSel == 2) {
setprop("/systems/fadec/powered2", 1);
me.Power.powered2.setValue(1);
} else if (powerAvailTemp and modeSel == 2) {
me.Power.powered2.setValue(1);
} else {
setprop("/systems/fadec/powered2", 0);
me.Power.powered2.setValue(0);
}
var powered1 = getprop("/systems/fadec/powered1");
var powered2 = getprop("/systems/fadec/powered2");
powered1 = me.Power.powered1.getValue();
powered2 = me.Power.powered2.getValue();
powerup = me.Power.powerup.getValue();
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);
if (powered1 or powerup or me.Eng1.eng1Off.getValue()) {
me.Eng1.n1 = 1;
me.Eng1.n2 = 1;
me.Eng1.egt = 1;
me.Eng1.ff = 1;
} else {
setprop("/systems/fadec/eng1/n1", 0);
setprop("/systems/fadec/eng1/egt", 0);
setprop("/systems/fadec/eng1/n2", 0);
setprop("/systems/fadec/eng1/ff", 0);
me.Eng1.n1 = 0;
me.Eng1.n2 = 0;
me.Eng1.egt = 0;
me.Eng1.ff = 0;
}
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);
if (powered2 or powerup or me.Eng2.eng2Off.getValue()) {
me.Eng2.n1 = 1;
me.Eng2.n2 = 1;
me.Eng2.egt = 1;
me.Eng2.ff = 1;
} else {
setprop("/systems/fadec/eng2/n1", 0);
setprop("/systems/fadec/eng2/egt", 0);
setprop("/systems/fadec/eng2/n2", 0);
setprop("/systems/fadec/eng2/ff", 0);
me.Eng2.n1 = 0;
me.Eng2.n2 = 0;
me.Eng2.egt = 0;
me.Eng2.ff = 0;
}
},
};

View file

@ -1,192 +1,222 @@
# A3XX IAE FADEC by Joshua Davidson (Octal450)
# Copyright (c) 2020 Josh Davidson (Octal450)
setprop("/controls/fadec/n1mode1", 0);
setprop("/controls/fadec/n1mode2", 0);
setprop("/systems/fadec/n1mode1", 0); # 0 == EPR, 1 == N1 Rated, 2 == N1 Unrated #
setprop("/systems/fadec/n1mode2", 0); # 0 == EPR, 1 == N1 Rated, 2 == N1 Unrated #
setprop("/systems/fadec/eng1/epr", 1);
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/epr", 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);
var powerAvailTemp = nil;
var master1 = nil;
var master2 = nil;
var state1 = nil;
var state2 = nil;
var modeSel = nil;
var powered1 = nil;
var powered2 = nil;
var powerup = nil;
var N11 = nil;
var N12 = nil;
var N21 = nil;
var N22 = nil;
var FADEC = {
Power: {
powered1: props.globals.initNode("/systems/fadec/powered1", 0, "BOOL"),
powered2: props.globals.initNode("/systems/fadec/powered2", 0, "BOOL"),
powerup: props.globals.initNode("/systems/fadec/powerup", 0, "BOOL"),
powerAvail: props.globals.initNode("/systems/fadec/power-avail", 0, "BOOL"),
poweredTime: props.globals.initNode("/systems/fadec/powered-time", 0, "DOUBLE"),
},
Eng1: {
eng1Time: props.globals.initNode("/systems/fadec/eng1-master-time", -300, "DOUBLE"),
eng1Off: props.globals.initNode("/systems/fadec/eng1-off-power", 0, "BOOL"),
eng1Counting: 0,
epr: 0,
egt: 0,
n1: 0,
n2: 0,
ff: 0,
},
Eng2: {
eng2Time: props.globals.initNode("/systems/fadec/eng2-master-time", -300, "DOUBLE"),
eng2Off: props.globals.initNode("/systems/fadec/eng2-off-power", 0, "BOOL"),
eng2Counting: 0,
epr: 0,
egt: 0,
n1: 0,
n2: 0,
ff: 0,
},
Switches: {
n1ModeSwitch1: props.globals.initNode("/controls/fadec/n1mode1", 0, "BOOL"),
n1ModeSwitch2: props.globals.initNode("/controls/fadec/n1mode2", 0, "BOOL"),
},
Modes: {
n1Mode1: props.globals.initNode("/systems/fadec/n1mode1", 0, "BOOL"), # 0 == EPR, 1 == N1 Rated, 2 == N1 Unrated #
n1Mode2: props.globals.initNode("/systems/fadec/n1mode2", 0, "BOOL"),
},
# Copyright (c) 2020 Josh Davidson (Octal450)
init: func() {
setprop("/systems/fadec/powered-time", 0);
setprop("/systems/fadec/eng1-master-time", -300);
setprop("/systems/fadec/eng2-master-time", -300);
me.Power.poweredTime.setValue(-300);
me.Eng1.eng1Time.setValue(-300);
me.Eng2.eng2Time.setValue(-300);
},
loop: func() {
var ac1 = systems.ELEC.Bus.ac1.getValue();
var ac2 = systems.ELEC.Bus.ac2.getValue();
var acess = systems.ELEC.Bus.acEss.getValue();
var state1 = pts.Engines.Engine.state[0].getValue();
var state2 = pts.Engines.Engine.state[1].getValue();
var master1 = pts.Controls.Engines.Engine.cutoffSw[0].getValue();
var master2 = pts.Controls.Engines.Engine.cutoffSw[1].getValue();
var modeSel = pts.Controls.Engines.startSw.getValue();
var elapsedSec = pts.Sim.Time.elapsedSec.getValue();
var N1Mode1_sw = getprop("/controls/fadec/n1mode1");
var N1Mode2_sw = getprop("/controls/fadec/n1mode2");
powerAvailTemp = me.Power.powerAvail.getValue();
if (ac1 >= 110 or ac2 >= 110 or acess >= 110) {
if (getprop("/systems/fadec/power-avail") != 1) {
setprop("/systems/fadec/powered-time", elapsedSec);
setprop("/systems/fadec/power-avail", 1);
if (systems.ELEC.Bus.ac1.getValue() >= 110 or systems.ELEC.Bus.ac2.getValue() >= 110 or systems.ELEC.Bus.acEss.getValue() >= 110) {
if (powerAvailTemp != 1) {
me.Power.poweredTime.setValue(elapsedSec);
me.Power.powerAvail.setValue(1);
}
} else {
if (getprop("/systems/fadec/power-avail") != 0) {
setprop("/systems/fadec/power-avail", 0);
if (powerAvailTemp != 0) {
me.Power.powerAvail.setValue(0);
}
}
var powerAvail = getprop("/systems/fadec/power-avail");
powerAvailTemp = me.Power.powerAvail.getValue();
if (getprop("/systems/fadec/powered-time") + 300 >= elapsedSec) {
setprop("/systems/fadec/powerup", 1);
if (me.Power.poweredTime.getValue() + 300 >= elapsedSec) {
if (!me.Power.powerup.getValue()) {
me.Power.powerup.setValue(1);
}
} else {
setprop("/systems/fadec/powerup", 0);
if (me.Power.powerup.getValue()) {
me.Power.powerup.setValue(0);
}
}
master1 = pts.Controls.Engines.Engine.cutoffSw[0].getValue();
if (master1 == 1) {
if (getprop("/systems/fadec/eng1-master-count") != 1) {
setprop("/systems/fadec/eng1-master-time", elapsedSec);
setprop("/systems/fadec/eng1-master-count", 1);
if (me.Eng1.eng1Counting != 1) {
me.Eng1.eng1Time.setValue(elapsedSec);
me.Eng1.eng1Counting = 1;
}
} else {
if (getprop("/systems/fadec/eng1-master-count") != 0) {
setprop("/systems/fadec/eng1-master-count", 0);
if (me.Eng1.eng1Counting != 0) {
me.Eng1.eng1Counting = 0;
}
}
if (getprop("/systems/fadec/eng1-master-time") + 300 >= elapsedSec) {
setprop("/systems/fadec/eng1-off-power", 1);
if (me.Eng1.eng1Time.getValue() + 300 >= elapsedSec) {
me.Eng1.eng1Off.setValue(1);
} else {
setprop("/systems/fadec/eng1-off-power", 0);
me.Eng1.eng1Off.setValue(0);
}
master2 = pts.Controls.Engines.Engine.cutoffSw[1].getValue();
if (master2 == 1) {
if (getprop("/systems/fadec/eng2-master-count") != 1) {
setprop("/systems/fadec/eng2-master-time", elapsedSec);
setprop("/systems/fadec/eng2-master-count", 1);
if (me.Eng2.eng2Counting != 1) {
me.Eng2.eng2Time.setValue(elapsedSec);
me.Eng2.eng2Counting = 1;
}
} else {
if (getprop("/systems/fadec/eng2-master-count") != 0) {
setprop("/systems/fadec/eng2-master-count", 0);
if (me.Eng2.eng2Counting != 0) {
me.Eng2.eng2Counting = 0;
}
}
if (getprop("/systems/fadec/eng2-master-time") + 300 >= elapsedSec) {
setprop("/systems/fadec/eng2-off-power", 1);
if (me.Eng2.eng2Time.getValue() + 300 >= elapsedSec) {
me.Eng2.eng2Off.setValue(1);
} else {
setprop("/systems/fadec/eng2-off-power", 0);
me.Eng2.eng2Off.setValue(0);
}
state1 = pts.Engines.Engine.state[0].getValue();
state2 = pts.Engines.Engine.state[1].getValue();
modeSel = pts.Controls.Engines.startSw.getValue();
if (state1 == 3) {
setprop("/systems/fadec/powered1", 1);
} else if (powerAvail and modeSel == 2) {
setprop("/systems/fadec/powered1", 1);
me.Power.powered1.setValue(1);
} else if (powerAvailTemp and modeSel == 2) {
me.Power.powered1.setValue(1);
} else {
setprop("/systems/fadec/powered1", 0);
me.Power.powered1.setValue(0);
}
if (state2 == 3) {
setprop("/systems/fadec/powered2", 1);
} else if (powerAvail and modeSel == 2) {
setprop("/systems/fadec/powered2", 1);
me.Power.powered2.setValue(1);
} else if (powerAvailTemp and modeSel == 2) {
me.Power.powered2.setValue(1);
} else {
setprop("/systems/fadec/powered2", 0);
me.Power.powered2.setValue(0);
}
if (N1Mode1_sw == 1) {
setprop("/systems/fadec/n1mode1", 1);
powered1 = me.Power.powered1.getValue();
powered2 = me.Power.powered2.getValue();
powerup = me.Power.powerup.getValue();
if (powered1 or powerup or me.Eng1.eng1Off.getValue()) {
if (me.Modes.n1Mode1.getValue() == 0) {
me.Eng1.epr = 1;
} else {
me.Eng1.epr = 0;
}
me.Eng1.egt = 1;
me.Eng1.ff = 1;
} else {
setprop("/systems/fadec/n1mode1", 0);
me.Eng1.epr = 0;
me.Eng1.egt = 0;
me.Eng1.ff = 0;
}
if (N1Mode2_sw == 1) {
setprop("/systems/fadec/n1mode2", 1);
if (powered2 or powerup or me.Eng2.eng2Off.getValue()) {
if (me.Modes.n1Mode2.getValue() == 0) {
me.Eng2.epr = 1;
} else {
me.Eng2.epr = 0;
}
me.Eng2.egt = 1;
me.Eng2.ff = 1;
} else {
setprop("/systems/fadec/n1mode2", 0);
me.Eng2.epr = 0;
me.Eng2.egt = 0;
me.Eng2.ff = 0;
}
var powered1 = getprop("/systems/fadec/powered1");
var powered2 = getprop("/systems/fadec/powered2");
var N1Mode1 = getprop("/systems/fadec/n1mode1");
var N1Mode2 = getprop("/systems/fadec/n1mode2");
var N11 = getprop("engines/engine[0]/n1-actual");
var N12 = getprop("engines/engine[1]/n1-actual");
var N21 = getprop("engines/engine[0]/n2-actual");
var N22 = getprop("engines/engine[1]/n2-actual");
if ((powered1 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng1-off-power")) and N1Mode1 == 0) {
setprop("/systems/fadec/eng1/epr", 1);
} else {
setprop("/systems/fadec/eng1/epr", 0);
}
if ((powered2 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng2-off-power")) and N1Mode2 == 0) {
setprop("/systems/fadec/eng2/epr", 1);
} else {
setprop("/systems/fadec/eng2/epr", 0);
}
if (powered1 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng1-off-power")) {
setprop("/systems/fadec/eng1/egt", 1);
setprop("/systems/fadec/eng1/ff", 1);
} else {
setprop("/systems/fadec/eng1/egt", 0);
setprop("/systems/fadec/eng1/ff", 0);
}
if (powered2 or getprop("/systems/fadec/powerup") or getprop("/systems/fadec/eng2-off-power")) {
setprop("/systems/fadec/eng2/egt", 1);
setprop("/systems/fadec/eng2/ff", 1);
} else {
setprop("/systems/fadec/eng2/egt", 0);
setprop("/systems/fadec/eng2/ff", 0);
}
N11 = pts.Engines.Engine.n1Actual[0].getValue();
N12 = pts.Engines.Engine.n1Actual[1].getValue();
N21 = pts.Engines.Engine.n2Actual[0].getValue();
N22 = pts.Engines.Engine.n2Actual[1].getValue();
if (powered1 and N11 >= 3.5) {
setprop("/systems/fadec/eng1/n1", 1);
me.Eng1.n1 = 1;
} else {
setprop("/systems/fadec/eng1/n1", 0);
me.Eng1.n1 = 0;
}
if (powered2 and N12 >= 3.5) {
setprop("/systems/fadec/eng2/n1", 1);
me.Eng2.n1 = 1;
} else {
setprop("/systems/fadec/eng2/n1", 0);
me.Eng2.n1 = 0;
}
if (powered1 and N21 >= 3.5) {
setprop("/systems/fadec/eng1/n2", 1);
me.Eng1.n2 = 1;
} else {
setprop("/systems/fadec/eng1/n2", 0);
me.Eng1.n2 = 0;
}
if (powered2 and N22 >= 3.5) {
setprop("/systems/fadec/eng2/n2", 1);
me.Eng2.n2 = 1;
} else {
setprop("/systems/fadec/eng2/n2", 0);
me.Eng2.n2 = 0;
}
},
};
setlistener("/controls/fadec/n1mode1", func() {
if (FADEC.Switches.n1ModeSwitch1.getValue()) {
FADEC.Modes.n1Mode1.setValue(1);
} else {
FADEC.Modes.n1Mode1.setValue(0);
}
}, 0, 0);
setlistener("/controls/fadec/n1mode2", func() {
if (FADEC.Switches.n1ModeSwitch2.getValue()) {
FADEC.Modes.n1Mode2.setValue(1);
} else {
FADEC.Modes.n1Mode2.setValue(0);
}
}, 0, 0);