FMGC: Add support for independant temporary flightplans, and begin new F-PLN code
This commit is contained in:
parent
b50fd37187
commit
ef255e7bbe
11 changed files with 142 additions and 114 deletions
Models/Instruments/ND/canvas
Nasal
Systems
|
@ -16,7 +16,7 @@ var A3XXRouteDriver = {
|
|||
me.update();
|
||||
},
|
||||
update: func(){
|
||||
me.flightplan = fmgc.fp[1];
|
||||
me.flightplan = fmgc.fp[2];
|
||||
},
|
||||
getNumberOfFlightPlans: func(){1},
|
||||
getFlightPlanType: func(fpNum){"current"},
|
||||
|
|
|
@ -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("/FMGC/flightplan[1]/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("/FMGC/flightplan[1]/wp[" ~ pln_wpt_idx ~ "]/lat");
|
||||
pos.lon = getprop("/FMGC/flightplan[1]/wp[" ~ pln_wpt_idx ~ "]/lon");
|
||||
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("/FMGC/flightplan[1]/wp[" ~ pln_wpt_idx ~ "]/lat");
|
||||
pos.lon = getprop("/FMGC/flightplan[1]/wp[" ~ pln_wpt_idx ~ "]/lon");
|
||||
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: "/FMGC/flightplan[1]/active",
|
||||
current_wp_node: "/FMGC/flightplan[1]/current-wp",
|
||||
wp_num: "/FMGC/flightplan[1]/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
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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: "/FMGC/flightplan[1]/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: "/FMGC/flightplan[1]/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("/FMGC/flightplan[1]/current-leg") != nil and
|
||||
getprop("FMGC/flightplan[1]/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("/FMGC/flightplan[1]/current-leg"));
|
||||
nd.symbols.wpActiveId.setText(getprop("/FMGC/flightplan[2]/current-leg"));
|
||||
nd.symbols.wpActiveId.show();
|
||||
},
|
||||
is_false: func(nd) nd.symbols.wpActiveId.hide(),
|
||||
|
@ -754,15 +754,15 @@ canvas.NDStyles["Airbus"] = {
|
|||
id: "wpActiveCrs",
|
||||
impl: {
|
||||
init: func(nd,symbol),
|
||||
predicate: func(nd) getprop("/FMGC/flightplan[1]/current-leg") != nil and
|
||||
getprop("FMGC/flightplan[1]/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");
|
||||
if (nd.get_switch("toggle_true_north")) {
|
||||
var deg = math.round(getprop("/FMGC/flightplan[1]/current-leg-course"));
|
||||
var deg = math.round(getprop("/FMGC/flightplan[2]/current-leg-course"));
|
||||
} else {
|
||||
var deg = math.round(getprop("/FMGC/flightplan[1]/current-leg-course-mag"));
|
||||
var deg = math.round(getprop("/FMGC/flightplan[2]/current-leg-course-mag"));
|
||||
}
|
||||
nd.symbols.wpActiveCrs.setText((deg or "")~"°");
|
||||
nd.symbols.wpActiveCrs.show();
|
||||
|
@ -774,11 +774,11 @@ canvas.NDStyles["Airbus"] = {
|
|||
id: "wpActiveDist",
|
||||
impl: {
|
||||
init: func(nd,symbol),
|
||||
predicate: func(nd) getprop("/FMGC/flightplan[1]/current-leg-dist") != nil and
|
||||
getprop("FMGC/flightplan[1]/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("/FMGC/flightplan[1]/current-leg-dist");
|
||||
var dst = getprop("/FMGC/flightplan[2]/current-leg-dist");
|
||||
nd.symbols.wpActiveDist.setText(sprintf("%3.01f",dst));
|
||||
nd.symbols.wpActiveDist.show();
|
||||
},
|
||||
|
@ -789,10 +789,10 @@ canvas.NDStyles["Airbus"] = {
|
|||
id: "wpActiveDistLbl",
|
||||
impl: {
|
||||
init: func(nd,symbol),
|
||||
predicate: func(nd) getprop("/FMGC/flightplan[1]/current-leg-dist") != nil and getprop("FMGC/flightplan[1]/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("/FMGC/flightplan[1]/current-leg-dist") > 1000)
|
||||
if(getprop("/FMGC/flightplan[2]/current-leg-dist") > 1000)
|
||||
nd.symbols.wpActiveDistLbl.setText(" NM");
|
||||
},
|
||||
is_false: func(nd) nd.symbols.wpActiveDistLbl.hide(),
|
||||
|
@ -802,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("FMGC/flightplan[1]/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");
|
||||
|
@ -1683,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("FMGC/flightplan[1]/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);
|
||||
|
@ -1712,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("FMGC/flightplan[1]/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);
|
||||
|
@ -1741,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("FMGC/flightplan[1]/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);
|
||||
|
@ -1770,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("FMGC/flightplan[1]/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);
|
||||
|
@ -1799,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("FMGC/flightplan[1]/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);
|
||||
|
|
|
@ -338,7 +338,7 @@ var lateral = func {
|
|||
setprop("/it-autoflight/mode/lat", "HDG");
|
||||
setprop("/it-autoflight/mode/arm", " ");
|
||||
} else if (latset == 1) {
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
|
||||
make_lnav_active();
|
||||
} else {
|
||||
if (getprop("/it-autoflight/output/lat") != 1) {
|
||||
|
@ -396,7 +396,7 @@ var lat_arm = func {
|
|||
setprop("/it-autoflight/mode/arm", " ");
|
||||
setprop("/it-autoflight/custom/show-hdg", 1);
|
||||
} else if (latset == 1) {
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1) {
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1) {
|
||||
setprop("/it-autoflight/input/lat-arm", 1);
|
||||
setprop("/it-autoflight/mode/arm", "LNV");
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ var vertical = func {
|
|||
setprop("/it-autoflight/internal/alt", altinput);
|
||||
thrustmodet.start();
|
||||
} else if (vertset == 8) {
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1 and getprop("/it-autoflight/internal/alt-const") >= 100) {
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and getprop("/it-autoflight/internal/alt-const") >= 100) {
|
||||
alandt.stop();
|
||||
alandt1.stop();
|
||||
setprop("/it-autoflight/output/appr-armed", 0);
|
||||
|
@ -662,19 +662,19 @@ var ap_various = func {
|
|||
setprop("/it-autoflight/internal/bank-limit", 25);
|
||||
}
|
||||
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1) {
|
||||
if ((getprop("/FMGC/flightplan[1]/current-wp") + 1) < getprop("/FMGC/flightplan[1]/num")) {
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1) {
|
||||
if ((getprop("/FMGC/flightplan[2]/current-wp") + 1) < getprop("/FMGC/flightplan[2]/num")) {
|
||||
gnds_mps = getprop("/velocities/groundspeed-kt") * 0.5144444444444;
|
||||
wp_fly_from = getprop("/FMGC/flightplan[1]/current-wp");
|
||||
wp_fly_from = getprop("/FMGC/flightplan[2]/current-wp");
|
||||
if (wp_fly_from < 0) {
|
||||
wp_fly_from = 0;
|
||||
}
|
||||
current_course = getprop("/FMGC/flightplan[1]/wp[" ~ wp_fly_from ~ "]/course");
|
||||
wp_fly_to = getprop("/FMGC/flightplan[1]/current-wp") + 1;
|
||||
current_course = getprop("/FMGC/flightplan[2]/wp[" ~ wp_fly_from ~ "]/course");
|
||||
wp_fly_to = getprop("/FMGC/flightplan[2]/current-wp") + 1;
|
||||
if (wp_fly_to < 0) {
|
||||
wp_fly_to = 0;
|
||||
}
|
||||
next_course = getprop("/FMGC/flightplan[1]/wp[" ~ wp_fly_to ~ "]/course");
|
||||
next_course = getprop("/FMGC/flightplan[2]/wp[" ~ wp_fly_to ~ "]/course");
|
||||
max_bank_limit = getprop("/it-autoflight/internal/bank-limit");
|
||||
|
||||
delta_angle = math.abs(geo.normdeg180(current_course - next_course));
|
||||
|
@ -696,8 +696,8 @@ var ap_various = func {
|
|||
}
|
||||
setprop("/it-autoflight/internal/lnav-advance-nm", turn_dist);
|
||||
|
||||
if (getprop("/FMGC/flightplan[1]/current-leg-dist") <= turn_dist) {
|
||||
currentWP[1] = currentWP[1] + 1;
|
||||
if (getprop("/FMGC/flightplan[2]/current-leg-dist") <= turn_dist) {
|
||||
currentWP[2] = currentWP[2] + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -914,7 +914,7 @@ var check_arms = func {
|
|||
}
|
||||
|
||||
var update_arms = func {
|
||||
if (getprop("/it-autoflight/input/lat-arm") == 1 and getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
|
||||
if (getprop("/it-autoflight/input/lat-arm") == 1 and getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
|
||||
make_lnav_active();
|
||||
}
|
||||
if (getprop("/instrumentation/nav[0]/in-range") == 1) {
|
||||
|
@ -1014,10 +1014,10 @@ var aland1 = func {
|
|||
|
||||
# Managed Climb/Descent
|
||||
var mng_main = func {
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1) {
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1) {
|
||||
altinput = getprop("/it-autoflight/input/alt");
|
||||
setprop("/it-autoflight/internal/alt", altinput);
|
||||
var wp_curr = getprop("/FMGC/flightplan[1]/current-wp");
|
||||
var wp_curr = getprop("/FMGC/flightplan[2]/current-wp");
|
||||
var mng_alt_wp = getprop("/autopilot/route-manager/route/wp", wp_curr, "altitude-ft");
|
||||
if (getprop("/it-autoflight/internal/alt-const") == mng_alt_wp) {
|
||||
# Do nothing
|
||||
|
@ -1056,7 +1056,7 @@ setlistener("/it-autoflight/internal/alt-const", func {
|
|||
}
|
||||
});
|
||||
|
||||
setlistener("/FMGC/flightplan[1]/current-wp", func {
|
||||
setlistener("/FMGC/flightplan[2]/current-wp", func {
|
||||
if (getprop("/it-autoflight/output/vert") == 8) {
|
||||
mng_alt_selector();
|
||||
mng_run();
|
||||
|
@ -1064,11 +1064,11 @@ setlistener("/FMGC/flightplan[1]/current-wp", func {
|
|||
});
|
||||
|
||||
var mng_run = func {
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1) {
|
||||
var wp_curr = getprop("/FMGC/flightplan[1]/current-wp");
|
||||
var wptnum = getprop("/FMGC/flightplan[1]/current-wp");
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1) {
|
||||
var wp_curr = getprop("/FMGC/flightplan[2]/current-wp");
|
||||
var wptnum = getprop("/FMGC/flightplan[2]/current-wp");
|
||||
var mng_alt_wp = getprop("/autopilot/route-manager/route/wp",wp_curr,"altitude-ft");
|
||||
if ((wptnum - 1) < getprop("/FMGC/flightplan[1]/num")) {
|
||||
if ((wptnum - 1) < getprop("/FMGC/flightplan[2]/num")) {
|
||||
var mng_alt_wp_prev = getprop("/autopilot/route-manager/route/wp",wp_curr - 1,"altitude-ft");
|
||||
var altcurr = getprop("/instrumentation/altimeter/indicated-altitude-ft");
|
||||
if (mng_alt_wp_prev >= 100) {
|
||||
|
@ -1134,11 +1134,11 @@ var mng_run = func {
|
|||
|
||||
# Managed Top of Descent
|
||||
var mng_des_tod = func {
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1) {
|
||||
var wp_curr = getprop("/FMGC/flightplan[1]/current-wp");
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1) {
|
||||
var wp_curr = getprop("/FMGC/flightplan[2]/current-wp");
|
||||
var mng_alt_wp = getprop("/autopilot/route-manager/route/wp",wp_curr,"altitude-ft");
|
||||
var alt_curr = getprop("/instrumentation/altimeter/indicated-altitude-ft");
|
||||
var dist = getprop("/FMGC/flightplan[1]/current-leg-dist");
|
||||
var dist = getprop("/FMGC/flightplan[2]/current-leg-dist");
|
||||
var vdist = dist + 1;
|
||||
var alttl = abs(alt_curr - mng_alt_wp);
|
||||
setprop("/it-autoflight/internal/top-of-des-nm", (alttl / 1000) * 3);
|
||||
|
@ -1180,7 +1180,7 @@ var mng_alt_selector = func {
|
|||
setprop("/it-autoflight/internal/mng-alt", getprop("/it-autoflight/internal/alt-const"));
|
||||
}
|
||||
} else if (getprop("/it-autoflight/internal/mng-mode") == "DES") {
|
||||
var dist = getprop("/FMGC/flightplan[1]/current-leg-dist");
|
||||
var dist = getprop("/FMGC/flightplan[2]/current-leg-dist");
|
||||
var vdist = dist - 1;
|
||||
if (vdist < getprop("/it-autoflight/internal/top-of-des-nm")) {
|
||||
if (sdif <= vdif) {
|
||||
|
@ -1231,7 +1231,7 @@ var mng_des_pth = func {
|
|||
mng_altcaptt.start();
|
||||
}
|
||||
var mng_des_fpm = func {
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1) {
|
||||
if (getprop("/FMGC/flightplan[2]/num") > 0 and getprop("/FMGC/flightplan[2]/active") == 1) {
|
||||
var gndspd = getprop("/velocities/groundspeed-kt");
|
||||
var desfpm = ((gndspd * 0.5) * 10);
|
||||
setprop("/it-autoflight/internal/mng-fpm", desfpm);
|
||||
|
|
|
@ -230,7 +230,7 @@ var masterFMGC = maketimer(0.2, func {
|
|||
setprop("/FMGC/status/phase", "5");
|
||||
}
|
||||
|
||||
if (getprop("/FMGC/flightplan[1]/num") > 0 and getprop("/FMGC/flightplan[1]/active") == 1 and getprop("/FMGC/flightplan[1]/arrival-leg-dist") <= 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);
|
||||
|
|
|
@ -31,12 +31,36 @@ var no_altn_fpln_end = "------NO ALTN F-PLN-----";
|
|||
|
||||
var num = 0;
|
||||
var page = "";
|
||||
var active_out = [nil, props.globals.getNode("/FMGC/flightplan[1]/active")];
|
||||
var num_out = [props.globals.getNode("/FMGC/flightplan[0]/num"), props.globals.getNode("/FMGC/flightplan[1]/num")];
|
||||
var TMPYActive = props.globals.getNode("/FMGC/internal/tmpy-active");
|
||||
var TMPYActive_out = props.globals.initNode("/MCDUC/tmpy-active", 0, "BOOL");
|
||||
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 TMPYActive_out = [props.globals.initNode("/MCDU[0]/tmpy-active", 0, "BOOL"), props.globals.initNode("/MCDU[1]/tmpy-active", 0, "BOOL")];
|
||||
var pageProp = [props.globals.getNode("/MCDU[0]/page", 1), props.globals.getNode("/MCDU[1]/page", 1)];
|
||||
|
||||
# Create text items
|
||||
var StaticText = {
|
||||
new: func (type) {
|
||||
var i = {parents:[StaticText]};
|
||||
i.type = type;
|
||||
return i;
|
||||
},
|
||||
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-----";
|
||||
}
|
||||
},
|
||||
getColor: func {
|
||||
return "wht";
|
||||
},
|
||||
type: nil,
|
||||
};
|
||||
|
||||
var slewFPLN = func(d, i) {
|
||||
|
||||
}
|
||||
|
@ -44,8 +68,9 @@ var slewFPLN = func(d, i) {
|
|||
var updateFPLN = func(i) {
|
||||
page = pageProp[i].getValue();
|
||||
|
||||
if (active_out[1].getBoolValue()) {
|
||||
if (active_out[2].getBoolValue()) {
|
||||
|
||||
TMPYActive_out[i].setBoolValue(TMPYActive[i].getBoolValue());
|
||||
} else {
|
||||
left1[i].setValue("");
|
||||
left1s[i].setValue("");
|
||||
|
@ -59,6 +84,7 @@ var updateFPLN = func(i) {
|
|||
left5s[i].setValue("");
|
||||
left6[i].setValue("");
|
||||
left6s[i].setValue("");
|
||||
TMPYActive_out[i].setBoolValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ var initInputA = func(key, i) {
|
|||
setprop("/FMGC/internal/arr-arpt", fromto[1]);
|
||||
setprop("/FMGC/internal/tofrom-set", 1);
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad", "");
|
||||
fmgc.flightplan.updateARPT(fromto[0], fromto[1], 1);
|
||||
fmgc.flightplan.updateARPT(fromto[0], fromto[1], 2);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
|
|
@ -377,7 +377,7 @@ 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[1].getBoolValue()) {
|
||||
if (active_out[2].getBoolValue()) {
|
||||
setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA");
|
||||
} else {
|
||||
setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1);
|
||||
|
|
|
@ -7,7 +7,7 @@ print("System: FMGC Dev Version - Copyright (c) 2019 Joshua Davidson (it0uchpods
|
|||
|
||||
# 0 = TEMP FP
|
||||
# 1 = ACTIVE FP
|
||||
var fp = [createFlightplan(), createFlightplan()];
|
||||
var fp = [createFlightplan(), createFlightplan(), createFlightplan()];
|
||||
var wpDep = nil;
|
||||
var wpArr = nil;
|
||||
var pos = nil;
|
||||
|
@ -18,44 +18,46 @@ var courseDistanceFrom = nil;
|
|||
var courseDistanceFromPrev = nil;
|
||||
var sizeWP = nil;
|
||||
var magTrueError = 0;
|
||||
var arrivalAirportI = [0, 0];
|
||||
var arrivalAirportI = [0, 0, 0];
|
||||
|
||||
# Vars for MultiFlightplan
|
||||
var currentWP = [nil, 0];
|
||||
var currentLeg = [nil, ""];
|
||||
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, props.globals.initNode("/FMGC/flightplan[1]/active", 0, "BOOL")];
|
||||
var currentWP_out = [nil, props.globals.initNode("/FMGC/flightplan[1]/current-wp", 0, "INT")];
|
||||
var currentLeg_out = [nil, props.globals.initNode("/FMGC/flightplan[1]/current-leg", "", "STRING")];
|
||||
var currentLegCourse_out = [nil, props.globals.initNode("/FMGC/flightplan[1]/current-leg-course", 0, "DOUBLE")];
|
||||
var currentLegDist_out = [nil, props.globals.initNode("/FMGC/flightplan[1]/current-leg-dist", 0, "DOUBLE")];
|
||||
var currentLegCourseMag_out = [nil, props.globals.initNode("/FMGC/flightplan[1]/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")];
|
||||
var num_out = [props.globals.initNode("/FMGC/flightplan[0]/num", 0, "INT"), props.globals.initNode("/FMGC/flightplan[1]/num", 0, "INT")];
|
||||
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, "BOOL");
|
||||
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")]];
|
||||
var wpLat = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/lat", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/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")]];
|
||||
var wpCourse = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/course", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/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")]];
|
||||
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")]];
|
||||
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")]];
|
||||
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.setBoolValue(0);
|
||||
TMPYActive[0].setBoolValue(0);
|
||||
TMPYActive[1].setBoolValue(0);
|
||||
me.reset0();
|
||||
me.reset1();
|
||||
me.reset2();
|
||||
},
|
||||
reset0: func() {
|
||||
fp[0].cleanPlan();
|
||||
|
@ -66,41 +68,48 @@ var flightplan = {
|
|||
fp[1].cleanPlan();
|
||||
fp[1].departure = nil;
|
||||
fp[1].destination = nil;
|
||||
currentWP[1] = 0;
|
||||
currentLeg[1] = "";
|
||||
},
|
||||
initTempFP: func(n) {
|
||||
fp[0] = fp[n].clone();
|
||||
me.checkWPOutputs(0);
|
||||
TMPYActive.setBoolValue(1);
|
||||
reset2: func() {
|
||||
fp[2].cleanPlan();
|
||||
fp[2].departure = nil;
|
||||
fp[2].destination = nil;
|
||||
currentWP[2] = 0;
|
||||
currentLeg[2] = "";
|
||||
},
|
||||
executeTempFP: func(n) {
|
||||
fp[n] = fp[0].clone();
|
||||
initTempFP: func(f, n) { # f is temp, n is active
|
||||
fp[f] = fp[n].clone();
|
||||
me.checkWPOutputs(f);
|
||||
TMPYActive[f].setBoolValue(1);
|
||||
},
|
||||
executeTempFP: func(f, n) { # f is temp, n is active
|
||||
fp[n] = fp[f].clone();
|
||||
me.checkWPOutputs(n);
|
||||
TMPYActive.setBoolValue(0);
|
||||
me.reset0();
|
||||
mcdu.offset[0] = 0;
|
||||
mcdu.offset[1] = 0;
|
||||
TMPYActive[f].setBoolValue(0);
|
||||
if (f == 0) {
|
||||
me.reset0();
|
||||
} else if (f == 1) {
|
||||
me.reset1();
|
||||
}
|
||||
},
|
||||
updateARPT: func(dep, arr, n) {
|
||||
if (n == 1) { # Which flightplan?
|
||||
me.reset1();
|
||||
if (n == 2) { # Which flightplan?
|
||||
me.reset2();
|
||||
|
||||
# Set Departure ARPT
|
||||
if (dep != nil) {
|
||||
fp[1].departure = airportinfo(dep);
|
||||
fp[2].departure = airportinfo(dep);
|
||||
} else {
|
||||
fp[1].departure = nil;
|
||||
fp[2].departure = nil;
|
||||
}
|
||||
|
||||
# Set Arrival ARPT
|
||||
if (arr != nil) {
|
||||
fp[1].destination = airportinfo(arr);
|
||||
fp[2].destination = airportinfo(arr);
|
||||
} else {
|
||||
fp[1].destination = nil;
|
||||
fp[2].destination = nil;
|
||||
}
|
||||
|
||||
currentWP[1] = 0;
|
||||
currentWP[2] = 0;
|
||||
}
|
||||
|
||||
me.checkWPOutputs(n);
|
||||
|
@ -146,13 +155,6 @@ var flightplan = {
|
|||
deleteWP: func(i, n) {
|
||||
var wp = wpID[n][i].getValue();
|
||||
if (fp[n].getPlanSize() > 2 and wp != FMGCdep.getValue() and wp != FMGCarr.getValue() and wp != "T/P" and wp != "PPOS") {
|
||||
for (var x = 0; x < 2; x += 1) { # If there is a blank that would come into view after delete, fix it.
|
||||
if (mcdu.left6i[x] == "" and TMPYActive.getBoolValue()) {
|
||||
math.max(mcdu.offset[x] = mcdu.offset[x] - 1, 0);
|
||||
} else if (mcdu.left7i[x] == "" and !TMPYActive.getBoolValue()) {
|
||||
math.max(mcdu.offset[x] = mcdu.offset[x] - 1, 0);
|
||||
}
|
||||
}
|
||||
fp[n].deleteWP(i);
|
||||
canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed");
|
||||
return 0;
|
||||
|
@ -176,9 +178,9 @@ var flightplan = {
|
|||
outputProps: func() {
|
||||
geoPos = geo.aircraft_position();
|
||||
|
||||
for (var n = 0; n < 2; n += 1) { # Note: Some things don't get done for TMPY (0) hence all the if (n != 0) {}
|
||||
if (((n == 0 and TMPYActive.getBoolValue()) or n > 0) and toFromSet.getBoolValue() and fp[n].departure != nil and fp[n].destination != nil) {
|
||||
if (n != 0) {
|
||||
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();
|
||||
}
|
||||
|
@ -230,7 +232,7 @@ var flightplan = {
|
|||
|
||||
arrivalLegDist_out[n].setValue(wpDistance[n][arrivalAirportI[n]].getValue());
|
||||
} else {
|
||||
if (n != 0) {
|
||||
if (n > 1) {
|
||||
if (active_out[n].getBoolValue() != 0) {
|
||||
active_out[n].setBoolValue(0);
|
||||
}
|
||||
|
@ -245,7 +247,7 @@ var flightplan = {
|
|||
}
|
||||
}
|
||||
|
||||
if (n != 0) {
|
||||
if (n > 1) {
|
||||
if (currentWP[n] != nil) {
|
||||
if (currentWP_out[n].getValue() != currentWP[n]) {
|
||||
currentWP_out[n].setValue(currentWP[n]);
|
||||
|
|
|
@ -449,7 +449,7 @@
|
|||
</condition>
|
||||
<expression>
|
||||
<sum>
|
||||
<property>/FMGC/flightplan[1]/current-leg-course</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