2019-10-14 16:48:35 +00:00
# A3XX FMGC/Autoflight
2021-04-23 17:21:07 +00:00
# Copyright (c) 2021 Josh Davidson (Octal450) and Jonathan Redpath (legoboyvdlp)
2019-10-14 16:48:35 +00:00
2020-10-03 09:29:57 +00:00
var at = nil;
var athr = nil;
var elapsedtime = nil;
var engout = nil;
var engstate1 = nil;
var engstate2 = nil;
var flx = nil;
var latText = nil;
var state1 = nil;
var state2 = nil;
var thr = nil;
var trk = nil;
var vert = nil;
var vertText = nil;
2019-10-14 16:48:35 +00:00
2020-10-03 09:29:57 +00:00
var Modes = {
FCU: {
2022-01-10 13:53:07 +00:00
hdgTime: -45,
2020-10-03 09:29:57 +00:00
},
PFD: {
FMA: {
2022-01-10 13:53:07 +00:00
apMode: " ",
apModeBox: 0,
apModeTime: 0,
athrArmed: 0,
athrMode: " ",
athrModeBox: 0,
athrModeTime: 0,
fdMode: " ",
fdModeBox: 0,
fdModeTime: 0,
rollMode: " ",
rollModeBox: 0,
rollModeArmed: " ",
rollModeArmedBox: 0,
rollModeTime: 0,
rollModeArmedTime: 0,
pitchMode: " ",
pitchModeBox: 0,
pitchModeArmed: " ",
pitchModeArmedBox: 0,
pitchMode2Armed: " ",
pitchModeTime: 0,
pitchModeArmedTime: 0,
pitchMode2ArmedTime: 0,
pitchMode2ArmedBox: 0,
throttle: " ",
throttleModeBox: 0,
throttleModeTime: 0,
2020-10-03 09:29:57 +00:00
},
},
};
2022-01-10 13:53:07 +00:00
var setFmaText = func(node, value, callback, timerNode) {
Modes.PFD.FMA[node] = value;
call(callback, [node, timerNode]);
};
var genericCallback = func(modeNode, timerNode) {
if (Modes.PFD.FMA[modeNode] != " ") {
Modes.PFD.FMA[timerNode] = pts.Sim.Time.elapsedSec.getValue();
}
}
var athrCallback = func(modeNode, timerNode) {
if (Modes.PFD.FMA[modeNode] != " ") {
elapsedtime = pts.Sim.Time.elapsedSec.getValue();
Modes.PFD.FMA[timerNode] = elapsedtime;
Modes.PFD.FMA.throttleModeTime = elapsedtime;
}
}
var throttleModeCallback = func(modeNode, timerNode) {
state1 = systems.FADEC.detentText[0].getValue();
state2 = systems.FADEC.detentText[1].getValue();
athr = Output.athr.getValue();
if (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
!systems.FADEC.engOut.getValue()) {
Modes.PFD.FMA[timerNode] = pts.Sim.Time.elapsedSec.getValue();
} else if (athr == 1 and state1 != "TOGA" and state2 != "TOGA" and state1 != "IDLE" and state2 != "IDLE" and systems.FADEC.engOut.getValue()) {
if (systems.FADEC.detent[0].getValue() <= 4 and systems.FADEC.detent[1].getValue() <= 4) {
Modes.PFD.FMA[timerNode] = pts.Sim.Time.elapsedSec.getValue();
}
}
}
var fma_init = func() {
2020-10-03 09:29:57 +00:00
Internal.alt.setValue(10000);
2022-01-10 13:53:07 +00:00
setFmaText("apMode", " ", genericCallback, "apModeTime");
setFmaText("athrMode", " ", athrCallback, "athrModeTime");
setFmaText("fdMode", " ", genericCallback, "fdModeTime");
setFmaText("pitchMode", " ", genericCallback, "pitchModeTime");
setFmaText("pitchModeArmed", " ", genericCallback, "pitchModeArmedTime");
setFmaText("pitchMode2Armed", " ", genericCallback, "pitchMode2ArmedTime");
setFmaText("rollMode", " ", genericCallback, "rollModeTime");
setFmaText("rollModeArmed", " ", genericCallback, "rollModeArmedTime");
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
Modes.PFD.FMA.apModeBox = 0;
Modes.PFD.FMA.athrModeBox = 0;
Modes.PFD.FMA.fdModeBox = 0;
Modes.PFD.FMA.pitchModeBox = 0;
Modes.PFD.FMA.pitchModeArmedBox = 0;
Modes.PFD.FMA.pitchMode2ArmedBox = 0;
Modes.PFD.FMA.rollModeBox = 0;
Modes.PFD.FMA.rollModeArmedBox = 0;
Modes.PFD.FMA.throttleModeBox = 0;
Modes.PFD.FMA.apModeTime = 0;
Modes.PFD.FMA.athrModeTime = 0;
Modes.PFD.FMA.fdModeTime = 0;
Modes.PFD.FMA.pitchModeTime = 0;
Modes.PFD.FMA.pitchModeArmedTime = 0;
Modes.PFD.FMA.pitchMode2ArmedTime = 0;
Modes.PFD.FMA.rollModeTime = 0;
Modes.PFD.FMA.rollModeArmedTime = 0;
Modes.PFD.FMA.throttleModeTime = 0;
2019-10-14 16:48:35 +00:00
loopFMA.start();
2020-10-03 09:29:57 +00:00
};
2019-10-14 16:48:35 +00:00
# Master Thrust
2022-01-09 19:55:30 +00:00
var loopFMA = maketimer(0.05, func() {
2021-04-22 21:44:17 +00:00
state1 = systems.FADEC.detentText[0].getValue();
state2 = systems.FADEC.detentText[1].getValue();
engout = systems.FADEC.engOut.getValue();
2020-10-03 09:29:57 +00:00
2019-10-14 16:48:35 +00:00
if (state1 == "TOGA" or state2 == "TOGA") {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
2021-04-22 21:44:17 +00:00
} else if ((state1 == "MAN THR" and systems.FADEC.manThrAboveMct[0]) or (state2 == "MAN THR" and systems.FADEC.manThrAboveMct[1])) {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
2020-10-03 09:29:57 +00:00
} else if ((state1 == "MCT" or state2 == "MCT") and !engout) {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
2021-04-22 21:44:17 +00:00
} else if (((state1 == "MAN THR" and !systems.FADEC.manThrAboveMct[0]) or (state2 == "MAN THR" and !systems.FADEC.manThrAboveMct[1])) and !engout) {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
2019-10-14 16:48:35 +00:00
} else {
2020-10-03 09:29:57 +00:00
vert = Output.vert.getValue();
if (vert == 4 or vert >= 6 or vert <= 8) {
if (Output.ap1.getBoolValue() or Output.ap2.getBoolValue() or Output.fd1.getBoolValue() or Output.fd2.getBoolValue()) {
thr = Output.thrMode.getValue();
2019-10-14 16:48:35 +00:00
if (thr == 0) {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", Input.ktsMach.getValue() ? "MACH" : "SPEED", throttleModeCallback, "throttleModeTime");
2019-10-14 16:48:35 +00:00
} else if (thr == 1) {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", "THR IDLE", throttleModeCallback, "throttleModeTime");
2019-10-14 16:48:35 +00:00
} else if (thr == 2) {
2020-10-03 09:29:57 +00:00
if (state1 == "MCT" or state2 == "MCT" and engout) {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", "THR MCT", throttleModeCallback, "throttleModeTime");
2019-10-14 16:48:35 +00:00
} else if (state1 == "CL" or state2 == "CL") {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", "THR CLB", throttleModeCallback, "throttleModeTime");
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", "THR LVR", throttleModeCallback, "throttleModeTime");
2019-10-14 16:48:35 +00:00
}
}
2020-10-03 09:29:57 +00:00
} else {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", Input.ktsMach.getValue() ? "MACH" : "SPEED", throttleModeCallback, "throttleModeTime");
2019-10-14 16:48:35 +00:00
}
} else {
2022-01-10 13:53:07 +00:00
setFmaText("throttle", Input.ktsMach.getValue() ? "MACH" : "SPEED", throttleModeCallback, "throttleModeTime");
2019-10-14 16:48:35 +00:00
}
}
# A/THR Armed/Active
2020-10-03 09:29:57 +00:00
athr = Output.athr.getValue();
if (athr and (state1 == "MAN THR" or state2 == "MAN THR" or state1 == "MCT" or state2 == "MCT" or state1 == "TOGA" or state2 == "TOGA") and engout != 1) {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.athrArmed = 1;
2021-04-22 21:44:17 +00:00
} else if (athr and ((state1 == "MAN THR" and systems.FADEC.manThrAboveMct[0]) or (state2 == "MAN THR" and systems.FADEC.manThrAboveMct[1]) or (systems.FADEC.Limit.activeMode.getValue() == "FLX" and (state1 == "MCT" or state2 == "MCT"))
2020-10-03 09:29:57 +00:00
or state1 == "TOGA" or state2 == "TOGA") and engout) {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.athrArmed = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.athrArmed = 0;
2019-10-14 16:48:35 +00:00
}
# SRS RWY Engagement
2022-01-09 19:55:30 +00:00
if (pts.Gear.wow[1].getValue() or pts.Gear.wow[2].getValue()) {
flx = systems.FADEC.Limit.flexActive.getBoolValue();
engstate1 = pts.Engines.Engine.state[0].getValue();
engstate2 = pts.Engines.Engine.state[1].getValue();
if (((state1 == "TOGA" or state2 == "TOGA") or (flx == 1 and (state1 == "MCT" or state2 == "MCT")) or (flx == 1 and ((state1 == "MAN THR" and systems.FADEC.manThrAboveMct[0]) or (state2 == "MAN THR" and systems.FADEC.manThrAboveMct[1])))) and (engstate1 == 3 or engstate2 == 3)) {
# RWY Engagement would go here, but automatic ILS selection is not simulated yet.
if (FMGCInternal.v2set and Output.vert.getValue() != 7) {
ITAF.setVertMode(7);
ITAF.updateVertText("T/O CLB");
}
} else {
if (Input.lat.getValue() == 5) {
ITAF.setLatMode(9);
}
if (Input.vert.getValue() == 7) {
ITAF.setVertMode(9);
}
2019-10-14 16:48:35 +00:00
}
}
# Boxes
2020-10-03 09:29:57 +00:00
elapsedtime = pts.Sim.Time.elapsedSec.getValue();
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.apModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.apModeBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.apModeBox = 0;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.fdModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.fdModeBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.fdModeBox = 0;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.athrModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.athrModeBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.athrModeBox = 0;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.throttleModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.throttleModeBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.throttleModeBox = 0;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.rollModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.rollModeBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.rollModeBox = 0;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchModeBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.pitchModeBox = 0;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.rollModeArmedTime + 10 >= elapsedtime) {
Modes.PFD.FMA.rollModeArmedBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.rollModeArmedBox = 0;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchModeArmedTime + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchModeArmedBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.pitchModeArmedBox = 0;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchMode2ArmedTime + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchMode2ArmedBox = 1;
2019-10-14 16:48:35 +00:00
} else {
2022-01-10 13:53:07 +00:00
Modes.PFD.FMA.pitchMode2ArmedBox = 0;
2019-10-14 16:48:35 +00:00
}
});
2020-12-22 18:41:07 +00:00
# Master FMA
var updateFma = {
lat: func() {
latText = Text.lat.getValue();
2021-10-05 14:34:16 +00:00
if (latText == "HDG") {
2022-01-10 13:53:07 +00:00
setFmaText("rollMode", Custom.trkFpa.getValue() ? "TRACK" : "HDG", genericCallback, "rollModeTime");
2021-10-05 14:34:16 +00:00
} else if (latText == "LNAV") {
2022-01-10 13:53:07 +00:00
setFmaText("rollMode", "NAV", genericCallback, "rollModeTime");
2020-12-22 18:41:07 +00:00
} else if (latText == "LOC") {
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.rollMode != "LOC*" and Modes.PFD.FMA.rollMode != "LOC") {
setFmaText("rollMode", "LOC*", genericCallback, "rollModeTime");
2020-12-22 18:41:07 +00:00
locupdate.start();
}
} else if (latText == "T/O") {
2022-01-10 13:53:07 +00:00
setFmaText("rollMode", "RWY", genericCallback, "rollModeTime");
} else if (latText == "ALGN" or latText == "RLOU" or latText == "") {
setFmaText("rollMode", " ", genericCallback, "rollModeTime");
2019-10-14 16:48:35 +00:00
}
2020-12-22 18:41:07 +00:00
},
vert: func() {
vertText = Text.vert.getValue();
2022-01-10 13:53:07 +00:00
if (vertText == "ALT HLD" or vertText == "ALT CAP") {
# altvert() call deals with this case
setFmaText("pitchMode2Armed", " ", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "V/S") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "V/S", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "G/S") {
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchMode != "G/S*" and Modes.PFD.FMA.pitchMode != "G/S") {
setFmaText("pitchMode", "G/S*", genericCallback, "pitchModeTime");
2020-12-22 18:41:07 +00:00
gsupdate.start();
}
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode2Armed", " ", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "SPD CLB") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "OP CLB", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "SPD DES") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "OP CLB", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "FPA") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "FPA", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "LAND") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "LAND", genericCallback, "pitchModeTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "FLARE") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "FLARE", genericCallback, "pitchModeTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "ROLLOUT") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "ROLL OUT", genericCallback, "pitchModeTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "T/O CLB") {
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchMode != "SRS") {
setFmaText("pitchMode", "SRS", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", FMGCInternal.v2set ? "CLB" : " ", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
}
} else if (vertText == "G/A CLB") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "SRS", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
} else if (vertText == "") {
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchMode != " ") {
setFmaText("pitchMode", " ", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", FMGCInternal.v2set ? "CLB" : " ", genericCallback, "pitchMode2ArmedTime");
2020-12-22 18:41:07 +00:00
}
2019-10-14 16:48:35 +00:00
}
2020-12-22 18:41:07 +00:00
altvert();
},
arm: func() {
if (Output.locArm.getBoolValue()) {
2022-01-10 13:53:07 +00:00
setFmaText("rollModeArmed", "LOC", genericCallback, "rollModeArmedTime");
2020-12-22 18:41:07 +00:00
} else if (Output.lnavArm.getBoolValue()) {
2022-01-10 13:53:07 +00:00
setFmaText("rollModeArmed", "NAV", genericCallback, "rollModeArmedTime");
2020-12-22 18:41:07 +00:00
} else {
2022-01-10 13:53:07 +00:00
setFmaText("rollModeArmed", " ", genericCallback, "rollModeArmedTime");
2019-10-14 16:48:35 +00:00
}
2020-12-22 18:41:07 +00:00
if (Output.apprArm.getBoolValue()) {
2022-01-10 13:53:07 +00:00
setFmaText("pitchModeArmed", "G/S", genericCallback, "pitchModeArmedTime");
2020-12-22 18:41:07 +00:00
} else {
2022-01-10 13:53:07 +00:00
setFmaText("pitchModeArmed", " ", genericCallback, "pitchModeArmedTime");
2019-10-14 16:48:35 +00:00
}
2020-12-22 18:41:07 +00:00
},
};
2019-10-14 16:48:35 +00:00
2022-01-09 19:55:30 +00:00
# Update localizer and glideslope
var locupdate = maketimer(0.5, func() {
if (Text.lat.getValue() == "LOC") {
2022-01-10 13:53:07 +00:00
if (abs(pts.Instrumentation.Nav.locDeflection.getValue()) < 0.06) {
2019-10-14 16:48:35 +00:00
locupdate.stop();
2022-01-10 13:53:07 +00:00
setFmaText("rollMode", "LOC", genericCallback, "rollModeTime");
2019-10-14 16:48:35 +00:00
}
}
});
2022-01-09 19:55:30 +00:00
var gsupdate = maketimer(0.5, func() {
if (Text.vert.getValue() == "G/S") {
2022-01-10 13:53:07 +00:00
if (abs(pts.Instrumentation.Nav.gsDeflection.getValue()) < 0.06) {
2022-01-09 19:55:30 +00:00
gsupdate.stop();
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "G/S", genericCallback, "pitchModeTime");
2022-01-09 19:55:30 +00:00
}
}
});
var altvert = func() {
2020-10-03 09:29:57 +00:00
vertText = Text.vert.getValue();
2022-01-09 19:55:30 +00:00
if (abs(fmgc.FMGCInternal.crzFt - Internal.alt.getValue()) <= 20) {
2020-10-03 09:29:57 +00:00
if (vertText == "ALT HLD") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "ALT CRZ", genericCallback, "pitchModeTime");
2020-10-03 09:29:57 +00:00
} else if (vertText == "ALT CAP") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "ALT CRZ*", genericCallback, "pitchModeTime");
2019-10-14 16:48:35 +00:00
}
} else {
2020-10-03 09:29:57 +00:00
if (vertText == "ALT HLD") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "ALT", genericCallback, "pitchModeTime");
2020-10-03 09:29:57 +00:00
} else if (vertText == "ALT CAP") {
2022-01-10 13:53:07 +00:00
setFmaText("pitchMode", "ALT*", genericCallback, "pitchModeTime");
2019-10-14 16:48:35 +00:00
}
}
}
# AP
2022-01-09 19:55:30 +00:00
var ap1 = nil;
var ap2 = nil;
var apTextVector = [nil, nil, nil, nil];
2022-01-10 13:53:07 +00:00
var newApText = nil;
2022-01-09 19:55:30 +00:00
var fmaAp = func() {
2020-10-03 09:29:57 +00:00
ap1 = Output.ap1.getValue();
ap2 = Output.ap2.getValue();
2022-01-09 19:55:30 +00:00
apTextVector[0] = (ap1 or ap2) ? "AP " : " ";
apTextVector[1] = ap1 ? "1" : "";
apTextVector[2] = (ap1 and ap2) ? "+" : "";
apTextVector[3] = ap2 ? "2" : "";
2022-01-10 13:53:07 +00:00
newApText = (apTextVector[0] ~ apTextVector[1] ~ apTextVector[2] ~ apTextVector[3]);
setFmaText("apMode", newApText, genericCallback, "apModeTime");
2019-10-14 16:48:35 +00:00
}
# FD
2022-01-09 19:55:30 +00:00
var fd1 = nil;
var fd2 = nil;
var fdTextVector = [nil, nil, nil];
2022-01-10 13:53:07 +00:00
var newFdText = nil;
2022-01-09 19:55:30 +00:00
var fmaFd = func() {
2020-10-03 09:29:57 +00:00
fd1 = Output.fd1.getValue();
fd2 = Output.fd2.getValue();
2022-01-09 19:55:30 +00:00
fdTextVector[0] = fd1 ? "1" : (fd2 ? "-" : "");
fdTextVector[1] = (fd1 or fd2) ? " FD " : " ";
fdTextVector[2] = fd2 ? "2" : (fd1 ? "-" : "");
2022-01-10 13:53:07 +00:00
newFdText = (fdTextVector[0] ~ fdTextVector[1] ~ fdTextVector[2]);
setFmaText("fdMode", newFdText, genericCallback, "fdModeTime");
2019-10-14 16:48:35 +00:00
}
2022-01-09 15:59:14 +00:00
# A/THR
2022-01-09 19:55:30 +00:00
var fmaAthr = func() {
2022-01-10 13:53:07 +00:00
setFmaText("athrMode", (Output.athr.getValue() ? "A/THR" : " "), athrCallback, "athrModeTime");
2019-10-14 16:48:35 +00:00
}
2022-01-09 19:55:30 +00:00
var showAllBoxes = func() {
elapsedtime = pts.Sim.Time.elapsedSec.getValue();
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.rollMode != " ") {
Modes.PFD.FMA.rollModeTime = elapsedtime;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchMode != " ") {
Modes.PFD.FMA.pitchModeTime = elapsedtime;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.rollModeArmed != " ") {
Modes.PFD.FMA.rollModeArmedTime = elapsedtime;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchModeArmed != " ") {
Modes.PFD.FMA.pitchModeArmedTime = elapsedtime;
2019-10-14 16:48:35 +00:00
}
2022-01-10 13:53:07 +00:00
if (Modes.PFD.FMA.pitchMode2Armed != " ") {
Modes.PFD.FMA.pitchMode2ArmedTime = elapsedtime;
2019-10-14 16:48:35 +00:00
}
}
2022-01-09 19:55:30 +00:00
setlistener("/sim/signals/fdm-initialized", func() {
2022-01-10 13:53:07 +00:00
fma_init();
});