2017-11-22 23:34:43 +00:00
# A3XX IAE V2500 Engine
2017-04-05 22:36:27 +00:00
# Joshua Davidson (it0uchpods)
2017-11-16 19:29:08 +00:00
##############################################
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
2017-07-13 17:30:33 +00:00
2017-04-05 22:36:27 +00:00
#####################
# Initializing Vars #
#####################
var engines = props.globals.getNode("/engines").getChildren("engine");
2017-06-02 00:53:50 +00:00
var egt_min = 434;
var egt_start = 587;
2017-05-31 22:56:52 +00:00
var egt_max = 712;
2017-04-05 22:36:27 +00:00
var start_time = 10;
2017-11-22 23:34:43 +00:00
var egt_lightup_time = 4;
var egt_lightdn_time = 10;
2017-04-05 22:36:27 +00:00
var shutdown_time = 20;
var egt_shutdown_time = 20;
2017-11-22 23:34:43 +00:00
2017-04-07 18:09:40 +00:00
setprop("/controls/engines/engine[0]/reverser", 0);
setprop("/controls/engines/engine[1]/reverser", 0);
2017-07-11 15:56:38 +00:00
setprop("/controls/engines/engine[0]/igniter-a", 0);
setprop("/controls/engines/engine[1]/igniter-a", 0);
setprop("/controls/engines/engine[0]/igniter-b", 0);
setprop("/controls/engines/engine[1]/igniter-b", 0);
setprop("/controls/engines/engine[0]/last-igniter", "B");
setprop("/controls/engines/engine[1]/last-igniter", "B");
2017-04-05 22:36:27 +00:00
2017-07-03 18:26:43 +00:00
var eng_init = func {
setprop("/controls/engines/engine[0]/man-start", 0);
setprop("/controls/engines/engine[1]/man-start", 0);
}
2017-11-22 23:34:43 +00:00
# Trigger Startups and Stops
2017-04-05 22:36:27 +00:00
setlistener("/controls/engines/engine[0]/cutoff-switch", func {
if (getprop("/controls/engines/engine[0]/cutoff-switch") == 0) {
2017-10-05 14:53:24 +00:00
if (getprop("/systems/acconfig/autoconfig-running") == 1) {
fast_start_one();
} else {
if (getprop("/controls/engines/engine[0]/man-start") == 0) {
start_one_check();
} else if (getprop("/controls/engines/engine[0]/man-start") == 1) {
2017-11-22 23:34:43 +00:00
eng_one_man_start.start();
2017-10-05 14:53:24 +00:00
}
2017-05-10 19:30:27 +00:00
}
2017-04-05 22:36:27 +00:00
} else if (getprop("/controls/engines/engine[0]/cutoff-switch") == 1) {
2018-04-03 17:46:19 +00:00
cutoff_one();
2017-04-05 22:36:27 +00:00
}
});
2018-04-03 17:46:19 +00:00
var cutoff_one = func {
eng_one_auto_start.stop();
eng_one_man_start.stop();
eng_one_n2_check.stop();
setprop("/controls/engines/engine[0]/igniter-a", 0);
setprop("/controls/engines/engine[0]/igniter-b", 0);
setprop("/controls/engines/engine[0]/man-start", 0);
setprop("/systems/pneumatic/eng1-starter", 0);
setprop("/controls/engines/engine[0]/starter", 0);
setprop("/controls/engines/engine[0]/cutoff", 1);
2018-09-12 16:43:35 +00:00
var engine0_state = props.globals.initNode("/engines/engine[0]/state", 0, "INT");
2018-04-03 17:46:19 +00:00
interpolate(engines[0].getNode("egt-actual"), 0, egt_shutdown_time);
eng_one_n2_check.stop();
}
2017-10-05 14:53:24 +00:00
var fast_start_one = func {
2017-10-15 20:41:43 +00:00
setprop("/controls/engines/engine[0]/cutoff", 0);
setprop("/engines/engine[0]/out-of-fuel", 0);
setprop("/engines/engine[0]/run", 1);
2017-10-05 14:53:24 +00:00
setprop("/engines/engine[0]/cutoff", 0);
setprop("/engines/engine[0]/starter", 0);
setprop("/fdm/jsbsim/propulsion/set-running", 0);
setprop("/engines/engine[0]/state", 3);
setprop("/systems/pneumatic/eng1-starter", 0);
}
2017-07-03 18:26:43 +00:00
setlistener("/controls/engines/engine[0]/man-start", func {
start_one_mancheck();
});
var start_one_mancheck = func {
if (getprop("/controls/engines/engine[0]/man-start") == 1) {
2017-07-13 00:45:02 +00:00
if (getprop("/controls/engines/engine-start-switch") == 2 and (getprop("/controls/engines/engine[0]/cutoff-switch") == 1)) {
2017-07-03 20:52:19 +00:00
setprop("/systems/pneumatic/eng1-starter", 1);
2017-07-13 00:45:02 +00:00
settimer(start_one_mancheck_b, 0.5);
2017-07-03 18:26:43 +00:00
}
} else {
if (getprop("/engines/engine[0]/state") == 1 or getprop("/engines/engine[0]/state") == 2) {
2017-07-03 20:52:19 +00:00
setprop("/systems/pneumatic/eng1-starter", 0);
2017-07-03 18:26:43 +00:00
setprop("/engines/engine[0]/state", 0);
setprop("/controls/engines/engine[0]/starter", 0);
}
}
}
2017-07-13 00:45:02 +00:00
var start_one_mancheck_b = func {
if (getprop("/systems/pneumatic/total-psi") >= 28) {
setprop("/engines/engine[0]/state", 1);
setprop("/controls/engines/engine[0]/starter", 1);
}
}
2017-04-05 22:36:27 +00:00
var start_one_check = func {
2017-07-13 00:21:17 +00:00
if (getprop("/controls/engines/engine-start-switch") == 2 and getprop("/controls/engines/engine[0]/cutoff-switch") == 0) {
setprop("/systems/pneumatic/eng1-starter", 1);
settimer(start_one_check_b, 0.5);
}
2017-05-03 15:16:20 +00:00
}
var start_one_check_b = func {
if ((getprop("/controls/engines/engine-start-switch") == 2) and (getprop("/systems/pneumatic/total-psi") >= 28) and (getprop("/controls/engines/engine[0]/cutoff-switch") == 0)) {
2017-04-05 22:36:27 +00:00
auto_start_one();
}
}
setlistener("/controls/engines/engine[1]/cutoff-switch", func {
if (getprop("/controls/engines/engine[1]/cutoff-switch") == 0) {
2017-10-05 14:53:24 +00:00
if (getprop("/systems/acconfig/autoconfig-running") == 1) {
fast_start_two();
} else {
if (getprop("/controls/engines/engine[1]/man-start") == 0) {
start_two_check();
} else if (getprop("/controls/engines/engine[1]/man-start") == 1) {
2017-11-22 23:34:43 +00:00
eng_two_man_start.start();
2017-10-05 14:53:24 +00:00
}
2017-05-10 19:30:27 +00:00
}
2017-04-05 22:36:27 +00:00
} else if (getprop("/controls/engines/engine[1]/cutoff-switch") == 1) {
2018-04-03 17:46:19 +00:00
cutoff_two();
2017-04-05 22:36:27 +00:00
}
});
2018-04-03 17:46:19 +00:00
var cutoff_two = func {
eng_two_auto_start.stop();
eng_two_man_start.stop();
eng_two_n2_check.stop();
setprop("/controls/engines/engine[1]/igniter-a", 0);
setprop("/controls/engines/engine[1]/igniter-b", 0);
setprop("/controls/engines/engine[1]/man-start", 0);
setprop("/systems/pneumatic/eng2-starter", 0);
setprop("/controls/engines/engine[1]/starter", 0);
setprop("/controls/engines/engine[1]/cutoff", 1);
2018-09-12 16:43:35 +00:00
var engine1_state = props.globals.initNode("/engines/engine[0]/state", 0, "INT");
2018-04-03 17:46:19 +00:00
interpolate(engines[1].getNode("egt-actual"), 0, egt_shutdown_time);
}
2017-10-05 14:53:24 +00:00
var fast_start_two = func {
2017-10-15 20:41:43 +00:00
setprop("/controls/engines/engine[1]/cutoff", 0);
setprop("/engines/engine[1]/out-of-fuel", 0);
setprop("/engines/engine[1]/run", 1);
2017-10-05 14:53:24 +00:00
setprop("/engines/engine[1]/cutoff", 0);
setprop("/engines/engine[1]/starter", 0);
setprop("/fdm/jsbsim/propulsion/set-running", 1);
setprop("/engines/engine[1]/state", 3);
setprop("/systems/pneumatic/eng2-starter", 0);
}
2017-07-03 18:26:43 +00:00
setlistener("/controls/engines/engine[1]/man-start", func {
start_two_mancheck();
});
var start_two_mancheck = func {
if (getprop("/controls/engines/engine[1]/man-start") == 1) {
2017-07-13 00:45:02 +00:00
if (getprop("/controls/engines/engine-start-switch") == 2 and (getprop("/controls/engines/engine[1]/cutoff-switch") == 1)) {
2017-07-03 20:52:19 +00:00
setprop("/systems/pneumatic/eng2-starter", 1);
2017-07-13 00:45:02 +00:00
settimer(start_two_mancheck_b, 0.5);
2017-07-03 18:26:43 +00:00
}
} else {
if (getprop("/engines/engine[1]/state") == 1 or getprop("/engines/engine[1]/state") == 2) {
2017-07-03 20:52:19 +00:00
setprop("/systems/pneumatic/eng2-starter", 0);
2017-07-03 18:26:43 +00:00
setprop("/engines/engine[1]/state", 0);
setprop("/controls/engines/engine[1]/starter", 0);
}
}
}
2017-07-13 00:45:02 +00:00
var start_two_mancheck_b = func {
if (getprop("/systems/pneumatic/total-psi") >= 28) {
setprop("/engines/engine[1]/state", 1);
setprop("/controls/engines/engine[1]/starter", 1);
}
}
2017-04-05 22:36:27 +00:00
var start_two_check = func {
2017-07-13 00:21:17 +00:00
if (getprop("/controls/engines/engine-start-switch") == 2 and getprop("/controls/engines/engine[1]/cutoff-switch") == 0) {
setprop("/systems/pneumatic/eng2-starter", 1);
settimer(start_two_check_b, 0.5);
}
2017-05-03 15:16:20 +00:00
}
var start_two_check_b = func {
if ((getprop("/controls/engines/engine-start-switch") == 2) and (getprop("/systems/pneumatic/total-psi") >= 28) and (getprop("/controls/engines/engine[1]/cutoff-switch") == 0)) {
2017-04-05 22:36:27 +00:00
auto_start_two();
}
}
2017-11-22 23:34:43 +00:00
# Start Engine One
2017-04-05 22:36:27 +00:00
var auto_start_one = func {
setprop("/engines/engine[0]/state", 1);
setprop("/controls/engines/engine[0]/starter", 1);
2017-11-22 23:34:43 +00:00
eng_one_auto_start.start();
2017-04-05 22:36:27 +00:00
}
2017-11-22 23:34:43 +00:00
var eng_one_auto_start = maketimer(0.5, func {
if (getprop("/engines/engine[0]/n2-actual") >= 22) {
eng_one_auto_start.stop();
2017-04-05 22:36:27 +00:00
setprop("/engines/engine[0]/state", 2);
setprop("/controls/engines/engine[0]/cutoff", 0);
2017-07-11 15:56:38 +00:00
if (getprop("/controls/engines/engine[0]/last-igniter") == "B") {
setprop("/controls/engines/engine[0]/igniter-a", 1);
setprop("/controls/engines/engine[0]/igniter-b", 0);
setprop("/controls/engines/engine[0]/last-igniter", "A");
} else if (getprop("/controls/engines/engine[0]/last-igniter") == "A") {
setprop("/controls/engines/engine[0]/igniter-a", 0);
setprop("/controls/engines/engine[0]/igniter-b", 1);
setprop("/controls/engines/engine[0]/last-igniter", "B");
}
2017-04-05 22:36:27 +00:00
interpolate(engines[0].getNode("egt-actual"), egt_start, egt_lightup_time);
2017-11-22 23:34:43 +00:00
eng_one_egt_check.start();
eng_one_n2_check.start();
2017-04-05 22:36:27 +00:00
}
2017-11-22 23:34:43 +00:00
});
2017-04-05 22:36:27 +00:00
2017-11-22 23:34:43 +00:00
var eng_one_man_start = maketimer(0.5, func {
2017-10-15 18:11:27 +00:00
if (getprop("/engines/engine[0]/n2-actual") >= 16.7) {
2017-11-22 23:34:43 +00:00
eng_one_man_start.stop();
2017-05-10 19:30:27 +00:00
setprop("/engines/engine[0]/state", 2);
setprop("/controls/engines/engine[0]/cutoff", 0);
2017-07-11 15:56:38 +00:00
setprop("/controls/engines/engine[0]/igniter-a", 1);
setprop("/controls/engines/engine[0]/igniter-b", 1);
2017-05-10 19:30:27 +00:00
interpolate(engines[0].getNode("egt-actual"), egt_start, egt_lightup_time);
2017-11-22 23:34:43 +00:00
eng_one_egt_check.start();
eng_one_n2_check.start();
2017-05-10 19:30:27 +00:00
}
2017-11-22 23:34:43 +00:00
});
2017-05-10 19:30:27 +00:00
2017-11-22 23:34:43 +00:00
var eng_one_egt_check = maketimer(0.5, func {
2017-04-05 22:36:27 +00:00
if (getprop("/engines/engine[0]/egt-actual") >= egt_start) {
2017-11-22 23:34:43 +00:00
eng_one_egt_check.stop();
2017-04-05 22:36:27 +00:00
interpolate(engines[0].getNode("egt-actual"), egt_min, egt_lightdn_time);
}
2017-11-22 23:34:43 +00:00
});
var eng_one_n2_check = maketimer(0.5, func {
2017-10-15 18:11:27 +00:00
if (getprop("/engines/engine[0]/n2-actual") >= 43.0) {
2017-11-22 23:34:43 +00:00
if (getprop("/controls/engines/engine[0]/igniter-a") != 0) {
setprop("/controls/engines/engine[0]/igniter-a", 0);
}
if (getprop("/controls/engines/engine[0]/igniter-b") != 0) {
setprop("/controls/engines/engine[0]/igniter-b", 0);
}
}
if (getprop("/engines/engine[0]/n2-actual") >= 57.0) {
eng_one_n2_check.stop();
2017-05-03 15:16:20 +00:00
setprop("/systems/pneumatic/eng1-starter", 0);
2017-04-05 22:36:27 +00:00
setprop("/engines/engine[0]/state", 3);
}
2017-11-22 23:34:43 +00:00
});
2017-04-05 22:36:27 +00:00
2017-11-22 23:34:43 +00:00
# Start Engine Two
2017-04-05 22:36:27 +00:00
var auto_start_two = func {
setprop("/engines/engine[1]/state", 1);
setprop("/controls/engines/engine[1]/starter", 1);
2017-11-22 23:34:43 +00:00
eng_two_auto_start.start();
2017-04-05 22:36:27 +00:00
}
2017-11-22 23:34:43 +00:00
var eng_two_auto_start = maketimer(0.5, func {
if (getprop("/engines/engine[1]/n2-actual") >= 22) {
eng_two_auto_start.stop();
2017-04-05 22:36:27 +00:00
setprop("/engines/engine[1]/state", 2);
setprop("/controls/engines/engine[1]/cutoff", 0);
2017-07-11 15:56:38 +00:00
if (getprop("/controls/engines/engine[1]/last-igniter") == "B") {
setprop("/controls/engines/engine[1]/igniter-a", 1);
setprop("/controls/engines/engine[1]/igniter-b", 0);
setprop("/controls/engines/engine[1]/last-igniter", "A");
} else if (getprop("/controls/engines/engine[1]/last-igniter") == "A") {
setprop("/controls/engines/engine[1]/igniter-a", 0);
setprop("/controls/engines/engine[1]/igniter-b", 1);
setprop("/controls/engines/engine[1]/last-igniter", "B");
}
2017-04-05 22:36:27 +00:00
interpolate(engines[1].getNode("egt-actual"), egt_start, egt_lightup_time);
2017-11-22 23:34:43 +00:00
eng_two_egt_check.start();
eng_two_n2_check.start();
2017-04-05 22:36:27 +00:00
}
2017-11-22 23:34:43 +00:00
});
2017-04-05 22:36:27 +00:00
2017-11-22 23:34:43 +00:00
var eng_two_man_start = maketimer(0.5, func {
2017-10-15 18:11:27 +00:00
if (getprop("/engines/engine[1]/n2-actual") >= 16.7) {
2017-11-22 23:34:43 +00:00
eng_two_man_start.stop();
2017-05-10 19:30:27 +00:00
setprop("/engines/engine[1]/state", 2);
setprop("/controls/engines/engine[1]/cutoff", 0);
2017-07-11 15:56:38 +00:00
setprop("/controls/engines/engine[1]/igniter-a", 1);
setprop("/controls/engines/engine[1]/igniter-b", 1);
2017-05-10 19:30:27 +00:00
interpolate(engines[1].getNode("egt-actual"), egt_start, egt_lightup_time);
2017-11-22 23:34:43 +00:00
eng_two_egt_check.start();
eng_two_n2_check.start();
2017-05-10 19:30:27 +00:00
}
2017-11-22 23:34:43 +00:00
});
2017-05-10 19:30:27 +00:00
2017-11-22 23:34:43 +00:00
var eng_two_egt_check = maketimer(0.5, func {
2017-04-05 22:36:27 +00:00
if (getprop("/engines/engine[1]/egt-actual") >= egt_start) {
2017-11-22 23:34:43 +00:00
eng_two_egt_check.stop();
2017-04-05 22:36:27 +00:00
interpolate(engines[1].getNode("egt-actual"), egt_min, egt_lightdn_time);
}
});
2017-11-22 23:34:43 +00:00
var eng_two_n2_check = maketimer(0.5, func {
if (getprop("/engines/engine[1]/n2-actual") >= 50.0) {
if (getprop("/controls/engines/engine[1]/igniter-a") != 0) {
setprop("/controls/engines/engine[1]/igniter-a", 0);
}
if (getprop("/controls/engines/engine[1]/igniter-b") != 0) {
setprop("/controls/engines/engine[1]/igniter-b", 0);
}
2017-07-07 03:51:33 +00:00
}
2017-11-22 23:34:43 +00:00
if (getprop("/engines/engine[1]/n2-actual") >= 57.0) {
eng_two_n2_check.stop();
setprop("/systems/pneumatic/eng2-starter", 0);
setprop("/engines/engine[1]/state", 3);
2017-04-05 22:36:27 +00:00
}
});
2017-11-22 23:34:43 +00:00
# Various Other Stuff
2017-04-05 22:36:27 +00:00
setlistener("/controls/engines/engine-start-switch", func {
2017-05-08 19:06:00 +00:00
if (getprop("/engines/engine[0]/state") == 0) {
start_one_check();
2017-07-03 18:26:43 +00:00
start_one_mancheck();
2017-05-08 19:06:00 +00:00
}
if (getprop("/engines/engine[1]/state") == 0) {
start_two_check();
2017-07-03 18:26:43 +00:00
start_two_mancheck();
2017-05-08 19:06:00 +00:00
}
2017-04-05 22:36:27 +00:00
if ((getprop("/controls/engines/engine-start-switch") == 0) or (getprop("/controls/engines/engine-start-switch") == 1)) {
2017-05-08 19:06:00 +00:00
if (getprop("/engines/engine[0]/state") == 1 or getprop("/engines/engine[0]/state") == 2) {
2017-04-28 22:27:21 +00:00
setprop("/controls/engines/engine[0]/starter", 0);
setprop("/controls/engines/engine[0]/cutoff", 1);
2017-07-13 00:21:17 +00:00
setprop("/systems/pneumatic/eng1-starter", 0);
2017-04-28 22:27:21 +00:00
setprop("/engines/engine[0]/state", 0);
interpolate(engines[0].getNode("egt-actual"), 0, egt_shutdown_time);
2017-04-05 22:36:27 +00:00
}
2017-05-08 19:06:00 +00:00
if (getprop("/engines/engine[1]/state") == 1 or getprop("/engines/engine[1]/state") == 2) {
2017-04-28 22:27:21 +00:00
setprop("/controls/engines/engine[1]/starter", 0);
setprop("/controls/engines/engine[1]/cutoff", 1);
2017-07-13 00:21:17 +00:00
setprop("/systems/pneumatic/eng2-starter", 0);
2017-04-28 22:27:21 +00:00
setprop("/engines/engine[1]/state", 0);
interpolate(engines[1].getNode("egt-actual"), 0, egt_shutdown_time);
2017-04-05 22:36:27 +00:00
}
}
});
2017-04-28 22:27:21 +00:00
setlistener("/systems/pneumatic/start-psi", func {
if (getprop("/systems/pneumatic/total-psi") < 12) {
2017-05-08 19:06:00 +00:00
if (getprop("/engines/engine[0]/state") == 1 or getprop("/engines/engine[0]/state") == 2) {
2017-04-28 22:27:21 +00:00
setprop("/controls/engines/engine[0]/starter", 0);
setprop("/controls/engines/engine[0]/cutoff", 1);
2017-07-13 00:21:17 +00:00
setprop("/systems/pneumatic/eng1-starter", 0);
2017-04-28 22:27:21 +00:00
setprop("/engines/engine[0]/state", 0);
interpolate(engines[0].getNode("egt-actual"), 0, egt_shutdown_time);
2017-04-05 22:36:27 +00:00
}
2017-05-08 19:06:00 +00:00
if (getprop("/engines/engine[1]/state") == 1 or getprop("/engines/engine[1]/state") == 2) {
2017-04-28 22:27:21 +00:00
setprop("/controls/engines/engine[1]/starter", 0);
setprop("/controls/engines/engine[1]/cutoff", 1);
2017-07-13 00:21:17 +00:00
setprop("/systems/pneumatic/eng2-starter", 0);
2017-04-28 22:27:21 +00:00
setprop("/engines/engine[1]/state", 0);
interpolate(engines[1].getNode("egt-actual"), 0, egt_shutdown_time);
2017-04-05 22:36:27 +00:00
}
}
});