1
0
Fork 0

Clean up ils logic

This commit is contained in:
Matthew Maring 2020-04-26 14:59:32 -04:00
parent 6792699ddd
commit 81edf65259
2 changed files with 21 additions and 30 deletions

View file

@ -2615,7 +2615,7 @@ var canvas_MCDU_base = {
me["Simple_R1S"].setText("FINAL");
if (fmgc.flightPlanController.flightplans[2].approach != nil) {
me["Simple_R1"].setText(sprintf("%s",fmgc.flightPlanController.flightplans[2].approach.id));
me["Simple_R1"].setText(sprintf("%s",fmgc.flightPlanController.flightplans[2].approach.id)); # should exclude ILS/LDA/RNAV etc in future
me["Simple_R1"].setColor(GREEN);
} else {
me["Simple_R1"].setText("--- ");

View file

@ -479,42 +479,33 @@ var masterFMGC = maketimer(0.2, func {
if (fmgc.flightPlanController.flightplans[2].approach != nil and phase >= 2) {
var airport = airportinfo(getprop("FMGC/internal/arr-arpt"));
setprop("FMGC/internal/ldg-elev", airport.elevation * M2FT);
var runways = airportinfo(airport.id).runways;
var rwy = string.replace(fmgc.flightPlanController.flightplans[2].approach.id, "ILS", "");
if (runways[rwy] != nil) {
var r = runways[rwy];
#print(r.lat);
#print(r.lon);
#print(r.length);
#print(r.width);
#print(r.heading);
#print(r.stopway);
#print(r.threshold);
magnetic_hdg = geo.normdeg(r.heading - getprop("environment/magnetic-variation-deg"));
if (r.ils_frequency_mhz != nil and !getprop("FMGC/internal/ils1freq-set") and !getprop("FMGC/internal/ils1crs-set")) {
setprop("FMGC/internal/ils1freq-calculated", r.ils_frequency_mhz);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz);
var rwy = fmgc.flightPlanController.flightplans[2].destination_runway;
if (rwy != nil) {
magnetic_hdg = geo.normdeg(rwy.heading - getprop("environment/magnetic-variation-deg"));
runway_ils = rwy.ils_frequency_mhz;
if (runway_ils != nil and !getprop("FMGC/internal/ils1freq-set") and !getprop("FMGC/internal/ils1crs-set")) {
setprop("FMGC/internal/ils1freq-calculated", runway_ils);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils);
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
} else if (r.ils_frequency_mhz != nil and !getprop("FMGC/internal/ils1freq-set")) {
setprop("FMGC/internal/ils1freq-calculated", r.ils_frequency_mhz);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz);
} else if (runway_ils != nil and !getprop("FMGC/internal/ils1freq-set")) {
setprop("FMGC/internal/ils1freq-calculated", runway_ils);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils);
} else if (!getprop("FMGC/internal/ils1crs-set")) {
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
}
}
} else if (fmgc.flightPlanController.flightplans[2].departure_runway != nil and phase <= 1) {
var runways = airportinfo(airportinfo(getprop("FMGC/internal/dep-arpt")).id).runways;
var rwy = fmgc.flightPlanController.flightplans[2].departure_runway.id;
if (runways[rwy] != nil) {
var r = runways[rwy];
magnetic_hdg = geo.normdeg(r.heading - getprop("environment/magnetic-variation-deg"));
if (r.ils_frequency_mhz != nil and !getprop("FMGC/internal/ils1freq-set") and !getprop("FMGC/internal/ils1crs-set")) {
setprop("FMGC/internal/ils1freq-calculated", r.ils_frequency_mhz);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz);
var rwy = fmgc.flightPlanController.flightplans[2].departure_runway;
if (rwy != nil) {
magnetic_hdg = geo.normdeg(rwy.heading - getprop("environment/magnetic-variation-deg"));
runway_ils = rwy.ils_frequency_mhz;
if (runway_ils != nil and !getprop("FMGC/internal/ils1freq-set") and !getprop("FMGC/internal/ils1crs-set")) {
setprop("FMGC/internal/ils1freq-calculated", runway_ils);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils);
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
} else if (r.ils_frequency_mhz != nil and !getprop("FMGC/internal/ils1freq-set")) {
setprop("FMGC/internal/ils1freq-calculated", r.ils_frequency_mhz);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz);
} else if (runway_ils != nil and !getprop("FMGC/internal/ils1freq-set")) {
setprop("FMGC/internal/ils1freq-calculated", runway_ils);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils);
} else if (!getprop("FMGC/internal/ils1crs-set")) {
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
}