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

207 lines
5.4 KiB
Text
Raw Normal View History

# A3XX IAE FADEC
2022-12-31 17:56:08 +00:00
# Copyright (c) 2023 Josh Davidson (Octal450)
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
var FADEC_S = {
2020-09-24 19:32:02 +00:00
Power: {
2022-07-27 17:26:58 +00:00
groundPower: [props.globals.initNode("/controls/fadec/gnd-power-1", 0, "BOOL"), props.globals.initNode("/controls/fadec/gnd-power-2", 0, "BOOL")],
2020-09-24 19:32:02 +00:00
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: props.globals.initNode("/systems/fadec/eng1/epr", 0, "BOOL"),
2020-09-24 19:32:02 +00:00
egt: 0,
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,
epr: props.globals.initNode("/systems/fadec/eng2/epr", 0, "BOOL"),
2020-09-24 19:32:02 +00:00
egt: 0,
n1: props.globals.initNode("/systems/fadec/eng2/n1", 0, "BOOL"),
2020-09-24 19:32:02 +00:00
n2: 0,
ff: 0,
},
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() {
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) {
2022-03-09 15:10:19 +00:00
if (acconfig.SYSTEM.autoConfigRunning.getBoolValue()) {
me.Power.poweredTime.setValue(elapsedSec - 300);
} else {
me.Power.poweredTime.setValue(elapsedSec);
}
2020-09-24 19:32:02 +00:00
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 = systems.IGNITION.startSw.getValue();
2020-09-24 19:32:02 +00:00
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);
2022-07-27 17:26:58 +00:00
} else if (me.Power.groundPower[0].getBoolValue()) {
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);
2022-07-27 17:26:58 +00:00
} else if (me.Power.groundPower[1].getBoolValue()) {
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()) {
2021-05-16 22:31:08 +00:00
if (FADEC.n1Mode[0].getValue() == 0) {
me.Eng1.epr.setValue(1);
2020-09-24 19:32:02 +00:00
} else {
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 {
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()) {
2021-05-16 22:31:08 +00:00
if (FADEC.n1Mode[1].getValue() == 0) {
me.Eng2.epr.setValue(1);
2020-09-24 19:32:02 +00:00
} else {
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 {
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) {
me.Eng1.n1.setValue(1);
2019-10-14 16:48:35 +00:00
} else {
me.Eng1.n1.setValue(0);
2019-10-14 16:48:35 +00:00
}
if (powered2 and N12 >= 3.5) {
me.Eng2.n1.setValue(1);
2019-10-14 16:48:35 +00:00
} else {
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
}
},
};