2017-06-03 15:53:36 +00:00
# Airbus PFD FMA
2016-11-05 03:39:28 +00:00
# Joshua Davidson (it0uchpods/411)
# Speed or Mach?
var speedmach = func {
2017-04-03 17:55:10 +00:00
if ((getprop("/it-autoflight/output/vert") == 4) or (getprop("/it-autoflight/output/vert") == 6) or (getprop("/it-autoflight/output/vert") == 7)) {
2017-05-07 23:18:38 +00:00
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) {
speedmach_b();
} else {
var thr = getprop("/it-autoflight/output/thr-mode");
2017-06-05 17:28:38 +00:00
var newthr = getprop("/modes/pfd/fma/throttle-mode");
2017-05-07 23:18:38 +00:00
if (thr == 0) {
speedmach_b();
} else if (thr == 1) {
2017-06-05 17:28:38 +00:00
if (newthr != "THR IDLE") {
setprop("/modes/pfd/fma/throttle-mode", "THR IDLE");
}
2017-05-07 23:18:38 +00:00
} else if (thr == 2) {
2017-06-05 17:28:38 +00:00
if (newthr != "THR CLB") {
setprop("/modes/pfd/fma/throttle-mode", "THR CLB");
}
2017-05-07 23:18:38 +00:00
}
2017-04-03 17:55:10 +00:00
}
2017-05-07 23:18:38 +00:00
} else {
speedmach_b();
}
}
var speedmach_b = func {
2017-06-05 17:28:38 +00:00
var newthr = getprop("/modes/pfd/fma/throttle-mode");
2017-05-07 23:18:38 +00:00
if (getprop("/it-autoflight/input/kts-mach") == 0) {
2017-06-05 17:28:38 +00:00
if (newthr != "SPEED") {
setprop("/modes/pfd/fma/throttle-mode", "SPEED");
}
2017-05-07 23:18:38 +00:00
} else if (getprop("/it-autoflight/input/kts-mach") == 1) {
2017-06-05 17:28:38 +00:00
if (newthr != "MACH") {
setprop("/modes/pfd/fma/throttle-mode", "MACH");
}
2017-04-03 17:55:10 +00:00
}
2016-11-05 03:39:28 +00:00
}
# Update Speed or Mach
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/input/kts-mach", func {
2017-04-03 17:55:10 +00:00
speedmach();
2016-11-05 03:39:28 +00:00
});
# Master Thrust
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/output/thr-mode", func {
2017-05-07 23:18:38 +00:00
speedmach();
2016-11-05 03:39:28 +00:00
});
# Master Lateral
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/mode/lat", func {
2017-04-03 17:55:10 +00:00
var lat = getprop("/it-autoflight/mode/lat");
2017-06-05 17:28:38 +00:00
var newlat = getprop("/modes/pfd/fma/roll-mode");
2017-04-03 17:55:10 +00:00
if (lat == "HDG") {
2017-06-05 17:28:38 +00:00
if (newlat != "HDG") {
setprop("/modes/pfd/fma/roll-mode", "HDG");
}
2017-04-03 17:55:10 +00:00
} else if (lat == "LNAV") {
2017-06-05 17:28:38 +00:00
if (newlat != "NAV") {
setprop("/modes/pfd/fma/roll-mode", "NAV");
}
2017-04-03 17:55:10 +00:00
} else if (lat == "LOC") {
2017-06-05 17:28:38 +00:00
if (newlat != "LOC") {
setprop("/modes/pfd/fma/roll-mode", "LOC");
}
2017-04-03 17:55:10 +00:00
} else if (lat == "ALGN") {
2017-06-05 17:28:38 +00:00
if (newlat != "LAND") {
setprop("/modes/pfd/fma/roll-mode", "LAND");
}
2017-04-03 17:55:10 +00:00
} else if (lat == "T/O") {
2017-06-05 17:28:38 +00:00
if (newlat != "RWY") {
setprop("/modes/pfd/fma/roll-mode", "RWY");
}
2017-04-03 17:55:10 +00:00
}
2016-11-05 03:39:28 +00:00
});
# Master Vertical
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/mode/vert", func {
2017-04-03 17:55:10 +00:00
var vert = getprop("/it-autoflight/mode/vert");
2017-06-05 17:28:38 +00:00
var newvert = getprop("/modes/pfd/fma/pitch-mode");
var newvertarm = getprop("/modes/pfd/fma/pitch-mode2-armed");
2017-04-03 17:55:10 +00:00
if (vert == "ALT HLD") {
2017-06-05 17:28:38 +00:00
if (newvert != "ALT") {
setprop("/modes/pfd/fma/pitch-mode", "ALT");
}
if (newvertarm != " ") {
setprop("/modes/pfd/fma/pitch-mode2-armed", " ");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "ALT CAP") {
2017-06-09 19:23:35 +00:00
if (newvert != "ALT*") {
setprop("/modes/pfd/fma/pitch-mode", "ALT*");
2017-06-05 17:28:38 +00:00
}
if (newvertarm != " ") {
setprop("/modes/pfd/fma/pitch-mode2-armed", " ");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "V/S") {
2017-06-05 17:28:38 +00:00
if (newvert != "V/S") {
setprop("/modes/pfd/fma/pitch-mode", "V/S");
}
if (newvertarm != "ALT") {
setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "G/S") {
2017-06-05 17:28:38 +00:00
if (newvert != "G/S") {
setprop("/modes/pfd/fma/pitch-mode", "G/S");
}
if (newvertarm != " ") {
setprop("/modes/pfd/fma/pitch-mode2-armed", " ");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "SPD CLB") {
2017-06-05 17:28:38 +00:00
if (newvert != "OP CLB") {
setprop("/modes/pfd/fma/pitch-mode", "OP CLB");
}
if (newvertarm != "ALT") {
setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "SPD DES") {
2017-06-05 17:28:38 +00:00
if (newvert != "OP DES") {
setprop("/modes/pfd/fma/pitch-mode", "OP DES");
}
if (newvertarm != "ALT") {
setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "FPA") {
2017-06-05 17:28:38 +00:00
if (newvert != "FPA") {
setprop("/modes/pfd/fma/pitch-mode", "FPA");
}
if (newvertarm != "ALT") {
setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT");
}
2017-04-14 22:02:06 +00:00
} else if (vert == "LAND") {
2017-06-05 17:28:38 +00:00
if (newvert != "LAND") {
setprop("/modes/pfd/fma/pitch-mode", "LAND");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "FLARE") {
2017-06-05 17:28:38 +00:00
if (newvert != "FLARE") {
setprop("/modes/pfd/fma/pitch-mode", "FLARE");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "T/O CLB") {
2017-06-05 17:28:38 +00:00
if (newvert != "SRS") {
setprop("/modes/pfd/fma/pitch-mode", "SRS");
}
if (newvertarm != "CLB") {
setprop("/modes/pfd/fma/pitch-mode2-armed", "CLB");
}
2017-04-03 17:55:10 +00:00
} else if (vert == "G/A CLB") {
2017-06-05 17:28:38 +00:00
if (newvert != "SRS") {
setprop("/modes/pfd/fma/pitch-mode", "SRS");
}
if (newvertarm != "ALT") {
setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT");
2017-04-03 17:55:10 +00:00
}
}
2017-06-05 17:28:38 +00:00
});
2017-04-03 17:55:10 +00:00
2017-05-24 22:24:51 +00:00
# Arm HDG or NAV
setlistener("/it-autoflight/mode/arm", func {
var arm = getprop("/it-autoflight/mode/arm");
2017-06-05 17:28:38 +00:00
var newarm = getprop("/modes/pfd/fma/roll-mode-armed");
2017-05-24 22:24:51 +00:00
if (arm == "HDG") {
2017-06-05 17:28:38 +00:00
if (newarm != "HDG") {
2017-06-05 17:45:51 +00:00
setprop("/modes/pfd/fma/roll-mode-armed", " ");
2017-06-05 17:28:38 +00:00
}
2017-05-24 22:24:51 +00:00
} else if (arm == "LNV") {
2017-06-05 17:28:38 +00:00
if (newarm != "NAV") {
setprop("/modes/pfd/fma/roll-mode-armed", "NAV");
}
2017-05-24 22:24:51 +00:00
} else if (arm == " ") {
2017-06-05 17:28:38 +00:00
if (newarm != " ") {
setprop("/modes/pfd/fma/roll-mode-armed", " ");
}
2017-05-24 22:24:51 +00:00
}
});
2016-11-05 03:39:28 +00:00
# Arm LOC
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/output/loc-armed", func {
2017-04-03 17:55:10 +00:00
var loca = getprop("/it-autoflight/output/loc-armed");
2017-06-05 17:28:38 +00:00
var newarm = getprop("/modes/pfd/fma/roll-mode-armed");
2017-04-03 17:55:10 +00:00
if (loca) {
2017-06-05 17:28:38 +00:00
if (newarm != "LOC") {
setprop("/modes/pfd/fma/roll-mode-armed", "LOC");
}
2017-04-03 17:55:10 +00:00
} else {
2017-06-05 17:28:38 +00:00
if (newarm != " ") {
setprop("/modes/pfd/fma/roll-mode-armed", " ");
}
2017-04-03 17:55:10 +00:00
}
2016-11-05 03:39:28 +00:00
});
# Arm G/S
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/output/appr-armed", func {
2017-04-03 17:55:10 +00:00
var appa = getprop("/it-autoflight/output/appr-armed");
2017-06-05 17:28:38 +00:00
var newvert2arm = getprop("/modes/pfd/fma/pitch-mode-armed");
2017-04-03 17:55:10 +00:00
if (appa) {
2017-06-05 17:28:38 +00:00
if (newvert2arm != "G/S") {
setprop("/modes/pfd/fma/pitch-mode-armed", "G/S");
}
2017-04-03 17:55:10 +00:00
} else {
2017-06-05 17:28:38 +00:00
if (newvert2arm != " ") {
setprop("/modes/pfd/fma/pitch-mode-armed", " ");
}
2017-04-03 17:55:10 +00:00
}
2016-11-05 03:39:28 +00:00
});
# AP
var ap = func {
2017-04-03 17:55:10 +00:00
var ap1 = getprop("/it-autoflight/output/ap1");
var ap2 = getprop("/it-autoflight/output/ap2");
if (ap1 and ap2) {
setprop("/modes/pfd/fma/ap-mode", "AP1+2");
} else if (ap1 and !ap2) {
setprop("/modes/pfd/fma/ap-mode", "AP1");
} else if (ap2 and !ap1) {
setprop("/modes/pfd/fma/ap-mode", "AP2");
} else {
setprop("/modes/pfd/fma/ap-mode", " ");
}
2016-11-05 03:39:28 +00:00
}
# FD
var fd = func {
2017-04-03 17:55:10 +00:00
var fd1 = getprop("/it-autoflight/output/fd1");
var fd2 = getprop("/it-autoflight/output/fd2");
if (fd1 and fd2) {
setprop("/modes/pfd/fma/fd-mode", "1FD2");
} else if (fd1 and !fd2) {
setprop("/modes/pfd/fma/fd-mode", "1FD-");
} else if (fd2 and !fd1) {
setprop("/modes/pfd/fma/fd-mode", "-FD2");
} else {
setprop("/modes/pfd/fma/fd-mode", " ");
}
2016-11-05 03:39:28 +00:00
}
# AT
var at = func {
2017-04-03 17:55:10 +00:00
var at = getprop("/it-autoflight/output/athr");
if (at) {
setprop("/modes/pfd/fma/at-mode", "A/THR");
} else {
setprop("/modes/pfd/fma/at-mode", " ");
}
2016-11-05 03:39:28 +00:00
}
2017-06-06 01:45:41 +00:00
var boxchk = func {
var ap1 = getprop("/it-autoflight/output/ap1");
var ap2 = getprop("/it-autoflight/output/ap2");
var fd1 = getprop("/it-autoflight/output/fd1");
var fd2 = getprop("/it-autoflight/output/fd2");
var fma_pwr = getprop("/it-autoflight/output/fma-pwr");
if (ap1 and !ap2 and !fd1 and !fd2 and !fma_pwr) {
setprop("/it-autoflight/input/lat", 3);
boxchk_b();
} else if (!ap1 and ap2 and !fd1 and !fd2 and !fma_pwr) {
setprop("/it-autoflight/input/lat", 3);
boxchk_b();
} else if (!ap1 and !ap2 and fd1 and !fd2 and !fma_pwr) {
setprop("/it-autoflight/input/lat", 3);
boxchk_b();
} else if (!ap1 and !ap2 and !fd1 and fd2 and !fma_pwr) {
setprop("/it-autoflight/input/lat", 3);
boxchk_b();
}
}
var boxchk_b = func {
setprop("/modes/pfd/fma/roll-mode-box", 1);
setprop("/modes/pfd/fma/pitch-mode-box", 1);
settimer(func {
setprop("/modes/pfd/fma/roll-mode-box", 0);
}, 5);
settimer(func {
setprop("/modes/pfd/fma/pitch-mode-box", 0);
}, 5);
var newarmr = getprop("/modes/pfd/fma/roll-mode-armed");
if (newarmr != " ") {
setprop("/modes/pfd/fma/roll-mode-armed-box", 1);
settimer(func {
setprop("/modes/pfd/fma/roll-mode-armed-box", 0);
}, 5);
}
var newarmp = getprop("/modes/pfd/fma/pitch-mode-armed");
if (newarmp != " ") {
setprop("/modes/pfd/fma/pitch-mode-armed-box", 1);
settimer(func {
setprop("/modes/pfd/fma/pitch-mode-armed-box", 0);
}, 5);
}
var newarmp2 = getprop("/modes/pfd/fma/pitch-mode2-armed");
if (newarmp2 != " ") {
setprop("/modes/pfd/fma/pitch-mode2-armed-box", 1);
settimer(func {
setprop("/modes/pfd/fma/pitch-mode2-armed-box", 0);
}, 5);
}
}
2016-12-05 20:20:56 +00:00
# Update AP FD ATHR
setlistener("/it-autoflight/output/ap1", func {
2017-06-06 01:45:41 +00:00
speedmach();
2017-04-03 17:55:10 +00:00
ap();
2017-06-06 01:45:41 +00:00
boxchk();
2016-11-05 03:39:28 +00:00
});
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/output/ap2", func {
2017-06-06 01:45:41 +00:00
speedmach();
2017-04-03 17:55:10 +00:00
ap();
2017-06-06 01:45:41 +00:00
boxchk();
2016-11-05 03:39:28 +00:00
});
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/output/fd1", func {
2017-05-07 23:18:38 +00:00
speedmach();
2017-04-03 17:55:10 +00:00
fd();
2017-06-06 01:45:41 +00:00
boxchk();
2016-11-05 03:39:28 +00:00
});
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/output/fd2", func {
2017-05-07 23:18:38 +00:00
speedmach();
2017-04-03 17:55:10 +00:00
fd();
2017-06-06 01:45:41 +00:00
boxchk();
2016-11-05 03:39:28 +00:00
});
2016-12-05 20:20:56 +00:00
setlistener("/it-autoflight/output/athr", func {
2017-04-03 17:55:10 +00:00
at();
2016-11-05 03:39:28 +00:00
});
2017-06-05 17:28:38 +00:00
# Boxes
setlistener("/modes/pfd/fma/throttle-mode", func {
setprop("/modes/pfd/fma/throttle-mode-box", 1);
settimer(func {
setprop("/modes/pfd/fma/throttle-mode-box", 0);
}, 5);
});
setlistener("/modes/pfd/fma/roll-mode", func {
setprop("/modes/pfd/fma/roll-mode-box", 1);
settimer(func {
setprop("/modes/pfd/fma/roll-mode-box", 0);
}, 5);
});
setlistener("/modes/pfd/fma/pitch-mode", func {
setprop("/modes/pfd/fma/pitch-mode-box", 1);
settimer(func {
setprop("/modes/pfd/fma/pitch-mode-box", 0);
}, 5);
});
setlistener("/modes/pfd/fma/roll-mode-armed", func {
var newarm = getprop("/modes/pfd/fma/roll-mode-armed");
if (newarm != " ") {
setprop("/modes/pfd/fma/roll-mode-armed-box", 1);
settimer(func {
setprop("/modes/pfd/fma/roll-mode-armed-box", 0);
}, 5);
}
});
setlistener("/modes/pfd/fma/pitch-mode-armed", func {
var newarm = getprop("/modes/pfd/fma/pitch-mode-armed");
if (newarm != " ") {
setprop("/modes/pfd/fma/pitch-mode-armed-box", 1);
settimer(func {
setprop("/modes/pfd/fma/pitch-mode-armed-box", 0);
}, 5);
}
});
setlistener("/modes/pfd/fma/pitch-mode2-armed", func {
var newarm = getprop("/modes/pfd/fma/pitch-mode2-armed");
if (newarm != " ") {
setprop("/modes/pfd/fma/pitch-mode2-armed-box", 1);
settimer(func {
setprop("/modes/pfd/fma/pitch-mode2-armed-box", 0);
}, 5);
}
});