Compare commits
72 commits
Author | SHA1 | Date | |
---|---|---|---|
|
f22fa4040e | ||
|
71794299cf | ||
|
733a6bd7d0 | ||
|
82201c11d0 | ||
|
7d1faf70a0 | ||
|
0aa13c1339 | ||
|
358c69296e | ||
|
2e226d0667 | ||
|
6b90acae4d | ||
|
f1072feaac | ||
|
03424de38f | ||
|
5be5321638 | ||
|
bbb7555e94 | ||
|
ae0a8c2aeb | ||
|
d3cc249c3c | ||
|
37d070c185 | ||
|
5dd23e0bf3 | ||
|
f9e4586f6d | ||
|
2a97e2a430 | ||
|
8cfb007e4a | ||
|
e60b2d1c5a | ||
|
6ab09e39f8 | ||
|
1b0b116127 | ||
|
f7c455edd4 | ||
|
2d3c6a97a9 | ||
|
cfff08578d | ||
|
ceb8a6fcdb | ||
|
9a92eaa0c5 | ||
|
8522565057 | ||
|
af802e70c8 | ||
|
8303cc4f7a | ||
|
011b5fac96 | ||
|
238663b9db | ||
|
f84f9f3516 | ||
|
f61b77c629 | ||
|
7cf037b698 | ||
|
c760a823b5 | ||
|
169a8c5e45 | ||
|
862ed64a28 | ||
|
ea699ab0cd | ||
|
832b928ed2 | ||
|
ef255e7bbe | ||
|
b50fd37187 | ||
|
4cb7f07e85 | ||
|
730a3cc35e | ||
|
1742f5b0c6 | ||
|
dbd72d9189 | ||
|
ab7375a53a | ||
|
4169b7261c | ||
|
4cd9d1e5eb | ||
|
76910c1762 | ||
|
c208121831 | ||
|
091bc5c422 | ||
|
e93de61a35 | ||
|
2e61924974 | ||
|
8e581f0e3b | ||
|
d4648754bd | ||
|
939e6e1dce | ||
|
44a5bdc653 | ||
|
446f95a5a7 | ||
|
40f22803cb | ||
|
74cf916ed6 | ||
|
d15f45f753 | ||
|
1e1eb44911 | ||
|
e2b32df4fb | ||
|
35522fba49 | ||
|
e64707d760 | ||
|
581565f39e | ||
|
f0b479606d | ||
|
b6a525d970 | ||
|
d482262aee | ||
|
55e48862fe |
36 changed files with 3848 additions and 2442 deletions
|
@ -214,13 +214,13 @@
|
|||
<dialog-name>autopilot</dialog-name>
|
||||
</binding>
|
||||
</item>
|
||||
<item>
|
||||
<!--item>
|
||||
<label>Route Manager</label>
|
||||
<binding>
|
||||
<command>dialog-show</command>
|
||||
<dialog-name>route-manager</dialog-name>
|
||||
</binding>
|
||||
</item>
|
||||
</item-->
|
||||
</menu>
|
||||
<menu n="103">
|
||||
<label>DU</label>
|
||||
|
@ -1505,12 +1505,14 @@
|
|||
<file>Aircraft/IDG-A32X/Nasal/it-fbw.nas</file>
|
||||
</fbw>
|
||||
<fmgc>
|
||||
<file>Aircraft/IDG-A32X/Nasal/flightplan.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/FMGC.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/FMGC-b.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/FMGC-c.nas</file>
|
||||
</fmgc>
|
||||
<mcdu>
|
||||
<file>Aircraft/IDG-A32X/Nasal/MCDU/MCDU.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/MCDU/F-PLN.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/MCDU/INITA.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/MCDU/INITB.nas</file>
|
||||
<file>Aircraft/IDG-A32X/Nasal/MCDU/PERFCLB.nas</file>
|
||||
|
|
|
@ -11,6 +11,19 @@ var symbol = "helvetica_medium.txf";
|
|||
var normal = 70;
|
||||
var small = 56;
|
||||
var page = "";
|
||||
var fplnLineSize = 0;
|
||||
var fplnl1 = "";
|
||||
var fplnl1s = "";
|
||||
var fplnl2 = "";
|
||||
var fplnl2s = "";
|
||||
var fplnl3 = "";
|
||||
var fplnl3s = "";
|
||||
var fplnl4 = "";
|
||||
var fplnl4s = "";
|
||||
var fplnl5 = "";
|
||||
var fplnl5s = "";
|
||||
var fplnl6 = "";
|
||||
var fplnl6s = "";
|
||||
setprop("/MCDUC/colors/wht/r", 1);
|
||||
setprop("/MCDUC/colors/wht/g", 1);
|
||||
setprop("/MCDUC/colors/wht/b", 1);
|
||||
|
@ -27,6 +40,12 @@ setprop("/MCDUC/colors/yel/r", 0.9333);
|
|||
setprop("/MCDUC/colors/yel/g", 0.9333);
|
||||
setprop("/MCDUC/colors/yel/b", 0.0000);
|
||||
|
||||
var WHITE = [1.0000,1.0000,1.0000];
|
||||
var GREEN = [0.0509,0.7529,0.2941];
|
||||
var BLUE = [0.0901,0.6039,0.7176];
|
||||
var AMBER = [0.7333,0.3803,0.0000];
|
||||
var YELLOW = [0.9333,0.9333,0.0000];
|
||||
|
||||
# Fetch nodes:
|
||||
var ac1 = props.globals.getNode("/systems/electrical/bus/ac1", 1);
|
||||
var ac2 = props.globals.getNode("/systems/electrical/bus/ac2", 1);
|
||||
|
@ -92,6 +111,7 @@ var engOutAcc = props.globals.getNode("/FMGC/internal/eng-out-reduc", 1);
|
|||
var engOutAccSet = props.globals.getNode("/MCDUC/reducacc-set", 1);
|
||||
var transAlt = props.globals.getNode("/FMGC/internal/trans-alt", 1);
|
||||
var managedSpeed = props.globals.getNode("/it-autoflight/input/spd-managed", 1);
|
||||
var TMPYActive = [props.globals.getNode("/FMGC/internal/tmpy-active[0]"), props.globals.getNode("/FMGC/internal/tmpy-active[1]")];
|
||||
|
||||
# Fetch nodes into vectors
|
||||
var pageProp = [props.globals.getNode("/MCDU[0]/page", 1), props.globals.getNode("/MCDU[1]/page", 1)];
|
||||
|
@ -150,7 +170,7 @@ var canvas_MCDU_base = {
|
|||
"Simple_L1_Arrow","Simple_L2_Arrow","Simple_L3_Arrow","Simple_L4_Arrow","Simple_L5_Arrow","Simple_L6_Arrow","Simple_R1","Simple_R2","Simple_R3","Simple_R4","Simple_R5","Simple_R6","Simple_R1S","Simple_R2S","Simple_R3S","Simple_R4S","Simple_R5S",
|
||||
"Simple_R6S","Simple_R1_Arrow","Simple_R2_Arrow","Simple_R3_Arrow","Simple_R4_Arrow","Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C4","Simple_C5","Simple_C6","Simple_C1S","Simple_C2S","Simple_C3S","Simple_C4S",
|
||||
"Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp","INITA_FromTo","INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","PERFTO","PERFTO_V1","PERFTO_VR",
|
||||
"PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE"];
|
||||
"PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","FPLN","FPLN_From","FPLN_TMPY_group","FPLN_Callsign","FPLN_L1","FPLN_L2","FPLN_L3","FPLN_L4","FPLN_L5","FPLN_L6","FPLN_L1S","FPLN_L2S","FPLN_L3S","FPLN_L4S","FPLN_L5S","FPLN_L6S","FPLN_6_group"];
|
||||
},
|
||||
update: func() {
|
||||
if (ac1.getValue() >= 110 and mcdu1_lgt.getValue() > 0.01) {
|
||||
|
@ -168,10 +188,174 @@ var canvas_MCDU_base = {
|
|||
},
|
||||
updateCommon: func(i) {
|
||||
page = pageProp[i].getValue();
|
||||
if (page == "MCDU") {
|
||||
if (page == "F-PLNA" or page == "F-PLNB") {
|
||||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].hide();
|
||||
me["Simple_Center"].hide();
|
||||
me["FPLN"].show();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
me["Simple_PageNum"].hide();
|
||||
me["ArrowLeft"].show();
|
||||
me["ArrowRight"].show();
|
||||
|
||||
pageSwitch[i].setBoolValue(1);
|
||||
}
|
||||
|
||||
if (flightNumSet.getValue()) {
|
||||
me["FPLN_Callsign"].setText(flightNum.getValue());
|
||||
me["FPLN_Callsign"].show();
|
||||
} else {
|
||||
me["FPLN_Callsign"].hide();
|
||||
}
|
||||
|
||||
fplnLineSize = size(mcdu.FPLNLines[i].output);
|
||||
|
||||
if (fplnLineSize >= 1) {
|
||||
fplnl1 = mcdu.FPLNLines[i].output[0].getText();
|
||||
if (fplnl1 != "") {
|
||||
me["FPLN_L1"].setColor(mcdu.FPLNLines[i].output[0].getColor(i));
|
||||
me["FPLN_L1"].setText(fplnl1);
|
||||
me["FPLN_L1"].show();
|
||||
} else {
|
||||
me["FPLN_L1"].hide();
|
||||
}
|
||||
fplnl1s = mcdu.FPLNLines[i].output[0].getSubText(i);
|
||||
if (fplnl1s != "") {
|
||||
me["FPLN_L1S"].setText(fplnl1s);
|
||||
me["FPLN_L1S"].show();
|
||||
} else {
|
||||
me["FPLN_L1S"].hide();
|
||||
}
|
||||
} else {
|
||||
me["FPLN_L1"].hide();
|
||||
me["FPLN_L1S"].hide();
|
||||
}
|
||||
|
||||
if (fplnLineSize >= 2) {
|
||||
fplnl2 = mcdu.FPLNLines[i].output[1].getText();
|
||||
if (fplnl2 != "") {
|
||||
me["FPLN_L2"].setColor(mcdu.FPLNLines[i].output[1].getColor(i));
|
||||
me["FPLN_L2"].setText(fplnl2);
|
||||
me["FPLN_L2"].show();
|
||||
} else {
|
||||
me["FPLN_L2"].hide();
|
||||
}
|
||||
fplnl2s = mcdu.FPLNLines[i].output[1].getSubText(i);
|
||||
if (fplnl2s != "") {
|
||||
me["FPLN_L2S"].setText(fplnl2s);
|
||||
me["FPLN_L2S"].show();
|
||||
} else {
|
||||
me["FPLN_L2S"].hide();
|
||||
}
|
||||
} else {
|
||||
me["FPLN_L2"].hide();
|
||||
me["FPLN_L2S"].hide();
|
||||
}
|
||||
|
||||
if (fplnLineSize >= 3) {
|
||||
fplnl3 = mcdu.FPLNLines[i].output[2].getText();
|
||||
if (fplnl3 != "") {
|
||||
me["FPLN_L3"].setColor(mcdu.FPLNLines[i].output[2].getColor(i));
|
||||
me["FPLN_L3"].setText(fplnl3);
|
||||
me["FPLN_L3"].show();
|
||||
} else {
|
||||
me["FPLN_L3"].hide();
|
||||
}
|
||||
fplnl3s = mcdu.FPLNLines[i].output[2].getSubText(i);
|
||||
if (fplnl3s != "") {
|
||||
me["FPLN_L3S"].setText(fplnl3s);
|
||||
me["FPLN_L3S"].show();
|
||||
} else {
|
||||
me["FPLN_L3S"].hide();
|
||||
}
|
||||
} else {
|
||||
me["FPLN_L3"].hide();
|
||||
me["FPLN_L3S"].hide();
|
||||
}
|
||||
|
||||
if (fplnLineSize >= 4) {
|
||||
fplnl4 = mcdu.FPLNLines[i].output[3].getText();
|
||||
if (fplnl4 != "") {
|
||||
me["FPLN_L4"].setColor(mcdu.FPLNLines[i].output[3].getColor(i));
|
||||
me["FPLN_L4"].setText(fplnl4);
|
||||
me["FPLN_L4"].show();
|
||||
} else {
|
||||
me["FPLN_L4"].hide();
|
||||
}
|
||||
fplnl4s = mcdu.FPLNLines[i].output[3].getSubText(i);
|
||||
if (fplnl4s != "") {
|
||||
me["FPLN_L4S"].setText(fplnl4s);
|
||||
me["FPLN_L4S"].show();
|
||||
} else {
|
||||
me["FPLN_L4S"].hide();
|
||||
}
|
||||
} else {
|
||||
me["FPLN_L4"].hide();
|
||||
me["FPLN_L4S"].hide();
|
||||
}
|
||||
|
||||
if (fplnLineSize >= 5) {
|
||||
fplnl5 = mcdu.FPLNLines[i].output[4].getText();
|
||||
if (fplnl5 != "") {
|
||||
me["FPLN_L5"].setColor(mcdu.FPLNLines[i].output[4].getColor(i));
|
||||
me["FPLN_L5"].setText(fplnl5);
|
||||
me["FPLN_L5"].show();
|
||||
} else {
|
||||
me["FPLN_L5"].hide();
|
||||
}
|
||||
fplnl5s = mcdu.FPLNLines[i].output[4].getSubText(i);
|
||||
if (fplnl5s != "") {
|
||||
me["FPLN_L5S"].setText(fplnl5s);
|
||||
me["FPLN_L5S"].show();
|
||||
} else {
|
||||
me["FPLN_L5S"].hide();
|
||||
}
|
||||
} else {
|
||||
me["FPLN_L5"].hide();
|
||||
me["FPLN_L5S"].hide();
|
||||
}
|
||||
|
||||
if (fplnLineSize >= 6) {
|
||||
fplnl6 = mcdu.FPLNLines[i].output[5].getText();
|
||||
if (fplnl6 != "") {
|
||||
me["FPLN_L6"].setColor(mcdu.FPLNLines[i].output[5].getColor(i));
|
||||
me["FPLN_L6"].setText(fplnl6);
|
||||
me["FPLN_L6"].show();
|
||||
} else {
|
||||
me["FPLN_L6"].hide();
|
||||
}
|
||||
fplnl6s = mcdu.FPLNLines[i].output[5].getSubText(i);
|
||||
if (fplnl6s != "") {
|
||||
me["FPLN_L6S"].setText(fplnl6s);
|
||||
me["FPLN_L6S"].show();
|
||||
} else {
|
||||
me["FPLN_L6S"].hide();
|
||||
}
|
||||
} else {
|
||||
me["FPLN_L6"].hide();
|
||||
me["FPLN_L6S"].hide();
|
||||
}
|
||||
|
||||
if (mcdu.FPLNLines[i].index == 0) {
|
||||
me["FPLN_From"].show();
|
||||
} else {
|
||||
me["FPLN_From"].hide();
|
||||
}
|
||||
|
||||
if (TMPYActive[i].getBoolValue()) {
|
||||
me["FPLN_TMPY_group"].show();
|
||||
me["FPLN_6_group"].hide();
|
||||
} else {
|
||||
me["FPLN_TMPY_group"].hide();
|
||||
me["FPLN_6_group"].show();
|
||||
}
|
||||
} else if (page == "MCDU") {
|
||||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].hide();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -253,6 +437,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].hide();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -334,6 +519,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].hide();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -413,6 +599,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].hide();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -497,6 +684,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].show();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -593,6 +781,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].hide();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -731,6 +920,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].hide();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].show();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -885,6 +1075,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].show();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].show();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -1014,6 +1205,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].show();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
@ -1125,6 +1317,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].show();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].show();
|
||||
|
@ -1282,6 +1475,7 @@ var canvas_MCDU_base = {
|
|||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me["Simple"].show();
|
||||
me["Simple_Center"].show();
|
||||
me["FPLN"].hide();
|
||||
me["INITA"].hide();
|
||||
me["INITB"].hide();
|
||||
me["PERFTO"].hide();
|
||||
|
|
File diff suppressed because it is too large
Load diff
Before (image error) Size: 86 KiB After (image error) Size: 106 KiB |
|
@ -16,7 +16,7 @@ var A3XXRouteDriver = {
|
|||
me.update();
|
||||
},
|
||||
update: func(){
|
||||
me.flightplan = flightplan();
|
||||
me.flightplan = fmgc.fp[2];
|
||||
},
|
||||
getNumberOfFlightPlans: func(){1},
|
||||
getFlightPlanType: func(fpNum){"current"},
|
||||
|
@ -25,7 +25,17 @@ var A3XXRouteDriver = {
|
|||
getWP: func(fpNum, idx){me.flightplan.getWP(idx)},
|
||||
getPlanModeWP: func(plan_wp_idx){me.flightplan.getWP(plan_wp_idx)},
|
||||
hasDiscontinuity: func(fpNum, wptID){0},
|
||||
getListeners: func(){[]},
|
||||
triggerSignal: func(signal){
|
||||
setprop(me.signalPath(signal),1);
|
||||
setprop(me.signalPath(signal),0);
|
||||
},
|
||||
signalPath: func(signal){
|
||||
"autopilot/route-manager/signals/rd-"~ signal;
|
||||
},
|
||||
getListeners: func(){[
|
||||
me.signalPath("fp-added"),
|
||||
me.signalPath("fp-removed")
|
||||
]},
|
||||
shouldUpdate: func 1
|
||||
};
|
||||
|
||||
|
@ -99,7 +109,8 @@ var MultiA3XXRouteDriver = {
|
|||
return fp.getWP(idx);
|
||||
},
|
||||
triggerSignal: func(signal){
|
||||
setprop(me.signalPath(signal));
|
||||
setprop(me.signalPath(signal), 1);
|
||||
setprop(me.signalPath(signal), 0);
|
||||
},
|
||||
signalPath: func(signal){
|
||||
"autopilot/route-manager/signals/rd-"~ signal;
|
||||
|
|
|
@ -233,7 +233,7 @@ canvas.NavDisplay.newMFD = func(canvas_group, parent=nil, nd_options=nil, update
|
|||
#print("navdisplay.mfd:ND layer setup completed");
|
||||
|
||||
# TODO: move this to RTE.lcontroller ?
|
||||
me.listen("/autopilot/route-manager/current-wp", func(activeWp) {
|
||||
me.listen("/FMGC/flightplan[2]/current-wp", func(activeWp) {
|
||||
canvas.updatewp( activeWp.getValue() );
|
||||
});
|
||||
|
||||
|
@ -304,12 +304,12 @@ canvas.NavDisplay.update_sub = func(){
|
|||
pos.lat = wp.wp_lat;
|
||||
pos.lon = wp.wp_lon;
|
||||
} else {
|
||||
pos.lat = getprop("/autopilot/route-manager/route/wp["~pln_wpt_idx~"]/latitude-deg");
|
||||
pos.lon = getprop("/autopilot/route-manager/route/wp["~pln_wpt_idx~"]/longitude-deg");
|
||||
pos.lat = getprop("/FMGC/flightplan[2]/wp[" ~ pln_wpt_idx ~ "]/lat");
|
||||
pos.lon = getprop("/FMGC/flightplan[2]/wp[" ~ pln_wpt_idx ~ "]/lon");
|
||||
}
|
||||
} else {
|
||||
pos.lat = getprop("/autopilot/route-manager/route/wp["~pln_wpt_idx~"]/latitude-deg");
|
||||
pos.lon = getprop("/autopilot/route-manager/route/wp["~pln_wpt_idx~"]/longitude-deg");
|
||||
pos.lat = getprop("/FMGC/flightplan[2]/wp[" ~ pln_wpt_idx ~ "]/lat");
|
||||
pos.lon = getprop("/FMGC/flightplan[2]/wp[" ~ pln_wpt_idx ~ "]/lon");
|
||||
}
|
||||
} else {
|
||||
pos.lat = userLat;
|
||||
|
|
|
@ -12,9 +12,9 @@ SymbolLayer.add(name, {
|
|||
type: name, # Symbol type
|
||||
df_controller: __self__, # controller to use by default -- this one
|
||||
df_options: { # default configuration options
|
||||
active_node: "/autopilot/route-manager/active",
|
||||
current_wp_node: "/autopilot/route-manager/current-wp",
|
||||
wp_num: "/autopilot/route-manager/route/num",
|
||||
active_node: "/FMGC/flightplan[2]/active",
|
||||
current_wp_node: "/FMGC/flightplan[2]/current-wp",
|
||||
wp_num: "/FMGC/flightplan[2]/num",
|
||||
display_inactive_rte: 0
|
||||
}
|
||||
});
|
||||
|
@ -74,12 +74,12 @@ var searchCmd = func {
|
|||
path = [{},{lon:leg.wp_lon, lat:leg.wp_lat}];
|
||||
else
|
||||
path = leg.path();
|
||||
if(i == (fpSize - 1) and !discontinuity){# WORKAROUND FOR FG BUG
|
||||
var ltype = leg.wp_type;
|
||||
var path_l = size(path);
|
||||
if(ltype != 'runway' and path_l >= 2)
|
||||
path = subvec(path, 0, 1) ~ subvec(path, path_l - 1, 1);
|
||||
}
|
||||
# if(i == (fpSize - 1) and !discontinuity){# WORKAROUND FOR FG BUG -- we don't need it anymore (I think)!
|
||||
# var ltype = leg.wp_type;
|
||||
# var path_l = size(path);
|
||||
# if(ltype != 'runway' and path_l >= 2)
|
||||
# path = subvec(path, 0, 1) ~ subvec(path, path_l - 1, 1);
|
||||
# }
|
||||
coords ~= path;
|
||||
discontinuity = driver.hasDiscontinuity(idx, leg);
|
||||
}
|
||||
|
|
|
@ -58,16 +58,16 @@ var init = func {
|
|||
var cstr_txt = "\n";
|
||||
if(alt > 0){
|
||||
if(alt > 10000)
|
||||
cstr_txt ~= sprintf('FL%3.0f', int(alt / 100));
|
||||
cstr_txt ~= sprintf('FL%3d', int(alt / 100));
|
||||
else
|
||||
cstr_txt ~= sprintf('%4.0f', int(alt));
|
||||
cstr_txt ~= sprintf('%4d', int(alt));
|
||||
}
|
||||
if(spd > 0){
|
||||
if(alt > 0) cstr_txt ~= "\n";
|
||||
if(spd <= 1)
|
||||
cstr_txt ~= sprintf('%1.2fM', spd);
|
||||
cstr_txt ~= sprintf('%4.2fM', spd);
|
||||
else
|
||||
cstr_txt ~= sprintf('%3.0fKT', int(spd));
|
||||
cstr_txt ~= sprintf('%3dKT', int(spd));
|
||||
}
|
||||
me.text_alt = wp_group.createChild("text", "wp-alt-text-" ~ me.model.idx)
|
||||
.setDrawMode( canvas.Text.TEXT )
|
||||
|
|
|
@ -46,12 +46,12 @@ canvas.NDStyles["Airbus"] = {
|
|||
# that the lateral flight mode is managed.
|
||||
# You can easily override these options before creating the ND, example:
|
||||
# canvas.NDStyles["Airbus"].options.defaults.fplan_active = "my/autpilot/f-plan/active"
|
||||
fplan_active: "autopilot/route-manager/active",
|
||||
fplan_active: "/FMGC/flightplan[2]/active",
|
||||
lat_ctrl: "/it-autoflight/output/lat",
|
||||
managed_val: 1,
|
||||
ver_ctrl: "/it-autoflight/output/vert",
|
||||
spd_ctrl: "/flight-management/control/spd-ctrl",
|
||||
current_wp: "/autopilot/route-manager/current-wp",
|
||||
current_wp: "/FMGC/flightplan[2]/current-wp",
|
||||
ap1: "/it-autoflight/output/ap1",
|
||||
ap2: "/it-autoflight/output/ap2",
|
||||
nav1_frq: "/instrumentation/nav[0]/frequencies/selected-mhz",
|
||||
|
@ -740,11 +740,11 @@ canvas.NDStyles["Airbus"] = {
|
|||
id: "wpActiveId",
|
||||
impl: {
|
||||
init: func(nd,symbol),
|
||||
predicate: func(nd) getprop("/autopilot/route-manager/wp/id") != nil and
|
||||
getprop("autopilot/route-manager/active") and
|
||||
predicate: func(nd) getprop("/FMGC/flightplan[2]/current-leg") != nil and
|
||||
getprop("FMGC/flightplan[2]/active") and
|
||||
nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]),
|
||||
is_true: func(nd) {
|
||||
nd.symbols.wpActiveId.setText(getprop("/autopilot/route-manager/wp/id"));
|
||||
nd.symbols.wpActiveId.setText(getprop("/FMGC/flightplan[2]/current-leg"));
|
||||
nd.symbols.wpActiveId.show();
|
||||
},
|
||||
is_false: func(nd) nd.symbols.wpActiveId.hide(),
|
||||
|
@ -754,12 +754,16 @@ canvas.NDStyles["Airbus"] = {
|
|||
id: "wpActiveCrs",
|
||||
impl: {
|
||||
init: func(nd,symbol),
|
||||
predicate: func(nd) getprop("/autopilot/route-manager/wp/id") != nil and
|
||||
getprop("autopilot/route-manager/active") and
|
||||
predicate: func(nd) getprop("/FMGC/flightplan[2]/current-leg") != nil and
|
||||
getprop("FMGC/flightplan[2]/active") and
|
||||
nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]),
|
||||
is_true: func(nd) {
|
||||
#var cur_wp = getprop("autopilot/route-manager/current-wp");
|
||||
var deg = int(getprop("/autopilot/route-manager/wp/bearing-deg"));
|
||||
if (nd.get_switch("toggle_true_north")) {
|
||||
var deg = math.round(getprop("/FMGC/flightplan[2]/current-leg-course"));
|
||||
} else {
|
||||
var deg = math.round(getprop("/FMGC/flightplan[2]/current-leg-course-mag"));
|
||||
}
|
||||
nd.symbols.wpActiveCrs.setText((deg or "")~"°");
|
||||
nd.symbols.wpActiveCrs.show();
|
||||
},
|
||||
|
@ -770,11 +774,11 @@ canvas.NDStyles["Airbus"] = {
|
|||
id: "wpActiveDist",
|
||||
impl: {
|
||||
init: func(nd,symbol),
|
||||
predicate: func(nd) getprop("/autopilot/route-manager/wp/dist") != nil and
|
||||
getprop("autopilot/route-manager/active") and
|
||||
predicate: func(nd) getprop("/FMGC/flightplan[2]/current-leg-dist") != nil and
|
||||
getprop("FMGC/flightplan[2]/active") and
|
||||
nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]),
|
||||
is_true: func(nd) {
|
||||
var dst = getprop("/autopilot/route-manager/wp/dist");
|
||||
var dst = getprop("/FMGC/flightplan[2]/current-leg-dist");
|
||||
nd.symbols.wpActiveDist.setText(sprintf("%3.01f",dst));
|
||||
nd.symbols.wpActiveDist.show();
|
||||
},
|
||||
|
@ -785,10 +789,10 @@ canvas.NDStyles["Airbus"] = {
|
|||
id: "wpActiveDistLbl",
|
||||
impl: {
|
||||
init: func(nd,symbol),
|
||||
predicate: func(nd) getprop("/autopilot/route-manager/wp/dist") != nil and getprop("autopilot/route-manager/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]),
|
||||
predicate: func(nd) getprop("/FMGC/flightplan[2]/current-leg-dist") != nil and getprop("FMGC/flightplan[2]/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]),
|
||||
is_true: func(nd) {
|
||||
nd.symbols.wpActiveDistLbl.show();
|
||||
if(getprop("/autopilot/route-manager/wp/dist") > 1000)
|
||||
if(getprop("/FMGC/flightplan[2]/current-leg-dist") > 1000)
|
||||
nd.symbols.wpActiveDistLbl.setText(" NM");
|
||||
},
|
||||
is_false: func(nd) nd.symbols.wpActiveDistLbl.hide(),
|
||||
|
@ -798,7 +802,7 @@ canvas.NDStyles["Airbus"] = {
|
|||
id: "eta",
|
||||
impl: {
|
||||
init: func(nd,symbol),
|
||||
predicate: func(nd) getprop("autopilot/route-manager/wp/eta") != nil and getprop("autopilot/route-manager/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]),
|
||||
predicate: func(nd) getprop("autopilot/route-manager/wp/eta") != nil and getprop("FMGC/flightplan[2]/active") and nd.in_mode("toggle_display_mode", ["MAP", "PLAN"]),
|
||||
is_true: func(nd) {
|
||||
var etaSec = getprop("/sim/time/utc/day-seconds")+
|
||||
getprop("autopilot/route-manager/wp/eta-seconds");
|
||||
|
@ -1679,7 +1683,7 @@ canvas.NDStyles["Airbus"] = {
|
|||
init: func(nd,symbol),
|
||||
predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and !nd.get_switch("toggle_centered")),
|
||||
is_true: func(nd){
|
||||
var active = getprop("autopilot/route-manager/active");
|
||||
var active = getprop("FMGC/flightplan[2]/active");
|
||||
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl);
|
||||
var managed_v = nd.options.defaults.managed_val;
|
||||
var is_managed = (lat_ctrl == managed_v);
|
||||
|
@ -1708,7 +1712,7 @@ canvas.NDStyles["Airbus"] = {
|
|||
init: func(nd,symbol),
|
||||
predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and !nd.get_switch("toggle_centered")),
|
||||
is_true: func(nd){
|
||||
var active = getprop("autopilot/route-manager/active");
|
||||
var active = getprop("FMGC/flightplan[2]/active");
|
||||
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl);
|
||||
var managed_v = nd.options.defaults.managed_val;
|
||||
var is_managed = (lat_ctrl == managed_v);
|
||||
|
@ -1737,7 +1741,7 @@ canvas.NDStyles["Airbus"] = {
|
|||
init: func(nd,symbol),
|
||||
predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and nd.get_switch("toggle_centered")),
|
||||
is_true: func(nd){
|
||||
var active = getprop("autopilot/route-manager/active");
|
||||
var active = getprop("FMGC/flightplan[2]/active");
|
||||
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl);
|
||||
var managed_v = nd.options.defaults.managed_val;
|
||||
var is_managed = (lat_ctrl == managed_v);
|
||||
|
@ -1766,7 +1770,7 @@ canvas.NDStyles["Airbus"] = {
|
|||
init: func(nd,symbol),
|
||||
predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and nd.get_switch("toggle_centered")),
|
||||
is_true: func(nd){
|
||||
var active = getprop("autopilot/route-manager/active");
|
||||
var active = getprop("FMGC/flightplan[2]/active");
|
||||
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl);
|
||||
var managed_v = nd.options.defaults.managed_val;
|
||||
var is_managed = (lat_ctrl == managed_v);
|
||||
|
@ -1795,7 +1799,7 @@ canvas.NDStyles["Airbus"] = {
|
|||
init: func(nd,symbol),
|
||||
predicate: func(nd) (nd.in_mode("toggle_display_mode", ["MAP", "PLAN"])),
|
||||
is_true: func(nd){
|
||||
var active = getprop("autopilot/route-manager/active");
|
||||
var active = getprop("FMGC/flightplan[2]/active");
|
||||
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl);
|
||||
var managed_v = nd.options.defaults.managed_val;
|
||||
var is_managed = (lat_ctrl == managed_v);
|
||||
|
|
|
@ -48,10 +48,10 @@ var Radio = {
|
|||
};
|
||||
|
||||
var FPLN = {
|
||||
active: props.globals.getNode("/autopilot/route-manager/active", 1),
|
||||
active: props.globals.getNode("/FMGC/flightplan[2]/active", 1),
|
||||
activeTemp: 0,
|
||||
currentCourse: 0,
|
||||
currentWP: props.globals.getNode("/autopilot/route-manager/current-wp", 1),
|
||||
currentWP: props.globals.getNode("/FMGC/flightplan[2]/current-wp", 1),
|
||||
currentWPTemp: 0,
|
||||
deltaAngle: 0,
|
||||
deltaAngleRad: 0,
|
||||
|
@ -59,12 +59,12 @@ var FPLN = {
|
|||
maxBank: 0,
|
||||
maxBankLimit: 0,
|
||||
nextCourse: 0,
|
||||
num: props.globals.getNode("/autopilot/route-manager/route/num", 1),
|
||||
num: props.globals.getNode("/FMGC/flightplan[2]/num", 1),
|
||||
numTemp: 0,
|
||||
R: 0,
|
||||
radius: 0,
|
||||
turnDist: 0,
|
||||
wp0Dist: props.globals.getNode("/autopilot/route-manager/wp/dist", 1),
|
||||
wp0Dist: props.globals.getNode("/FMGC/flightplan[2]/current-leg-dist", 1),
|
||||
wpFlyFrom: 0,
|
||||
wpFlyTo: 0,
|
||||
};
|
||||
|
@ -405,12 +405,12 @@ var ITAF = {
|
|||
if (FPLN.wpFlyFrom < 0) {
|
||||
FPLN.wpFlyFrom = 0;
|
||||
}
|
||||
FPLN.currentCourse = getprop("/autopilot/route-manager/route/wp[" ~ FPLN.wpFlyFrom ~ "]/leg-bearing-true-deg"); # Best left at getprop
|
||||
FPLN.currentCourse = getprop("/FMGC/flightplan[2]/wp[" ~ FPLN.wpFlyFrom ~ "]/course"); # Best left at getprop
|
||||
FPLN.wpFlyTo = FPLN.currentWPTemp + 1;
|
||||
if (FPLN.wpFlyTo < 0) {
|
||||
FPLN.wpFlyTo = 0;
|
||||
}
|
||||
FPLN.nextCourse = getprop("/autopilot/route-manager/route/wp[" ~ FPLN.wpFlyTo ~ "]/leg-bearing-true-deg"); # Best left at getprop
|
||||
FPLN.nextCourse = getprop("/FMGC/flightplan[2]/wp[" ~ FPLN.wpFlyTo ~ "]/course"); # Best left at getprop
|
||||
FPLN.maxBankLimit = Internal.bankLimit.getValue();
|
||||
|
||||
FPLN.deltaAngle = math.abs(geo.normdeg180(FPLN.currentCourse - FPLN.nextCourse));
|
||||
|
@ -432,7 +432,11 @@ var ITAF = {
|
|||
Internal.lnavAdvanceNm.setValue(FPLN.turnDist);
|
||||
|
||||
if (FPLN.wp0Dist.getValue() <= FPLN.turnDist) {
|
||||
FPLN.currentWP.setValue(FPLN.currentWPTemp + 1);
|
||||
if (currentWP[2] < 1) {
|
||||
currentWP[2] = 1;
|
||||
} else if (num_out[2].getValue() > 2) { # The Airbus doesn't display anything past the previous waypoint after advancing
|
||||
flightplan.advanceDelete(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,24 +148,6 @@ var trimReset = func {
|
|||
}
|
||||
}
|
||||
|
||||
###############
|
||||
# MCDU Inputs #
|
||||
###############
|
||||
|
||||
var updateARPT = func {
|
||||
dep = getprop("/FMGC/internal/dep-arpt");
|
||||
arr = getprop("/FMGC/internal/arr-arpt");
|
||||
setprop("/autopilot/route-manager/departure/airport", dep);
|
||||
setprop("/autopilot/route-manager/destination/airport", arr);
|
||||
if (getprop("/autopilot/route-manager/active") != 1) {
|
||||
fgcommand("activate-flightplan", props.Node.new({"activate": 1}));
|
||||
}
|
||||
}
|
||||
|
||||
setlistener("/FMGC/internal/cruise-ft", func {
|
||||
setprop("/autopilot/route-manager/cruise/altitude-ft", getprop("/FMGC/internal/cruise-ft"));
|
||||
});
|
||||
|
||||
############################
|
||||
# Flight Phase and Various #
|
||||
############################
|
||||
|
@ -248,7 +230,7 @@ var masterFMGC = maketimer(0.2, func {
|
|||
setprop("/FMGC/status/phase", "5");
|
||||
}
|
||||
|
||||
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1 and getprop("/autopilot/route-manager/distance-remaining-nm") <= 15) {
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and getprop("/FMGC/flightplan[2]/arrival-leg-dist") <= 15) {
|
||||
setprop("/FMGC/internal/decel", 1);
|
||||
} else if (getprop("/FMGC/internal/decel") == 1 and (phase == 0 or phase == 6)) {
|
||||
setprop("/FMGC/internal/decel", 0);
|
||||
|
@ -302,6 +284,7 @@ var reset_FMGC = func {
|
|||
alt = getprop("/it-autoflight/input/alt");
|
||||
ITAF.init();
|
||||
FMGCinit();
|
||||
flightplan.reset();
|
||||
mcdu.MCDU_reset(0);
|
||||
mcdu.MCDU_reset(1);
|
||||
setprop("/it-autoflight/input/fd1", fd1);
|
||||
|
|
514
Nasal/MCDU/F-PLN.nas
Normal file
514
Nasal/MCDU/F-PLN.nas
Normal file
|
@ -0,0 +1,514 @@
|
|||
# Airbus A3XX FMGC MCDU Bridge
|
||||
|
||||
# Copyright (c) 2019 Joshua Davidson (it0uchpods) and Nikolai V. Chr. (Necolatis)
|
||||
|
||||
# Lowercase "g" is a degree symbol in the MCDU font.
|
||||
|
||||
var TMPY = 5;
|
||||
var MAIN = 6;
|
||||
var debug = 0; # Set to 1 to check inner functionality
|
||||
var insertReturn = nil;
|
||||
var active_out = [nil, nil, props.globals.getNode("/FMGC/flightplan[2]/active")];
|
||||
var num_out = [props.globals.getNode("/FMGC/flightplan[0]/num"), props.globals.getNode("/FMGC/flightplan[1]/num"), props.globals.getNode("/FMGC/flightplan[2]/num")];
|
||||
var TMPYActive = [props.globals.getNode("/FMGC/internal/tmpy-active[0]"), props.globals.getNode("/FMGC/internal/tmpy-active[1]")];
|
||||
|
||||
var clearFPLNComputer = func {
|
||||
FPLNLines[0].clear();
|
||||
FPLNLines[1].clear();
|
||||
}
|
||||
|
||||
var StaticText = {
|
||||
new: func(computer, type) {
|
||||
var in = {parents:[StaticText]};
|
||||
in.type = type;
|
||||
in.computer = computer;
|
||||
return in;
|
||||
},
|
||||
getText: func() {
|
||||
if (me.type == "discontinuity") {
|
||||
return "---F-PLN DISCONTINUITY--";
|
||||
} else if (me.type == "fplnEnd") {
|
||||
return "------END OF F-PLN------";
|
||||
} else if (me.type == "altnFplnEnd") {
|
||||
return "----END OF ALTN F-PLN---";
|
||||
} else if (me.type == "noAltnFpln") {
|
||||
return "------NO ALTN F-PLN-----";
|
||||
} else if (me.type == "empty") {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
getColor: func() {
|
||||
return canvas_mcdu.WHITE;
|
||||
},
|
||||
getSubText: func() {
|
||||
return "";
|
||||
},
|
||||
type: nil,
|
||||
pushButtonLeft: func() {
|
||||
notAllowed(me.computer.mcdu);
|
||||
},
|
||||
pushButtonRight: func() {
|
||||
notAllowed(me.computer.mcdu);
|
||||
},
|
||||
};
|
||||
|
||||
var FPLNText = {
|
||||
new: func(computer, wp, dest, fp, wpIndex) {
|
||||
var in = {parents:[FPLNText]};
|
||||
in.wp = wp;
|
||||
in.dest = dest;
|
||||
in.fp = fp;
|
||||
in.index = wpIndex;
|
||||
in.computer = computer;
|
||||
return in;
|
||||
},
|
||||
getText: func() {
|
||||
return me.wp.wp_name;
|
||||
},
|
||||
getColor: func(i) {
|
||||
if (TMPYActive[i].getBoolValue()) {
|
||||
if (me.dest) {
|
||||
return canvas_mcdu.WHITE;
|
||||
} else {
|
||||
return canvas_mcdu.YELLOW;
|
||||
}
|
||||
} else {
|
||||
if (me.dest) {
|
||||
return canvas_mcdu.WHITE;
|
||||
} else {
|
||||
return canvas_mcdu.GREEN;
|
||||
}
|
||||
}
|
||||
},
|
||||
getSubText: func(i) {
|
||||
if (me.index == 0) {
|
||||
return "";
|
||||
} else if (TMPYActive[i].getBoolValue()) {
|
||||
if (fmgc.arrivalAirportI[i] == me.index) {
|
||||
return "DEST";
|
||||
} else {
|
||||
return "C" ~ sprintf("%03d", fmgc.wpCoursePrev[me.fp][me.index].getValue()) ~ "g";
|
||||
}
|
||||
} else {
|
||||
if (fmgc.arrivalAirportI[2] == me.index) {
|
||||
return "DEST";
|
||||
} else {
|
||||
return "C" ~ sprintf("%03d", fmgc.wpCoursePrev[me.fp][me.index].getValue()) ~ "g";
|
||||
}
|
||||
}
|
||||
},
|
||||
wp: nil,
|
||||
pushButtonLeft: func() {
|
||||
if (me.computer.lines == MAIN) {
|
||||
fmgc.flightplan.initTempFP(me.computer.mcdu, 2);
|
||||
}
|
||||
var scratchpad = getprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad");
|
||||
if (scratchpad == "CLR") {
|
||||
if (fmgc.flightplan.deleteWP(me.index, me.computer.mcdu, 0) != 0) {
|
||||
notAllowed(me.computer.mcdu);
|
||||
} else {
|
||||
setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad-msg", 0);
|
||||
setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", "");
|
||||
}
|
||||
} else {
|
||||
if (size(scratchpad) == 5) {
|
||||
var insertReturn = fmgc.flightplan.insertFix(scratchpad, me.index, me.computer.mcdu);
|
||||
if (insertReturn == 2) {
|
||||
notAllowed(me.computer.mcdu);
|
||||
} else if (insertReturn == 1) {
|
||||
notInDataBase(me.computer.mcdu);
|
||||
} else {
|
||||
setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", "");
|
||||
}
|
||||
} else if (size(scratchpad) == 4) {
|
||||
var insertReturn = fmgc.flightplan.insertArpt(scratchpad, me.index, me.computer.mcdu);
|
||||
if (insertReturn == 2) {
|
||||
notAllowed(me.computer.mcdu);
|
||||
} else if (insertReturn == 1) {
|
||||
notInDataBase(me.computer.mcdu);
|
||||
} else {
|
||||
setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", "");
|
||||
}
|
||||
} else if (size(scratchpad) == 3) {
|
||||
var insertReturn = fmgc.flightplan.insertNavaid(scratchpad, me.index, me.computer.mcdu);
|
||||
if (insertReturn == 2) {
|
||||
notAllowed(me.computer.mcdu);
|
||||
} else if (insertReturn == 1) {
|
||||
notInDataBase(me.computer.mcdu);
|
||||
} else {
|
||||
setprop("/MCDU[" ~ me.computer.mcdu ~ "]/scratchpad", "");
|
||||
}
|
||||
} else {
|
||||
formatError(me.computer.mcdu);
|
||||
}
|
||||
}
|
||||
},
|
||||
pushButtonRight: func() {
|
||||
notAllowed(me.computer.mcdu);
|
||||
},
|
||||
};
|
||||
|
||||
var FPLNLineComputer = {
|
||||
new: func(mcdu) {
|
||||
var in = {parents:[FPLNLineComputer]};
|
||||
in.mcdu = mcdu;
|
||||
in.planEnd = StaticText.new(in, "fplnEnd");
|
||||
in.planNoAlt = StaticText.new(in, "noAltnFpln");
|
||||
if (debug == 1) printf("%d: Line computer created.", in.mcdu);
|
||||
return in;
|
||||
},
|
||||
index: 0,
|
||||
planList: [],
|
||||
destination: nil,
|
||||
destIndex: nil,
|
||||
planEnd: nil,
|
||||
planNoAlt: nil,
|
||||
lines: nil,
|
||||
output: [],
|
||||
mcdu: nil,
|
||||
fplnID: nil,
|
||||
enableScroll: 0,
|
||||
clear: func() {
|
||||
me.planList = [];
|
||||
me.destIndex = -1;
|
||||
me.destination = nil;
|
||||
me.index = 0;
|
||||
me.output = [];
|
||||
me.enableScroll = 0;
|
||||
if (me.lines == nil) {
|
||||
me.lines = MAIN;
|
||||
}
|
||||
me.updateScroll();
|
||||
},
|
||||
replacePlan: func(fplnID, lines, firstLineIndex) {
|
||||
# Here you set another plan, do this when changing plan on display or when destination changes
|
||||
if (debug == 1) printf("%d: replacePlan called for %d lines and firstLine %d", me.mcdu, lines, firstLineIndex);
|
||||
var fpln = nil;
|
||||
|
||||
me.planList = [];
|
||||
|
||||
if (!fmgc.active_out[2].getBoolValue()) {
|
||||
me.destIndex = -1;
|
||||
me.destination = nil;
|
||||
} else {
|
||||
fpln = fmgc.fp[fplnID]; # Get the Nasal Flightplan
|
||||
me.destIndex = fmgc.arrivalAirportI[fplnID];
|
||||
me.destination = FPLNText.new(me, fpln.getWP(me.destIndex), 1, fplnID, me.destIndex);
|
||||
for (var j = 0; j < fpln.getPlanSize(); j += 1) {
|
||||
me.dest = 0;
|
||||
if (j == me.destIndex) {
|
||||
me.dest = 1;
|
||||
}
|
||||
append(me.planList, FPLNText.new(me, fpln.getWP(j), me.dest, fplnID, j));
|
||||
}
|
||||
if (debug == 1) printf("%d: dest is: %s", me.mcdu, fpln.getWP(me.destIndex).wp_name);
|
||||
}
|
||||
me.index = firstLineIndex;
|
||||
me.lines = lines;
|
||||
me.initScroll();
|
||||
},
|
||||
initScroll: func() {
|
||||
me.maxItems = size(me.planList) + 2; # + 2 is for end of plan line and altn end of plan.
|
||||
me.enableScroll = me.lines < me.maxItems;
|
||||
me.checkIndex();
|
||||
if (debug == 1) printf("%d: scroll is %d. Size of plan is %d", me.mcdu, me.enableScroll, size(me.planList));
|
||||
me.updateScroll();
|
||||
},
|
||||
checkIndex: func() {
|
||||
if (!me.enableScroll) {
|
||||
me.index = 0;
|
||||
if (debug == 1) printf("%d: index forced to 0",me.mcdu);
|
||||
} elsif (me.index > size(me.planList) + 2 - me.lines) {
|
||||
me.index = size(me.planList) + 2 - me.lines;
|
||||
if (debug == 1) printf("%d: index forced to %d",me.mcdu,me.index);
|
||||
}
|
||||
},
|
||||
scrollDown: func() { # Scroll Up in Thales Manual
|
||||
if (debug == 1) printf("%d: scroll down", me.mcdu);
|
||||
me.extra = 1;
|
||||
if (!me.enableScroll) {
|
||||
me.index = 0;
|
||||
} else {
|
||||
me.index += 1;
|
||||
if (me.index > size(me.planList) + 2 - me.lines) {
|
||||
me.index = 0;
|
||||
}
|
||||
}
|
||||
me.updateScroll();
|
||||
},
|
||||
scrollUp: func() { # Scroll Down in Thales Manual
|
||||
if (debug == 1) printf("%d: scroll up", me.mcdu);
|
||||
me.extra = 1;
|
||||
if (!me.enableScroll) {
|
||||
me.index = 0;
|
||||
} else {
|
||||
me.index -= 1;
|
||||
if (me.index < 0) {
|
||||
me.index = size(me.planList) + 2 - me.lines;
|
||||
}
|
||||
}
|
||||
me.updateScroll();
|
||||
},
|
||||
updateScroll: func() {
|
||||
me.output = [];
|
||||
if (me.index <= size(me.planList) + 1) {
|
||||
var i = 0;
|
||||
me.realIndex = me.index - 1;
|
||||
if (debug == 1) printf("%d: updating display from index %d", me.mcdu, me.realIndex);
|
||||
for (i = me.index; i < math.min(size(me.planList), me.index + 5); i += 1) {
|
||||
append(me.output, me.planList[i]);
|
||||
me.realIndex = i;
|
||||
}
|
||||
if (debug == 1) printf("%d: populated until wp index %d", me.mcdu,me.realIndex);
|
||||
if (me.realIndex < me.destIndex and me.lines == MAIN) {
|
||||
# Destination has not been shown yet, now its time (if we show 6 lines)
|
||||
append(me.output, me.destination);
|
||||
if (debug == 1) printf("%d: added dest at bottom for total of %d lines", me.mcdu, size(me.output));
|
||||
return;
|
||||
} else if (size(me.output) < me.lines) {
|
||||
for (i = me.realIndex + 1; size(me.output) < me.lines and i < size(me.planList); i += 1) {
|
||||
append(me.output, me.planList[i]);
|
||||
me.realIndex = i;
|
||||
}
|
||||
if (debug == 1) printf("%d: populated after until wp index %d", me.mcdu,me.realIndex);
|
||||
if (size(me.output) < me.lines) {
|
||||
if (me.realIndex == size(me.planList)-1) {
|
||||
# Show the end of plan
|
||||
append(me.output, me.planEnd);
|
||||
me.realIndex += 1;
|
||||
if (debug == 1) printf("%d: added end, wp index=%d", me.mcdu, me.realIndex);
|
||||
}
|
||||
if (size(me.output) < me.lines and (me.realIndex == size(me.planList))) {
|
||||
append(me.output, me.planNoAlt);
|
||||
me.realIndex += 1;
|
||||
if (debug == 1) printf("%d: added no-alt, wp index=%d", me.mcdu,me.realIndex);
|
||||
if (me.enableScroll and size(me.output) < me.lines) {
|
||||
# We start wrapping
|
||||
for (var j = 0; size(me.output) < me.lines; j += 1) {
|
||||
append(me.output, me.planList[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (size(me.output) < me.lines) {
|
||||
append(me.output, StaticText.new(me, "empty"));
|
||||
}
|
||||
if (debug == 1) printf("%d: %d lines", me.mcdu, size(me.output));
|
||||
},
|
||||
};
|
||||
|
||||
var FPLNLines = [FPLNLineComputer.new(0), FPLNLineComputer.new(1)];
|
||||
clearFPLNComputer(); # Just in case, we have it in the clear state.
|
||||
|
||||
var slewFPLN = func(d, i) { # Scrolling function. d is -1 or 1 for direction, and i is instance.
|
||||
if (d == 1) {
|
||||
FPLNLines[i].scrollDown(); # Scroll Up in Thales Manual
|
||||
} else if (d == -1) {
|
||||
FPLNLines[i].scrollUp(); # Scroll Down in Thales Manual
|
||||
}
|
||||
}
|
||||
|
||||
# Button and Inputs
|
||||
var FPLNButton = func(s, key, i) {
|
||||
var scratchpad = getprop("/MCDU[" ~ i ~ "]/scratchpad");
|
||||
if (s == "L") {
|
||||
if (key == 6 and TMPYActive[i].getBoolValue()) {
|
||||
fmgc.flightplan.eraseTempFP(i, 2);
|
||||
} else {
|
||||
if (scratchpad != "") {
|
||||
if (size(FPLNLines[i].output) >= key) {
|
||||
FPLNLines[i].output[key - 1].pushButtonLeft();
|
||||
}
|
||||
} else {
|
||||
notAllowed(i); # Remove when has functionality
|
||||
# FIXME: Add LAT REV Logic
|
||||
}
|
||||
}
|
||||
} else if (s == "R") {
|
||||
if (key == 6 and TMPYActive[i].getBoolValue()) {
|
||||
fmgc.flightplan.executeTempFP(i, 2);
|
||||
} else {
|
||||
# if (scratchpad != "") {
|
||||
# if (size(FPLNLines[i].output) >= key) {
|
||||
# FPLNLines[i].output[key - 1].pushButtonRight();
|
||||
# }
|
||||
# } else {
|
||||
notAllowed(i); # Remove when has functionality
|
||||
# FIXME: Add VERT REV Logic
|
||||
# }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var notInDataBase = func(i) {
|
||||
if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { # Messages clear after NOT IN DATABASE
|
||||
setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE");
|
||||
} else {
|
||||
setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad"));
|
||||
}
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1);
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE");
|
||||
}
|
||||
|
||||
# For testing purposes only -- do not touch!
|
||||
var test = func {
|
||||
var fp = createFlightplan(getprop("sim/aircraft-dir")~"/plan.gpx");
|
||||
var desti = int(fp.getPlanSize()*0.5);
|
||||
FPLNLines[0].replacePlan(fp,6,desti,0);
|
||||
print("Display:");
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("down");FPLNLines[0].scrollDown();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
print("up");FPLNLines[0].scrollUp();
|
||||
foreach(line;FPLNLines[0].output) {
|
||||
printf("line: %s",line.getText());
|
||||
}
|
||||
}
|
||||
|
||||
#test();
|
|
@ -70,10 +70,11 @@ var initInputA = func(key, i) {
|
|||
}
|
||||
} else if (key == "R1") {
|
||||
if (scratchpad == "CLR") {
|
||||
clearFPLNComputer();
|
||||
setprop("/FMGC/internal/dep-arpt", "");
|
||||
setprop("/FMGC/internal/arr-arpt", "");
|
||||
setprop("/FMGC/internal/tofrom-set", 0);
|
||||
fmgc.updateARPT();
|
||||
fmgc.flightplan.reset();
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0);
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "");
|
||||
} else {
|
||||
|
@ -87,7 +88,7 @@ var initInputA = func(key, i) {
|
|||
setprop("/FMGC/internal/arr-arpt", fromto[1]);
|
||||
setprop("/FMGC/internal/tofrom-set", 1);
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "");
|
||||
fmgc.updateARPT();
|
||||
fmgc.flightplan.updateARPT(fromto[0], fromto[1], 2);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
|
|
@ -105,6 +105,8 @@ var lskbutton = func(btn, i) {
|
|||
printInput("L1", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") {
|
||||
printInput2("L1", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
FPLNButton("L", 1, i);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
@ -127,6 +129,8 @@ var lskbutton = func(btn, i) {
|
|||
printInput("L2", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") {
|
||||
printInput2("L2", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
FPLNButton("L", 2, i);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
@ -143,6 +147,8 @@ var lskbutton = func(btn, i) {
|
|||
printInput("L3", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") {
|
||||
printInput2("L3", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
FPLNButton("L", 3, i);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
@ -155,6 +161,8 @@ var lskbutton = func(btn, i) {
|
|||
radnavInput("L4", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") {
|
||||
printInput2("L4", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
FPLNButton("L", 4, i);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
@ -175,6 +183,8 @@ var lskbutton = func(btn, i) {
|
|||
printInput("L5", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") {
|
||||
printInput2("L5", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
FPLNButton("L", 5, i);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
@ -189,6 +199,8 @@ var lskbutton = func(btn, i) {
|
|||
perfDESInput("L6", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2") {
|
||||
printInput2("L6", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
FPLNButton("L", 6, i);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
@ -285,6 +297,8 @@ var rskbutton = func(btn, i) {
|
|||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "AOC DISABLED");
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") {
|
||||
initInputA("R6", i);
|
||||
} else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
FPLNButton("R", 6, i);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
@ -333,9 +347,13 @@ var arrowbutton = func(btn, i) {
|
|||
setprop("/MCDU[" ~ i ~ "]/page", "PRINTFUNC");
|
||||
}
|
||||
} else if (btn == "up") {
|
||||
# Nothing for now
|
||||
if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
slewFPLN(1, i);
|
||||
}
|
||||
} else if (btn == "down") {
|
||||
# Nothing for now
|
||||
if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") {
|
||||
slewFPLN(-1, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +381,12 @@ var pagebutton = func(btn, i) {
|
|||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "SELECT DESIRED SYSTEM");
|
||||
setprop("/MCDU[" ~ i ~ "]/page", "MCDU");
|
||||
} else if (btn == "f-pln") {
|
||||
if (active_out[2].getBoolValue()) {
|
||||
setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA");
|
||||
} else {
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1);
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "ERROR. INITIALIZE ROUTE"); # Should be ERROR:, but the : character doesn't show in our MCDU font right now...
|
||||
}
|
||||
} else if (btn == "fuel-pred") {
|
||||
setprop("/MCDU[" ~ i ~ "]/page", "FUELPRED");
|
||||
}
|
||||
|
@ -534,6 +557,18 @@ var notAllowed = func(i) {
|
|||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT ALLOWED");
|
||||
}
|
||||
|
||||
var formatError = func(i) {
|
||||
if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "FORMAT ERROR") {
|
||||
if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) {
|
||||
setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "");
|
||||
} else {
|
||||
setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad"));
|
||||
}
|
||||
}
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1);
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "FORMAT ERROR");
|
||||
}
|
||||
|
||||
var screenFlash = func(time, i) {
|
||||
var page = getprop("/MCDU[" ~ i ~ "]/page");
|
||||
setprop("/MCDU[" ~ i ~ "]/page", "NONE");
|
||||
|
|
316
Nasal/flightplan.nas
Normal file
316
Nasal/flightplan.nas
Normal file
|
@ -0,0 +1,316 @@
|
|||
# A3XX FMGC Flightplan Driver
|
||||
|
||||
# Copyright (c) 2019 Joshua Davidson (it0uchpods)
|
||||
# This thing replaces the Route Manager, it's far from finished though
|
||||
print("System: You are using an experimental version of the IDG-A32X. Things may go TERRIBLY WRONG!");
|
||||
print("System: FMGC Dev Version - Copyright (c) 2019 Joshua Davidson (it0uchpods)");
|
||||
|
||||
# 0 = TEMP FP Captain MCDU
|
||||
# 1 = TEMP FP First Officer MCDU
|
||||
# 2 = ACTIVE FP
|
||||
var fp = [createFlightplan(), createFlightplan(), createFlightplan()];
|
||||
var wpDep = nil;
|
||||
var wpArr = nil;
|
||||
var pos = nil;
|
||||
var geoPos = nil;
|
||||
var geoPosPrev = geo.Coord.new();
|
||||
var currentLegCourseDist = nil;
|
||||
var courseDistanceFrom = nil;
|
||||
var courseDistanceFromPrev = nil;
|
||||
var sizeWP = nil;
|
||||
var magTrueError = 0;
|
||||
var arrivalAirportI = [0, 0, 0];
|
||||
|
||||
# Vars for MultiFlightplan
|
||||
var currentWP = [nil, nil, 0];
|
||||
var currentLeg = [nil, nil, ""];
|
||||
|
||||
# Create/Fetch props.nas for MultiFlightplan
|
||||
var altFeet = props.globals.getNode("/instrumentation/altimeter/indicated-altitude-ft", 1);
|
||||
var active_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/active", 0, "BOOL")];
|
||||
var currentWP_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-wp", 0, "INT")];
|
||||
var currentLeg_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg", "", "STRING")];
|
||||
var currentLegCourse_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-course", 0, "DOUBLE")];
|
||||
var currentLegDist_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-dist", 0, "DOUBLE")];
|
||||
var currentLegCourseMag_out = [nil, nil, props.globals.initNode("/FMGC/flightplan[2]/current-leg-course-mag", 0, "DOUBLE")];
|
||||
var arrivalLegDist_out = [props.globals.initNode("/FMGC/flightplan[0]/arrival-leg-dist", 0, "DOUBLE"), props.globals.initNode("/FMGC/flightplan[1]/arrival-leg-dist", 0, "DOUBLE"), props.globals.initNode("/FMGC/flightplan[2]/arrival-leg-dist", 0, "DOUBLE")];
|
||||
var num_out = [props.globals.initNode("/FMGC/flightplan[0]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[1]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[2]/num", 0, "INT")];
|
||||
var toFromSet = props.globals.initNode("/FMGC/internal/tofrom-set", 0, "BOOL");
|
||||
var magHDG = props.globals.getNode("/orientation/heading-magnetic-deg", 1);
|
||||
var trueHDG = props.globals.getNode("/orientation/heading-deg", 1);
|
||||
var FMGCdep = props.globals.getNode("/FMGC/internal/dep-arpt", 1);
|
||||
var FMGCarr = props.globals.getNode("/FMGC/internal/arr-arpt", 1);
|
||||
var TMPYActive = [props.globals.initNode("/FMGC/internal/tmpy-active[0]", 0, "BOOL"), props.globals.initNode("/FMGC/internal/tmpy-active[1]", 0, "BOOL")];
|
||||
|
||||
# Create props.nas for flightplan
|
||||
# Vectors inside vectors, so we can use as many flightplans or waypoints as we want
|
||||
var wpID = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/id", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/id", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/id", "", "STRING")]];
|
||||
var wpLat = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/lat", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/lat", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/lat", 0, "DOUBLE")]];
|
||||
var wpLon = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/lon", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/lon", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/lon", 0, "DOUBLE")]];
|
||||
var wpCourse = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/course", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/course", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/course", 0, "DOUBLE")]];
|
||||
var wpDistance = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/distance", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/distance", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/distance", 0, "DOUBLE")]];
|
||||
var wpCoursePrev = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/course-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/course-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/course-from-prev", 0, "DOUBLE")]];
|
||||
var wpDistancePrev = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/distance-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/distance-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/distance-from-prev", 0, "DOUBLE")]];
|
||||
|
||||
var flightplan = {
|
||||
reset: func() {
|
||||
TMPYActive[0].setBoolValue(0);
|
||||
TMPYActive[1].setBoolValue(0);
|
||||
me.reset0();
|
||||
me.reset1();
|
||||
me.reset2();
|
||||
},
|
||||
reset0: func() {
|
||||
fp[0].cleanPlan();
|
||||
fp[0].departure = nil;
|
||||
fp[0].destination = nil;
|
||||
},
|
||||
reset1: func() {
|
||||
fp[1].cleanPlan();
|
||||
fp[1].departure = nil;
|
||||
fp[1].destination = nil;
|
||||
},
|
||||
reset2: func() {
|
||||
fp[2].cleanPlan();
|
||||
fp[2].departure = nil;
|
||||
fp[2].destination = nil;
|
||||
currentWP[2] = 0;
|
||||
currentLeg[2] = "";
|
||||
},
|
||||
initTempFP: func(f, n) { # f is temp, n is active
|
||||
fp[f] = fp[n].clone();
|
||||
TMPYActive[f].setBoolValue(1);
|
||||
me.checkWPOutputs(f);
|
||||
},
|
||||
eraseTempFP: func(f, n) { # f is temp, n is active
|
||||
TMPYActive[f].setBoolValue(0);
|
||||
if (f == 0) {
|
||||
me.reset0();
|
||||
} else if (f == 1) {
|
||||
me.reset1();
|
||||
}
|
||||
me.checkWPOutputs(n);
|
||||
},
|
||||
executeTempFP: func(f, n) { # f is temp, n is active
|
||||
fp[n] = fp[f].clone();
|
||||
TMPYActive[f].setBoolValue(0);
|
||||
if (f == 0) {
|
||||
me.reset0();
|
||||
} else if (f == 1) {
|
||||
me.reset1();
|
||||
}
|
||||
me.checkWPOutputs(n);
|
||||
},
|
||||
advanceDelete: func(n) {
|
||||
if (num_out[n].getValue() > 2) {
|
||||
if (TMPYActive[0].getBoolValue() and wpID[0][0] == wpID[n][0]) {
|
||||
me.deleteWP(0, 0);
|
||||
}
|
||||
if (TMPYActive[1].getBoolValue() and wpID[1][0] == wpID[n][0]) {
|
||||
me.deleteWP(0, 1);
|
||||
}
|
||||
me.deleteWP(0, n, 1);
|
||||
}
|
||||
},
|
||||
updateARPT: func(dep, arr, n) {
|
||||
if (n == 2) { # Which flightplan?
|
||||
me.reset2();
|
||||
|
||||
# Set Departure ARPT
|
||||
if (dep != nil) {
|
||||
fp[2].departure = airportinfo(dep);
|
||||
} else {
|
||||
fp[2].departure = nil;
|
||||
}
|
||||
|
||||
# Set Arrival ARPT
|
||||
if (arr != nil) {
|
||||
fp[2].destination = airportinfo(arr);
|
||||
} else {
|
||||
fp[2].destination = nil;
|
||||
}
|
||||
|
||||
currentWP[2] = 0;
|
||||
}
|
||||
|
||||
me.checkWPOutputs(n);
|
||||
},
|
||||
# return 1 will cause NOT IN DATABASE, return 2 will cause NOT ALLOWED
|
||||
insertFix: func(wp, i, n) {
|
||||
var pos = findFixesByID(wp);
|
||||
if (i == 0) {
|
||||
return 2;
|
||||
} else if (pos != nil and size(pos) > 0) {
|
||||
fp[n].insertWP(createWPFrom(pos[0]), i);
|
||||
me.checkWPOutputs(n);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
insertArpt: func(wp, i, n) {
|
||||
var pos = findAirportsByICAO(wp);
|
||||
if (i == 0) {
|
||||
return 2;
|
||||
} else if (pos != nil and size(pos) > 0) {
|
||||
fp[n].insertWP(createWPFrom(pos[0]), i);
|
||||
me.checkWPOutputs(n);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
insertNavaid: func(nav, i, n) {
|
||||
var pos = findNavaidsByID(nav);
|
||||
if (i == 0) {
|
||||
return 2;
|
||||
} else if (pos != nil and size(pos) > 0) {
|
||||
fp[n].insertWP(createWPFrom(pos[0]), i);
|
||||
me.checkWPOutputs(n);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
insertPPOS: func(n) {
|
||||
fp[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), 0);
|
||||
me.checkWPOutputs(n);
|
||||
},
|
||||
insertTP: func(n) {
|
||||
fp[n].insertWP(createWP(geo.aircraft_position(), "T/P"), 0);
|
||||
me.checkWPOutputs(n);
|
||||
},
|
||||
deleteWP: func(i, n, t) {
|
||||
var wp = wpID[n][i].getValue();
|
||||
if (t == 1) {
|
||||
fp[n].deleteWP(i);
|
||||
me.outputProps(); # Make sure everything is updated before we update the MCDUs.
|
||||
me.updateMCDUDriver(n);
|
||||
canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed");
|
||||
return 0;
|
||||
} else {
|
||||
if (i == 0) {
|
||||
return 2;
|
||||
} else if (fp[n].getPlanSize() > 2 and wp != FMGCdep.getValue() and wp != FMGCarr.getValue() and wp != "T/P" and wp != "PPOS") {
|
||||
fp[n].deleteWP(i);
|
||||
me.outputProps(); # Make sure everything is updated before we update the MCDUs.
|
||||
me.updateMCDUDriver(n);
|
||||
canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed");
|
||||
return 0;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
},
|
||||
checkWPOutputs: func(n) {
|
||||
sizeWP = size(wpID[n]);
|
||||
for (var counter = sizeWP; counter < fp[n].getPlanSize(); counter += 1) {
|
||||
append(wpID[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/id", "", "STRING"));
|
||||
append(wpLat[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/lat", 0, "DOUBLE"));
|
||||
append(wpLon[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/lon", 0, "DOUBLE"));
|
||||
append(wpCourse[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course", 0, "DOUBLE"));
|
||||
append(wpDistance[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance", 0, "DOUBLE"));
|
||||
append(wpCoursePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course-from-prev", 0, "DOUBLE"));
|
||||
append(wpDistancePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance-from-prev", 0, "DOUBLE"));
|
||||
}
|
||||
me.outputProps(); # Make sure everything is updated before we update the MCDUs.
|
||||
me.updateMCDUDriver(n);
|
||||
canvas_nd.A3XXRouteDriver.triggerSignal("fp-added"); # Update the NDs
|
||||
},
|
||||
updateMCDUDriver: func(n) {
|
||||
for (var i = 0; i < 2; i += 1) { # Update the 2 MCDUs
|
||||
if (TMPYActive[i].getBoolValue()) {
|
||||
mcdu.FPLNLines[i].replacePlan(i, mcdu.TMPY, mcdu.FPLNLines[i].index);
|
||||
} else {
|
||||
mcdu.FPLNLines[i].replacePlan(2, mcdu.MAIN, mcdu.FPLNLines[i].index);
|
||||
}
|
||||
}
|
||||
},
|
||||
outputProps: func() {
|
||||
geoPos = geo.aircraft_position();
|
||||
|
||||
for (var n = 0; n < 3; n += 1) { # Note: Some things don't get done for TMPY (0) hence all the if (n > 1) {}
|
||||
if (((n == 0 and TMPYActive[0].getBoolValue()) or (n == 1 and TMPYActive[1].getBoolValue()) or n > 1) and toFromSet.getBoolValue() and fp[n].departure != nil and fp[n].destination != nil) {
|
||||
if (n > 1) {
|
||||
if (currentWP[n] > fp[n].getPlanSize()) {
|
||||
currentWP[n] = fp[n].getPlanSize();
|
||||
}
|
||||
|
||||
if (active_out[n].getBoolValue() != 1) {
|
||||
active_out[n].setBoolValue(1);
|
||||
}
|
||||
|
||||
currentLeg[n] = fp[n].getWP(currentWP[n]).wp_name;
|
||||
|
||||
if (currentLeg_out[n].getValue() != currentLeg[n]) {
|
||||
currentLeg_out[n].setValue(currentLeg[n]);
|
||||
}
|
||||
|
||||
currentLegCourseDist = fp[n].getWP(currentWP[n]).courseAndDistanceFrom(geoPos);
|
||||
currentLegCourse_out[n].setValue(currentLegCourseDist[0]);
|
||||
currentLegDist_out[n].setValue(currentLegCourseDist[1]);
|
||||
|
||||
magTrueError = magHDG.getValue() - trueHDG.getValue();
|
||||
currentLegCourseMag_out[n].setValue(currentLegCourseDist[0] + magTrueError); # Convert to Magnetic
|
||||
}
|
||||
|
||||
if (num_out[n].getValue() != fp[n].getPlanSize()) {
|
||||
num_out[n].setValue(fp[n].getPlanSize());
|
||||
}
|
||||
|
||||
for (var i = 0; i < fp[n].getPlanSize(); i += 1) {
|
||||
wpID[n][i].setValue(fp[n].getWP(i).wp_name);
|
||||
wpLat[n][i].setValue(fp[n].getWP(i).wp_lat);
|
||||
wpLon[n][i].setValue(fp[n].getWP(i).wp_lon);
|
||||
courseDistanceFrom = fp[n].getWP(i).courseAndDistanceFrom(geoPos);
|
||||
wpCourse[n][i].setValue(courseDistanceFrom[0]);
|
||||
wpDistance[n][i].setValue(courseDistanceFrom[1]);
|
||||
|
||||
if (i > 0) { # Impossible to do from the first WP
|
||||
geoPosPrev.set_latlon(fp[n].getWP(i - 1).lat, fp[n].getWP(i - 1).lon, altFeet.getValue() * 0.3048);
|
||||
courseDistanceFromPrev = fp[n].getWP(i).courseAndDistanceFrom(geoPosPrev);
|
||||
wpCoursePrev[n][i].setValue(courseDistanceFromPrev[0]);
|
||||
wpDistancePrev[n][i].setValue(courseDistanceFromPrev[1]);
|
||||
} else { # So if its the first WP, we just use current position instead
|
||||
wpCoursePrev[n][i].setValue(courseDistanceFrom[0]);
|
||||
wpDistancePrev[n][i].setValue(courseDistanceFrom[1]);
|
||||
}
|
||||
|
||||
if (wpID[n][i].getValue() == FMGCarr.getValue()) {
|
||||
arrivalAirportI[n] = i;
|
||||
}
|
||||
}
|
||||
|
||||
arrivalLegDist_out[n].setValue(wpDistance[n][arrivalAirportI[n]].getValue());
|
||||
} else {
|
||||
if (n > 1) {
|
||||
if (active_out[n].getBoolValue() != 0) {
|
||||
active_out[n].setBoolValue(0);
|
||||
}
|
||||
|
||||
if (currentLeg_out[n].getValue() != "") {
|
||||
currentLeg_out[n].setValue("");
|
||||
}
|
||||
}
|
||||
|
||||
if (num_out[n].getValue() != 0) {
|
||||
num_out[n].setValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (n > 1) {
|
||||
if (currentWP[n] != nil) {
|
||||
if (currentWP_out[n].getValue() != currentWP[n]) {
|
||||
currentWP_out[n].setValue(currentWP[n]);
|
||||
}
|
||||
} else {
|
||||
if (currentWP_out[n].getValue() != 0) {
|
||||
currentWP_out[n].setValue(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
var outputPropsTimer = maketimer(0.1, flightplan.outputProps);
|
|
@ -192,6 +192,7 @@ var systemsInit = func {
|
|||
systems.fire_init();
|
||||
systems.autobrake_init();
|
||||
fadec.FADEC.init();
|
||||
fmgc.flightplan.reset();
|
||||
fmgc.ITAF.init();
|
||||
fmgc.FMGCinit();
|
||||
mcdu.MCDU_init(0);
|
||||
|
@ -209,6 +210,7 @@ var systemsInit = func {
|
|||
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
systemsInit();
|
||||
fmgc.outputPropsTimer.start();
|
||||
});
|
||||
|
||||
var systemsLoop = maketimer(0.1, func {
|
||||
|
|
|
@ -449,7 +449,7 @@
|
|||
</condition>
|
||||
<expression>
|
||||
<sum>
|
||||
<property>/autopilot/route-manager/wp[0]/true-bearing-deg</property>
|
||||
<property>/FMGC/flightplan[2]/current-leg-course</property>
|
||||
<product>
|
||||
<property>/it-autoflight/internal/drift-angle-deg</property>
|
||||
<value>-1.0</value>
|
||||
|
|
Reference in a new issue