1
0
Fork 0
A320-family/Nasal/Systems/efis.nas

216 lines
8.6 KiB
Text
Raw Normal View History

2019-10-14 16:48:35 +00:00
# A3XX EFIS controller by Joshua Davidson (Octal450).
2020-04-18 05:36:46 +00:00
# Copyright (c) 2020 Josh Davidson (Octal450)
2019-10-14 16:48:35 +00:00
setlistener("sim/signals/fdm-initialized", func {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "NAV");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 2);
setprop("instrumentation/efis[0]/inputs/range-nm", 20);
setprop("instrumentation/efis[0]/inputs/tfc", 0);
setprop("instrumentation/efis[0]/inputs/CSTR", 0);
setprop("instrumentation/efis[0]/inputs/wpt", 0);
setprop("instrumentation/efis[0]/inputs/VORD", 0);
setprop("instrumentation/efis[0]/inputs/DME", 0);
setprop("instrumentation/efis[0]/inputs/NDB", 0);
setprop("instrumentation/efis[0]/inputs/arpt", 0);
setprop("instrumentation/efis[1]/nd/display-mode", "NAV");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 2);
setprop("instrumentation/efis[1]/inputs/range-nm", 20);
setprop("instrumentation/efis[1]/inputs/tfc", 0);
setprop("instrumentation/efis[1]/inputs/CSTR", 0);
setprop("instrumentation/efis[1]/inputs/wpt", 0);
setprop("instrumentation/efis[1]/inputs/VORD", 0);
setprop("instrumentation/efis[1]/inputs/DME", 0);
setprop("instrumentation/efis[1]/inputs/NDB", 0);
setprop("instrumentation/efis[1]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
});
var setCptND = func(d) {
2020-02-07 16:10:54 +00:00
var mode = getprop("instrumentation/efis[0]/nd/display-mode");
2019-10-14 16:48:35 +00:00
if (d == 1) {
if (mode == "ILS") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "VOR");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 1);
2019-10-14 16:48:35 +00:00
} else if (mode == "VOR") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "NAV");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 2);
2019-10-14 16:48:35 +00:00
} else if (mode == "NAV") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "ARC");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 3);
2019-10-14 16:48:35 +00:00
} else if (mode == "ARC") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "PLAN");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 4);
2019-10-14 16:48:35 +00:00
}
} else if (d == -1) {
if (mode == "PLAN") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "ARC");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 3);
2019-10-14 16:48:35 +00:00
} else if (mode == "ARC") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "NAV");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 2);
2019-10-14 16:48:35 +00:00
} else if (mode == "NAV") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "VOR");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 1);
2019-10-14 16:48:35 +00:00
} else if (mode == "VOR") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/nd/display-mode", "ILS");
setprop("instrumentation/efis[0]/mfd/pnl_mode-num", 0);
2019-10-14 16:48:35 +00:00
}
}
}
var setFoND = func(d) {
2020-02-07 16:10:54 +00:00
var mode = getprop("instrumentation/efis[1]/nd/display-mode");
2019-10-14 16:48:35 +00:00
if (d == 1) {
if (mode == "ILS") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/nd/display-mode", "VOR");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 1);
2019-10-14 16:48:35 +00:00
} else if (mode == "VOR") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/nd/display-mode", "NAV");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 2);
2019-10-14 16:48:35 +00:00
} else if (mode == "NAV") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/nd/display-mode", "ARC");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 3);
2019-10-14 16:48:35 +00:00
} else if (mode == "ARC") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/nd/display-mode", "PLAN");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 4);
2019-10-14 16:48:35 +00:00
}
} else if (d == -1) {
if (mode == "PLAN") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/nd/display-mode", "ARC");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 3);
2019-10-14 16:48:35 +00:00
} else if (mode == "ARC") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/nd/display-mode", "NAV");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 2);
2019-10-14 16:48:35 +00:00
} else if (mode == "NAV") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/nd/display-mode", "VOR");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 1);
2019-10-14 16:48:35 +00:00
} else if (mode == "VOR") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/nd/display-mode", "ILS");
setprop("instrumentation/efis[1]/mfd/pnl_mode-num", 0);
2019-10-14 16:48:35 +00:00
}
}
}
var setNDRange = func(n, d) {
2020-02-07 16:10:54 +00:00
var rng = getprop("instrumentation/efis[" ~ n ~ "]/inputs/range-nm");
2019-10-14 16:48:35 +00:00
if (d == 1) {
rng = rng * 2;
if (rng > 320) {
rng = 320;
}
} else if (d == -1){
rng = rng / 2;
if (rng < 10) {
rng = 10;
}
}
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[" ~ n ~ "]/inputs/range-nm", rng);
2019-10-14 16:48:35 +00:00
}
var cpt_efis_btns = func(i) {
if (i == "cstr") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/inputs/CSTR", 1);
setprop("instrumentation/efis[0]/inputs/wpt", 0);
setprop("instrumentation/efis[0]/inputs/VORD", 0);
setprop("instrumentation/efis[0]/inputs/DME", 0);
setprop("instrumentation/efis[0]/inputs/NDB", 0);
setprop("instrumentation/efis[0]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
} else if (i == "wpt") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/inputs/CSTR", 0);
setprop("instrumentation/efis[0]/inputs/wpt", 1);
setprop("instrumentation/efis[0]/inputs/VORD", 0);
setprop("instrumentation/efis[0]/inputs/DME", 0);
setprop("instrumentation/efis[0]/inputs/NDB", 0);
setprop("instrumentation/efis[0]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
} else if (i == "vord") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/inputs/CSTR", 0);
setprop("instrumentation/efis[0]/inputs/wpt", 0);
setprop("instrumentation/efis[0]/inputs/VORD", 1);
setprop("instrumentation/efis[0]/inputs/DME", 1);
setprop("instrumentation/efis[0]/inputs/NDB", 0);
setprop("instrumentation/efis[0]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
} else if (i == "ndb") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/inputs/CSTR", 0);
setprop("instrumentation/efis[0]/inputs/wpt", 0);
setprop("instrumentation/efis[0]/inputs/VORD", 0);
setprop("instrumentation/efis[0]/inputs/DME", 0);
setprop("instrumentation/efis[0]/inputs/NDB", 1);
setprop("instrumentation/efis[0]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
} else if (i == "arpt") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/inputs/CSTR", 0);
setprop("instrumentation/efis[0]/inputs/wpt", 0);
setprop("instrumentation/efis[0]/inputs/VORD", 0);
setprop("instrumentation/efis[0]/inputs/DME", 0);
setprop("instrumentation/efis[0]/inputs/NDB", 0);
setprop("instrumentation/efis[0]/inputs/arpt", 1);
2019-10-14 16:48:35 +00:00
} else if (i == "off") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[0]/inputs/CSTR", 0);
setprop("instrumentation/efis[0]/inputs/wpt", 0);
setprop("instrumentation/efis[0]/inputs/VORD", 0);
setprop("instrumentation/efis[0]/inputs/DME", 0);
setprop("instrumentation/efis[0]/inputs/NDB", 0);
setprop("instrumentation/efis[0]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
}
}
var fo_efis_btns = func(i) {
if (i == "cstr") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/inputs/CSTR", 1);
setprop("instrumentation/efis[1]/inputs/wpt", 0);
setprop("instrumentation/efis[1]/inputs/VORD", 0);
setprop("instrumentation/efis[1]/inputs/DME", 0);
setprop("instrumentation/efis[1]/inputs/NDB", 0);
setprop("instrumentation/efis[1]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
} else if (i == "wpt") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/inputs/CSTR", 0);
setprop("instrumentation/efis[1]/inputs/wpt", 1);
setprop("instrumentation/efis[1]/inputs/VORD", 0);
setprop("instrumentation/efis[1]/inputs/DME", 0);
setprop("instrumentation/efis[1]/inputs/NDB", 0);
setprop("instrumentation/efis[1]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
} else if (i == "vord") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/inputs/CSTR", 0);
setprop("instrumentation/efis[1]/inputs/wpt", 0);
setprop("instrumentation/efis[1]/inputs/VORD", 1);
setprop("instrumentation/efis[1]/inputs/DME", 1);
setprop("instrumentation/efis[1]/inputs/NDB", 0);
setprop("instrumentation/efis[1]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
} else if (i == "ndb") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/inputs/CSTR", 0);
setprop("instrumentation/efis[1]/inputs/wpt", 0);
setprop("instrumentation/efis[1]/inputs/VORD", 0);
setprop("instrumentation/efis[1]/inputs/DME", 0);
setprop("instrumentation/efis[1]/inputs/NDB", 1);
setprop("instrumentation/efis[1]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
} else if (i == "arpt") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/inputs/CSTR", 0);
setprop("instrumentation/efis[1]/inputs/wpt", 0);
setprop("instrumentation/efis[1]/inputs/VORD", 0);
setprop("instrumentation/efis[1]/inputs/DME", 0);
setprop("instrumentation/efis[1]/inputs/NDB", 0);
setprop("instrumentation/efis[1]/inputs/arpt", 1);
2019-10-14 16:48:35 +00:00
} else if (i == "off") {
2020-02-07 16:10:54 +00:00
setprop("instrumentation/efis[1]/inputs/CSTR", 0);
setprop("instrumentation/efis[1]/inputs/wpt", 0);
setprop("instrumentation/efis[1]/inputs/VORD", 0);
setprop("instrumentation/efis[1]/inputs/DME", 0);
setprop("instrumentation/efis[1]/inputs/NDB", 0);
setprop("instrumentation/efis[1]/inputs/arpt", 0);
2019-10-14 16:48:35 +00:00
}
}
var toggleSTD = func {
2020-02-07 16:10:54 +00:00
var Std = getprop("modes/altimeter/std");
if (Std == 1) {
2020-02-07 16:10:54 +00:00
var oldqnh = getprop("modes/altimeter/oldqnh");
setprop("instrumentation/altimeter/setting-inhg", oldqnh);
setprop("modes/altimeter/std", 0);
} else if (Std == 0) {
2020-02-07 16:10:54 +00:00
var qnh = getprop("instrumentation/altimeter/setting-inhg");
setprop("modes/altimeter/oldqnh", qnh);
setprop("instrumentation/altimeter/setting-inhg", 29.92);
setprop("modes/altimeter/std", 1);
}
}