1
0
Fork 0
A320-family/Nasal/FMGC/FMGC-c.nas

620 lines
20 KiB
Text
Raw Normal View History

2019-10-14 16:48:35 +00:00
# A3XX FMGC/Autoflight
# Joshua Davidson (Octal450) and Jonathan Redpath (legoboyvdlp)
2020-04-18 05:36:46 +00:00
# Copyright (c) 2020 Josh Davidson (Octal450)
2019-10-14 16:48:35 +00:00
2020-02-07 16:10:54 +00:00
setprop("FMGC/internal/cruise-ft", 10000);
setprop("it-autoflight/internal/alt", 10000);
setprop("modes/pfd/fma/throttle-mode", " ");
setprop("modes/pfd/fma/pitch-mode", " ");
setprop("modes/pfd/fma/pitch-mode-armed", " ");
setprop("modes/pfd/fma/pitch-mode2-armed", " ");
setprop("modes/pfd/fma/roll-mode", " ");
setprop("modes/pfd/fma/roll-mode-armed", " ");
setprop("modes/pfd/fma/ap-mode", " ");
setprop("modes/pfd/fma/fd-mode", " ");
setprop("modes/pfd/fma/at-mode", " ");
setprop("modes/pfd/fma/athr-armed", 0);
setprop("modes/pfd/fma/throttle-mode-box", 0);
setprop("modes/pfd/fma/pitch-mode-box", 0);
setprop("modes/pfd/fma/pitch-mode-armed-box", 0);
setprop("modes/pfd/fma/pitch-mode2-armed-box", 0);
setprop("modes/pfd/fma/roll-mode-box", 0);
setprop("modes/pfd/fma/roll-mode-armed-box", 0);
setprop("modes/pfd/fma/ap-mode-box", 0);
setprop("modes/pfd/fma/fd-mode-box", 0);
setprop("modes/pfd/fma/athr-mode-box", 0);
setprop("modes/pfd/fma/throttle-mode-time", 0);
setprop("modes/pfd/fma/pitch-mode-time", 0);
setprop("modes/pfd/fma/pitch-mode-armed-time", 0);
setprop("modes/pfd/fma/pitch-mode2-armed-time", 0);
setprop("modes/pfd/fma/roll-mode-time", 0);
setprop("modes/pfd/fma/roll-mode-armed-time", 0);
setprop("modes/pfd/fma/ap-mode-time", 0);
setprop("modes/pfd/fma/fd-mode-time", 0);
setprop("modes/pfd/fma/athr-mode-time", 0);
setprop("modes/fcu/hdg-time", -45);
2019-10-14 16:48:35 +00:00
setlistener("sim/signals/fdm-initialized", func {
loopFMA.start();
});
# Master Thrust
var loopFMA = maketimer(0.05, func {
2020-02-07 16:10:54 +00:00
var state1 = getprop("systems/thrust/state1");
var state2 = getprop("systems/thrust/state2");
var newthr = getprop("modes/pfd/fma/throttle-mode");
var thr1 = getprop("controls/engines/engine[0]/throttle-pos");
var thr2 = getprop("controls/engines/engine[1]/throttle-pos");
2019-10-14 16:48:35 +00:00
if (state1 == "TOGA" or state2 == "TOGA") {
if (newthr != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", " ");
2019-10-14 16:48:35 +00:00
}
} else if ((state1 == "MAN THR" and thr1 >= 0.83) or (state2 == "MAN THR" and thr2 >= 0.83)) {
if (newthr != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", " ");
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
} else if ((state1 == "MCT" or state2 == "MCT") and getprop("systems/thrust/eng-out") != 1) {
2019-10-14 16:48:35 +00:00
if (newthr != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", " ");
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
} else if (((state1 == "MAN THR" and thr1 < 0.83) or (state2 == "MAN THR" and thr2 < 0.83)) and getprop("systems/thrust/eng-out") != 1) {
2019-10-14 16:48:35 +00:00
if (newthr != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", " ");
2019-10-14 16:48:35 +00:00
}
} else {
2020-02-07 16:10:54 +00:00
if ((getprop("it-autoflight/output/vert") == 4) or (getprop("it-autoflight/output/vert") == 6) or (getprop("it-autoflight/output/vert") == 7) or (getprop("it-autoflight/output/vert") == 8)) {
if (getprop("it-autoflight/output/fd1") == 0 and getprop("it-autoflight/output/fd2") == 0 and getprop("it-autoflight/output/ap1") == 0 and getprop("it-autoflight/output/ap2") == 0) {
2019-10-14 16:48:35 +00:00
loopFMA_b();
} else {
2020-02-07 16:10:54 +00:00
var thr = getprop("it-autoflight/output/thr-mode");
2019-10-14 16:48:35 +00:00
if (thr == 0) {
loopFMA_b();
} else if (thr == 1) {
if (newthr != "THR IDLE") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", "THR IDLE");
2019-10-14 16:48:35 +00:00
}
} else if (thr == 2) {
2020-02-07 16:10:54 +00:00
if (state1 == "MCT" or state2 == "MCT" and getprop("systems/thrust/eng-out") == 1) {
2019-10-14 16:48:35 +00:00
if (newthr != "THR MCT") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", "THR MCT");
2019-10-14 16:48:35 +00:00
}
} else if (state1 == "CL" or state2 == "CL") {
if (newthr != "THR CLB") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", "THR CLB");
2019-10-14 16:48:35 +00:00
}
} else {
if (newthr != "THR LVR") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", "THR LVR");
2019-10-14 16:48:35 +00:00
}
}
}
}
} else {
loopFMA_b();
}
}
# A/THR Armed/Active
2020-02-07 16:10:54 +00:00
if (getprop("it-autoflight/output/athr") == 1 and (state1 == "MAN THR" or state2 == "MAN THR" or state1 == "MCT" or state2 == "MCT" or state1 == "TOGA" or state2 == "TOGA") and getprop("systems/thrust/eng-out") != 1) {
if (getprop("modes/pfd/fma/athr-armed") != 1) {
setprop("modes/pfd/fma/athr-armed", 1);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
} else if (getprop("it-autoflight/output/athr") == 1 and ((state1 == "MAN THR" and thr1 >= 0.83) or (state2 == "MAN THR" and thr2 >= 0.83) or (state1 == "MCT" and getprop("controls/engines/thrust-limit") == "FLX") or
(state2 == "MCT" and getprop("controls/engines/thrust-limit") == "FLX") or state1 == "TOGA" or state2 == "TOGA") and getprop("systems/thrust/eng-out") == 1) {
if (getprop("modes/pfd/fma/athr-armed") != 1) {
setprop("modes/pfd/fma/athr-armed", 1);
2019-10-14 16:48:35 +00:00
}
} else {
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/athr-armed") != 0) {
setprop("modes/pfd/fma/athr-armed", 0);
2019-10-14 16:48:35 +00:00
}
}
# SRS RWY Engagement
2020-02-07 16:10:54 +00:00
var flx = getprop("systems/thrust/lim-flex");
var lat = getprop("it-autoflight/mode/lat");
var newlat = getprop("modes/pfd/fma/roll-mode");
var vert = getprop("it-autoflight/mode/vert");
var newvert = getprop("modes/pfd/fma/pitch-mode");
var newvertarm = getprop("modes/pfd/fma/pitch-mode2-armed");
var thr1 = getprop("controls/engines/engine[0]/throttle-pos");
var thr2 = getprop("controls/engines/engine[1]/throttle-pos");
var wow = getprop("gear/gear[0]/wow");
var engstate1 = getprop("engines/engine[0]/state");
var engstate2 = getprop("engines/engine[1]/state");
2019-10-14 16:48:35 +00:00
if (((state1 == "TOGA" or state2 == "TOGA") or (flx == 1 and (state1 == "MCT" or state2 == "MCT")) or (flx == 1 and ((state1 == "MAN THR" and thr1 >= 0.83) or (state2 == "MAN THR" and thr2 >= 0.83)))) and (engstate1 == 3 or engstate2 == 3)) {
# RWY Engagement would go here, but automatic ILS selection is not simulated yet.
2020-02-07 16:10:54 +00:00
if (wow and getprop("FMGC/internal/v2-set") == 1 and getprop("it-autoflight/output/vert") != 7) {
2019-10-14 16:48:35 +00:00
ITAF.setVertMode(7);
2020-02-07 16:10:54 +00:00
setprop("it-autoflight/mode/vert", "T/O CLB");
2019-10-14 16:48:35 +00:00
}
} else {
2020-02-07 16:10:54 +00:00
var gear1 = getprop("gear/gear[1]/wow");
var gear2 = getprop("gear/gear[2]/wow");
if (getprop("it-autoflight/input/lat") == 5 and (gear1 or gear2)) {
2019-10-14 16:48:35 +00:00
ITAF.setLatMode(9);
}
2020-02-07 16:10:54 +00:00
if (getprop("it-autoflight/output/vert") == 7 and (gear1 or gear2)) {
2019-10-14 16:48:35 +00:00
ITAF.setVertMode(9);
}
}
2020-02-07 16:10:54 +00:00
var trk = getprop("it-autoflight/custom/trk-fpa");
2019-10-14 16:48:35 +00:00
if (lat == "HDG" and trk == 0) {
if (newlat != "HDG") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", "HDG");
2019-10-14 16:48:35 +00:00
}
} else if (lat == "HDG" and trk == 1) {
if (newlat != "TRACK") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", "TRACK");
2019-10-14 16:48:35 +00:00
}
}
# Boxes
2020-02-07 16:10:54 +00:00
var elapsedtime = getprop("sim/time/elapsed-sec");
if (getprop("modes/pfd/fma/ap-mode-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/ap-mode-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/ap-mode-box", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/fd-mode-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/fd-mode-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/fd-mode-box", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/athr-mode-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/athr-mode-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/athr-mode-box", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/throttle-mode-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/throttle-mode-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode-box", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/roll-mode-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/roll-mode-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-box", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/pitch-mode-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/pitch-mode-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode-box", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/roll-mode-armed-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/roll-mode-armed-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-armed-box", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/pitch-mode-armed-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/pitch-mode-armed-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode-armed-box", 0);
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/pitch-mode2-armed-time") + 10 >= elapsedtime) {
setprop("modes/pfd/fma/pitch-mode2-armed-box", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed-box", 0);
2019-10-14 16:48:35 +00:00
}
});
var loopFMA_b = func {
2020-02-07 16:10:54 +00:00
var newthr = getprop("modes/pfd/fma/throttle-mode");
if (getprop("it-autoflight/input/kts-mach") == 0) {
2019-10-14 16:48:35 +00:00
if (newthr != "SPEED") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", "SPEED");
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
} else if (getprop("it-autoflight/input/kts-mach") == 1) {
2019-10-14 16:48:35 +00:00
if (newthr != "MACH") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/throttle-mode", "MACH");
2019-10-14 16:48:35 +00:00
}
}
}
# Master Lateral
setlistener("/it-autoflight/mode/lat", func {
2020-02-07 16:10:54 +00:00
var lat = getprop("it-autoflight/mode/lat");
var newlat = getprop("modes/pfd/fma/roll-mode");
2019-10-14 16:48:35 +00:00
if (lat == "LNAV") {
if (newlat != "NAV") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", "NAV");
2019-10-14 16:48:35 +00:00
}
} else if (lat == "LOC") {
if (newlat != "LOC*" and newlat != "LOC") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", "LOC*");
2019-10-14 16:48:35 +00:00
locupdate.start();
}
} else if (lat == "ALGN") {
if (newlat != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", " ");
2019-10-14 16:48:35 +00:00
}
} else if (lat == "RLOU") {
if (newlat != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", " ");
2019-10-14 16:48:35 +00:00
}
} else if (lat == "T/O") {
if (newlat != "RWY") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", "RWY");
2019-10-14 16:48:35 +00:00
}
} else if (lat == " ") {
if (newlat != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", " ");
2019-10-14 16:48:35 +00:00
}
}
});
var locupdate = maketimer(0.5, func {
2020-02-07 16:10:54 +00:00
var lat = getprop("it-autoflight/mode/lat");
var newlat = getprop("modes/pfd/fma/roll-mode");
var nav_defl = getprop("instrumentation/nav[0]/heading-needle-deflection-norm");
2019-10-14 16:48:35 +00:00
if (lat == "LOC") {
if (nav_defl > -0.06 and nav_defl < 0.06) {
locupdate.stop();
if (newlat != "LOC") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode", "LOC");
2019-10-14 16:48:35 +00:00
}
}
}
});
# Master Vertical
setlistener("/it-autoflight/mode/vert", func {
2020-02-07 16:10:54 +00:00
var vert = getprop("it-autoflight/mode/vert");
var newvert = getprop("modes/pfd/fma/pitch-mode");
var newvertarm = getprop("modes/pfd/fma/pitch-mode2-armed");
2019-10-14 16:48:35 +00:00
if (vert == "ALT HLD") {
altvert();
if (newvertarm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed", " ");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "ALT CAP") {
altvert();
if (newvertarm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed", " ");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "V/S") {
if (newvert != "V/S") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "V/S");
2019-10-14 16:48:35 +00:00
}
if (newvertarm != "ALT") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed", "ALT");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "G/S") {
if (newvert != "G/S*" and newvert != "G/S") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "G/S*");
2019-10-14 16:48:35 +00:00
gsupdate.start();
}
if (newvertarm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed", " ");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "SPD CLB") {
if (newvert != "OP CLB") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "OP CLB");
2019-10-14 16:48:35 +00:00
}
if (newvertarm != "ALT") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed", "ALT");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "SPD DES") {
if (newvert != "OP DES") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "OP DES");
2019-10-14 16:48:35 +00:00
}
if (newvertarm != "ALT") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed", "ALT");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "FPA") {
if (newvert != "FPA") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "FPA");
2019-10-14 16:48:35 +00:00
}
if (newvertarm != "ALT") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed", "ALT");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "LAND") {
if (newvert != "LAND") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "LAND");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "FLARE") {
if (newvert != "FLARE") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "FLARE");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "ROLLOUT") {
if (newvert != "ROLL OUT") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "ROLL OUT");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "T/O CLB") {
if (newvert != "SRS") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "SRS");
2019-10-14 16:48:35 +00:00
}
updatePitchArm2();
} else if (vert == "G/A CLB") {
if (newvert != "SRS") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "SRS");
2019-10-14 16:48:35 +00:00
}
if (newvertarm != "ALT") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed", "ALT");
2019-10-14 16:48:35 +00:00
}
} else if (vert == " ") {
if (newvert != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", " ");
2019-10-14 16:48:35 +00:00
}
updatePitchArm2();
}
altvert();
});
setlistener("/FMGC/internal/v2-set", func {
updatePitchArm2();
});
var updatePitchArm2 = func {
2020-02-07 16:10:54 +00:00
var newvertarm = getprop("modes/pfd/fma/pitch-mode2-armed");
if (newvertarm != "CLB" and getprop("FMGC/internal/v2-set") == 1) {
setprop("modes/pfd/fma/pitch-mode2-armed", "CLB");
} else if (newvertarm != " " and getprop("FMGC/internal/v2-set") != 1) {
setprop("modes/pfd/fma/pitch-mode2-armed", " ");
2019-10-14 16:48:35 +00:00
}
}
var gsupdate = maketimer(0.5, func {
2020-02-07 16:10:54 +00:00
var vert = getprop("it-autoflight/mode/vert");
var newvert = getprop("modes/pfd/fma/pitch-mode");
var gs_defl = getprop("instrumentation/nav[0]/gs-needle-deflection-norm");
2019-10-14 16:48:35 +00:00
if (vert == "G/S") {
if (gs_defl > -0.06 and gs_defl < 0.06) {
gsupdate.stop();
if (newvert != "G/S") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "G/S");
2019-10-14 16:48:35 +00:00
}
}
}
});
var altvert = func {
2020-02-07 16:10:54 +00:00
var FMGCalt = getprop("FMGC/internal/cruise-ft");
var MCPalt = getprop("it-autoflight/internal/alt");
2019-10-14 16:48:35 +00:00
var ALTdif = abs(FMGCalt - MCPalt);
2020-02-07 16:10:54 +00:00
var vert = getprop("it-autoflight/mode/vert");
var newvert = getprop("modes/pfd/fma/pitch-mode");
2019-10-14 16:48:35 +00:00
if (ALTdif <= 20) {
if (vert == "ALT HLD") {
if (newvert != "ALT CRZ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "ALT CRZ");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "ALT CAP") {
if (newvert != "ALT CRZ*") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "ALT CRZ*");
2019-10-14 16:48:35 +00:00
}
}
} else {
if (vert == "ALT HLD") {
if (newvert != "ALT") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "ALT");
2019-10-14 16:48:35 +00:00
}
} else if (vert == "ALT CAP") {
if (newvert != "ALT*") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode", "ALT*");
2019-10-14 16:48:35 +00:00
}
}
}
}
setlistener("/FMGC/internal/cruise-ft", altvert);
# Arm HDG or NAV
setlistener("/it-autoflight/mode/arm", func {
2020-02-07 16:10:54 +00:00
var arm = getprop("it-autoflight/mode/arm");
var newarm = getprop("modes/pfd/fma/roll-mode-armed");
2019-10-14 16:48:35 +00:00
if (arm == "HDG") {
if (newarm != "HDG") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-armed", " ");
2019-10-14 16:48:35 +00:00
}
} else if (arm == "LNV") {
if (newarm != "NAV") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-armed", "NAV");
2019-10-14 16:48:35 +00:00
}
} else if (arm == " ") {
if (newarm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-armed", " ");
2019-10-14 16:48:35 +00:00
}
}
});
# Arm LOC
setlistener("/it-autoflight/output/loc-armed", func {
2020-02-07 16:10:54 +00:00
var loca = getprop("it-autoflight/output/loc-armed");
var newarm = getprop("modes/pfd/fma/roll-mode-armed");
2019-10-14 16:48:35 +00:00
if (loca) {
if (newarm != "LOC") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-armed", "LOC");
2019-10-14 16:48:35 +00:00
}
} else {
if (newarm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-armed", " ");
2019-10-14 16:48:35 +00:00
}
}
});
# Arm G/S
setlistener("/it-autoflight/output/appr-armed", func {
2020-02-07 16:10:54 +00:00
var appa = getprop("it-autoflight/output/appr-armed");
var newvert2arm = getprop("modes/pfd/fma/pitch-mode-armed");
2019-10-14 16:48:35 +00:00
if (appa) {
if (newvert2arm != "G/S") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode-armed", "G/S");
2019-10-14 16:48:35 +00:00
}
} else {
if (newvert2arm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode-armed", " ");
2019-10-14 16:48:35 +00:00
}
}
});
# AP
var ap = func {
2020-02-07 16:10:54 +00:00
var ap1 = getprop("it-autoflight/output/ap1");
var ap2 = getprop("it-autoflight/output/ap2");
var newap = getprop("modes/pfd/fma/ap-mode");
2019-10-14 16:48:35 +00:00
if (ap1 and ap2 and newap != "AP1+2") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/ap-mode", "AP 1+2");
2019-10-14 16:48:35 +00:00
} else if (ap1 and !ap2 and newap != "AP 1") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/ap-mode", "AP 1");
2019-10-14 16:48:35 +00:00
} else if (ap2 and !ap1 and newap != "AP 2") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/ap-mode", "AP 2");
2019-10-14 16:48:35 +00:00
} else if (!ap1 and !ap2) {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/ap-mode", " ");
2019-10-14 16:48:35 +00:00
}
}
# FD
var fd = func {
2020-02-07 16:10:54 +00:00
var fd1 = getprop("it-autoflight/output/fd1");
var fd2 = getprop("it-autoflight/output/fd2");
var newfd = getprop("modes/pfd/fma/fd-mode");
2019-10-14 16:48:35 +00:00
if (fd1 and fd2 and newfd != "1FD2") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/fd-mode", "1 FD 2");
2019-10-14 16:48:35 +00:00
} else if (fd1 and !fd2 and newfd != "1 FD -") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/fd-mode", "1 FD -");
2019-10-14 16:48:35 +00:00
} else if (fd2 and !fd1 and newfd != "- FD 2") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/fd-mode", "- FD 2");
2019-10-14 16:48:35 +00:00
} else if (!fd1 and !fd2) {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/fd-mode", " ");
2019-10-14 16:48:35 +00:00
}
}
# AT
var at = func {
2020-02-07 16:10:54 +00:00
var at = getprop("it-autoflight/output/athr");
var newat = getprop("modes/pfd/fma/at-mode");
2019-10-14 16:48:35 +00:00
if (at and newat != "A/THR") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/at-mode", "A/THR");
2019-10-14 16:48:35 +00:00
} else if (!at) {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/at-mode", " ");
2019-10-14 16:48:35 +00:00
}
}
var boxchk = func {
2020-02-07 16:10:54 +00:00
if ((getprop("it-autoflight/output/ap1") or getprop("it-autoflight/output/ap2") or getprop("it-autoflight/output/fd1") or getprop("it-autoflight/output/fd2")) and getprop("it-autoflight/output/fma-pwr") == 0) {
setprop("it-autoflight/input/lat", 3);
2019-10-14 16:48:35 +00:00
boxchk_b();
}
}
var boxchk_b = func {
2020-02-07 16:10:54 +00:00
var newlat = getprop("modes/pfd/fma/roll-mode");
2019-10-14 16:48:35 +00:00
if (newlat != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
var newvert = getprop("modes/pfd/fma/pitch-mode");
2019-10-14 16:48:35 +00:00
if (newvert != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
var newarmr = getprop("modes/pfd/fma/roll-mode-armed");
2019-10-14 16:48:35 +00:00
if (newarmr != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-armed-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
var newarmp = getprop("modes/pfd/fma/pitch-mode-armed");
2019-10-14 16:48:35 +00:00
if (newarmp != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode-armed-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
2020-02-07 16:10:54 +00:00
var newarmp2 = getprop("modes/pfd/fma/pitch-mode2-armed");
2019-10-14 16:48:35 +00:00
if (newarmp2 != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
}
# Update AP FD ATHR
setlistener("/it-autoflight/output/ap1", func {
ap();
boxchk();
});
setlistener("/it-autoflight/output/ap2", func {
ap();
boxchk();
});
setlistener("/it-autoflight/output/fd1", func {
fd();
boxchk();
});
setlistener("/it-autoflight/output/fd2", func {
fd();
boxchk();
});
setlistener("/it-autoflight/output/athr", func {
at();
});
# Boxes
setlistener("/modes/pfd/fma/ap-mode", func {
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/ap-mode") != " ") {
setprop("modes/pfd/fma/ap-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});
setlistener("/modes/pfd/fma/fd-mode", func {
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/fd-mode") != " ") {
setprop("modes/pfd/fma/fd-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});
setlistener("/modes/pfd/fma/at-mode", func {
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/at-mode") != " ") {
setprop("modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec"));
setprop("modes/pfd/fma/athr-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});
setlistener("/modes/pfd/fma/athr-armed", func {
2020-02-07 16:10:54 +00:00
if (getprop("modes/pfd/fma/at-mode") != " ") {
setprop("modes/pfd/fma/athr-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});
setlistener("/modes/pfd/fma/throttle-mode", func {
2020-02-07 16:10:54 +00:00
var state1 = getprop("systems/thrust/state1");
var state2 = getprop("systems/thrust/state2");
if (getprop("it-autoflight/output/athr") == 1 and state1 != "MCT" and state2 != "MCT" and state1 != "MAN THR" and state2 != "MAN THR" and state1 != "TOGA" and state2 != "TOGA" and state1 != "IDLE" and state2 != "IDLE" and
getprop("systems/thrust/eng-out") != 1) {
setprop("modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec"));
} else if (getprop("it-autoflight/output/athr") == 1 and state1 != "TOGA" and state2 != "TOGA" and state1 != "IDLE" and state2 != "IDLE" and getprop("systems/thrust/eng-out") == 1) {
if (getprop("controls/engines/engine[0]/throttle-pos") < 0.83 and getprop("controls/engines/engine[1]/throttle-pos") < 0.83) {
setprop("modes/pfd/fma/throttle-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
}
});
setlistener("/modes/pfd/fma/roll-mode", func {
2020-02-07 16:10:54 +00:00
var newlat = getprop("modes/pfd/fma/roll-mode");
2019-10-14 16:48:35 +00:00
if (newlat != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});
setlistener("/modes/pfd/fma/pitch-mode", func {
2020-02-07 16:10:54 +00:00
var newvert = getprop("modes/pfd/fma/pitch-mode");
2019-10-14 16:48:35 +00:00
if (newvert != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});
setlistener("/modes/pfd/fma/roll-mode-armed", func {
2020-02-07 16:10:54 +00:00
var newarm = getprop("modes/pfd/fma/roll-mode-armed");
2019-10-14 16:48:35 +00:00
if (newarm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/roll-mode-armed-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});
setlistener("/modes/pfd/fma/pitch-mode-armed", func {
2020-02-07 16:10:54 +00:00
var newarm = getprop("modes/pfd/fma/pitch-mode-armed");
2019-10-14 16:48:35 +00:00
if (newarm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode-armed-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});
setlistener("/modes/pfd/fma/pitch-mode2-armed", func {
2020-02-07 16:10:54 +00:00
var newarm = getprop("modes/pfd/fma/pitch-mode2-armed");
2019-10-14 16:48:35 +00:00
if (newarm != " ") {
2020-02-07 16:10:54 +00:00
setprop("modes/pfd/fma/pitch-mode2-armed-time", getprop("sim/time/elapsed-sec"));
2019-10-14 16:48:35 +00:00
}
});