1
0
Fork 0
A320-family/Nasal/Systems/FADEC/engines-common.nas

140 lines
6.2 KiB
Text
Raw Normal View History

2019-10-14 16:48:35 +00:00
# A3XX Engine Control
# 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 manStart = [props.globals.initNode("/controls/engines/engine[0]/man-start", 0, "BOOL"),props.globals.initNode("/controls/engines/engine[1]/man-start", 0, "BOOL")];
var lastIgniter = [props.globals.getNode("/controls/engines/engine[0]/last-igniter"),props.globals.initNode("/controls/engines/engine[1]/last-igniter")];
var igniterA = [props.globals.initNode("/controls/engines/engine[0]/igniter-a", 0, "BOOL"),props.globals.initNode("/controls/engines/engine[1]/igniter-a", 0, "BOOL")];
var igniterB = [props.globals.initNode("/controls/engines/engine[0]/igniter-b", 0, "BOOL"),props.globals.initNode("/controls/engines/engine[1]/igniter-b", 0, "BOOL")];
2020-09-15 17:17:06 +00:00
if (pts.Options.eng.getValue() == "IAE") {
2019-10-14 16:48:35 +00:00
io.include("engines-iae.nas");
} else {
io.include("engines-cfm.nas");
}
var eng_common_init = func {
manStart[0].setValue(0);
manStart[1].setValue(0);
2019-10-14 16:48:35 +00:00
}
2020-07-26 12:43:14 +00:00
# Engine thrust commands
2019-10-14 16:48:35 +00:00
var doIdleThrust = func {
# Idle does not respect selected engines, because it is used to respond
# to "Retard" and both engines must be idle for spoilers to deploy
2020-07-26 12:43:14 +00:00
pts.Controls.Engines.Engine.throttle[0].setValue(0.0);
pts.Controls.Engines.Engine.throttle[1].setValue(0.0);
2019-10-14 16:48:35 +00:00
}
var doCLThrust = func {
2020-07-26 12:43:14 +00:00
if (pts.Sim.Input.Selected.engine[0].getBoolValue()) {
pts.Controls.Engines.Engine.throttle[0].setValue(0.63);
}
2020-07-26 12:43:14 +00:00
if (pts.Sim.Input.Selected.engine[1].getBoolValue()) {
pts.Controls.Engines.Engine.throttle[1].setValue(0.63);
}
2019-10-14 16:48:35 +00:00
}
var doMCTThrust = func {
2020-07-26 12:43:14 +00:00
if (pts.Sim.Input.Selected.engine[0].getBoolValue()) {
pts.Controls.Engines.Engine.throttle[0].setValue(0.80);
}
2020-07-26 12:43:14 +00:00
if (pts.Sim.Input.Selected.engine[1].getBoolValue()) {
pts.Controls.Engines.Engine.throttle[1].setValue(0.80);
}
2019-10-14 16:48:35 +00:00
}
var doTOGAThrust = func {
2020-07-26 12:43:14 +00:00
if (pts.Sim.Input.Selected.engine[0].getBoolValue()) {
pts.Controls.Engines.Engine.throttle[0].setValue(1.00);
}
2020-07-26 12:43:14 +00:00
if (pts.Sim.Input.Selected.engine[1].getBoolValue()) {
pts.Controls.Engines.Engine.throttle[1].setValue(1.00);
}
2019-10-14 16:48:35 +00:00
}
# Reverse Thrust System
var toggleFastRevThrust = func {
2020-09-15 17:22:35 +00:00
if (pts.Systems.Thrust.state[0].getValue() == "IDLE" and pts.Systems.Thrust.state[1].getValue() == "IDLE" and pts.Controls.Engines.Engine.reverser[0].getValue() == 0 and pts.Controls.Engines.Engine.reverser[1].getValue() == 0 and pts.Gear.wow[1].getValue() == 1 and pts.Gear.wow[2].getValue() == 1) {
2020-09-15 17:17:06 +00:00
if (pts.Sim.Input.Selected.engine[0].getBoolValue()) {
interpolate("/engines/engine[0]/reverser-pos-norm", 1, 1.4);
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.reverser[0].setValue(1);
pts.Controls.Engines.Engine.throttleRev[0].setValue(0.65);
pts.Fdm.JSBsim.Propulsion.Engine.reverserAngle[0].setValue(3.14);
}
2020-09-15 17:17:06 +00:00
if (pts.Sim.Input.Selected.engine[1].getBoolValue()) {
interpolate("/engines/engine[1]/reverser-pos-norm", 1, 1.4);
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.reverser[1].setValue(1);
pts.Controls.Engines.Engine.throttleRev[1].setValue(0.65);
pts.Fdm.JSBsim.Propulsion.Engine.reverserAngle[1].setValue(3.14);
}
2020-09-15 17:22:35 +00:00
} else if (pts.Controls.Engines.Engine.reverser[0].getValue() == 1 or pts.Controls.Engines.Engine.reverser[1].getValue() == 1) {
2019-10-14 16:48:35 +00:00
interpolate("/engines/engine[0]/reverser-pos-norm", 0, 1.0);
interpolate("/engines/engine[1]/reverser-pos-norm", 0, 1.0);
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[0].setValue(0);
pts.Controls.Engines.Engine.throttleRev[1].setValue(0);
pts.Fdm.JSBsim.Propulsion.Engine.reverserAngle[0].setValue(0);
pts.Fdm.JSBsim.Propulsion.Engine.reverserAngle[1].setValue(0);
pts.Controls.Engines.Engine.reverser[0].setValue(0);
pts.Controls.Engines.Engine.reverser[1].setValue(0);
2019-10-14 16:48:35 +00:00
}
}
var doRevThrust = func {
2020-09-15 17:17:06 +00:00
if (pts.Gear.wow[1].getValue() != 1 and pts.Gear.wow[2].getValue() != 1) {
# Can't select reverse if not on the ground
return;
}
2020-09-15 17:22:35 +00:00
if (pts.Sim.Input.Selected.engine[0].getBoolValue() and pts.Controls.Engines.Engine.reverser[0].getValue() == 1) {
2020-09-15 17:17:06 +00:00
var pos = pts.Controls.Engines.Engine.throttleRev[0].getValue();
if (pos < 0.649) {
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[0].setValue(pos + 0.15);
2019-10-14 16:48:35 +00:00
}
}
2020-09-15 17:22:35 +00:00
if (pts.Sim.Input.Selected.engine[1].getBoolValue() and pts.Controls.Engines.Engine.reverser[1].getValue() == 1) {
2020-09-15 17:17:06 +00:00
var pos = pts.Controls.Engines.Engine.throttleRev[1].getValue();
if (pos < 0.649) {
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[1].setValue(pos + 0.15);
2019-10-14 16:48:35 +00:00
}
}
2020-09-15 17:17:06 +00:00
2020-09-15 17:22:35 +00:00
if (pts.Sim.Input.Selected.engine[0].getBoolValue() and pts.Systems.Thrust.state[0].getValue() == "IDLE" and pts.Controls.Engines.Engine.reverser[0].getValue() == 0) {
2019-10-14 16:48:35 +00:00
interpolate("/engines/engine[0]/reverser-pos-norm", 1, 1.4);
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[0].setValue(0.05);
pts.Controls.Engines.Engine.reverser[0].setValue(1);
pts.Fdm.JSBsim.Propulsion.Engine.reverserAngle[0].setValue(3.14);
}
2020-09-15 17:22:35 +00:00
if (pts.Sim.Input.Selected.engine[1].getBoolValue() and pts.Systems.Thrust.state[1].getValue() == "IDLE" and pts.Controls.Engines.Engine.reverser[1].getValue() == 0) {
interpolate("/engines/engine[1]/reverser-pos-norm", 1, 1.4);
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[1].setValue(0.05);
pts.Controls.Engines.Engine.reverser[1].setValue(1);
pts.Fdm.JSBsim.Propulsion.Engine.reverserAngle[1].setValue(3.14);
2019-10-14 16:48:35 +00:00
}
}
var unRevThrust = func {
2020-09-15 17:22:35 +00:00
if (pts.Sim.Input.Selected.engine[0].getBoolValue() and pts.Controls.Engines.Engine.reverser[0].getValue() == 1) {
2020-09-15 17:17:06 +00:00
var pos = pts.Controls.Engines.Engine.throttleRev[0].getValue();
if (pos > 0.051) {
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[0].setValue(pos - 0.15);
2019-10-14 16:48:35 +00:00
} else {
interpolate("/engines/engine[0]/reverser-pos-norm", 0, 1.0);
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[0].setValue(0);
pts.Controls.Engines.Engine.reverser[0].setValue(0);
pts.Fdm.JSBsim.Propulsion.Engine.reverserAngle[0].setValue(0);
2019-10-14 16:48:35 +00:00
}
}
2020-09-15 17:22:35 +00:00
if (pts.Sim.Input.Selected.engine[1].getBoolValue() and pts.Controls.Engines.Engine.reverser[1].getValue() == 1) {
2020-09-15 17:17:06 +00:00
var pos = pts.Controls.Engines.Engine.throttleRev[1].getValue();
if (pos > 0.051) {
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[1].setValue(pos - 0.15);
2019-10-14 16:48:35 +00:00
} else {
interpolate("/engines/engine[1]/reverser-pos-norm", 0, 1.0);
2020-09-15 17:17:06 +00:00
pts.Controls.Engines.Engine.throttleRev[1].setValue(0);
pts.Controls.Engines.Engine.reverser[1].setValue(0);
2020-09-15 17:18:34 +00:00
pts.Fdm.JSBsim.Propulsion.Engine.reverserAngle[1].setValue(0);
2019-10-14 16:48:35 +00:00
}
}
}