Proper mda/dh implementation
This commit is contained in:
parent
bf68dbf4d4
commit
04ee431d13
2 changed files with 128 additions and 49 deletions
|
@ -167,6 +167,7 @@ var altFlash1 = props.globals.initNode("/instrumentation/pfd/flash-indicators/al
|
||||||
var altFlash2 = props.globals.initNode("/instrumentation/pfd/flash-indicators/alt-flash-2", 0, "BOOL");
|
var altFlash2 = props.globals.initNode("/instrumentation/pfd/flash-indicators/alt-flash-2", 0, "BOOL");
|
||||||
var amberFlash1 = props.globals.initNode("/instrumentation/pfd/flash-indicators/amber-flash-1", 0, "BOOL");
|
var amberFlash1 = props.globals.initNode("/instrumentation/pfd/flash-indicators/amber-flash-1", 0, "BOOL");
|
||||||
var amberFlash2 = props.globals.initNode("/instrumentation/pfd/flash-indicators/amber-flash-2", 0, "BOOL");
|
var amberFlash2 = props.globals.initNode("/instrumentation/pfd/flash-indicators/amber-flash-2", 0, "BOOL");
|
||||||
|
var dhFlash = props.globals.initNode("/instrumentation/pfd/flash-indicators/dh-flash", 0, "BOOL");
|
||||||
|
|
||||||
var canvas_PFD_base = {
|
var canvas_PFD_base = {
|
||||||
init: func(canvas_group, file) {
|
init: func(canvas_group, file) {
|
||||||
|
@ -754,10 +755,26 @@ var canvas_PFD_base = {
|
||||||
|
|
||||||
me["AI_agl"].setText(sprintf("%s", math.round(math.clamp(gear_agl_cur, 0, 2500))));
|
me["AI_agl"].setText(sprintf("%s", math.round(math.clamp(gear_agl_cur, 0, 2500))));
|
||||||
|
|
||||||
|
if (FMGCphase.getValue() < 3) {
|
||||||
|
me["FMA_dh_box"].hide();
|
||||||
|
me["FMA_dh"].hide();
|
||||||
|
me["FMA_dhn"].hide();
|
||||||
|
me["FMA_nodh"].hide();
|
||||||
|
me["dhReached"].hide();
|
||||||
|
if (gear_agl_cur <= 2500) {
|
||||||
|
me["AI_agl"].show();
|
||||||
|
if (gear_agl_cur <= decision.getValue()) {
|
||||||
|
me["AI_agl"].setColor(0.7333,0.3803,0);
|
||||||
|
} else {
|
||||||
|
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
me["AI_agl"].hide();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (gear_agl_cur <= 2500) {
|
if (gear_agl_cur <= 2500) {
|
||||||
me["AI_agl"].show();
|
me["AI_agl"].show();
|
||||||
me["FMA_dh_box"].hide(); #not implemented
|
me["FMA_dh_box"].hide(); #not implemented
|
||||||
me["dhReached"].hide(); #not implemented
|
|
||||||
if (getprop("FMGC/internal/radio") != -1) {
|
if (getprop("FMGC/internal/radio") != -1) {
|
||||||
me["FMA_dh"].setText("DH");
|
me["FMA_dh"].setText("DH");
|
||||||
me["FMA_dh"].show();
|
me["FMA_dh"].show();
|
||||||
|
@ -769,6 +786,27 @@ var canvas_PFD_base = {
|
||||||
} else {
|
} else {
|
||||||
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
||||||
}
|
}
|
||||||
|
me["dhReached"].hide();
|
||||||
|
# if (gear_agl_cur <= getprop("FMGC/internal/radio")) {
|
||||||
|
# if (dh_going == 0) {
|
||||||
|
# dh_going = 1;
|
||||||
|
# }
|
||||||
|
# if (dh_going == 1) {
|
||||||
|
# dhTimer.start();
|
||||||
|
# if (dhFlash.getValue() == 1) {
|
||||||
|
# me["dhReached"].show();
|
||||||
|
# } else {
|
||||||
|
# me["dhReached"].hide();
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# if (dh_going == -1) {
|
||||||
|
# me["dhReached"].show();
|
||||||
|
# }
|
||||||
|
# } else {
|
||||||
|
# dhTimer.stop();
|
||||||
|
# dh_going = 0;
|
||||||
|
# me["dhReached"].hide();
|
||||||
|
# }
|
||||||
} else if (getprop("FMGC/internal/baro") != -1) {
|
} else if (getprop("FMGC/internal/baro") != -1) {
|
||||||
me["FMA_dh"].setText("MDA");
|
me["FMA_dh"].setText("MDA");
|
||||||
me["FMA_dh"].show();
|
me["FMA_dh"].show();
|
||||||
|
@ -780,6 +818,7 @@ var canvas_PFD_base = {
|
||||||
} else {
|
} else {
|
||||||
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
||||||
}
|
}
|
||||||
|
me["dhReached"].hide();
|
||||||
} else if (getprop("FMGC/internal/radio-no")) {
|
} else if (getprop("FMGC/internal/radio-no")) {
|
||||||
me["FMA_dh"].setText("DH");
|
me["FMA_dh"].setText("DH");
|
||||||
me["FMA_dh"].show();
|
me["FMA_dh"].show();
|
||||||
|
@ -791,6 +830,27 @@ var canvas_PFD_base = {
|
||||||
} else {
|
} else {
|
||||||
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
||||||
}
|
}
|
||||||
|
me["dhReached"].hide();
|
||||||
|
# if (gear_agl_cur <= getprop("FMGC/internal/radio")) {
|
||||||
|
# if (dh_going == 0) {
|
||||||
|
# dh_going = 1;
|
||||||
|
# }
|
||||||
|
# if (dh_going == 1) {
|
||||||
|
# dhTimer.start();
|
||||||
|
# if (dhFlash.getValue() == 1) {
|
||||||
|
# me["dhReached"].show();
|
||||||
|
# } else {
|
||||||
|
# me["dhReached"].hide();
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# if (dh_going == -1) {
|
||||||
|
# me["dhReached"].show();
|
||||||
|
# }
|
||||||
|
# } else {
|
||||||
|
# dhTimer.stop();
|
||||||
|
# dh_going = 0;
|
||||||
|
# me["dhReached"].hide();
|
||||||
|
# }
|
||||||
} else {
|
} else {
|
||||||
me["FMA_dh"].hide();
|
me["FMA_dh"].hide();
|
||||||
me["FMA_dhn"].hide();
|
me["FMA_dhn"].hide();
|
||||||
|
@ -800,6 +860,7 @@ var canvas_PFD_base = {
|
||||||
} else {
|
} else {
|
||||||
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
me["AI_agl"].setColor(0.0509,0.7529,0.2941);
|
||||||
}
|
}
|
||||||
|
me["dhReached"].hide();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
me["AI_agl"].hide();
|
me["AI_agl"].hide();
|
||||||
|
@ -807,6 +868,7 @@ var canvas_PFD_base = {
|
||||||
me["FMA_dh_box"].hide();
|
me["FMA_dh_box"].hide();
|
||||||
me["dhReached"].hide();
|
me["dhReached"].hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
me["AI_agl_g"].setRotation(-roll_cur * D2R);
|
me["AI_agl_g"].setRotation(-roll_cur * D2R);
|
||||||
|
|
||||||
|
@ -2675,3 +2737,18 @@ var amberTimer2 = maketimer(0.50, func {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var dh_going = 0;
|
||||||
|
var dh_count = 0;
|
||||||
|
var dhTimer = maketimer(0.50, func {
|
||||||
|
if (!dhFlash.getBoolValue()) {
|
||||||
|
dhFlash.setBoolValue(1);
|
||||||
|
} else {
|
||||||
|
dhFlash.setBoolValue(0);
|
||||||
|
}
|
||||||
|
if (dh_count == 18) {
|
||||||
|
dh_count = 0;
|
||||||
|
} else {
|
||||||
|
dh_count = dh_count + 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -469,9 +469,9 @@ var masterFMGC = maketimer(0.2, func {
|
||||||
|
|
||||||
#handle radios, runways, v1/vr/v2
|
#handle radios, runways, v1/vr/v2
|
||||||
if (fmgc.flightPlanController.flightplans[2].approach != nil and phase >= 2) {
|
if (fmgc.flightPlanController.flightplans[2].approach != nil and phase >= 2) {
|
||||||
var airport = airportinfo(getprop("FMGC/internal/arr-arpt")).id;
|
var airport = airportinfo(getprop("FMGC/internal/arr-arpt"));
|
||||||
setprop("FMGC/internal/ldg-elev", airport.elevation * M2FT);
|
setprop("FMGC/internal/ldg-elev", airport.elevation * M2FT);
|
||||||
var runways = airportinfo(airport).runways;
|
var runways = airportinfo(airport.id).runways;
|
||||||
var rwy = string.replace(fmgc.flightPlanController.flightplans[2].approach.id, "ILS", "");
|
var rwy = string.replace(fmgc.flightPlanController.flightplans[2].approach.id, "ILS", "");
|
||||||
if (runways[rwy] != nil) {
|
if (runways[rwy] != nil) {
|
||||||
var r = runways[rwy];
|
var r = runways[rwy];
|
||||||
|
@ -482,12 +482,13 @@ var masterFMGC = maketimer(0.2, func {
|
||||||
#print(r.heading);
|
#print(r.heading);
|
||||||
#print(r.stopway);
|
#print(r.stopway);
|
||||||
#print(r.threshold);
|
#print(r.threshold);
|
||||||
setprop("FMGC/internal/ils1freq-calculated", r.ils_frequency_mhz);
|
|
||||||
magnetic_hdg = geo.normdeg(r.heading - getprop("environment/magnetic-variation-deg"));
|
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")) {
|
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);
|
setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz);
|
||||||
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
|
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
|
||||||
} else if (r.ils_frequency_mhz != nil and !getprop("FMGC/internal/ils1freq-set")) {
|
} 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);
|
setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz);
|
||||||
} else if (!getprop("FMGC/internal/ils1crs-set")) {
|
} else if (!getprop("FMGC/internal/ils1crs-set")) {
|
||||||
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
|
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
|
||||||
|
@ -498,12 +499,13 @@ var masterFMGC = maketimer(0.2, func {
|
||||||
var rwy = fmgc.flightPlanController.flightplans[2].departure_runway.id;
|
var rwy = fmgc.flightPlanController.flightplans[2].departure_runway.id;
|
||||||
if (runways[rwy] != nil) {
|
if (runways[rwy] != nil) {
|
||||||
var r = runways[rwy];
|
var r = runways[rwy];
|
||||||
setprop("FMGC/internal/ils1freq-calculated", r.ils_frequency_mhz);
|
|
||||||
magnetic_hdg = geo.normdeg(r.heading - getprop("environment/magnetic-variation-deg"));
|
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")) {
|
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);
|
setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz);
|
||||||
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
|
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
|
||||||
} else if (r.ils_frequency_mhz != nil and !getprop("FMGC/internal/ils1freq-set")) {
|
} 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);
|
setprop("instrumentation/nav[0]/frequencies/selected-mhz", r.ils_frequency_mhz);
|
||||||
} else if (!getprop("FMGC/internal/ils1crs-set")) {
|
} else if (!getprop("FMGC/internal/ils1crs-set")) {
|
||||||
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
|
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
|
||||||
|
|
Loading…
Reference in a new issue