2021-04-22 21:44:17 +00:00
|
|
|
# A3XX IAE FADEC
|
2021-04-23 17:21:07 +00:00
|
|
|
# Copyright (c) 2021 Josh Davidson (Octal450)
|
2021-04-22 21:44:17 +00:00
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
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;
|
2019-10-14 16:48:35 +00:00
|
|
|
|
2021-04-22 21:44:17 +00:00
|
|
|
var FADEC_S = {
|
2020-09-24 19:32:02 +00:00
|
|
|
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,
|
2020-10-30 21:14:14 +00:00
|
|
|
epr: props.globals.initNode("/systems/fadec/eng1/epr", 0, "BOOL"),
|
2020-09-24 19:32:02 +00:00
|
|
|
egt: 0,
|
2020-10-30 21:14:14 +00:00
|
|
|
n1: props.globals.initNode("/systems/fadec/eng1/n1", 0, "BOOL"),
|
2020-09-24 19:32:02 +00:00
|
|
|
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,
|
2020-10-30 21:14:14 +00:00
|
|
|
epr: props.globals.initNode("/systems/fadec/eng2/epr", 0, "BOOL"),
|
2020-09-24 19:32:02 +00:00
|
|
|
egt: 0,
|
2020-10-30 21:14:14 +00:00
|
|
|
n1: props.globals.initNode("/systems/fadec/eng2/n1", 0, "BOOL"),
|
2020-09-24 19:32:02 +00:00
|
|
|
n2: 0,
|
|
|
|
ff: 0,
|
|
|
|
},
|
|
|
|
Switches: {
|
|
|
|
n1ModeSwitch1: props.globals.initNode("/controls/fadec/n1mode1", 0, "BOOL"),
|
|
|
|
n1ModeSwitch2: props.globals.initNode("/controls/fadec/n1mode2", 0, "BOOL"),
|
|
|
|
},
|
|
|
|
Modes: {
|
2021-04-22 21:44:17 +00:00
|
|
|
n1Mode1: props.globals.initNode("/fdm/jsbsim/fadec/control-1/n1-mode", 0, "BOOL"), # 0 == EPR, 1 == N1 Rated, 2 == N1 Unrated #
|
|
|
|
n1Mode2: props.globals.initNode("/fdm/jsbsim/fadec/control-2/n1-mode", 0, "BOOL"),
|
2020-09-24 19:32:02 +00:00
|
|
|
},
|
2019-10-14 16:48:35 +00:00
|
|
|
init: func() {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Power.poweredTime.setValue(-300);
|
|
|
|
me.Eng1.eng1Time.setValue(-300);
|
|
|
|
me.Eng2.eng2Time.setValue(-300);
|
2019-10-14 16:48:35 +00:00
|
|
|
},
|
|
|
|
loop: func() {
|
2020-09-12 18:07:52 +00:00
|
|
|
var elapsedSec = pts.Sim.Time.elapsedSec.getValue();
|
2020-09-24 19:32:02 +00:00
|
|
|
powerAvailTemp = me.Power.powerAvail.getValue();
|
2019-10-14 16:48:35 +00:00
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
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);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
if (powerAvailTemp != 0) {
|
|
|
|
me.Power.powerAvail.setValue(0);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
powerAvailTemp = me.Power.powerAvail.getValue();
|
2019-10-14 16:48:35 +00:00
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
if (me.Power.poweredTime.getValue() + 300 >= elapsedSec) {
|
|
|
|
if (!me.Power.powerup.getValue()) {
|
|
|
|
me.Power.powerup.setValue(1);
|
|
|
|
}
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
if (me.Power.powerup.getValue()) {
|
|
|
|
me.Power.powerup.setValue(0);
|
|
|
|
}
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
master1 = pts.Controls.Engines.Engine.cutoffSw[0].getValue();
|
|
|
|
|
2019-10-14 16:48:35 +00:00
|
|
|
if (master1 == 1) {
|
2020-09-24 19:32:02 +00:00
|
|
|
if (me.Eng1.eng1Counting != 1) {
|
|
|
|
me.Eng1.eng1Time.setValue(elapsedSec);
|
|
|
|
me.Eng1.eng1Counting = 1;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
if (me.Eng1.eng1Counting != 0) {
|
|
|
|
me.Eng1.eng1Counting = 0;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
if (me.Eng1.eng1Time.getValue() + 300 >= elapsedSec) {
|
|
|
|
me.Eng1.eng1Off.setValue(1);
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Eng1.eng1Off.setValue(0);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
master2 = pts.Controls.Engines.Engine.cutoffSw[1].getValue();
|
|
|
|
|
2019-10-14 16:48:35 +00:00
|
|
|
if (master2 == 1) {
|
2020-09-24 19:32:02 +00:00
|
|
|
if (me.Eng2.eng2Counting != 1) {
|
|
|
|
me.Eng2.eng2Time.setValue(elapsedSec);
|
|
|
|
me.Eng2.eng2Counting = 1;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
if (me.Eng2.eng2Counting != 0) {
|
|
|
|
me.Eng2.eng2Counting = 0;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
if (me.Eng2.eng2Time.getValue() + 300 >= elapsedSec) {
|
|
|
|
me.Eng2.eng2Off.setValue(1);
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Eng2.eng2Off.setValue(0);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
state1 = pts.Engines.Engine.state[0].getValue();
|
|
|
|
state2 = pts.Engines.Engine.state[1].getValue();
|
|
|
|
modeSel = pts.Controls.Engines.startSw.getValue();
|
|
|
|
|
2019-10-14 16:48:35 +00:00
|
|
|
if (state1 == 3) {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Power.powered1.setValue(1);
|
|
|
|
} else if (powerAvailTemp and modeSel == 2) {
|
|
|
|
me.Power.powered1.setValue(1);
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Power.powered1.setValue(0);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (state2 == 3) {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Power.powered2.setValue(1);
|
|
|
|
} else if (powerAvailTemp and modeSel == 2) {
|
|
|
|
me.Power.powered2.setValue(1);
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Power.powered2.setValue(0);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
powered1 = me.Power.powered1.getValue();
|
|
|
|
powered2 = me.Power.powered2.getValue();
|
|
|
|
powerup = me.Power.powerup.getValue();
|
2019-10-14 16:48:35 +00:00
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
if (powered1 or powerup or me.Eng1.eng1Off.getValue()) {
|
|
|
|
if (me.Modes.n1Mode1.getValue() == 0) {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng1.epr.setValue(1);
|
2020-09-24 19:32:02 +00:00
|
|
|
} else {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng1.epr.setValue(0);
|
2020-09-24 19:32:02 +00:00
|
|
|
}
|
|
|
|
me.Eng1.egt = 1;
|
|
|
|
me.Eng1.ff = 1;
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng1.epr.setValue(0);
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Eng1.egt = 0;
|
|
|
|
me.Eng1.ff = 0;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
if (powered2 or powerup or me.Eng2.eng2Off.getValue()) {
|
|
|
|
if (me.Modes.n1Mode2.getValue() == 0) {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng2.epr.setValue(1);
|
2020-09-24 19:32:02 +00:00
|
|
|
} else {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng2.epr.setValue(0);
|
2020-09-24 19:32:02 +00:00
|
|
|
}
|
|
|
|
me.Eng2.egt = 1;
|
|
|
|
me.Eng2.ff = 1;
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng2.epr.setValue(0);
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Eng2.egt = 0;
|
|
|
|
me.Eng2.ff = 0;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:32:02 +00:00
|
|
|
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();
|
2019-10-14 16:48:35 +00:00
|
|
|
|
|
|
|
if (powered1 and N11 >= 3.5) {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng1.n1.setValue(1);
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng1.n1.setValue(0);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (powered2 and N12 >= 3.5) {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng2.n1.setValue(1);
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-10-30 21:14:14 +00:00
|
|
|
me.Eng2.n1.setValue(0);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (powered1 and N21 >= 3.5) {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Eng1.n2 = 1;
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Eng1.n2 = 0;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (powered2 and N22 >= 3.5) {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Eng2.n2 = 1;
|
2019-10-14 16:48:35 +00:00
|
|
|
} else {
|
2020-09-24 19:32:02 +00:00
|
|
|
me.Eng2.n2 = 0;
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
2020-09-24 19:32:02 +00:00
|
|
|
|
|
|
|
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);
|