2017-06-03 15:53:36 +00:00
# Airbus PFD FMA
2017-07-02 00:00:18 +00:00
# Joshua Davidson (it0uchpods)
2016-11-05 03:39:28 +00:00
2017-08-16 20:53:35 +00:00
#########################################
# Copyright (c) it0uchpods Design Group #
#########################################
2017-07-13 17:30:33 +00:00
2017-06-13 18:20:03 +00:00
setprop("/FMGC/internal/cruise-ft", 10000);
setprop("/it-autoflight/internal/alt", 10000);
2017-10-19 04:05:42 +00:00
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", " ");
2017-10-25 02:50:31 +00:00
setprop("/modes/pfd/fma/athr-armed", 0);
2017-10-19 04:05:42 +00:00
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);
2017-10-25 02:38:24 +00:00
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);
2017-06-13 18:20:03 +00:00
2017-07-02 00:00:18 +00:00
setlistener("sim/signals/fdm-initialized", func {
2017-09-17 19:22:36 +00:00
loopFMA.start();
2017-07-02 00:00:18 +00:00
});
# Master Thrust
2017-09-17 19:22:36 +00:00
var loopFMA = maketimer(0.05, func {
2017-07-02 00:00:18 +00:00
var state1 = getprop("/systems/thrust/state1");
var state2 = getprop("/systems/thrust/state2");
var newthr = getprop("/modes/pfd/fma/throttle-mode");
if (state1 == "TOGA" or state2 == "TOGA") {
if (newthr != " ") {
setprop("/modes/pfd/fma/throttle-mode", " ");
}
} else if (state1 == "MCT" or state2 == "MCT") {
if (newthr != " ") {
setprop("/modes/pfd/fma/throttle-mode", " ");
}
} else if (state1 == "MAN THR" or state2 == "MAN THR") {
if (newthr != " ") {
setprop("/modes/pfd/fma/throttle-mode", " ");
}
} else {
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) {
2017-09-17 19:22:36 +00:00
loopFMA_b();
2017-07-02 00:00:18 +00:00
} else {
var thr = getprop("/it-autoflight/output/thr-mode");
if (thr == 0) {
2017-09-17 19:22:36 +00:00
loopFMA_b();
2017-07-02 00:00:18 +00:00
} else if (thr == 1) {
if (newthr != "THR IDLE") {
setprop("/modes/pfd/fma/throttle-mode", "THR IDLE");
}
} else if (thr == 2) {
if (state1 == "CL" or state2 == "CL") {
if (newthr != "THR CLB") {
setprop("/modes/pfd/fma/throttle-mode", "THR CLB");
}
} else {
if (newthr != "THR LVR") {
setprop("/modes/pfd/fma/throttle-mode", "THR LVR");
}
}
2017-06-05 17:28:38 +00:00
}
2017-05-07 23:18:38 +00:00
}
2017-07-02 00:00:18 +00:00
} else {
2017-09-17 19:22:36 +00:00
loopFMA_b();
}
}
2017-10-25 02:50:31 +00:00
# A/THR Armed/Active
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")) {
if (getprop("/modes/pfd/fma/athr-armed") != 1) {
setprop("/modes/pfd/fma/athr-armed", 1);
}
} else {
if (getprop("/modes/pfd/fma/athr-armed") != 0) {
setprop("/modes/pfd/fma/athr-armed", 0);
}
}
2017-09-17 19:22:36 +00:00
# SRS RWY Engagement
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");
2017-10-25 02:50:31 +00:00
var thr2 = getprop("/controls/engines/engine[1]/throttle-pos");
2017-10-26 14:51:27 +00:00
var wow = getprop("/gear/gear[0]/wow");
2017-10-26 18:59:38 +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)))) {
2017-10-24 22:57:27 +00:00
# RWY Engagement would go here, but automatic ILS selection is not simulated yet.
2017-10-26 18:59:38 +00:00
if (wow and getprop("/FMGC/internal/v2-set") == 1 and getprop("/it-autoflight/output/vert") != 7) {
2017-10-24 22:57:27 +00:00
setprop("/it-autoflight/input/vert", 7);
setprop("/it-autoflight/mode/vert", "T/O CLB");
fmgc.vertical();
2017-09-17 19:22:36 +00:00
}
} else {
var gear1 = getprop("/gear/gear[1]/wow");
var gear2 = getprop("/gear/gear[2]/wow");
2017-10-24 22:57:27 +00:00
if (getprop("/it-autoflight/input/lat") == 5 and (gear1 or gear2)) {
setprop("/it-autoflight/input/lat", 9);
fmgc.lateral();
2017-09-17 19:22:36 +00:00
}
2017-10-24 22:57:27 +00:00
if (getprop("/it-autoflight/output/vert") == 7 and (gear1 or gear2)) {
setprop("/it-autoflight/input/vert", 9);
fmgc.vertical();
2017-04-03 17:55:10 +00:00
}
2017-05-07 23:18:38 +00:00
}
2017-10-21 02:51:30 +00:00
var trk = getprop("/it-autoflight/custom/trk-fpa");
if (lat == "HDG" and trk == 0) {
if (newlat != "HDG") {
setprop("/modes/pfd/fma/roll-mode", "HDG");
}
} else if (lat == "HDG" and trk == 1) {
if (newlat != "TRACK") {
setprop("/modes/pfd/fma/roll-mode", "TRACK");
}
}
2017-10-25 02:38:24 +00:00
# Boxes
var boxtime = getprop("/sim/time/elapsed-sec");
if (getprop("/modes/pfd/fma/ap-mode-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/ap-mode-box", 1);
} else {
setprop("/modes/pfd/fma/ap-mode-box", 0);
}
if (getprop("/modes/pfd/fma/fd-mode-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/fd-mode-box", 1);
} else {
setprop("/modes/pfd/fma/fd-mode-box", 0);
}
if (getprop("/modes/pfd/fma/athr-mode-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/athr-mode-box", 1);
} else {
setprop("/modes/pfd/fma/athr-mode-box", 0);
}
if (getprop("/modes/pfd/fma/throttle-mode-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/throttle-mode-box", 1);
} else {
setprop("/modes/pfd/fma/throttle-mode-box", 0);
}
if (getprop("/modes/pfd/fma/roll-mode-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/roll-mode-box", 1);
} else {
setprop("/modes/pfd/fma/roll-mode-box", 0);
}
if (getprop("/modes/pfd/fma/pitch-mode-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/pitch-mode-box", 1);
} else {
setprop("/modes/pfd/fma/pitch-mode-box", 0);
}
if (getprop("/modes/pfd/fma/roll-mode-armed-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/roll-mode-armed-box", 1);
} else {
setprop("/modes/pfd/fma/roll-mode-armed-box", 0);
}
if (getprop("/modes/pfd/fma/pitch-mode-armed-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/pitch-mode-armed-box", 1);
} else {
setprop("/modes/pfd/fma/pitch-mode-armed-box", 0);
}
if (getprop("/modes/pfd/fma/pitch-mode2-armed-time") + 10 >= boxtime) {
setprop("/modes/pfd/fma/pitch-mode2-armed-box", 1);
} else {
setprop("/modes/pfd/fma/pitch-mode2-armed-box", 0);
}
2017-07-02 00:00:18 +00:00
});
2017-05-07 23:18:38 +00:00
2017-09-17 19:22:36 +00:00
var loopFMA_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
}
2017-06-21 03:25:51 +00:00
# Master Lateral
setlistener("/it-autoflight/mode/lat", func {
var lat = getprop("/it-autoflight/mode/lat");
var newlat = getprop("/modes/pfd/fma/roll-mode");
2017-10-21 02:51:30 +00:00
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-07-03 23:46:42 +00:00
if (newlat != "LOC*" and newlat != "LOC") {
setprop("/modes/pfd/fma/roll-mode", "LOC*");
locupdate.start();
2017-06-05 17:28:38 +00:00
}
2017-04-03 17:55:10 +00:00
} else if (lat == "ALGN") {
2017-10-08 19:56:15 +00:00
if (newlat != " ") {
setprop("/modes/pfd/fma/roll-mode", " ");
}
} else if (lat == "RLOU") {
if (newlat != " ") {
setprop("/modes/pfd/fma/roll-mode", " ");
2017-06-05 17:28:38 +00:00
}
2017-10-24 22:57:27 +00:00
} else if (lat == "T/O") {
if (newlat != "RWY") {
setprop("/modes/pfd/fma/roll-mode", "RWY");
}
} else if (lat == " ") {
if (newlat != " ") {
setprop("/modes/pfd/fma/roll-mode", " ");
}
2017-04-03 17:55:10 +00:00
}
2016-11-05 03:39:28 +00:00
});
2017-07-03 23:46:42 +00:00
var locupdate = maketimer(0.5, func {
var lat = getprop("/it-autoflight/mode/lat");
var newlat = getprop("/modes/pfd/fma/roll-mode");
var nav_defl = getprop("/it-autoflight/internal/nav-heading-error-deg");
if (lat == "LOC") {
if (nav_defl > -1 and nav_defl < 1) {
locupdate.stop();
if (newlat != "LOC") {
setprop("/modes/pfd/fma/roll-mode", "LOC");
}
}
}
});
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-13 16:45:05 +00:00
altvert();
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 == "ALT CAP") {
2017-06-13 16:45:05 +00:00
altvert();
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-07-03 23:46:42 +00:00
if (newvert != "G/S*" and newvert != "G/S") {
setprop("/modes/pfd/fma/pitch-mode", "G/S*");
gsupdate.start();
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 == "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-10-08 19:56:15 +00:00
} else if (vert == "ROLLOUT") {
2017-10-19 01:53:38 +00:00
if (newvert != "ROLL OUT") {
setprop("/modes/pfd/fma/pitch-mode", "ROLL OUT");
2017-10-08 19:56:15 +00:00
}
2017-04-03 17:55:10 +00:00
} else if (vert == "T/O CLB") {
2017-10-24 22:57:27 +00:00
if (newvert != "SRS") {
setprop("/modes/pfd/fma/pitch-mode", "SRS");
2017-06-05 17:28:38 +00:00
}
2017-10-24 22:57:27 +00:00
updatePitchArm2();
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") {
2017-06-13 18:20:03 +00:00
setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT");
}
2017-06-13 19:24:56 +00:00
} else if (vert == "MNG HLD") {
if (newvert != "ALT") {
setprop("/modes/pfd/fma/pitch-mode", "ALT");
}
if (newvertarm != " ") {
setprop("/modes/pfd/fma/pitch-mode2-armed", " ");
}
} else if (vert == "MNG CAP") {
if (newvert != "ALT*") {
setprop("/modes/pfd/fma/pitch-mode", "ALT*");
}
if (newvertarm != " ") {
setprop("/modes/pfd/fma/pitch-mode2-armed", " ");
}
2017-06-13 18:20:03 +00:00
} else if (vert == "MNG CLB") {
if (newvert != "CLB") {
setprop("/modes/pfd/fma/pitch-mode", "CLB");
}
if (newvertarm != "ALT") {
setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT");
}
} else if (vert == "MNG DES") {
if (newvert != "DES") {
setprop("/modes/pfd/fma/pitch-mode", "DES");
}
if (newvertarm != "ALT") {
2017-06-05 17:28:38 +00:00
setprop("/modes/pfd/fma/pitch-mode2-armed", "ALT");
2017-04-03 17:55:10 +00:00
}
2017-10-24 22:57:27 +00:00
} else if (vert == " ") {
if (newvert != " ") {
setprop("/modes/pfd/fma/pitch-mode", " ");
}
updatePitchArm2();
2017-04-03 17:55:10 +00:00
}
2017-06-13 16:45:05 +00:00
altvert();
2017-06-05 17:28:38 +00:00
});
2017-04-03 17:55:10 +00:00
2017-10-24 22:57:27 +00:00
setlistener("/FMGC/internal/v2-set", func {
updatePitchArm2();
});
var updatePitchArm2 = func {
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", " ");
}
}
2017-07-03 23:46:42 +00:00
var gsupdate = maketimer(0.5, func {
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");
if (vert == "G/S") {
if (gs_defl > -0.06 and gs_defl < 0.06) {
gsupdate.stop();
if (newvert != "G/S") {
setprop("/modes/pfd/fma/pitch-mode", "G/S");
}
}
}
});
2017-06-13 16:45:05 +00:00
var altvert = func {
var FMGCalt = getprop("/FMGC/internal/cruise-ft");
var MCPalt = getprop("/it-autoflight/internal/alt");
var ALTdif = abs(FMGCalt - MCPalt);
var vert = getprop("/it-autoflight/mode/vert");
var newvert = getprop("/modes/pfd/fma/pitch-mode");
if (ALTdif <= 20) {
if (vert == "ALT HLD") {
if (newvert != "ALT CRZ") {
setprop("/modes/pfd/fma/pitch-mode", "ALT CRZ");
}
} else if (vert == "ALT CAP") {
if (newvert != "ALT CRZ*") {
setprop("/modes/pfd/fma/pitch-mode", "ALT CRZ*");
}
}
} else {
if (vert == "ALT HLD") {
if (newvert != "ALT") {
setprop("/modes/pfd/fma/pitch-mode", "ALT");
}
} else if (vert == "ALT CAP") {
if (newvert != "ALT*") {
setprop("/modes/pfd/fma/pitch-mode", "ALT*");
}
}
}
}
setlistener("/FMGC/internal/cruise-ft", altvert);
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");
2017-06-11 03:59:15 +00:00
var newap = getprop("/modes/pfd/fma/ap-mode");
if (ap1 and ap2 and newap != "AP1+2") {
2017-10-19 04:05:42 +00:00
setprop("/modes/pfd/fma/ap-mode", "AP 1+2");
} else if (ap1 and !ap2 and newap != "AP 1") {
setprop("/modes/pfd/fma/ap-mode", "AP 1");
} else if (ap2 and !ap1 and newap != "AP 2") {
setprop("/modes/pfd/fma/ap-mode", "AP 2");
2017-06-11 03:59:15 +00:00
} else if (!ap1 and !ap2) {
2017-04-03 17:55:10 +00:00
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");
2017-06-11 03:59:15 +00:00
var newfd = getprop("/modes/pfd/fma/fd-mode");
if (fd1 and fd2 and newfd != "1FD2") {
2017-10-19 04:05:42 +00:00
setprop("/modes/pfd/fma/fd-mode", "1 FD 2");
} else if (fd1 and !fd2 and newfd != "1 FD -") {
setprop("/modes/pfd/fma/fd-mode", "1 FD -");
} else if (fd2 and !fd1 and newfd != "- FD 2") {
setprop("/modes/pfd/fma/fd-mode", "- FD 2");
2017-06-11 03:59:15 +00:00
} else if (!fd1 and !fd2) {
2017-04-03 17:55:10 +00:00
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");
2017-06-11 03:59:15 +00:00
var newat = getprop("/modes/pfd/fma/at-mode");
if (at and newat != "A/THR") {
2017-04-03 17:55:10 +00:00
setprop("/modes/pfd/fma/at-mode", "A/THR");
2017-06-11 03:59:15 +00:00
} else if (!at) {
2017-04-03 17:55:10 +00:00
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 {
2017-09-17 19:22:36 +00:00
var newlat = getprop("/modes/pfd/fma/roll-mode");
if (newlat != " ") {
setprop("/modes/pfd/fma/roll-mode-box", 1);
settimer(func {
setprop("/modes/pfd/fma/roll-mode-box", 0);
}, 5);
}
var newvert = getprop("/modes/pfd/fma/pitch-mode");
if (newvert != " ") {
setprop("/modes/pfd/fma/pitch-mode-box", 1);
settimer(func {
setprop("/modes/pfd/fma/pitch-mode-box", 0);
}, 5);
}
2017-06-06 01:45:41 +00:00
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-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-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-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-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
2017-06-11 03:59:15 +00:00
setlistener("/modes/pfd/fma/ap-mode", func {
if (getprop("/modes/pfd/fma/ap-mode") != " ") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/ap-mode-time", getprop("/sim/time/elapsed-sec"));
2017-06-11 03:59:15 +00:00
}
});
setlistener("/modes/pfd/fma/fd-mode", func {
if (getprop("/modes/pfd/fma/fd-mode") != " ") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/fd-mode-time", getprop("/sim/time/elapsed-sec"));
2017-06-11 03:59:15 +00:00
}
});
setlistener("/modes/pfd/fma/at-mode", func {
if (getprop("/modes/pfd/fma/at-mode") != " ") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/throttle-mode-time", getprop("/sim/time/elapsed-sec"));
setprop("/modes/pfd/fma/athr-mode-time", getprop("/sim/time/elapsed-sec"));
2017-06-11 03:59:15 +00:00
}
});
2017-10-25 02:50:31 +00:00
setlistener("/modes/pfd/fma/athr-armed", func {
if (getprop("/modes/pfd/fma/at-mode") != " ") {
setprop("/modes/pfd/fma/athr-mode-time", getprop("/sim/time/elapsed-sec"));
}
});
2017-06-05 17:28:38 +00:00
setlistener("/modes/pfd/fma/throttle-mode", func {
2017-06-11 03:59:15 +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") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/throttle-mode-time", getprop("/sim/time/elapsed-sec"));
2017-06-11 03:59:15 +00:00
}
2017-06-05 17:28:38 +00:00
});
setlistener("/modes/pfd/fma/roll-mode", func {
2017-09-17 19:22:36 +00:00
var newlat = getprop("/modes/pfd/fma/roll-mode");
if (newlat != " ") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/roll-mode-time", getprop("/sim/time/elapsed-sec"));
2017-09-17 19:22:36 +00:00
}
2017-06-05 17:28:38 +00:00
});
setlistener("/modes/pfd/fma/pitch-mode", func {
2017-09-17 19:22:36 +00:00
var newvert = getprop("/modes/pfd/fma/pitch-mode");
if (newvert != " ") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/pitch-mode-time", getprop("/sim/time/elapsed-sec"));
2017-09-17 19:22:36 +00:00
}
2017-06-05 17:28:38 +00:00
});
setlistener("/modes/pfd/fma/roll-mode-armed", func {
var newarm = getprop("/modes/pfd/fma/roll-mode-armed");
if (newarm != " ") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/roll-mode-armed-time", getprop("/sim/time/elapsed-sec"));
2017-06-05 17:28:38 +00:00
}
});
setlistener("/modes/pfd/fma/pitch-mode-armed", func {
var newarm = getprop("/modes/pfd/fma/pitch-mode-armed");
if (newarm != " ") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/pitch-mode-armed-time", getprop("/sim/time/elapsed-sec"));
2017-06-05 17:28:38 +00:00
}
});
setlistener("/modes/pfd/fma/pitch-mode2-armed", func {
var newarm = getprop("/modes/pfd/fma/pitch-mode2-armed");
if (newarm != " ") {
2017-10-25 02:38:24 +00:00
setprop("/modes/pfd/fma/pitch-mode2-armed-time", getprop("/sim/time/elapsed-sec"));
2017-06-05 17:28:38 +00:00
}
});