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) { props.UpdateManager.FromHashList(["fd1","fd2","ap1","ap2"], nil, func(val) {
if (val.fd1 or val.fd2 or val.ap1 or val.ap2) { if (val.fd1 or val.fd2 or val.ap1 or val.ap2) {
obj["FMA_pitcharm"].show(); obj["FMA_pitcharm"].show();
@ -528,36 +420,6 @@ var canvas_pfd = {
obj["GS_pointer"].hide(); 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) { props.UpdateManager.FromHashValue("flexTemp", nil, func(val) {
obj["FMA_flxtemp"].setText(sprintf("%s", "+" ~ val)); obj["FMA_flxtemp"].setText(sprintf("%s", "+" ~ val));
}), }),
@ -1338,7 +1200,13 @@ var canvas_pfd = {
me["ALT_digit_UP_metric"].hide(); 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) { if (ecam.directLaw.active) {
me["FMA_ctr_msg"].setText("USE MAN PITCH TRIM"); me["FMA_ctr_msg"].setText("USE MAN PITCH TRIM");
me["FMA_ctr_msg"].setColor(0.7333,0.3803,0); 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.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")) { 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(); 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(); me["FMA_thrust_box"].show();
} else { } else {
me["FMA_thrust_box"].hide(); 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 } 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"))) { (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(); 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(); me["FMA_thrust_box"].show();
} else { } else {
me["FMA_thrust_box"].hide(); me["FMA_thrust_box"].hide();
@ -1756,6 +1624,130 @@ var canvas_pfd = {
me["CRS_pointer"].hide(); 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) foreach(var update_item; me.update_items)
{ {
update_item.update(notification); update_item.update(notification);
@ -1955,27 +1947,7 @@ var input = {
du6Lgt: "/controls/lighting/DU/du6", du6Lgt: "/controls/lighting/DU/du6",
attSwitch: "/controls/navigation/switching/att-hdg", 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", 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", altitudeAutopilot: "/it-autoflight/internal/alt",
pitchPFD: "/instrumentation/pfd/pitch-deg-non-linear", pitchPFD: "/instrumentation/pfd/pitch-deg-non-linear",
horizonGround: "/instrumentation/pfd/horizon-ground", horizonGround: "/instrumentation/pfd/horizon-ground",
@ -2201,10 +2173,3 @@ setlistener(autoland_alarm, func(alarm) {
} }
}, 0, 0); }, 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 { var hdgInput = func {
if (fmgc.Output.lat.getValue() != 0) { if (fmgc.Output.lat.getValue() != 0) {
fmgc.Custom.showHdg.setBoolValue(1); 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 # A3XX Custom
var Custom = { var Custom = {
apFdOn: 0, 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)], 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"), showHdg: props.globals.initNode("/it-autoflight/custom/show-hdg", 1, "BOOL"),
trkFpa: props.globals.initNode("/it-autoflight/custom/trk-fpa", 0, "BOOL"), trkFpa: props.globals.initNode("/it-autoflight/custom/trk-fpa", 0, "BOOL"),
@ -347,7 +347,7 @@ var ITAF = {
# Preselect Heading # Preselect Heading
if (Output.latTemp != 0 and Output.latTemp != 9) { # Modes that always show HDG 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); Custom.showHdg.setBoolValue(1);
} else { } else {
Custom.showHdg.setBoolValue(0); Custom.showHdg.setBoolValue(0);

View file

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

View file

@ -11,8 +11,6 @@ var dep = "";
var arr = ""; var arr = "";
var n1_left = 0; var n1_left = 0;
var n1_right = 0; var n1_right = 0;
var modelat = "";
var mode = 0;
var gs = 0; var gs = 0;
var state1 = 0; var state1 = 0;
var state2 = 0; var state2 = 0;
@ -571,8 +569,6 @@ var newphase = nil;
var masterFMGC = maketimer(0.2, func { var masterFMGC = maketimer(0.2, func {
n1_left = pts.Engines.Engine.n1Actual[0].getValue(); n1_left = pts.Engines.Engine.n1Actual[0].getValue();
n1_right = pts.Engines.Engine.n1Actual[1].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(); gs = pts.Velocities.groundspeedKt.getValue();
alt = pts.Instrumentation.Altimeter.indicatedFt.getValue(); alt = pts.Instrumentation.Altimeter.indicatedFt.getValue();
# cruiseft = FMGCInternal.crzFt; # cruiseft = FMGCInternal.crzFt;
@ -586,22 +582,22 @@ var masterFMGC = maketimer(0.2, func {
newphase = FMGCInternal.phase; newphase = FMGCInternal.phase;
if (FMGCInternal.phase == 0) { 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; newphase = 1;
systems.PNEU.pressMode.setValue("TO"); systems.PNEU.pressMode.setValue("TO");
} }
} elsif (FMGCInternal.phase == 1) { } elsif (FMGCInternal.phase == 1) {
if (gear0) { 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; newphase = 0;
systems.PNEU.pressMode.setValue("GN"); 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; newphase = 2;
systems.PNEU.pressMode.setValue("TO"); systems.PNEU.pressMode.setValue("TO");
} }
} elsif (FMGCInternal.phase == 2) { } 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; newphase = 3;
systems.PNEU.pressMode.setValue("CR"); 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 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); FMGCNodes.decel.setValue(1);
} elsif (FMGCNodes.decel.getValue() and (FMGCInternal.phase == 0 or FMGCInternal.phase == 6)) { } elsif (FMGCNodes.decel.getValue() and (FMGCInternal.phase == 0 or FMGCInternal.phase == 6)) {
FMGCNodes.decel.setValue(0); FMGCNodes.decel.setValue(0);
@ -929,7 +925,6 @@ var ManagedSPD = maketimer(0.25, func {
altitude = pts.Instrumentation.Altimeter.indicatedFt.getValue(); altitude = pts.Instrumentation.Altimeter.indicatedFt.getValue();
decel = FMGCNodes.decel.getValue(); decel = FMGCNodes.decel.getValue();
ktsmach = Input.ktsMach.getValue(); ktsmach = Input.ktsMach.getValue();
mode = Modes.PFD.FMA.pitchMode.getValue();
srsSPD = srsSpeedNode.getValue(); srsSPD = srsSpeedNode.getValue();
mng_alt_spd = math.round(FMGCNodes.mngSpdAlt.getValue(), 1); mng_alt_spd = math.round(FMGCNodes.mngSpdAlt.getValue(), 1);
@ -942,7 +937,7 @@ var ManagedSPD = maketimer(0.25, func {
FMGCInternal.machSwitchover = 0; 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.mngKtsMach = 0;
FMGCInternal.mngSpdCmd = srsSPD; FMGCInternal.mngSpdCmd = srsSPD;
} elsif ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude <= FMGCInternal.clbSpdLimAlt) { } 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/du6", 1);
setprop("/controls/lighting/DU/mcdu1", 1); setprop("/controls/lighting/DU/mcdu1", 1);
setprop("/controls/lighting/DU/mcdu2", 1); setprop("/controls/lighting/DU/mcdu2", 1);
setprop("/modes/fcu/hdg-time", -45);
setprop("/controls/navigation/switching/att-hdg", 0); setprop("/controls/navigation/switching/att-hdg", 0);
setprop("/controls/navigation/switching/air-data", 0); setprop("/controls/navigation/switching/air-data", 0);
pts.Controls.Switches.noSmokingSwitch.setValue(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) { if (int(scratchpad) != nil and scratchpad >= 100 and scratchpad <= 350) {
fmgc.FMGCInternal.v2 = scratchpad; fmgc.FMGCInternal.v2 = scratchpad;
fmgc.FMGCInternal.v2set = 1; fmgc.FMGCInternal.v2set = 1;
fmgc.updatePitchArm2(); fmgc.setFmaText("pitchMode2Armed", fmgc.FMGCInternal.v2set ? "CLB" : " ", genericCallback, "pitchMode2ArmedTime");
setprop("/it-autoflight/settings/togaspd", scratchpad); setprop("/it-autoflight/settings/togaspd", scratchpad);
mcdu_scratchpad.scratchpads[i].empty(); mcdu_scratchpad.scratchpads[i].empty();