FMGC: Add initial custom flightplan system logic, and make various stuffs work with it
This commit is contained in:
parent
71320aa1ff
commit
55e48862fe
10 changed files with 191 additions and 80 deletions
|
@ -215,13 +215,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>
|
||||
|
@ -1510,6 +1510,7 @@
|
|||
<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>
|
||||
|
|
|
@ -16,7 +16,7 @@ var A3XXRouteDriver = {
|
|||
me.update();
|
||||
},
|
||||
update: func(){
|
||||
me.flightplan = flightplan();
|
||||
me.flightplan = fmgc.r1;
|
||||
},
|
||||
getNumberOfFlightPlans: func(){1},
|
||||
getFlightPlanType: func(fpNum){"current"},
|
||||
|
|
|
@ -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/r1/active",
|
||||
current_wp_node: "/FMGC/flightplan/r1/current-wp",
|
||||
wp_num: "/FMGC/flightplan/r1/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: "autopilot/route-manager/active",
|
||||
fplan_active: "/FMGC/flightplan/r1/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/r1/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/r1/current-leg") != nil and
|
||||
getprop("FMGC/flightplan/r1/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/r1/current-leg"));
|
||||
nd.symbols.wpActiveId.show();
|
||||
},
|
||||
is_false: func(nd) nd.symbols.wpActiveId.hide(),
|
||||
|
@ -754,12 +754,12 @@ 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/r1/current-leg") != nil and
|
||||
getprop("FMGC/flightplan/r1/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"));
|
||||
var deg = int(getprop("/FMGC/flightplan/r1/current-leg-course"));
|
||||
nd.symbols.wpActiveCrs.setText((deg or "")~"°");
|
||||
nd.symbols.wpActiveCrs.show();
|
||||
},
|
||||
|
@ -770,11 +770,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/r1/current-leg-dist") != nil and
|
||||
getprop("FMGC/flightplan/r1/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/r1/current-leg-dist");
|
||||
nd.symbols.wpActiveDist.setText(sprintf("%3.01f",dst));
|
||||
nd.symbols.wpActiveDist.show();
|
||||
},
|
||||
|
@ -785,10 +785,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/r1/current-leg-dist") != nil and getprop("FMGC/flightplan/r1/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/r1/current-leg-dist") > 1000)
|
||||
nd.symbols.wpActiveDistLbl.setText(" NM");
|
||||
},
|
||||
is_false: func(nd) nd.symbols.wpActiveDistLbl.hide(),
|
||||
|
@ -798,7 +798,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/r1/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 +1679,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/r1/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 +1708,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/r1/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 +1737,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/r1/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 +1766,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/r1/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 +1795,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/r1/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("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
|
||||
if (getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/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("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
|
||||
if (getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/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("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1 and getprop("/it-autoflight/internal/alt-const") >= 100) {
|
||||
if (getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/active") == 1 and getprop("/it-autoflight/internal/alt-const") >= 100) {
|
||||
alandt.stop();
|
||||
alandt1.stop();
|
||||
setprop("/it-autoflight/output/appr-armed", 0);
|
||||
|
@ -652,10 +652,6 @@ var trkfpa_on = func {
|
|||
}
|
||||
}
|
||||
|
||||
setlistener("/autopilot/route-manager/current-wp", func {
|
||||
setprop("/autopilot/internal/wp-change-time", getprop("/sim/time/elapsed-sec"));
|
||||
});
|
||||
|
||||
var ap_various = func {
|
||||
trueSpeedKts = getprop("/instrumentation/airspeed-indicator/true-speed-kt");
|
||||
if (trueSpeedKts > 420) {
|
||||
|
@ -666,19 +662,19 @@ var ap_various = func {
|
|||
setprop("/it-autoflight/internal/bank-limit", 25);
|
||||
}
|
||||
|
||||
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
|
||||
if ((getprop("/autopilot/route-manager/current-wp") + 1) < getprop("/autopilot/route-manager/route/num")) {
|
||||
if (getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/active") == 1) {
|
||||
if ((getprop("/FMGC/flightplan/r1/current-wp") + 1) < getprop("/FMGC/flightplan/r1/num")) {
|
||||
gnds_mps = getprop("/velocities/groundspeed-kt") * 0.5144444444444;
|
||||
wp_fly_from = getprop("/autopilot/route-manager/current-wp");
|
||||
wp_fly_from = getprop("/FMGC/flightplan/r1/current-wp");
|
||||
if (wp_fly_from < 0) {
|
||||
wp_fly_from = 0;
|
||||
}
|
||||
current_course = getprop("/autopilot/route-manager/route/wp[" ~ wp_fly_from ~ "]/leg-bearing-true-deg");
|
||||
wp_fly_to = getprop("/autopilot/route-manager/current-wp") + 1;
|
||||
current_course = getprop("/FMGC/flightplan/r1/wp[" ~ wp_fly_from ~ "]/course");
|
||||
wp_fly_to = getprop("/FMGC/flightplan/r1/current-wp") + 1;
|
||||
if (wp_fly_to < 0) {
|
||||
wp_fly_to = 0;
|
||||
}
|
||||
next_course = getprop("/autopilot/route-manager/route/wp[" ~ wp_fly_to ~ "]/leg-bearing-true-deg");
|
||||
next_course = getprop("/FMGC/flightplan/r1/wp[" ~ wp_fly_to ~ "]/course");
|
||||
max_bank_limit = getprop("/it-autoflight/internal/bank-limit");
|
||||
|
||||
delta_angle = math.abs(geo.normdeg180(current_course - next_course));
|
||||
|
@ -699,12 +695,9 @@ var ap_various = func {
|
|||
turn_dist = 1;
|
||||
}
|
||||
setprop("/it-autoflight/internal/lnav-advance-nm", turn_dist);
|
||||
if (getprop("/sim/time/elapsed-sec")-getprop("/autopilot/internal/wp-change-time") > 60) {
|
||||
setprop("/autopilot/internal/wp-change-check-period", time);
|
||||
}
|
||||
|
||||
if (getprop("/autopilot/route-manager/wp/dist") <= turn_dist) {
|
||||
setprop("/autopilot/route-manager/current-wp", getprop("/autopilot/route-manager/current-wp") + 1);
|
||||
if (getprop("/FMGC/flightplan/r1/current-leg-dist") <= turn_dist) {
|
||||
r1_currentWP = r1_currentWP + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -921,7 +914,7 @@ var check_arms = func {
|
|||
}
|
||||
|
||||
var update_arms = func {
|
||||
if (getprop("/it-autoflight/input/lat-arm") == 1 and getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
|
||||
if (getprop("/it-autoflight/input/lat-arm") == 1 and getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/active") == 1 and getprop("/position/gear-agl-ft") >= 30) {
|
||||
make_lnav_active();
|
||||
}
|
||||
if (getprop("/instrumentation/nav[0]/in-range") == 1) {
|
||||
|
@ -1021,11 +1014,11 @@ var aland1 = func {
|
|||
|
||||
# Managed Climb/Descent
|
||||
var mng_main = func {
|
||||
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
|
||||
if (getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/active") == 1) {
|
||||
altinput = getprop("/it-autoflight/input/alt");
|
||||
setprop("/it-autoflight/internal/alt", altinput);
|
||||
var wp_curr = getprop("/autopilot/route-manager/current-wp");
|
||||
var mng_alt_wp = getprop("/autopilot/route-manager/route/wp",wp_curr,"altitude-ft");
|
||||
var wp_curr = getprop("/FMGC/flightplan/r1/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
|
||||
} else {
|
||||
|
@ -1063,7 +1056,7 @@ setlistener("/it-autoflight/internal/alt-const", func {
|
|||
}
|
||||
});
|
||||
|
||||
setlistener("/autopilot/route-manager/current-wp", func {
|
||||
setlistener("/FMGC/flightplan/r1/current-wp", func {
|
||||
if (getprop("/it-autoflight/output/vert") == 8) {
|
||||
mng_alt_selector();
|
||||
mng_run();
|
||||
|
@ -1071,11 +1064,11 @@ setlistener("/autopilot/route-manager/current-wp", func {
|
|||
});
|
||||
|
||||
var mng_run = func {
|
||||
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
|
||||
var wp_curr = getprop("/autopilot/route-manager/current-wp");
|
||||
var wptnum = getprop("/autopilot/route-manager/current-wp");
|
||||
if (getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/active") == 1) {
|
||||
var wp_curr = getprop("/FMGC/flightplan/r1/current-wp");
|
||||
var wptnum = getprop("/FMGC/flightplan/r1/current-wp");
|
||||
var mng_alt_wp = getprop("/autopilot/route-manager/route/wp",wp_curr,"altitude-ft");
|
||||
if ((wptnum - 1) < getprop("/autopilot/route-manager/route/num")) {
|
||||
if ((wptnum - 1) < getprop("/FMGC/flightplan/r1/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) {
|
||||
|
@ -1141,11 +1134,11 @@ var mng_run = func {
|
|||
|
||||
# Managed Top of Descent
|
||||
var mng_des_tod = func {
|
||||
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
|
||||
var wp_curr = getprop("/autopilot/route-manager/current-wp");
|
||||
if (getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/active") == 1) {
|
||||
var wp_curr = getprop("/FMGC/flightplan/r1/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("/autopilot/route-manager/wp/dist");
|
||||
var dist = getprop("/FMGC/flightplan/r1/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);
|
||||
|
@ -1187,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("/autopilot/route-manager/wp/dist");
|
||||
var dist = getprop("/FMGC/flightplan/r1/current-leg-dist");
|
||||
var vdist = dist - 1;
|
||||
if (vdist < getprop("/it-autoflight/internal/top-of-des-nm")) {
|
||||
if (sdif <= vdif) {
|
||||
|
@ -1238,7 +1231,7 @@ var mng_des_pth = func {
|
|||
mng_altcaptt.start();
|
||||
}
|
||||
var mng_des_fpm = func {
|
||||
if (getprop("/autopilot/route-manager/route/num") > 0 and getprop("/autopilot/route-manager/active") == 1) {
|
||||
if (getprop("/FMGC/flightplan/r1/num") > 0 and getprop("/FMGC/flightplan/r1/active") == 1) {
|
||||
var gndspd = getprop("/velocities/groundspeed-kt");
|
||||
var desfpm = ((gndspd * 0.5) * 10);
|
||||
setprop("/it-autoflight/internal/mng-fpm", desfpm);
|
||||
|
|
|
@ -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/r1/num") > 0 and getprop("/FMGC/flightplan/r1/active") == 1 and getprop("/autopilot/route-manager/distance-remaining-nm") <= 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");
|
||||
APinit();
|
||||
FMGCinit();
|
||||
flightplan.reset();
|
||||
mcdu.MCDU_reset(0);
|
||||
mcdu.MCDU_reset(1);
|
||||
setprop("/it-autoflight/input/fd1", fd1);
|
||||
|
|
|
@ -73,7 +73,7 @@ var initInputA = func(key, i) {
|
|||
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 +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.updateARPT();
|
||||
fmgc.flightplan.updateARPT(fromto[0], fromto[1], 1);
|
||||
} else {
|
||||
notAllowed(i);
|
||||
}
|
||||
|
|
132
Nasal/flightplan.nas
Normal file
132
Nasal/flightplan.nas
Normal file
|
@ -0,0 +1,132 @@
|
|||
# A3XX FMGC Flightplan System
|
||||
# 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)");
|
||||
|
||||
# r0 = TEMP FP
|
||||
# r1 = ACTIVE FP
|
||||
var r1 = createFlightplan();
|
||||
var wpDep = nil;
|
||||
var wpArr = nil;
|
||||
var pos = nil;
|
||||
var r1_currentWP = 0;
|
||||
var r1_currentLeg = nil;
|
||||
var r1_currentLegCourseDist = 0;
|
||||
var geoPos = nil;
|
||||
var r1_active_out = props.globals.initNode("/FMGC/flightplan/r1/active", 0, "BOOL");
|
||||
var r1_currentWP_out = props.globals.initNode("/FMGC/flightplan/r1/current-wp", 0, "INT");
|
||||
var r1_currentLeg_out = props.globals.initNode("/FMGC/flightplan/r1/current-leg", "", "STRING");
|
||||
var r1_currentLegCourse_out = props.globals.initNode("/FMGC/flightplan/r1/current-leg-course", 0, "DOUBLE");
|
||||
var r1_currentLegDist_out = props.globals.initNode("/FMGC/flightplan/r1/current-leg-dist", 0, "DOUBLE");
|
||||
var r1_num_out = props.globals.initNode("/FMGC/flightplan/r1/num", 0, "INT");
|
||||
var toFromSet = props.globals.initNode("/FMGC/internal/tofrom-set", 0, "BOOL");
|
||||
|
||||
var flightplan = {
|
||||
initProps: func() {
|
||||
|
||||
},
|
||||
reset: func() {
|
||||
# me.reset0();
|
||||
me.reset1();
|
||||
me.initProps();
|
||||
},
|
||||
reset1: func() {
|
||||
r1.cleanPlan();
|
||||
r1.departure = nil;
|
||||
r1.destination = nil;
|
||||
r1_currentWP = 0;
|
||||
r1_currentWPData = nil;
|
||||
r1_currentLeg = nil;
|
||||
},
|
||||
updateARPT: func(dep, arr, n) {
|
||||
if (n == 1) { # Which flightplan?
|
||||
me.reset1();
|
||||
|
||||
# Set Departure ARPT
|
||||
if (dep != nil) {
|
||||
r1.departure = airportinfo(dep);
|
||||
r1_currentWP = 0;
|
||||
} else {
|
||||
r1.departure = nil;
|
||||
r1_currentWP = 0;
|
||||
}
|
||||
|
||||
# Set Arrival ARPT
|
||||
if (arr != nil) {
|
||||
r1.destination = airportinfo(arr);
|
||||
} else {
|
||||
r1.destination = nil;
|
||||
}
|
||||
}
|
||||
},
|
||||
insertFix: func(wp, i) {
|
||||
var pos = findFixesByID(wp);
|
||||
if (pos != nil and size(pos) > 0) {
|
||||
r1.insertWP(createWPFrom(pos[0]), i);
|
||||
}
|
||||
},
|
||||
insertNavaid: func(nav, i) {
|
||||
var pos = findNavaidsByID(nav);
|
||||
if (pos != nil and size(pos) > 0) {
|
||||
r1.insertWP(createWPFrom(pos[0]), i);
|
||||
}
|
||||
},
|
||||
outputProps: func() {
|
||||
geoPos = geo.aircraft_position();
|
||||
|
||||
if (r1_currentWP > r1.getPlanSize()) {
|
||||
r1_currentWP = r1.getPlanSize();
|
||||
}
|
||||
|
||||
if (toFromSet.getBoolValue() and r1.departure != nil and r1.destination != nil) {
|
||||
if (r1_active_out.getBoolValue() != 1) {
|
||||
r1_active_out.setBoolValue(1);
|
||||
}
|
||||
|
||||
if (r1_num_out.getValue() != r1.getPlanSize()) {
|
||||
r1_num_out.setValue(r1.getPlanSize());
|
||||
}
|
||||
|
||||
r1_currentLeg = r1.getWP(r1_currentWP).wp_name;
|
||||
if (r1_currentLeg_out.getValue() != r1_currentLeg) {
|
||||
r1_currentLeg_out.setValue(r1_currentLeg);
|
||||
}
|
||||
|
||||
r1_currentLegCourseDist = r1.getWP(r1_currentWP).courseAndDistanceFrom(geoPos);
|
||||
r1_currentLegCourse_out.setValue(r1_currentLegCourseDist[0]);
|
||||
r1_currentLegDist_out.setValue(r1_currentLegCourseDist[1]);
|
||||
|
||||
for (var i = 0; i < r1.getPlanSize(); i += 1) {
|
||||
setprop("/FMGC/flightplan/r1/wp[" ~ i ~ "]/id", r1.getWP(i).wp_name);
|
||||
setprop("/FMGC/flightplan/r1/wp[" ~ i ~ "]/course", r1.getWP(i).courseAndDistanceFrom(geoPos)[0]);
|
||||
setprop("/FMGC/flightplan/r1/wp[" ~ i ~ "]/distance", r1.getWP(i).courseAndDistanceFrom(geoPos)[1]);
|
||||
}
|
||||
} else {
|
||||
if (r1_active_out.getBoolValue() != 0) {
|
||||
r1_active_out.setBoolValue(0);
|
||||
}
|
||||
|
||||
if (r1_num_out.getValue() != 0) {
|
||||
r1_num_out.setValue(0);
|
||||
}
|
||||
|
||||
if (r1_currentLeg_out.getValue() != "") {
|
||||
r1_currentLeg_out.setValue("");
|
||||
}
|
||||
}
|
||||
|
||||
if (r1_currentWP != nil) {
|
||||
if (r1_currentWP_out.getValue() != r1_currentWP) {
|
||||
r1_currentWP_out.setValue(r1_currentWP);
|
||||
}
|
||||
} else {
|
||||
if (r1_currentWP_out.getValue() != 0) {
|
||||
r1_currentWP_out.setValue(0);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
flightplan.initProps();
|
||||
var outputPropsTimer = maketimer(0.4, flightplan.outputProps);
|
|
@ -187,7 +187,8 @@ var systemsInit = func {
|
|||
systems.fire_init();
|
||||
systems.autobrake_init();
|
||||
fadec.FADEC.init();
|
||||
fmgc.APinit();
|
||||
fmgc.flightplan.reset();
|
||||
fmgc.APinit();
|
||||
fmgc.FMGCinit();
|
||||
mcdu.MCDU_init(0);
|
||||
mcdu.MCDU_init(1);
|
||||
|
@ -206,6 +207,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/r1/current-leg-course</property>
|
||||
<product>
|
||||
<property>/it-autoflight/internal/drift-angle-deg</property>
|
||||
<value>-1.0</value>
|
||||
|
|
Reference in a new issue