1
0
Fork 0

FMA: rewrite code to not use properties

This commit is contained in:
Jonathan Redpath 2022-01-10 13:53:07 +00:00
parent 69bea9f6e4
commit 9cc8d5aa71
7 changed files with 340 additions and 548 deletions

View file

@ -353,114 +353,6 @@ var canvas_pfd = {
}
}
}),
props.UpdateManager.FromHashValue("athrArm", nil, func(val) {
if (val != 1) {
obj["FMA_athr"].setColor(0.8078,0.8039,0.8078);
} else {
obj["FMA_athr"].setColor(0.0901,0.6039,0.7176);
}
}),
props.UpdateManager.FromHashList(["apBox","apMode"], nil, func(val) {
obj["FMA_ap"].setText(sprintf("%s", val.apMode));
if (val.apBox and val.apMode != " ") {
obj["FMA_ap_box"].show();
} else {
obj["FMA_ap_box"].hide();
}
}),
props.UpdateManager.FromHashList(["atBox","atMode"], nil, func(val) {
obj["FMA_athr"].setText(sprintf("%s", val.atMode));
if (val.atBox and val.atMode != " ") {
obj["FMA_athr_box"].show();
} else {
obj["FMA_athr_box"].hide();
}
}),
props.UpdateManager.FromHashValue("rollMode", nil, func(val) {
obj["FMA_roll"].setText(sprintf("%s", val));
}),
props.UpdateManager.FromHashValue("rollModeArmed", nil, func(val) {
obj["FMA_rollarm"].setText(sprintf("%s", val));
}),
props.UpdateManager.FromHashList(["pitchMode","pitchModeBox","autopilotVS","autopilotFPA","pitchMode2Armed","pitchModeArmed","pitchMode2ArmedBox","pitchModeArmedBox","rollMode","rollModeBox","rollModeArmed","rollModeArmedBox","ap1","ap2","fd1","fd2"], nil, func(val) {
obj["FMA_combined"].setText(sprintf("%s", val.pitchMode));
if (val.pitchMode == "V/S") {
obj["FMA_pitch"].setText(sprintf("%s ", val.pitchMode));
obj["vsFMArate"].setText(sprintf("%+4.0f",val.autopilotVS));
obj["vsFMArate"].show();
} elsif (val.pitchMode == "FPA") {
obj["FMA_pitch"].setText(sprintf("%s ", val.pitchMode));
obj["vsFMArate"].setText(sprintf("%+3.1f°",val.autopilotFPA));
obj["vsFMArate"].show();
} else {
obj["FMA_pitch"].setText(sprintf("%s", val.pitchMode));
obj["vsFMArate"].hide();
}
if (val.pitchMode == "LAND" or val.pitchMode == "FLARE" or val.pitchMode == "ROLL OUT") {
obj["FMA_pitch"].hide();
obj["FMA_roll"].hide();
obj["FMA_pitch_box"].hide();
obj["FMA_roll_box"].hide();
obj["FMA_pitcharm_box"].hide();
obj["FMA_rollarm_box"].hide();
obj["FMA_Middle1"].hide();
obj["FMA_Middle2"].hide();
obj["FMA_combined"].show();
if (val.pitchModeBox and val.pitchMode != " ") {
obj["FMA_combined_box"].show();
} else {
obj["FMA_combined_box"].hide();
}
} else {
obj["FMA_combined"].hide();
obj["FMA_combined_box"].hide();
if (val.pitchModeBox and val.pitchMode != " " and (val.ap1 or val.ap2 or val.fd1 or val.fd2)) {
obj["FMA_pitch_box"].show();
} else {
obj["FMA_pitch_box"].hide();
}
if (val.pitchModeArmed == "" and val.pitchMode2Armed == "") {
obj["FMA_pitcharm_box"].hide();
} else {
if ((val.pitchModeArmedBox or val.pitchMode2ArmedBox) and (val.ap1 or val.ap2 or val.fd1 or val.fd2)) {
obj["FMA_pitcharm_box"].show();
} else {
obj["FMA_pitcharm_box"].hide();
}
}
if (val.rollModeBox == 1 and val.rollMode != " " and (val.ap1 or val.ap2 or val.fd1 or val.fd2)) {
obj["FMA_roll_box"].show();
} else {
obj["FMA_roll_box"].hide();
}
if (val.rollModeArmedBox == 1 and val.rollModeArmed != " " and (val.ap1 or val.ap2 or val.fd1 or val.fd2)) {
obj["FMA_rollarm_box"].show();
} else {
obj["FMA_rollarm_box"].hide();
}
}
}),
props.UpdateManager.FromHashValue("pitchModeArmed", nil, func(val) {
obj["FMA_pitcharm"].setText(sprintf("%s", val));
}),
props.UpdateManager.FromHashValue("pitchMode2Armed", nil, func(val) {
obj["FMA_pitcharm2"].setText(sprintf("%s", val));
}),
props.UpdateManager.FromHashList(["fdBox","fdMode"], nil, func(val) {
obj["FMA_fd"].setText(sprintf("%s", val.fdMode));
if (val.fdBox and val.fdMode != " ") {
obj["FMA_fd_box"].show();
} else {
obj["FMA_fd_box"].hide();
}
}),
props.UpdateManager.FromHashList(["fd1","fd2","ap1","ap2"], nil, func(val) {
if (val.fd1 or val.fd2 or val.ap1 or val.ap2) {
obj["FMA_pitcharm"].show();
@ -528,36 +420,6 @@ var canvas_pfd = {
obj["GS_pointer"].hide();
}
}),
props.UpdateManager.FromHashList(["fd1","fd2","rollMode","pitchMode","trkFpa","pitchPFD","roll","gear1Wow"], nil, func(val) {
if (((obj.number == 0 and val.fd1) or (obj.number == 1 and val.fd2)) and val.trkFpa == 0 and val.pitchPFD < 25 and val.pitchPFD > -13 and val.roll < 45 and val.roll > -45) {
if (val.rollMode != " " and !val.gear1Wow) {
obj["FD_roll"].show();
} else {
obj["FD_roll"].hide();
}
if (val.pitchMode != " ") {
obj["FD_pitch"].show();
} else {
obj["FD_pitch"].hide();
}
} else {
obj["FD_roll"].hide();
obj["FD_pitch"].hide();
}
}),
props.UpdateManager.FromHashList(["alphaFloor","togaLk","throttleMode"], nil, func(val) {
if (val.alphaFloor) {
obj["FMA_thrust"].setText("A.FLOOR");
obj["FMA_thrust_box"].setColor(0.7333,0.3803,0);
} else if (val.togaLk) {
obj["FMA_thrust"].setText("TOGA LK");
obj["FMA_thrust_box"].setColor(0.7333,0.3803,0);
} else {
obj["FMA_thrust"].setText(sprintf("%s", val.throttleMode));
obj["FMA_thrust_box"].setColor(0.8078,0.8039,0.8078);
}
}),
props.UpdateManager.FromHashValue("flexTemp", nil, func(val) {
obj["FMA_flxtemp"].setText(sprintf("%s", "+" ~ val));
}),
@ -1338,7 +1200,13 @@ var canvas_pfd = {
me["ALT_digit_UP_metric"].hide();
}
if (notification.pitchMode == "LAND" or notification.pitchMode == "FLARE" or notification.pitchMode == "ROLL OUT") {
if (fmgc.Modes.PFD.FMA.pitchMode == "LAND" or fmgc.Modes.PFD.FMA.pitchMode == "FLARE" or fmgc.Modes.PFD.FMA.pitchMode == "ROLL OUT") {
if (fmgc.Modes.PFD.FMA.pitchMode == "LAND") {
autoland_pitch_land.setBoolValue(1);
} else {
autoland_pitch_land.setBoolValue(0);
}
if (ecam.directLaw.active) {
me["FMA_ctr_msg"].setText("USE MAN PITCH TRIM");
me["FMA_ctr_msg"].setColor(0.7333,0.3803,0);
@ -1452,7 +1320,7 @@ var canvas_pfd = {
if (notification.alphaFloor != 1 and notification.togaLk != 1) {
if (notification.athr and notification.engOut != 1 and (notification.thrust1 == "MAN" or notification.thrust1 == "CL") and (notification.thrust2 == "MAN" or notification.thrust2 == "CL")) {
me["FMA_thrust"].show();
if (notification.throttleModeBox and notification.throttleMode != " ") {
if (fmgc.Modes.PFD.FMA.throttleBox and fmgc.Modes.PFD.FMA.throttle != " ") {
me["FMA_thrust_box"].show();
} else {
me["FMA_thrust_box"].hide();
@ -1460,7 +1328,7 @@ var canvas_pfd = {
} else if (notification.athr and notification.engOut and (notification.thrust1 == "MAN" or notification.thrust1 == "CL" or (notification.thrust1 == "MAN THR" and !systems.FADEC.manThrAboveMct[0]) or (notification.thrust1 == "MCT" and notification.thrustLimit != "FLX")) and
(notification.thrust2 == "MAN" or notification.thrust2 == "CL" or (notification.thrust2 == "MAN THR" and !systems.FADEC.manThrAboveMct[1]) or (notification.thrust2 == "MCT" and notification.thrustLimit != "FLX"))) {
me["FMA_thrust"].show();
if (notification.throttleModeBox and notification.throttleMode != " ") {
if (fmgc.Modes.PFD.FMA.throttleBox and fmgc.Modes.PFD.FMA.throttle != " ") {
me["FMA_thrust_box"].show();
} else {
me["FMA_thrust_box"].hide();
@ -1756,6 +1624,130 @@ var canvas_pfd = {
me["CRS_pointer"].hide();
}
me["FMA_ap"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.apMode));
if (fmgc.Modes.PFD.FMA.apModeBox and fmgc.Modes.PFD.FMA.apMode != " ") {
me["FMA_ap_box"].show();
} else {
me["FMA_ap_box"].hide();
}
me["FMA_athr"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.athrMode));
if (fmgc.Modes.PFD.FMA.athrModeBox and fmgc.Modes.PFD.FMA.athrMode != " ") {
me["FMA_athr_box"].show();
} else {
me["FMA_athr_box"].hide();
}
me["FMA_fd"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.fdMode));
if (fmgc.Modes.PFD.FMA.fdModeBox and fmgc.Modes.PFD.FMA.fdMode != " ") {
me["FMA_fd_box"].show();
} else {
me["FMA_fd_box"].hide();
}
if (fmgc.Modes.PFD.FMA.athrArmed != 1) {
me["FMA_athr"].setColor(0.8078,0.8039,0.8078);
} else {
me["FMA_athr"].setColor(0.0901,0.6039,0.7176);
}
me["FMA_roll"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.rollMode));
me["FMA_rollarm"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.rollModeArmed));
me["FMA_combined"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.pitchMode));
me["FMA_pitcharm"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.pitchModeArmed));
me["FMA_pitcharm2"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.pitchMode2Armed));
if (fmgc.Modes.PFD.FMA.pitchMode == "V/S") {
me["FMA_pitch"].setText(sprintf("%s ", fmgc.Modes.PFD.FMA.pitchMode));
me["vsFMArate"].setText(sprintf("%+4.0f",notification.autopilotVS));
me["vsFMArate"].show();
} elsif (fmgc.Modes.PFD.FMA.pitchMode == "FPA") {
me["FMA_pitch"].setText(sprintf("%s ", fmgc.Modes.PFD.FMA.pitchMode));
me["vsFMArate"].setText(sprintf("%+3.1f°",notification.autopilotFPA));
me["vsFMArate"].show();
} else {
me["FMA_pitch"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.pitchMode));
me["vsFMArate"].hide();
}
if (fmgc.Modes.PFD.FMA.pitchMode == "LAND" or fmgc.Modes.PFD.FMA.pitchMode == "FLARE" or fmgc.Modes.PFD.FMA.pitchMode == "ROLL OUT") {
me["FMA_pitch"].hide();
me["FMA_roll"].hide();
me["FMA_pitch_box"].hide();
me["FMA_roll_box"].hide();
me["FMA_pitcharm_box"].hide();
me["FMA_rollarm_box"].hide();
me["FMA_Middle1"].hide();
me["FMA_Middle2"].hide();
me["FMA_combined"].show();
if (fmgc.Modes.PFD.FMA.pitchModeBox and fmgc.Modes.PFD.FMA.pitchMode != " ") {
me["FMA_combined_box"].show();
} else {
me["FMA_combined_box"].hide();
}
} else {
me["FMA_combined"].hide();
me["FMA_combined_box"].hide();
if (fmgc.Modes.PFD.FMA.pitchModeBox and fmgc.Modes.PFD.FMA.pitchMode != " " and (notification.ap1 or notification.notification or val.fd1 or notification.fd2)) {
me["FMA_pitch_box"].show();
} else {
me["FMA_pitch_box"].hide();
}
if (fmgc.Modes.PFD.FMA.pitchModeArmed == " " and fmgc.Modes.PFD.FMA.pitchMode2Armed == " ") {
me["FMA_pitcharm_box"].hide();
} else {
if ((fmgc.Modes.PFD.FMA.pitchModeArmedBox or fmgc.Modes.PFD.FMA.pitchMode2ArmedBox) and (notification.ap1 or notification.notification or val.fd1 or notification.fd2)) {
me["FMA_pitcharm_box"].show();
} else {
me["FMA_pitcharm_box"].hide();
}
}
if (fmgc.Modes.PFD.FMA.rollModeBox == 1 and fmgc.Modes.PFD.FMA.rollMode != " " and (notification.ap1 or notification.notification or val.fd1 or notification.fd2)) {
me["FMA_roll_box"].show();
} else {
me["FMA_roll_box"].hide();
}
if (fmgc.Modes.PFD.FMA.rollModeArmedBox == 1 and fmgc.Modes.PFD.FMA.rollModeArmed != " " and (notification.ap1 or notification.notification or val.fd1 or notification.fd2)) {
me["FMA_rollarm_box"].show();
} else {
me["FMA_rollarm_box"].hide();
}
}
if (notification.alphaFloor) {
me["FMA_thrust"].setText("A.FLOOR");
me["FMA_thrust_box"].setColor(0.7333,0.3803,0);
} else if (notification.togaLk) {
me["FMA_thrust"].setText("TOGA LK");
me["FMA_thrust_box"].setColor(0.7333,0.3803,0);
} else {
me["FMA_thrust"].setText(sprintf("%s", fmgc.Modes.PFD.FMA.throttle));
me["FMA_thrust_box"].setColor(0.8078,0.8039,0.8078);
}
if (((me.number == 0 and notification.fd1) or (me.number == 1 and notification.fd2)) and notification.trkFpa == 0 and notification.pitchPFD < 25 and notification.pitchPFD > -13 and notification.roll < 45 and notification.roll > -45) {
if (fmgc.Modes.PFD.FMA.rollMode != " " and !notification.gear1Wow) {
me["FD_roll"].show();
} else {
me["FD_roll"].hide();
}
if (fmgc.Modes.PFD.FMA.pitchMode != " ") {
me["FD_pitch"].show();
} else {
me["FD_pitch"].hide();
}
} else {
me["FD_roll"].hide();
me["FD_pitch"].hide();
}
foreach(var update_item; me.update_items)
{
update_item.update(notification);
@ -1955,27 +1947,7 @@ var input = {
du6Lgt: "/controls/lighting/DU/du6",
attSwitch: "/controls/navigation/switching/att-hdg",
atMode: "/modes/pfd/fma/at-mode",
apMode: "/modes/pfd/fma/ap-mode",
fdMode: "/modes/pfd/fma/fd-mode",
atBox: "/modes/pfd/fma/athr-mode-box",
apBox: "/modes/pfd/fma/ap-mode-box",
fdBox: "/modes/pfd/fma/fd-mode-box",
athr: "/it-autoflight/output/athr",
athrArm: "/modes/pfd/fma/athr-armed",
rollMode: "/modes/pfd/fma/roll-mode",
rollModeArmed: "/modes/pfd/fma/roll-mode-armed",
rollModeBox: "/modes/pfd/fma/roll-mode-box",
rollModeArmedBox: "/modes/pfd/fma/roll-mode-armed-box",
pitchMode: "/modes/pfd/fma/pitch-mode",
pitchModeArmed: "/modes/pfd/fma/pitch-mode-armed",
pitchMode2Armed: "/modes/pfd/fma/pitch-mode2-armed",
pitchModeBox: "/modes/pfd/fma/pitch-mode-box",
pitchModeArmedBox: "/modes/pfd/fma/pitch-mode-armed-box",
pitchMode2ArmedBox: "/modes/pfd/fma/pitch-mode2-armed-box",
throttleMode: "/modes/pfd/fma/throttle-mode",
throttleModeBox: "/modes/pfd/fma/throttle-mode-box",
altitudeAutopilot: "/it-autoflight/internal/alt",
pitchPFD: "/instrumentation/pfd/pitch-deg-non-linear",
horizonGround: "/instrumentation/pfd/horizon-ground",
@ -2201,10 +2173,3 @@ setlistener(autoland_alarm, func(alarm) {
}
}, 0, 0);
setlistener("/modes/pfd/fma/pitch-mode", func(pitch) {
if (pitch.getValue() == "LAND") {
autoland_pitch_land.setBoolValue(1);
} else {
autoland_pitch_land.setBoolValue(0);
}
},0,0);

View file

@ -555,6 +555,6 @@ var athrOff = func(type) {
var hdgInput = func {
if (fmgc.Output.lat.getValue() != 0) {
fmgc.Custom.showHdg.setBoolValue(1);
fmgc.Custom.hdgTime.setValue(pts.Sim.Time.elapsedSec.getValue());
fmgc.Custom.hdgTime = pts.Sim.Time.elapsedSec.getValue();
}
}

View file

@ -173,7 +173,7 @@ var Sound = {
# A3XX Custom
var Custom = {
apFdOn: 0,
hdgTime: props.globals.getNode("/modes/fcu/hdg-time", 1),
hdgTime: -45,
ndTrkSel: [props.globals.getNode("/instrumentation/efis[0]/trk-selected", 1), props.globals.getNode("/instrumentation/efis[1]/trk-selected", 1)],
showHdg: props.globals.initNode("/it-autoflight/custom/show-hdg", 1, "BOOL"),
trkFpa: props.globals.initNode("/it-autoflight/custom/trk-fpa", 0, "BOOL"),
@ -347,7 +347,7 @@ var ITAF = {
# Preselect Heading
if (Output.latTemp != 0 and Output.latTemp != 9) { # Modes that always show HDG
if (Custom.hdgTime.getValue() + 45 >= Misc.elapsedSec.getValue()) {
if (Custom.hdgTime + 45 >= Misc.elapsedSec.getValue()) {
Custom.showHdg.setBoolValue(1);
} else {
Custom.showHdg.setBoolValue(0);

View file

@ -8,17 +8,7 @@ var engout = nil;
var engstate1 = nil;
var engstate2 = nil;
var flx = nil;
var gs_defl = nil;
var latText = nil;
var nav_defl = nil;
var newfd = nil;
var newarm = nil;
var newap = nil;
var newlat = nil;
var newvert = nil;
var newvert2arm = nil;
var newvertarm = nil;
var newthr = nil;
var state1 = nil;
var state2 = nil;
var thr = nil;
@ -29,73 +19,106 @@ var vertText = nil;
var Modes = {
FCU: {
hdgTime: props.globals.initNode("/modes/fcu/hdg-time", -45, "DOUBLE")
hdgTime: -45,
},
PFD: {
FMA: {
athr: props.globals.initNode("/modes/pfd/fma/athr-armed", 0, "BOOL"),
athrBox: props.globals.initNode("/modes/pfd/fma/athr-armed-box", 0, "BOOL"),
athrMode: props.globals.initNode("/modes/pfd/fma/at-mode", " ", "STRING"),
athrModeBox: props.globals.initNode("/modes/pfd/fma/athr-mode-box", 0, "BOOL"),
apMode: props.globals.initNode("/modes/pfd/fma/ap-mode", " ", "STRING"),
apModeBox: props.globals.initNode("/modes/pfd/fma/ap-mode-box", 0, "BOOL"),
apModeTime: props.globals.initNode("/modes/pfd/fma/ap-mode-time", 0, "DOUBLE"),
athrModeTime: props.globals.initNode("/modes/pfd/fma/athr-mode-time", 0, "DOUBLE"),
fdMode: props.globals.initNode("/modes/pfd/fma/fd-mode", " ", "STRING"),
fdModeBox: props.globals.initNode("/modes/pfd/fma/fd-mode-box", 0, "BOOL"),
fdModeTime: props.globals.initNode("/modes/pfd/fma/fd-mode-time", 0, "DOUBLE"),
rollMode: props.globals.initNode("/modes/pfd/fma/roll-mode", " ", "STRING"),
rollModeBox: props.globals.initNode("/modes/pfd/fma/roll-mode-box", 0, "BOOL"),
rollModeArmed: props.globals.initNode("/modes/pfd/fma/roll-mode-armed", " ", "STRING"),
rollModeArmedBox: props.globals.initNode("/modes/pfd/fma/roll-mode-armed-box", 0, "BOOL"),
rollModeTime: props.globals.initNode("/modes/pfd/fma/roll-mode-time", 0, "DOUBLE"),
rollModeArmedTime: props.globals.initNode("/modes/pfd/fma/roll-mode-armed-time", 0, "DOUBLE"),
pitchMode: props.globals.initNode("/modes/pfd/fma/pitch-mode", " ", "STRING"),
pitchModeBox: props.globals.initNode("/modes/pfd/fma/pitch-mode-box", 0, "BOOL"),
pitchModeArmed: props.globals.initNode("/modes/pfd/fma/pitch-mode-armed", " ", "STRING"),
pitchModeArmedBox: props.globals.initNode("/modes/pfd/fma/pitch-mode-armed-box", 0, "BOOL"),
pitchMode2Armed: props.globals.initNode("/modes/pfd/fma/pitch-mode2-armed", " ", "STRING"),
pitchModeTime: props.globals.initNode("/modes/pfd/fma/pitch-mode-time", 0, "DOUBLE"),
pitchModeArmedTime: props.globals.initNode("/modes/pfd/fma/pitch-mode-armed-time", 0, "DOUBLE"),
pitchMode2ArmedTime: props.globals.initNode("/modes/pfd/fma/pitch-mode2-armed-time", 0, "DOUBLE"),
pitchMode2ArmedBox: props.globals.initNode("/modes/pfd/fma/pitch-mode2-armed-box", 0, "BOOL"),
throttle: props.globals.initNode("/modes/pfd/fma/throttle-mode", " ", "STRING"),
throttleModeBox: props.globals.initNode("/modes/pfd/fma/throttle-mode-box", 0, "BOOL"),
throttleModeTime: props.globals.initNode("/modes/pfd/fma/throttle-mode-time", 0, "DOUBLE"),
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,
},
},
};
var init = func() {
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() {
Internal.alt.setValue(10000);
Modes.PFD.FMA.throttle.setValue(" ");
Modes.PFD.FMA.pitchMode.setValue(" ");
Modes.PFD.FMA.pitchModeArmed.setValue(" ");
Modes.PFD.FMA.pitchMode2Armed.setValue(" ");
Modes.PFD.FMA.rollMode.setValue(" ");
Modes.PFD.FMA.rollModeArmed.setValue(" ");
Modes.PFD.FMA.apMode.setValue(" ");
Modes.PFD.FMA.fdMode.setValue(" ");
Modes.PFD.FMA.athrMode.setValue(" ");
Modes.PFD.FMA.athr.setValue(0);
Modes.PFD.FMA.throttleModeBox.setValue(0);
Modes.PFD.FMA.pitchModeBox.setValue(0);
Modes.PFD.FMA.pitchModeArmedBox.setValue(0);
Modes.PFD.FMA.pitchMode2ArmedBox.setValue(0);
Modes.PFD.FMA.rollModeBox.setValue(0);
Modes.PFD.FMA.rollModeArmedBox.setValue(0);
Modes.PFD.FMA.apModeBox.setValue(0);
Modes.PFD.FMA.fdModeBox.setValue(0);
Modes.PFD.FMA.athrModeBox.setValue(0);
Modes.PFD.FMA.throttleModeTime.setValue(0);
Modes.PFD.FMA.pitchModeTime.setValue(0);
Modes.PFD.FMA.pitchModeArmedTime.setValue(0);
Modes.PFD.FMA.pitchMode2ArmedTime.setValue(0);
Modes.PFD.FMA.rollModeTime.setValue(0);
Modes.PFD.FMA.rollModeArmedTime.setValue(0);
Modes.PFD.FMA.apModeTime.setValue(0);
Modes.PFD.FMA.fdModeTime.setValue(0);
Modes.PFD.FMA.athrModeTime.setValue(0);
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;
loopFMA.start();
};
@ -103,56 +126,39 @@ var init = func() {
var loopFMA = maketimer(0.05, func() {
state1 = systems.FADEC.detentText[0].getValue();
state2 = systems.FADEC.detentText[1].getValue();
newthr = Modes.PFD.FMA.throttle.getValue();
engout = systems.FADEC.engOut.getValue();
if (state1 == "TOGA" or state2 == "TOGA") {
if (newthr != " ") {
Modes.PFD.FMA.throttle.setValue(" ");
}
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
} else if ((state1 == "MAN THR" and systems.FADEC.manThrAboveMct[0]) or (state2 == "MAN THR" and systems.FADEC.manThrAboveMct[1])) {
if (newthr != " ") {
Modes.PFD.FMA.throttle.setValue(" ");
}
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
} else if ((state1 == "MCT" or state2 == "MCT") and !engout) {
if (newthr != " ") {
Modes.PFD.FMA.throttle.setValue(" ");
}
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
} else if (((state1 == "MAN THR" and !systems.FADEC.manThrAboveMct[0]) or (state2 == "MAN THR" and !systems.FADEC.manThrAboveMct[1])) and !engout) {
if (newthr != " ") {
Modes.PFD.FMA.throttle.setValue(" ");
}
setFmaText("throttle", " ", throttleModeCallback, "throttleModeTime");
} else {
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();
if (thr == 0) {
updateFMAThrottleMode();
setFmaText("throttle", Input.ktsMach.getValue() ? "MACH" : "SPEED", throttleModeCallback, "throttleModeTime");
} else if (thr == 1) {
if (newthr != "THR IDLE") {
Modes.PFD.FMA.throttle.setValue("THR IDLE");
}
setFmaText("throttle", "THR IDLE", throttleModeCallback, "throttleModeTime");
} else if (thr == 2) {
if (state1 == "MCT" or state2 == "MCT" and engout) {
if (newthr != "THR MCT") {
Modes.PFD.FMA.throttle.setValue("THR MCT");
}
setFmaText("throttle", "THR MCT", throttleModeCallback, "throttleModeTime");
} else if (state1 == "CL" or state2 == "CL") {
if (newthr != "THR CLB") {
Modes.PFD.FMA.throttle.setValue("THR CLB");
}
setFmaText("throttle", "THR CLB", throttleModeCallback, "throttleModeTime");
} else {
if (newthr != "THR LVR") {
Modes.PFD.FMA.throttle.setValue("THR LVR");
}
setFmaText("throttle", "THR LVR", throttleModeCallback, "throttleModeTime");
}
}
} else {
updateFMAThrottleMode();
setFmaText("throttle", Input.ktsMach.getValue() ? "MACH" : "SPEED", throttleModeCallback, "throttleModeTime");
}
} else {
updateFMAThrottleMode();
setFmaText("throttle", Input.ktsMach.getValue() ? "MACH" : "SPEED", throttleModeCallback, "throttleModeTime");
}
}
@ -160,24 +166,17 @@ var loopFMA = maketimer(0.05, func() {
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) {
if (!Modes.PFD.FMA.athr.getValue()) {
Modes.PFD.FMA.athr.setValue(1);
}
Modes.PFD.FMA.athrArmed = 1;
} 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"))
or state1 == "TOGA" or state2 == "TOGA") and engout) {
if (!Modes.PFD.FMA.athr.getValue()) {
Modes.PFD.FMA.athr.setValue(1);
}
Modes.PFD.FMA.athrArmed = 1;
} else {
if (Modes.PFD.FMA.athr.getValue()) {
Modes.PFD.FMA.athr.setValue(0);
}
Modes.PFD.FMA.athrArmed = 0;
}
# SRS RWY Engagement
if (pts.Gear.wow[1].getValue() or pts.Gear.wow[2].getValue()) {
flx = systems.FADEC.Limit.flexActive.getBoolValue();
newlat = Modes.PFD.FMA.rollMode.getValue();
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)) {
@ -198,265 +197,166 @@ var loopFMA = maketimer(0.05, func() {
# Boxes
elapsedtime = pts.Sim.Time.elapsedSec.getValue();
if (Modes.PFD.FMA.apModeTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.apModeBox.setValue(1);
if (Modes.PFD.FMA.apModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.apModeBox = 1;
} else {
Modes.PFD.FMA.apModeBox.setValue(0);
Modes.PFD.FMA.apModeBox = 0;
}
if (Modes.PFD.FMA.fdModeTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.fdModeBox.setValue(1);
if (Modes.PFD.FMA.fdModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.fdModeBox = 1;
} else {
Modes.PFD.FMA.fdModeBox.setValue(0);
Modes.PFD.FMA.fdModeBox = 0;
}
if (Modes.PFD.FMA.athrModeTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.athrModeBox.setValue(1);
if (Modes.PFD.FMA.athrModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.athrModeBox = 1;
} else {
Modes.PFD.FMA.athrModeBox.setValue(0);
Modes.PFD.FMA.athrModeBox = 0;
}
if (Modes.PFD.FMA.throttleModeTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.throttleModeBox.setValue(1);
if (Modes.PFD.FMA.throttleModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.throttleModeBox = 1;
} else {
Modes.PFD.FMA.throttleModeBox.setValue(0);
Modes.PFD.FMA.throttleModeBox = 0;
}
if (Modes.PFD.FMA.rollModeTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.rollModeBox.setValue(1);
if (Modes.PFD.FMA.rollModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.rollModeBox = 1;
} else {
Modes.PFD.FMA.rollModeBox.setValue(0);
Modes.PFD.FMA.rollModeBox = 0;
}
if (Modes.PFD.FMA.pitchModeTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchModeBox.setValue(1);
if (Modes.PFD.FMA.pitchModeTime + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchModeBox = 1;
} else {
Modes.PFD.FMA.pitchModeBox.setValue(0);
Modes.PFD.FMA.pitchModeBox = 0;
}
if (Modes.PFD.FMA.rollModeArmedTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.rollModeArmedBox.setValue(1);
if (Modes.PFD.FMA.rollModeArmedTime + 10 >= elapsedtime) {
Modes.PFD.FMA.rollModeArmedBox = 1;
} else {
Modes.PFD.FMA.rollModeArmedBox.setValue(0);
Modes.PFD.FMA.rollModeArmedBox = 0;
}
if (Modes.PFD.FMA.pitchModeArmedTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchModeArmedBox.setValue(1);
if (Modes.PFD.FMA.pitchModeArmedTime + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchModeArmedBox = 1;
} else {
Modes.PFD.FMA.pitchModeArmedBox.setValue(0);
Modes.PFD.FMA.pitchModeArmedBox = 0;
}
if (Modes.PFD.FMA.pitchMode2ArmedTime.getValue() + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchMode2ArmedBox.setValue(1);
if (Modes.PFD.FMA.pitchMode2ArmedTime + 10 >= elapsedtime) {
Modes.PFD.FMA.pitchMode2ArmedBox = 1;
} else {
Modes.PFD.FMA.pitchMode2ArmedBox.setValue(0);
Modes.PFD.FMA.pitchMode2ArmedBox = 0;
}
});
var updateFMAThrottleMode = func() {
newthr = Modes.PFD.FMA.throttle.getValue();
if (!Input.ktsMach.getValue()) {
if (newthr != "SPEED") {
Modes.PFD.FMA.throttle.setValue("SPEED");
}
} else {
if (newthr != "MACH") {
Modes.PFD.FMA.throttle.setValue("MACH");
}
}
}
# Master FMA
var updateFma = {
lat: func() {
latText = Text.lat.getValue();
newlat = Modes.PFD.FMA.rollMode.getValue();
if (latText == "HDG") {
if (Custom.trkFpa.getValue()) {
if (newlat != "TRACK") {
Modes.PFD.FMA.rollMode.setValue("TRACK");
}
} else {
if (newlat != "HDG") {
Modes.PFD.FMA.rollMode.setValue("HDG");
}
}
setFmaText("rollMode", Custom.trkFpa.getValue() ? "TRACK" : "HDG", genericCallback, "rollModeTime");
} else if (latText == "LNAV") {
if (newlat != "NAV") {
Modes.PFD.FMA.rollMode.setValue("NAV");
}
setFmaText("rollMode", "NAV", genericCallback, "rollModeTime");
} else if (latText == "LOC") {
if (newlat != "LOC*" and newlat != "LOC") {
Modes.PFD.FMA.rollMode.setValue("LOC*");
if (Modes.PFD.FMA.rollMode != "LOC*" and Modes.PFD.FMA.rollMode != "LOC") {
setFmaText("rollMode", "LOC*", genericCallback, "rollModeTime");
locupdate.start();
}
} else if (latText == "ALGN") {
if (newlat != " ") {
Modes.PFD.FMA.rollMode.setValue(" ");
}
} else if (latText == "RLOU") {
if (newlat != " ") {
Modes.PFD.FMA.rollMode.setValue(" ");
}
} else if (latText == "T/O") {
if (newlat != "RWY") {
Modes.PFD.FMA.rollMode.setValue("RWY");
}
} else if (latText == "") {
if (newlat != " ") {
Modes.PFD.FMA.rollMode.setValue(" ");
}
setFmaText("rollMode", "RWY", genericCallback, "rollModeTime");
} else if (latText == "ALGN" or latText == "RLOU" or latText == "") {
setFmaText("rollMode", " ", genericCallback, "rollModeTime");
}
},
vert: func() {
vertText = Text.vert.getValue();
newvert = Modes.PFD.FMA.pitchMode.getValue();
newvertarm = Modes.PFD.FMA.pitchMode2Armed.getValue();
if (vertText == "ALT HLD") {
altvert();
if (newvertarm != " ") {
Modes.PFD.FMA.pitchMode2Armed.setValue(" ");
}
} else if (vertText == "ALT CAP") {
altvert();
if (newvertarm != " ") {
Modes.PFD.FMA.pitchMode2Armed.setValue(" ");
}
if (vertText == "ALT HLD" or vertText == "ALT CAP") {
# altvert() call deals with this case
setFmaText("pitchMode2Armed", " ", genericCallback, "pitchMode2ArmedTime");
} else if (vertText == "V/S") {
if (newvert != "V/S") {
Modes.PFD.FMA.pitchMode.setValue("V/S");
}
if (newvertarm != "ALT") {
Modes.PFD.FMA.pitchMode2Armed.setValue("ALT");
}
setFmaText("pitchMode", "V/S", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
} else if (vertText == "G/S") {
if (newvert != "G/S*" and newvert != "G/S") {
Modes.PFD.FMA.pitchMode.setValue("G/S*");
if (Modes.PFD.FMA.pitchMode != "G/S*" and Modes.PFD.FMA.pitchMode != "G/S") {
setFmaText("pitchMode", "G/S*", genericCallback, "pitchModeTime");
gsupdate.start();
}
if (newvertarm != " ") {
Modes.PFD.FMA.pitchMode2Armed.setValue(" ");
}
setFmaText("pitchMode2Armed", " ", genericCallback, "pitchMode2ArmedTime");
} else if (vertText == "SPD CLB") {
if (newvert != "OP CLB") {
Modes.PFD.FMA.pitchMode.setValue("OP CLB");
}
if (newvertarm != "ALT") {
Modes.PFD.FMA.pitchMode2Armed.setValue("ALT");
}
setFmaText("pitchMode", "OP CLB", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
} else if (vertText == "SPD DES") {
if (newvert != "OP DES") {
Modes.PFD.FMA.pitchMode.setValue("OP DES");
}
if (newvertarm != "ALT") {
Modes.PFD.FMA.pitchMode2Armed.setValue("ALT");
}
setFmaText("pitchMode", "OP CLB", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
} else if (vertText == "FPA") {
if (newvert != "FPA") {
Modes.PFD.FMA.pitchMode.setValue("FPA");
}
if (newvertarm != "ALT") {
Modes.PFD.FMA.pitchMode2Armed.setValue("ALT");
}
setFmaText("pitchMode", "FPA", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
} else if (vertText == "LAND") {
if (newvert != "LAND") {
Modes.PFD.FMA.pitchMode.setValue("LAND");
}
setFmaText("pitchMode", "LAND", genericCallback, "pitchModeTime");
} else if (vertText == "FLARE") {
if (newvert != "FLARE") {
Modes.PFD.FMA.pitchMode.setValue("FLARE");
}
setFmaText("pitchMode", "FLARE", genericCallback, "pitchModeTime");
} else if (vertText == "ROLLOUT") {
if (newvert != "ROLL OUT") {
Modes.PFD.FMA.pitchMode.setValue("ROLL OUT");
}
setFmaText("pitchMode", "ROLL OUT", genericCallback, "pitchModeTime");
} else if (vertText == "T/O CLB") {
if (newvert != "SRS") {
Modes.PFD.FMA.pitchMode.setValue("SRS");
if (Modes.PFD.FMA.pitchMode != "SRS") {
setFmaText("pitchMode", "SRS", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", FMGCInternal.v2set ? "CLB" : " ", genericCallback, "pitchMode2ArmedTime");
}
updatePitchArm2();
} else if (vertText == "G/A CLB") {
if (newvert != "SRS") {
Modes.PFD.FMA.pitchMode.setValue("SRS");
}
if (newvertarm != "ALT") {
Modes.PFD.FMA.pitchMode2Armed.setValue("ALT");
}
setFmaText("pitchMode", "SRS", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", "ALT", genericCallback, "pitchMode2ArmedTime");
} else if (vertText == "") {
if (newvert != " ") {
Modes.PFD.FMA.pitchMode.setValue(" ");
if (Modes.PFD.FMA.pitchMode != " ") {
setFmaText("pitchMode", " ", genericCallback, "pitchModeTime");
setFmaText("pitchMode2Armed", FMGCInternal.v2set ? "CLB" : " ", genericCallback, "pitchMode2ArmedTime");
}
updatePitchArm2();
}
altvert();
},
arm: func() {
if (Output.locArm.getBoolValue()) {
Modes.PFD.FMA.rollModeArmed.setValue("LOC");
setFmaText("rollModeArmed", "LOC", genericCallback, "rollModeArmedTime");
} else if (Output.lnavArm.getBoolValue()) {
Modes.PFD.FMA.rollModeArmed.setValue("NAV");
setFmaText("rollModeArmed", "NAV", genericCallback, "rollModeArmedTime");
} else {
Modes.PFD.FMA.rollModeArmed.setValue(" ");
setFmaText("rollModeArmed", " ", genericCallback, "rollModeArmedTime");
}
if (Output.apprArm.getBoolValue()) {
Modes.PFD.FMA.pitchModeArmed.setValue("G/S");
setFmaText("pitchModeArmed", "G/S", genericCallback, "pitchModeArmedTime");
} else {
Modes.PFD.FMA.pitchModeArmed.setValue(" ");
setFmaText("pitchModeArmed", " ", genericCallback, "pitchModeArmedTime");
}
},
};
# Update localizer and glideslope
var locupdate = maketimer(0.5, func() {
nav_defl = pts.Instrumentation.Nav.locDeflection.getValue();
if (Text.lat.getValue() == "LOC") {
if (nav_defl > -0.06 and nav_defl < 0.06) {
if (abs(pts.Instrumentation.Nav.locDeflection.getValue()) < 0.06) {
locupdate.stop();
if (Modes.PFD.FMA.rollMode.getValue() != "LOC") {
Modes.PFD.FMA.rollMode.setValue("LOC");
}
setFmaText("rollMode", "LOC", genericCallback, "rollModeTime");
}
}
});
var gsupdate = maketimer(0.5, func() {
gs_defl = pts.Instrumentation.Nav.gsDeflection.getValue();
if (Text.vert.getValue() == "G/S") {
if (gs_defl > -0.06 and gs_defl < 0.06) {
if (abs(pts.Instrumentation.Nav.gsDeflection.getValue()) < 0.06) {
gsupdate.stop();
if (Modes.PFD.FMA.pitchMode.getValue() != "G/S") {
Modes.PFD.FMA.pitchMode.setValue("G/S");
}
setFmaText("pitchMode", "G/S", genericCallback, "pitchModeTime");
}
}
});
# Vertical Special
var updatePitchArm2 = func() {
newvertarm = Modes.PFD.FMA.pitchMode2Armed.getValue();
if (newvertarm != "CLB" and FMGCInternal.v2set) {
Modes.PFD.FMA.pitchMode2Armed.setValue("CLB");
} else if (newvertarm != " " and !FMGCInternal.v2set) {
Modes.PFD.FMA.pitchMode2Armed.setValue(" ");
}
}
var altvert = func() {
vertText = Text.vert.getValue();
newvert = Modes.PFD.FMA.pitchMode.getValue();
if (abs(fmgc.FMGCInternal.crzFt - Internal.alt.getValue()) <= 20) {
if (vertText == "ALT HLD") {
if (newvert != "ALT CRZ") {
Modes.PFD.FMA.pitchMode.setValue("ALT CRZ");
}
setFmaText("pitchMode", "ALT CRZ", genericCallback, "pitchModeTime");
} else if (vertText == "ALT CAP") {
if (newvert != "ALT CRZ*") {
Modes.PFD.FMA.pitchMode.setValue("ALT CRZ*");
}
setFmaText("pitchMode", "ALT CRZ*", genericCallback, "pitchModeTime");
}
} else {
if (vertText == "ALT HLD") {
if (newvert != "ALT") {
Modes.PFD.FMA.pitchMode.setValue("ALT");
}
setFmaText("pitchMode", "ALT", genericCallback, "pitchModeTime");
} else if (vertText == "ALT CAP") {
if (newvert != "ALT*") {
Modes.PFD.FMA.pitchMode.setValue("ALT*");
}
setFmaText("pitchMode", "ALT*", genericCallback, "pitchModeTime");
}
}
}
@ -465,6 +365,7 @@ var altvert = func() {
var ap1 = nil;
var ap2 = nil;
var apTextVector = [nil, nil, nil, nil];
var newApText = nil;
var fmaAp = func() {
ap1 = Output.ap1.getValue();
ap2 = Output.ap2.getValue();
@ -473,13 +374,15 @@ var fmaAp = func() {
apTextVector[1] = ap1 ? "1" : "";
apTextVector[2] = (ap1 and ap2) ? "+" : "";
apTextVector[3] = ap2 ? "2" : "";
Modes.PFD.FMA.apMode.setValue(apTextVector[0] ~ apTextVector[1] ~ apTextVector[2] ~ apTextVector[3]);
newApText = (apTextVector[0] ~ apTextVector[1] ~ apTextVector[2] ~ apTextVector[3]);
setFmaText("apMode", newApText, genericCallback, "apModeTime");
}
# FD
var fd1 = nil;
var fd2 = nil;
var fdTextVector = [nil, nil, nil];
var newFdText = nil;
var fmaFd = func() {
fd1 = Output.fd1.getValue();
fd2 = Output.fd2.getValue();
@ -487,104 +390,34 @@ var fmaFd = func() {
fdTextVector[0] = fd1 ? "1" : (fd2 ? "-" : "");
fdTextVector[1] = (fd1 or fd2) ? " FD " : " ";
fdTextVector[2] = fd2 ? "2" : (fd1 ? "-" : "");
Modes.PFD.FMA.fdMode.setValue(fdTextVector[0] ~ fdTextVector[1] ~ fdTextVector[2]);
newFdText = (fdTextVector[0] ~ fdTextVector[1] ~ fdTextVector[2]);
setFmaText("fdMode", newFdText, genericCallback, "fdModeTime");
}
# A/THR
var fmaAthr = func() {
Modes.PFD.FMA.athrMode.setValue( Output.athr.getValue() ? "A/THR" : " ");
setFmaText("athrMode", (Output.athr.getValue() ? "A/THR" : " "), athrCallback, "athrModeTime");
}
var showAllBoxes = func() {
elapsedtime = pts.Sim.Time.elapsedSec.getValue();
if (Modes.PFD.FMA.rollMode.getValue() != " ") {
Modes.PFD.FMA.rollModeTime.setValue(elapsedtime);
if (Modes.PFD.FMA.rollMode != " ") {
Modes.PFD.FMA.rollModeTime = elapsedtime;
}
if (Modes.PFD.FMA.pitchMode.getValue() != " ") {
Modes.PFD.FMA.pitchModeTime.setValue(elapsedtime);
if (Modes.PFD.FMA.pitchMode != " ") {
Modes.PFD.FMA.pitchModeTime = elapsedtime;
}
if (Modes.PFD.FMA.rollModeArmed.getValue() != " ") {
Modes.PFD.FMA.rollModeArmedTime.setValue(elapsedtime);
if (Modes.PFD.FMA.rollModeArmed != " ") {
Modes.PFD.FMA.rollModeArmedTime = elapsedtime;
}
if (Modes.PFD.FMA.pitchModeArmed.getValue() != " ") {
Modes.PFD.FMA.pitchModeArmedTime.setValue(elapsedtime);
if (Modes.PFD.FMA.pitchModeArmed != " ") {
Modes.PFD.FMA.pitchModeArmedTime = elapsedtime;
}
if (Modes.PFD.FMA.pitchMode2Armed.getValue() != " ") {
Modes.PFD.FMA.pitchMode2ArmedTime.setValue(elapsedtime);
if (Modes.PFD.FMA.pitchMode2Armed != " ") {
Modes.PFD.FMA.pitchMode2ArmedTime = elapsedtime;
}
}
# Boxes
setlistener("/modes/pfd/fma/ap-mode", func() {
if (Modes.PFD.FMA.apMode.getValue() != " ") {
Modes.PFD.FMA.apModeTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}, 0, 0);
setlistener("/modes/pfd/fma/fd-mode", func() {
if (Modes.PFD.FMA.fdMode.getValue() != " ") {
Modes.PFD.FMA.fdModeTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}, 0, 0);
setlistener("/modes/pfd/fma/at-mode", func() {
if (Modes.PFD.FMA.athrMode.getValue() != " ") {
elapsedtime = pts.Sim.Time.elapsedSec.getValue();
Modes.PFD.FMA.throttleModeTime.setValue(elapsedtime);
Modes.PFD.FMA.athrModeTime.setValue(elapsedtime);
}
}, 0, 0);
setlistener("/modes/pfd/fma/athr-armed", func() {
if (Modes.PFD.FMA.athrMode.getValue() != " ") {
Modes.PFD.FMA.athrModeTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}, 0, 0);
setlistener("/modes/pfd/fma/throttle-mode", func() {
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.throttleModeTime.setValue(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.throttleModeTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}
}, 0, 0);
setlistener("/modes/pfd/fma/roll-mode", func() {
if (Modes.PFD.FMA.rollMode.getValue() != " ") {
Modes.PFD.FMA.rollModeTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}, 0, 0);
setlistener("/modes/pfd/fma/pitch-mode", func() {
if (Modes.PFD.FMA.pitchMode.getValue() != " ") {
Modes.PFD.FMA.pitchModeTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}, 0, 0);
setlistener("/modes/pfd/fma/roll-mode-armed", func() {
if (Modes.PFD.FMA.rollModeArmed.getValue() != " ") {
Modes.PFD.FMA.rollModeArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}, 0, 0);
setlistener("/modes/pfd/fma/pitch-mode-armed", func() {
if (Modes.PFD.FMA.pitchModeArmed.getValue() != " ") {
Modes.PFD.FMA.pitchModeArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}, 0, 0);
setlistener("/modes/pfd/fma/pitch-mode2-armed", func() {
if (Modes.PFD.FMA.pitchMode2Armed.getValue() != " ") {
Modes.PFD.FMA.pitchMode2ArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue());
}
}, 0, 0);
setlistener("/sim/signals/fdm-initialized", func() {
init();
});
fma_init();
});

View file

@ -11,8 +11,6 @@ var dep = "";
var arr = "";
var n1_left = 0;
var n1_right = 0;
var modelat = "";
var mode = 0;
var gs = 0;
var state1 = 0;
var state2 = 0;
@ -571,8 +569,6 @@ var newphase = nil;
var masterFMGC = maketimer(0.2, func {
n1_left = pts.Engines.Engine.n1Actual[0].getValue();
n1_right = pts.Engines.Engine.n1Actual[1].getValue();
modelat = Modes.PFD.FMA.rollMode.getValue();
mode = Modes.PFD.FMA.pitchMode.getValue();
gs = pts.Velocities.groundspeedKt.getValue();
alt = pts.Instrumentation.Altimeter.indicatedFt.getValue();
# cruiseft = FMGCInternal.crzFt;
@ -586,22 +582,22 @@ var masterFMGC = maketimer(0.2, func {
newphase = FMGCInternal.phase;
if (FMGCInternal.phase == 0) {
if (gear0 and ((n1_left >= 85 and n1_right >= 85 and mode == "SRS") or gs >= 90)) {
if (gear0 and ((n1_left >= 85 and n1_right >= 85 and Modes.PFD.FMA.pitchMode == "SRS") or gs >= 90)) {
newphase = 1;
systems.PNEU.pressMode.setValue("TO");
}
} elsif (FMGCInternal.phase == 1) {
if (gear0) {
if ((n1_left < 85 or n1_right < 85) and gs < 90 and mode == " ") { # rejected takeoff
if ((n1_left < 85 or n1_right < 85) and gs < 90 and Modes.PFD.FMA.pitchMode == " ") { # rejected takeoff
newphase = 0;
systems.PNEU.pressMode.setValue("GN");
}
} elsif (((mode != "SRS" and mode != " ") or alt >= accel_agl_ft)) {
} elsif (((Modes.PFD.FMA.pitchMode != "SRS" and Modes.PFD.FMA.pitchMode != " ") or alt >= accel_agl_ft)) {
newphase = 2;
systems.PNEU.pressMode.setValue("TO");
}
} elsif (FMGCInternal.phase == 2) {
if ((mode == "ALT CRZ" or mode == "ALT CRZ*")) {
if ((Modes.PFD.FMA.pitchMode == "ALT CRZ" or Modes.PFD.FMA.pitchMode == "ALT CRZ*")) {
newphase = 3;
systems.PNEU.pressMode.setValue("CR");
}
@ -634,7 +630,7 @@ var masterFMGC = maketimer(0.2, func {
}
if (flightPlanController.num[2].getValue() > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and
flightPlanController.arrivalDist <= 15 and (modelat == "NAV" or modelat == "LOC" or modelat == "LOC*") and pts.Position.gearAglFt.getValue() < 9500) { #todo decel pseudo waypoint
flightPlanController.arrivalDist <= 15 and (Modes.PFD.FMA.rollMode == "NAV" or Modes.PFD.FMA.rollMode == "LOC" or Modes.PFD.FMA.rollMode == "LOC*") and pts.Position.gearAglFt.getValue() < 9500) { #todo decel pseudo waypoint
FMGCNodes.decel.setValue(1);
} elsif (FMGCNodes.decel.getValue() and (FMGCInternal.phase == 0 or FMGCInternal.phase == 6)) {
FMGCNodes.decel.setValue(0);
@ -929,7 +925,6 @@ var ManagedSPD = maketimer(0.25, func {
altitude = pts.Instrumentation.Altimeter.indicatedFt.getValue();
decel = FMGCNodes.decel.getValue();
ktsmach = Input.ktsMach.getValue();
mode = Modes.PFD.FMA.pitchMode.getValue();
srsSPD = srsSpeedNode.getValue();
mng_alt_spd = math.round(FMGCNodes.mngSpdAlt.getValue(), 1);
@ -942,7 +937,7 @@ var ManagedSPD = maketimer(0.25, func {
FMGCInternal.machSwitchover = 0;
}
if ((mode == " " or mode == "SRS") and (FMGCInternal.phase == 0 or FMGCInternal.phase == 1)) {
if ((Modes.PFD.FMA.pitchMode == " " or Modes.PFD.FMA.pitchMode == "SRS") and (FMGCInternal.phase == 0 or FMGCInternal.phase == 1)) {
FMGCInternal.mngKtsMach = 0;
FMGCInternal.mngSpdCmd = srsSPD;
} elsif ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude <= FMGCInternal.clbSpdLimAlt) {

View file

@ -57,7 +57,6 @@ var variousReset = func() {
setprop("/controls/lighting/DU/du6", 1);
setprop("/controls/lighting/DU/mcdu1", 1);
setprop("/controls/lighting/DU/mcdu2", 1);
setprop("/modes/fcu/hdg-time", -45);
setprop("/controls/navigation/switching/att-hdg", 0);
setprop("/controls/navigation/switching/air-data", 0);
pts.Controls.Switches.noSmokingSwitch.setValue(0);

View file

@ -83,7 +83,7 @@ var perfTOInput = func(key, i) {
if (int(scratchpad) != nil and scratchpad >= 100 and scratchpad <= 350) {
fmgc.FMGCInternal.v2 = scratchpad;
fmgc.FMGCInternal.v2set = 1;
fmgc.updatePitchArm2();
fmgc.setFmaText("pitchMode2Armed", fmgc.FMGCInternal.v2set ? "CLB" : " ", genericCallback, "pitchMode2ArmedTime");
setprop("/it-autoflight/settings/togaspd", scratchpad);
mcdu_scratchpad.scratchpads[i].empty();