1
0
Fork 0
A320-family/Nasal/MCDU/PERFAPPR.nas

135 lines
4.8 KiB
Text
Raw Normal View History

# Copyright (c) 2020 Matthew Maring (hayden2000)
# APPR PERF
var ldg_config_3_set = props.globals.getNode("FMGC/internal/ldg-config-3-set", 1);
var ldg_config_f_set = props.globals.getNode("FMGC/internal/ldg-config-f-set", 1);
var perfAPPRInput = func(key, i) {
2020-03-28 20:40:02 +00:00
var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad");
if (key == "L1") {
2020-03-28 20:40:02 +00:00
if (scratchpad == "CLR") {
setprop("FMGC/internal/dest-qnh", -1);
setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
2020-04-15 23:31:05 +00:00
} else if (num(scratchpad) != nil and (scratchpad >= 28.06 and scratchpad <= 31.01) or (scratchpad >= 745 and scratchpad <= 1050)) {
2020-03-28 20:40:02 +00:00
# doesn't support accidental temp input yet
setprop("FMGC/internal/dest-qnh", scratchpad);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
2020-03-28 20:40:02 +00:00
} else {
notAllowed(i);
}
} else if (key == "L2") {
2020-03-28 20:40:02 +00:00
if (scratchpad == "CLR") {
setprop("FMGC/internal/dest-temp", -999);
setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
2020-04-15 23:31:05 +00:00
} else if (num(scratchpad) != nil and scratchpad >= -99 and scratchpad < 99) {
setprop("FMGC/internal/dest-temp", scratchpad);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
2020-03-28 20:40:02 +00:00
} else {
notAllowed(i);
}
} else if (key == "L3") {
2020-03-28 20:40:02 +00:00
var tfs = size(scratchpad);
if (scratchpad == "CLR") {
setprop("FMGC/internal/dest-mag", -1);
setprop("FMGC/internal/dest-wind", -1);
setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
2020-03-28 20:40:02 +00:00
} else if (tfs >= 3 and tfs <= 7 and find("/", scratchpad) != -1) {
var weather = split("/", scratchpad);
var mag = int(weather[0]);
var mags = size(weather[0]);
var wind = int(weather[1]);
var winds = size(weather[1]);
if (mags >= 1 and mags <= 3 and winds >= 1 and winds <= 3) {
2020-04-15 23:31:05 +00:00
if (mag != nil and wind != nil and mag >= 0 and mag <= 360 and wind >= 0 and wind <= 200) {
setprop("FMGC/internal/dest-mag", weather[0]);
setprop("FMGC/internal/dest-wind", weather[1]);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
fmgc.updateARPT();
} else {
notAllowed(i);
}
2020-03-28 20:40:02 +00:00
} else {
notAllowed(i);
}
} else {
notAllowed(i);
}
} else if (key == "L4") {
2020-03-28 20:40:02 +00:00
if (scratchpad == "CLR") {
setprop("FMGC/internal/trans-alt", 18000);
setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
} else if (int(scratchpad) != nil and scratchpad >= 0 and scratchpad <= 50000) {
setprop("FMGC/internal/trans-alt", scratchpad);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
2020-03-28 20:40:02 +00:00
} else {
notAllowed(i);
}
} else if (key == "L5") {
2020-03-28 20:40:02 +00:00
if (scratchpad == "CLR") {
setprop("FMGC/internal/vapp-speed-set", 0);
setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
} else if (int(scratchpad) != nil and scratchpad >= 0 and scratchpad <= 200) {
setprop("FMGC/internal/vapp-speed-set", 1);
setprop("FMGC/internal/computed-speeds/vapp_appr", scratchpad);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
2020-03-28 20:40:02 +00:00
} else {
notAllowed(i);
}
} else if (key == "L6") {
setprop("MCDU[" ~ i ~ "]/page", "PERFDES");
2020-04-18 13:59:05 +00:00
} else if (key == "R2") {
2020-04-19 01:22:36 +00:00
# if (scratchpad == "CLR") {
# setprop("FMGC/internal/baro", -1);
# setprop("MCDU[" ~ i ~ "]/scratchpad", "");
# } else
if (int(scratchpad) != nil and scratchpad >= getprop("FMGC/internal/ldg-elev") and scratchpad <= 5000 + getprop("FMGC/internal/ldg-elev")) {
2020-04-18 13:59:05 +00:00
if (getprop("FMGC/internal/radio-no") == 0) {
setprop("FMGC/internal/radio", -1);
}
setprop("FMGC/internal/baro", scratchpad);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
} else {
notAllowed(i);
}
} else if (key == "R3") {
2020-04-19 01:22:36 +00:00
# if (scratchpad == "CLR") {
# setprop("FMGC/internal/radio", -1);
# setprop("FMGC/internal/radio-no", 0);
# setprop("MCDU[" ~ i ~ "]/scratchpad", "");
# } else
if (scratchpad == "NO") {
2020-04-18 13:59:05 +00:00
setprop("FMGC/internal/radio", -1);
setprop("FMGC/internal/radio-no", 1);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
} else if (int(scratchpad) != nil and scratchpad >= 0 and scratchpad <= 700) {
setprop("FMGC/internal/baro", -1);
setprop("FMGC/internal/radio-no", 0);
setprop("FMGC/internal/radio", scratchpad);
setprop("MCDU[" ~ i ~ "]/scratchpad", "");
} else {
notAllowed(i);
}
2020-04-19 01:22:36 +00:00
} else if (key == "R4") {
if (scratchpad == "" and ldg_config_f_set.getValue() == 1 and ldg_config_3_set.getValue() == 0) {
setprop("FMGC/internal/ldg-config-3-set", 1);
setprop("FMGC/internal/ldg-config-f-set", 0);
} else {
notAllowed(i);
}
} else if (key == "R5") {
2020-03-28 20:40:02 +00:00
if (scratchpad == "" and ldg_config_3_set.getValue() == 1 and ldg_config_f_set.getValue() == 0) {
setprop("FMGC/internal/ldg-config-3-set", 0);
setprop("FMGC/internal/ldg-config-f-set", 1);
} else {
notAllowed(i);
}
} else if (key == "R6") {
setprop("MCDU[" ~ i ~ "]/page", "PERFGA");
}
}