1
0
Fork 0
A320-family/Nasal/Systems/fuel.nas

104 lines
4.5 KiB
Text
Raw Normal View History

2019-10-14 16:48:35 +00:00
# A3XX Fuel System
# 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
var FUEL = {
2019-11-08 18:22:29 +00:00
offset1: 0,
offset2: 0,
2019-11-07 21:47:16 +00:00
timeEngStart: 0,
cmdCtrOn: props.globals.getNode("/systems/fuel/ctr-pump-cmd-on-eng-start"),
refuelling: props.globals.getNode("/systems/fuel/refuel/refuelling"),
2019-11-07 21:47:16 +00:00
Fail: {
2020-06-26 13:00:28 +00:00
pumpLeft1: props.globals.getNode("/systems/failures/fuel/left-tank-pump-1"),
pumpLeft2: props.globals.getNode("/systems/failures/fuel/left-tank-pump-2"),
pumpCenter1: props.globals.getNode("/systems/failures/fuel/center-tank-pump-1"),
pumpCenter2: props.globals.getNode("/systems/failures/fuel/center-tank-pump-2"),
pumpRight1: props.globals.getNode("/systems/failures/fuel/right-tank-pump-1"),
pumpRight2: props.globals.getNode("/systems/failures/fuel/right-tank-pump-2"),
2019-11-07 21:47:16 +00:00
},
Switches: {
centerTkMode: props.globals.getNode("/controls/fuel/switches/center-mode"),
crossfeed: props.globals.getNode("/controls/fuel/switches/crossfeed"),
pumpLeft1: props.globals.getNode("/controls/fuel/switches/pump-left-1"),
pumpLeft2: props.globals.getNode("/controls/fuel/switches/pump-left-2"),
pumpCenter1: props.globals.getNode("/controls/fuel/switches/pump-center-1"),
pumpCenter2: props.globals.getNode("/controls/fuel/switches/pump-center-2"),
pumpRight1: props.globals.getNode("/controls/fuel/switches/pump-right-1"),
pumpRight2: props.globals.getNode("/controls/fuel/switches/pump-right-2"),
2019-11-07 21:47:16 +00:00
},
Pumps: {
apu: props.globals.getNode("/systems/fuel/pumps/apu-operate"),
allOff: props.globals.getNode("/systems/fuel/pumps/all-eng-pump-off"),
},
2019-11-07 21:47:16 +00:00
Valves: {
apu: props.globals.getNode("/systems/fuel/valves/apu-lp-valve"),
crossfeed: props.globals.getNode("/systems/fuel/valves/crossfeed-valve"),
lpValve1: props.globals.getNode("/systems/fuel/valves/engine-1-lp-valve"),
lpValve2: props.globals.getNode("/systems/fuel/valves/engine-2-lp-valve"),
transfer1: props.globals.getNode("/systems/fuel/valves/outer-inner-transfer-valve-1"),
transfer2: props.globals.getNode("/systems/fuel/valves/outer-inner-transfer-valve-2"),
refuelLeft: props.globals.getNode("/systems/fuel/refuel/left-valve"),
refuelCenter: props.globals.getNode("/systems/fuel/refuel/center-valve"),
refuelRight: props.globals.getNode("/systems/fuel/refuel/right-valve"),
2019-11-07 21:47:16 +00:00
},
Quantity: {
leftOuter: props.globals.getNode("/consumables/fuel/tank[0]/level-lbs"),
leftOuterPct: props.globals.getNode("/consumables/fuel/tank[0]/level-norm"),
leftInner: props.globals.getNode("/consumables/fuel/tank[1]/level-lbs"),
leftInnerPct: props.globals.getNode("/consumables/fuel/tank[1]/level-norm"),
center: props.globals.getNode("/consumables/fuel/tank[2]/level-lbs"),
centerPct: props.globals.getNode("/consumables/fuel/tank[2]/level-norm"),
rightInner: props.globals.getNode("/consumables/fuel/tank[3]/level-lbs"),
rightInnerPct: props.globals.getNode("/consumables/fuel/tank[3]/level-norm"),
rightOuter: props.globals.getNode("/consumables/fuel/tank[4]/level-lbs"),
rightOuterPct: props.globals.getNode("/consumables/fuel/tank[4]/level-norm"),
offsetLeft: props.globals.getNode("/systems/fuel/offset-left"),
offsetRight: props.globals.getNode("/systems/fuel/offset-right"),
2019-11-07 21:47:16 +00:00
},
resetFail: func() {
2020-06-26 13:00:28 +00:00
me.Fail.pumpLeft1.setValue(0);
me.Fail.pumpLeft2.setValue(0);
me.Fail.pumpCenter1.setValue(0);
me.Fail.pumpCenter1.setValue(0);
me.Fail.pumpRight1.setValue(0);
me.Fail.pumpRight2.setValue(0);
2019-11-07 21:47:16 +00:00
},
init: func() {
2020-06-26 13:00:28 +00:00
me.resetFail();
2019-11-07 21:47:16 +00:00
},
setOffsetLeft: func() {
me.Quantity.offsetLeft.setValue(me.Quantity.offsetLeft.getValue() - pts.Fdm.JSBsim.Propulsion.Engine.fuelUsed[0].getValue());
2019-11-07 21:47:16 +00:00
},
setOffsetRight: func() {
me.Quantity.offsetRight.setValue(me.Quantity.offsetRight.getValue() - pts.Fdm.JSBsim.Propulsion.Engine.fuelUsed[1].getValue());
2019-11-08 18:22:29 +00:00
}
2019-11-07 21:47:16 +00:00
};
setlistener("/engines/engine[0]/state", func() {
2020-04-27 13:58:38 +00:00
if (pts.Engines.Engine.state[0].getValue() == 3) {
2019-11-07 21:47:16 +00:00
FUEL.timeEngStart = pts.Sim.Time.elapsedSec.getValue();
FUEL.cmdCtrOn.setValue(1);
ctrTkTimer.start();
} elsif (pts.Engines.Engine.state[0].getValue() == 2) {
FUEL.setOffsetLeft();
2019-11-07 21:47:16 +00:00
}
}, 0, 0);
setlistener("/engines/engine[1]/state", func() {
2020-04-27 13:58:38 +00:00
if (pts.Engines.Engine.state[1].getValue() == 3) {
2019-11-07 21:47:16 +00:00
FUEL.timeEngStart = pts.Sim.Time.elapsedSec.getValue();
FUEL.cmdCtrOn.setValue(1);
ctrTkTimer.start();
} elsif (pts.Engines.Engine.state[1].getValue() == 2) {
FUEL.setOffsetRight();
2019-11-07 21:47:16 +00:00
}
}, 0, 0);
var ctrTkTimer = maketimer(0.5, func() {
if (pts.Sim.Time.elapsedSec.getValue() > (FUEL.timeEngStart + 120)) {
FUEL.cmdCtrOn.setValue(0);
ctrTkTimer.stop()
}
});