2016-11-04 22:13:12 +00:00
|
|
|
# IT AUTOFLIGHT System Controller by Joshua Davidson (it0uchpods/411).
|
2017-01-11 22:39:47 +00:00
|
|
|
# V3.0.0 Build 110
|
|
|
|
# This program is 100% GPL!
|
2016-11-04 22:13:12 +00:00
|
|
|
|
|
|
|
print("IT-AUTOFLIGHT: Please Wait!");
|
|
|
|
|
|
|
|
var ap_init = func {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/kts-mach", 0);
|
|
|
|
setprop("/it-autoflight/input/ap1", 0);
|
|
|
|
setprop("/it-autoflight/input/ap2", 0);
|
|
|
|
setprop("/it-autoflight/input/athr", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/input/cws", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/fd1", 0);
|
|
|
|
setprop("/it-autoflight/input/fd2", 0);
|
|
|
|
setprop("/it-autoflight/input/spd-kts", 200);
|
|
|
|
setprop("/it-autoflight/input/spd-mach", 0.68);
|
|
|
|
setprop("/it-autoflight/input/hdg", 360);
|
|
|
|
setprop("/it-autoflight/input/alt", 10000);
|
|
|
|
setprop("/it-autoflight/input/vs", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/input/lat", 5);
|
|
|
|
setprop("/it-autoflight/input/vert", 7);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/bank-limit", 30);
|
|
|
|
setprop("/it-autoflight/input/trk", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/input/toga", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/ap1", 0);
|
|
|
|
setprop("/it-autoflight/output/ap2", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/output/athr", 0);
|
|
|
|
setprop("/it-autoflight/output/cws", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/fd1", 0);
|
|
|
|
setprop("/it-autoflight/output/fd2", 0);
|
|
|
|
setprop("/it-autoflight/output/loc-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/thr-mode", 0);
|
|
|
|
setprop("/it-autoflight/output/retard", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/settings/min-pitch", -8);
|
2016-11-04 22:13:12 +00:00
|
|
|
setprop("/it-autoflight/settings/max-pitch", 8);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/internal/min-pitch", -8);
|
2016-11-04 22:13:12 +00:00
|
|
|
setprop("/it-autoflight/internal/max-pitch", 8);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/internal/alt", 10000);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/internal/cwsr", 0);
|
|
|
|
setprop("/it-autoflight/internal/cwsp", 0);
|
|
|
|
setprop("/it-autoflight/autoland/target-vs", "-650");
|
|
|
|
setprop("/it-autoflight/mode/lat", "T/O");
|
|
|
|
setprop("/it-autoflight/mode/vert", "T/O CLB");
|
2016-11-04 22:13:12 +00:00
|
|
|
update_arms();
|
|
|
|
print("IT-AUTOFLIGHT: Done!");
|
|
|
|
}
|
|
|
|
|
|
|
|
# AP 1 Master System
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/ap1", func {
|
|
|
|
var apmas = getprop("/it-autoflight/input/ap1");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (apmas == 0) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/ap1", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/controls/flight/rudder", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
if (getprop("/it-autoflight/sound/enableapoffsound") == 1) {
|
|
|
|
setprop("/it-autoflight/sound/apoffsound", 1);
|
|
|
|
setprop("/it-autoflight/sound/enableapoffsound", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
} else if (apmas == 1) {
|
|
|
|
setprop("/controls/flight/rudder", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/ap1", 1);
|
|
|
|
setprop("/it-autoflight/sound/enableapoffsound", 1);
|
|
|
|
setprop("/it-autoflight/sound/apoffsound", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
# AP 2 Master System
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/ap2", func {
|
|
|
|
var apmas = getprop("/it-autoflight/input/ap2");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (apmas == 0) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/ap2", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/controls/flight/rudder", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
if (getprop("/it-autoflight/sound/enableapoffsound2") == 1) {
|
|
|
|
setprop("/it-autoflight/sound/apoffsound2", 1);
|
|
|
|
setprop("/it-autoflight/sound/enableapoffsound2", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
} else if (apmas == 1) {
|
|
|
|
setprop("/controls/flight/rudder", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/ap2", 1);
|
|
|
|
setprop("/it-autoflight/sound/enableapoffsound2", 1);
|
|
|
|
setprop("/it-autoflight/sound/apoffsound2", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
# AT Master System
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/athr", func {
|
|
|
|
var atmas = getprop("/it-autoflight/input/athr");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (atmas == 0) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/athr", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (atmas == 1) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/athr", 1);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-01-11 22:39:47 +00:00
|
|
|
# CWS Master System
|
|
|
|
setlistener("/it-autoflight/input/cws", func {
|
|
|
|
var cwsmas = getprop("/it-autoflight/input/cws");
|
|
|
|
if (cwsmas == 1) {
|
|
|
|
setprop("/it-autoflight/sound/enableapoffsound", 1);
|
|
|
|
setprop("/it-autoflight/sound/apoffsound", 0);
|
|
|
|
setprop("/it-autoflight/sound/enableapoffsound2", 1);
|
|
|
|
setprop("/it-autoflight/sound/apoffsound2", 0);
|
|
|
|
setprop("/it-autoflight/output/ap1", 0);
|
|
|
|
setprop("/it-autoflight/output/ap2", 0);
|
|
|
|
setprop("/it-autoflight/internal/cws-roll-deg", getprop("/orientation/roll-deg"));
|
|
|
|
setprop("/it-autoflight/internal/cws-pitch-deg", getprop("/orientation/pitch-deg"));
|
|
|
|
cwsrollt.start();
|
|
|
|
cwspitcht.start();
|
|
|
|
setprop("/it-autoflight/output/cws", 1);
|
|
|
|
} else if (cwsmas == 0) {
|
|
|
|
cwsrollt.stop();
|
|
|
|
cwspitcht.stop();
|
|
|
|
setprop("/it-autoflight/output/cws", 0);
|
|
|
|
setprop("/controls/flight/aileron-trim", 0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-11-04 22:13:12 +00:00
|
|
|
# Flight Director 1 Master System
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/fd1", func {
|
|
|
|
var fdmas = getprop("/it-autoflight/input/fd1");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (fdmas == 0) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/fd1", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (fdmas == 1) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/fd1", 1);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
# Flight Director 2 Master System
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/fd2", func {
|
|
|
|
var fdmas = getprop("/it-autoflight/input/fd2");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (fdmas == 0) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/fd2", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (fdmas == 1) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/fd2", 1);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
# Master Lateral
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/lat", func {
|
2017-01-11 22:39:47 +00:00
|
|
|
lateral();
|
|
|
|
});
|
|
|
|
|
|
|
|
var lateral = func {
|
2016-12-05 20:20:56 +00:00
|
|
|
var latset = getprop("/it-autoflight/input/lat");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (latset == 0) {
|
2017-01-11 22:39:47 +00:00
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/loc-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/lat", 0);
|
|
|
|
setprop("/it-autoflight/mode/lat", "HDG");
|
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (latset == 1) {
|
2017-01-11 22:39:47 +00:00
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/loc-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/lat", 1);
|
|
|
|
setprop("/it-autoflight/mode/lat", "LNAV");
|
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (latset == 2) {
|
|
|
|
setprop("/instrumentation/nav/signal-quality-norm", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/loc-armed", 1);
|
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/mode/arm", "LOC");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (latset == 3) {
|
2017-01-11 22:39:47 +00:00
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/loc-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/lat", 0);
|
|
|
|
setprop("/it-autoflight/mode/lat", "HDG");
|
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2016-11-04 22:13:12 +00:00
|
|
|
var hdgnow = int(getprop("/orientation/heading-magnetic-deg")+0.5);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/hdg", hdgnow);
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (latset == 4) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/lat", 4);
|
|
|
|
setprop("/it-autoflight/mode/lat", "ALGN");
|
2017-01-11 22:39:47 +00:00
|
|
|
} else if (latset == 5) {
|
|
|
|
setprop("/it-autoflight/output/lat", 5);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
2017-01-11 22:39:47 +00:00
|
|
|
}
|
2016-11-04 22:13:12 +00:00
|
|
|
|
|
|
|
# Master Vertical
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/vert", func {
|
2017-01-11 22:39:47 +00:00
|
|
|
vertical();
|
|
|
|
});
|
|
|
|
|
|
|
|
var vertical = func {
|
2016-12-05 20:20:56 +00:00
|
|
|
var vertset = getprop("/it-autoflight/input/vert");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (vertset == 0) {
|
2017-01-11 22:39:47 +00:00
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/vert", 0);
|
|
|
|
setprop("/it-autoflight/mode/vert", "ALT HLD");
|
|
|
|
if (getprop("/it-autoflight/output/loc-armed")) {
|
|
|
|
setprop("/it-autoflight/mode/arm", "LOC");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
var altnow = int((getprop("/instrumentation/altimeter/indicated-altitude-ft")+50)/100)*100;
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/alt", altnow);
|
|
|
|
setprop("/it-autoflight/internal/alt", altnow);
|
2017-01-11 22:39:47 +00:00
|
|
|
thrustmode();
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (vertset == 1) {
|
2017-01-11 22:39:47 +00:00
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-12-05 20:20:56 +00:00
|
|
|
var altinput = getprop("/it-autoflight/input/alt");
|
|
|
|
setprop("/it-autoflight/internal/alt", altinput);
|
2016-11-04 22:13:12 +00:00
|
|
|
var vsnow = int(getprop("/velocities/vertical-speed-fps")*0.6)*100;
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/vs", vsnow);
|
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/vert", 1);
|
|
|
|
setprop("/it-autoflight/mode/vert", "V/S");
|
|
|
|
if (getprop("/it-autoflight/output/loc-armed")) {
|
|
|
|
setprop("/it-autoflight/mode/arm", "LOC");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
2017-01-11 22:39:47 +00:00
|
|
|
thrustmode();
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (vertset == 2) {
|
2017-01-11 22:39:47 +00:00
|
|
|
if (getprop("/it-autoflight/output/lat") == 2) {
|
|
|
|
# Do nothing because VORLOC is active
|
|
|
|
} else {
|
|
|
|
setprop("/instrumentation/nav/signal-quality-norm", 0);
|
|
|
|
setprop("/it-autoflight/output/loc-armed", 1);
|
|
|
|
}
|
2016-11-04 22:13:12 +00:00
|
|
|
setprop("/instrumentation/nav/gs-rate-of-climb", 0);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/appr-armed", 1);
|
|
|
|
setprop("/it-autoflight/mode/arm", "ILS");
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/autoland/target-vs", "-650");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (vertset == 3) {
|
2017-01-11 22:39:47 +00:00
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-11-04 22:13:12 +00:00
|
|
|
var pitchdeg = getprop("/orientation/pitch-deg");
|
|
|
|
var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft");
|
2016-12-05 20:20:56 +00:00
|
|
|
var alt = getprop("/it-autoflight/internal/alt");
|
2016-11-04 22:13:12 +00:00
|
|
|
var dif = calt - alt;
|
|
|
|
if (calt < alt) {
|
|
|
|
setprop("/it-autoflight/internal/max-pitch", pitchdeg);
|
|
|
|
} else if (calt > alt) {
|
|
|
|
setprop("/it-autoflight/internal/min-pitch", pitchdeg);
|
|
|
|
}
|
|
|
|
minmaxtimer.start();
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/vert", 0);
|
|
|
|
setprop("/it-autoflight/mode/vert", "ALT CAP");
|
2017-01-11 22:39:47 +00:00
|
|
|
thrustmode();
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (vertset == 4) {
|
2017-01-11 22:39:47 +00:00
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-12-05 20:20:56 +00:00
|
|
|
var altinput = getprop("/it-autoflight/input/alt");
|
|
|
|
setprop("/it-autoflight/internal/alt", altinput);
|
2016-11-04 22:13:12 +00:00
|
|
|
var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft");
|
2016-12-05 20:20:56 +00:00
|
|
|
var alt = getprop("/it-autoflight/internal/alt");
|
2016-11-04 22:13:12 +00:00
|
|
|
var dif = calt - alt;
|
|
|
|
if (dif < 550 and dif > -550) {
|
|
|
|
alt_on();
|
|
|
|
} else {
|
|
|
|
flch_on();
|
|
|
|
}
|
2016-12-05 20:20:56 +00:00
|
|
|
if (getprop("/it-autoflight/output/loc-armed")) {
|
|
|
|
setprop("/it-autoflight/mode/arm", "LOC");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
} else if (vertset == 5) {
|
2017-01-11 22:39:47 +00:00
|
|
|
# FPA not ready yet, so do nothing
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (vertset == 6) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/vert", 6);
|
|
|
|
setprop("/it-autoflight/mode/vert", "LAND 3");
|
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2017-01-11 22:39:47 +00:00
|
|
|
thrustmode();
|
2016-11-04 22:13:12 +00:00
|
|
|
alandt.stop();
|
|
|
|
alandt1.start();
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/autoland/target-vs", "-650");
|
|
|
|
} else if (vertset == 7) {
|
|
|
|
setprop("/it-autoflight/output/vert", 7);
|
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
|
|
|
togasel();
|
|
|
|
thrustmode();
|
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
2017-01-11 22:39:47 +00:00
|
|
|
}
|
2016-11-04 22:13:12 +00:00
|
|
|
|
|
|
|
var flch_on = func {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/vert", 4);
|
2017-01-11 22:39:47 +00:00
|
|
|
thrustmodet.start();
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
var alt_on = func {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/vert", 0);
|
|
|
|
setprop("/it-autoflight/mode/vert", "ALT CAP");
|
2016-11-04 22:13:12 +00:00
|
|
|
setprop("/it-autoflight/internal/max-pitch", 8);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/internal/min-pitch", -8);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/kts-mach", func {
|
|
|
|
var modez = getprop("/it-autoflight/input/kts-mach");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (modez == 0) {
|
|
|
|
var iasnow = int(getprop("/instrumentation/airspeed-indicator/indicated-speed-kt")+0.5);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/spd-kts", iasnow);
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (modez == 1) {
|
|
|
|
var machnow = (int(1000*getprop("/velocities/mach")))*0.001;
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/spd-mach", machnow);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
# Capture Logic
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/output/vert", func {
|
|
|
|
var vertm = getprop("/it-autoflight/output/vert");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (vertm == 1) {
|
|
|
|
altcaptt.start();
|
|
|
|
} else if (vertm == 4) {
|
|
|
|
altcaptt.start();
|
|
|
|
} else {
|
|
|
|
altcaptt.stop();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var altcapt = func {
|
2017-01-11 22:39:47 +00:00
|
|
|
var vsnow = getprop("/it-autoflight/internal/vert-speed-fpm");
|
|
|
|
if ((vsnow >= 0 and vsnow < 500) or (vsnow < 0 and vsnow > -500)) {
|
|
|
|
setprop("/it-autoflight/internal/captvs", 100);
|
|
|
|
setprop("/it-autoflight/internal/captvsneg", -100);
|
|
|
|
} else if ((vsnow >= 500 and vsnow < 1000) or (vsnow < -500 and vsnow > -1000)) {
|
|
|
|
setprop("/it-autoflight/internal/captvs", 150);
|
|
|
|
setprop("/it-autoflight/internal/captvsneg", -150);
|
|
|
|
} else if ((vsnow >= 1000 and vsnow < 1500) or (vsnow < -1000 and vsnow > -1500)) {
|
|
|
|
setprop("/it-autoflight/internal/captvs", 200);
|
|
|
|
setprop("/it-autoflight/internal/captvsneg", -200);
|
|
|
|
} else if ((vsnow >= 1500 and vsnow < 2000) or (vsnow < -1500 and vsnow > -2000)) {
|
|
|
|
setprop("/it-autoflight/internal/captvs", 300);
|
|
|
|
setprop("/it-autoflight/internal/captvsneg", -300);
|
|
|
|
} else if ((vsnow >= 2000 and vsnow < 3000) or (vsnow < -2000 and vsnow > -3000)) {
|
|
|
|
setprop("/it-autoflight/internal/captvs", 450);
|
|
|
|
setprop("/it-autoflight/internal/captvsneg", -450);
|
|
|
|
} else if ((vsnow >= 3000 and vsnow < 4000) or (vsnow < -3000 and vsnow > -4000)) {
|
|
|
|
setprop("/it-autoflight/internal/captvs", 650);
|
|
|
|
setprop("/it-autoflight/internal/captvsneg", -650);
|
|
|
|
} else if ((vsnow >= 4000 and vsnow < 5000) or (vsnow < -4000 and vsnow > -5000)) {
|
|
|
|
setprop("/it-autoflight/internal/captvs", 1000);
|
|
|
|
setprop("/it-autoflight/internal/captvsneg", -1000);
|
|
|
|
} else if ((vsnow >= 5000) or (vsnow < -5000)) {
|
|
|
|
setprop("/it-autoflight/internal/captvs", 1250);
|
|
|
|
setprop("/it-autoflight/internal/captvsneg", -1250);
|
|
|
|
}
|
2016-11-04 22:13:12 +00:00
|
|
|
var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft");
|
2016-12-05 20:20:56 +00:00
|
|
|
var alt = getprop("/it-autoflight/internal/alt");
|
2016-11-04 22:13:12 +00:00
|
|
|
var dif = calt - alt;
|
2017-01-11 22:39:47 +00:00
|
|
|
if (dif < getprop("/it-autoflight/internal/captvs") and dif > getprop("/it-autoflight/internal/captvsneg")) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/vert", 3);
|
|
|
|
setprop("/it-autoflight/output/thr-mode", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
2016-12-05 20:20:56 +00:00
|
|
|
var altinput = getprop("/it-autoflight/input/alt");
|
|
|
|
setprop("/it-autoflight/internal/alt", altinput);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
|
2017-01-11 22:39:47 +00:00
|
|
|
# Thrust Mode Selector
|
|
|
|
var thrustmode = func {
|
2016-11-04 22:13:12 +00:00
|
|
|
var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft");
|
2016-12-05 20:20:56 +00:00
|
|
|
var alt = getprop("/it-autoflight/internal/alt");
|
|
|
|
var vertm = getprop("/it-autoflight/output/vert");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (vertm == 4) {
|
|
|
|
if (calt < alt) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/thr-mode", 2);
|
|
|
|
setprop("/it-autoflight/mode/thr", " PITCH");
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/mode/vert", "SPD CLB");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else if (calt > alt) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/thr-mode", 1);
|
|
|
|
setprop("/it-autoflight/mode/thr", " PITCH");
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/mode/vert", "SPD DES");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/thr-mode", 0);
|
|
|
|
setprop("/it-autoflight/mode/thr", "THRUST");
|
|
|
|
setprop("/it-autoflight/input/vert", 3);
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
2017-01-11 22:39:47 +00:00
|
|
|
} else if (vertm == 7) {
|
|
|
|
setprop("/it-autoflight/output/thr-mode", 2);
|
|
|
|
setprop("/it-autoflight/mode/thr", " PITCH");
|
2016-11-04 22:13:12 +00:00
|
|
|
} else {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/thr-mode", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/mode/thr", "THRUST");
|
|
|
|
thrustmodet.stop();
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Min and Max Pitch Reset
|
|
|
|
var minmax = func {
|
|
|
|
var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft");
|
2016-12-05 20:20:56 +00:00
|
|
|
var alt = getprop("/it-autoflight/internal/alt");
|
2016-11-04 22:13:12 +00:00
|
|
|
var dif = calt - alt;
|
|
|
|
if (dif < 100 and dif > -100) {
|
|
|
|
setprop("/it-autoflight/internal/max-pitch", 8);
|
2017-01-11 22:39:47 +00:00
|
|
|
setprop("/it-autoflight/internal/min-pitch", -5);
|
2016-12-05 20:20:56 +00:00
|
|
|
var vertmode = getprop("/it-autoflight/output/vert");
|
2017-01-11 22:39:47 +00:00
|
|
|
if (vertmode == 1 or vertmode == 2 or vertmode == 4 or vertmode == 5 or vertmode == 6 or vertmode == 7) {
|
2016-11-04 22:13:12 +00:00
|
|
|
# Do not change the vertical mode because we are not trying to capture altitude.
|
|
|
|
} else {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/mode/vert", "ALT HLD");
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
minmaxtimer.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Retard
|
|
|
|
setlistener("/controls/flight/flaps", func {
|
|
|
|
var flapc = getprop("/controls/flight/flaps");
|
|
|
|
var flapl = getprop("/it-autoflight/settings/land-flap");
|
|
|
|
if (flapc >= flapl) {
|
|
|
|
retardt.start();
|
|
|
|
} else {
|
|
|
|
retardt.stop();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var retardchk = func {
|
|
|
|
if (getprop("/it-autoflight/settings/retard-enable") == 1) {
|
|
|
|
var altpos = getprop("/position/gear-agl-ft");
|
|
|
|
var retardalt = getprop("/it-autoflight/settings/retard-ft");
|
2016-12-05 20:20:56 +00:00
|
|
|
var aton = getprop("/it-autoflight/output/athr");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (altpos < retardalt) {
|
|
|
|
if (aton == 1) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/retard", 1);
|
|
|
|
setprop("/it-autoflight/mode/thr", "RETARD");
|
2016-11-04 22:13:12 +00:00
|
|
|
atofft.start();
|
|
|
|
} else {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/retard", 0);
|
2017-01-11 22:39:47 +00:00
|
|
|
thrustmode();
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var atoffchk = func{
|
|
|
|
var gear1 = getprop("/gear/gear[1]/wow");
|
|
|
|
var gear2 = getprop("/gear/gear[2]/wow");
|
|
|
|
if (gear1 == 1 or gear2 == 1) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/athr", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
setprop("/controls/engines/engine[0]/throttle", 0);
|
|
|
|
setprop("/controls/engines/engine[1]/throttle", 0);
|
|
|
|
setprop("/controls/engines/engine[2]/throttle", 0);
|
|
|
|
setprop("/controls/engines/engine[3]/throttle", 0);
|
|
|
|
setprop("/controls/engines/engine[4]/throttle", 0);
|
|
|
|
setprop("/controls/engines/engine[5]/throttle", 0);
|
|
|
|
setprop("/controls/engines/engine[6]/throttle", 0);
|
|
|
|
setprop("/controls/engines/engine[7]/throttle", 0);
|
|
|
|
atofft.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# For Canvas Nav Display.
|
2016-12-05 20:20:56 +00:00
|
|
|
setlistener("/it-autoflight/input/hdg", func {
|
|
|
|
setprop("/autopilot/settings/heading-bug-deg", getprop("/it-autoflight/input/hdg"));
|
2016-11-04 22:13:12 +00:00
|
|
|
});
|
|
|
|
|
2017-01-11 22:39:47 +00:00
|
|
|
# TOGA
|
|
|
|
setlistener("/it-autoflight/input/toga", func {
|
|
|
|
if (getprop("/it-autoflight/input/toga") == 1) {
|
|
|
|
setprop("/it-autoflight/input/vert", 7);
|
|
|
|
setprop("/it-autoflight/output/loc-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/input/toga", 0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var togasel = func {
|
|
|
|
if ((getprop("/gear/gear[1]/wow") == 0) and (getprop("/gear/gear[2]/wow") == 0)) {
|
|
|
|
setprop("/it-autoflight/mode/vert", "G/A CLB");
|
|
|
|
} else {
|
|
|
|
setprop("/it-autoflight/input/lat", 5);
|
|
|
|
setprop("/it-autoflight/mode/lat", "T/O");
|
|
|
|
setprop("/it-autoflight/mode/vert", "T/O CLB");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-04 22:13:12 +00:00
|
|
|
# LOC and G/S arming
|
|
|
|
var update_arms = func {
|
|
|
|
update_locarmelec();
|
|
|
|
update_apparmelec();
|
|
|
|
|
|
|
|
settimer(update_arms, 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
var update_locarmelec = func {
|
2016-12-05 20:20:56 +00:00
|
|
|
var loca = getprop("/it-autoflight/output/loc-armed");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (loca) {
|
|
|
|
locarmcheck();
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var update_apparmelec = func {
|
2016-12-05 20:20:56 +00:00
|
|
|
var appra = getprop("/it-autoflight/output/appr-armed");
|
2016-11-04 22:13:12 +00:00
|
|
|
if (appra) {
|
|
|
|
apparmcheck();
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var locarmcheck = func {
|
|
|
|
var locdefl = getprop("instrumentation/nav/heading-needle-deflection-norm");
|
|
|
|
if ((locdefl < 0.9233) and (getprop("instrumentation/nav/signal-quality-norm") > 0.99)) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/loc-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/lat", 2);
|
|
|
|
setprop("/it-autoflight/mode/lat", "LOC");
|
|
|
|
if (getprop("/it-autoflight/output/appr-armed") == 1) {
|
2016-11-04 22:13:12 +00:00
|
|
|
# Do nothing because G/S is armed
|
|
|
|
} else {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var apparmcheck = func {
|
|
|
|
var signal = getprop("/instrumentation/nav/gs-needle-deflection-norm");
|
|
|
|
if (signal <= -0.000000001) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/vert", 2);
|
|
|
|
setprop("/it-autoflight/mode/vert", "G/S");
|
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
2017-01-11 22:39:47 +00:00
|
|
|
if (getprop("/it-autoflight/settings/land-enable") == 1){
|
|
|
|
alandt.start();
|
|
|
|
}
|
|
|
|
thrustmode();
|
2016-11-04 22:13:12 +00:00
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Autoland Stage 1 Logic (Land)
|
|
|
|
var aland = func {
|
2016-12-05 20:20:56 +00:00
|
|
|
var ap1 = getprop("/it-autoflight/output/ap1");
|
|
|
|
var ap2 = getprop("/it-autoflight/output/ap2");
|
2017-01-11 22:39:47 +00:00
|
|
|
if (getprop("/position/gear-agl-ft") <= 100) {
|
|
|
|
if (ap1 or ap2) {
|
|
|
|
setprop("/it-autoflight/input/lat", 4);
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/vert", 6);
|
2017-01-11 22:39:47 +00:00
|
|
|
} else {
|
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
2016-12-05 20:20:56 +00:00
|
|
|
}
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-11 22:39:47 +00:00
|
|
|
|
2016-11-04 22:13:12 +00:00
|
|
|
var aland1 = func {
|
|
|
|
var aglal = getprop("/position/gear-agl-ft");
|
2017-01-11 22:39:47 +00:00
|
|
|
var flarealt = getprop("/it-autoflight/settings/flare-altitude");
|
2016-12-05 20:20:56 +00:00
|
|
|
if (aglal <= flarealt and aglal > 5) {
|
|
|
|
setprop("/it-autoflight/mode/vert", "FLARE");
|
|
|
|
setprop("/it-autoflight/autoland/target-vs", "-120");
|
2016-11-04 22:13:12 +00:00
|
|
|
}
|
2017-01-11 22:39:47 +00:00
|
|
|
if ((getprop("/it-autoflight/output/ap1") == 0) and (getprop("/it-autoflight/output/ap2") == 0)) {
|
|
|
|
alandt.stop();
|
|
|
|
alandt1.stop();
|
|
|
|
setprop("/it-autoflight/output/loc-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/lat", 2);
|
|
|
|
setprop("/it-autoflight/mode/lat", "LOC");
|
|
|
|
setprop("/it-autoflight/output/appr-armed", 0);
|
|
|
|
setprop("/it-autoflight/output/vert", 2);
|
|
|
|
setprop("/it-autoflight/mode/vert", "G/S");
|
|
|
|
setprop("/it-autoflight/mode/arm", " ");
|
|
|
|
}
|
2016-11-04 22:13:12 +00:00
|
|
|
var gear1 = getprop("/gear/gear[1]/wow");
|
|
|
|
var gear2 = getprop("/gear/gear[2]/wow");
|
|
|
|
if (gear1 == 1 or gear2 == 1) {
|
2016-12-05 20:20:56 +00:00
|
|
|
setprop("/it-autoflight/input/ap1", 0);
|
|
|
|
setprop("/it-autoflight/input/ap2", 0);
|
2016-11-04 22:13:12 +00:00
|
|
|
alandt1.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Autoland Stage 2 Logic (Rollout)
|
2017-01-11 22:39:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
# CWS
|
|
|
|
var cwsroll = func {
|
|
|
|
var ail = getprop("/controls/flight/aileron");
|
|
|
|
if (ail < 0.05 and ail > -0.05) {
|
|
|
|
if (getprop("/it-autoflight/internal/cwsr") == 0) {
|
|
|
|
setprop("/it-autoflight/internal/cws-roll-deg", getprop("/orientation/roll-deg"));
|
|
|
|
}
|
|
|
|
setprop("/it-autoflight/internal/cwsr", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/it-autoflight/internal/cwsr", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var cwspitch = func {
|
|
|
|
var elv = getprop("/controls/flight/elevator");
|
|
|
|
if (elv < 0.05 and elv > -0.05) {
|
|
|
|
if (getprop("/it-autoflight/internal/cwsp") == 0) {
|
|
|
|
setprop("/it-autoflight/internal/cws-pitch-deg", getprop("/orientation/pitch-deg"));
|
|
|
|
}
|
|
|
|
setprop("/it-autoflight/internal/cwsp", 1);
|
|
|
|
} else {
|
|
|
|
setprop("/it-autoflight/internal/cwsp", 0);
|
|
|
|
}
|
|
|
|
}
|
2016-11-04 22:13:12 +00:00
|
|
|
|
|
|
|
# Timers
|
|
|
|
var altcaptt = maketimer(0.5, altcapt);
|
2017-01-11 22:39:47 +00:00
|
|
|
var thrustmodet = maketimer(0.5, thrustmode);
|
2016-11-04 22:13:12 +00:00
|
|
|
var minmaxtimer = maketimer(0.5, minmax);
|
|
|
|
var retardt = maketimer(0.5, retardchk);
|
|
|
|
var atofft = maketimer(0.5, atoffchk);
|
|
|
|
var alandt = maketimer(0.5, aland);
|
2017-01-11 22:39:47 +00:00
|
|
|
var alandt1 = maketimer(0.5, aland1);
|
|
|
|
var cwsrollt = maketimer(0.1, cwsroll);
|
|
|
|
var cwspitcht = maketimer(0.1, cwspitch);
|