2007-03-26 03:32:24 +00:00
|
|
|
#### Bendix-King KFC-200 Flight Director ####
|
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
#Buttons
|
|
|
|
# HDG ...heading hold
|
|
|
|
# FD ..... flightdirector on/off
|
|
|
|
# ALT ....altitude arm
|
|
|
|
# NAV ...VOR / LOC arm
|
|
|
|
# BC ....LOC back course
|
|
|
|
# APPR ... LOC / GS arm
|
|
|
|
|
|
|
|
#### lnav ####
|
|
|
|
# 0 = wingleveler
|
|
|
|
# 1 = heading hold
|
|
|
|
# 2 = NAV arm
|
|
|
|
# 3 = NAV cap
|
|
|
|
# 4 = APPR arm
|
|
|
|
# 5 = APPR cap
|
|
|
|
|
|
|
|
#### vnav ####
|
|
|
|
# 0 = pitch hold
|
|
|
|
# 1 = ALT arm
|
|
|
|
# 2 = ALT cap
|
|
|
|
# 3 = GS arm
|
|
|
|
# 4 = GS cap
|
|
|
|
|
|
|
|
var L_list=["wing-leveler","dg-heading-hold","dg-heading-hold","nav1-hold","dg-heading-hold","nav1-hold","dg-heading-hold","nav1-hold"];
|
|
|
|
|
|
|
|
var V_list=["pitch-hold","pitch-hold","altitude-hold","pitch-hold","gs1-hold"];
|
|
|
|
|
|
|
|
var fdprop = props.globals.getNode("/instrumentation/kfc200",1);
|
|
|
|
var lnav = 0;
|
|
|
|
var vnav = 0;
|
|
|
|
var current_alt=0.0;
|
|
|
|
var alt_select = 0.0;
|
|
|
|
var DH = 0;
|
|
|
|
|
|
|
|
var HASGS = "/instrumentation/nav/has-gs";
|
|
|
|
var NAVLOC = "/instrumentation/nav/nav-loc";
|
|
|
|
var NAVDST = "/instrumentation/nav/nav-dist";
|
|
|
|
var NAVRNG = "/instrumentation/nav/in-range";
|
|
|
|
var HDEFL = "/instrumentation/nav/heading-needle-deflection";
|
2009-09-09 10:49:36 +00:00
|
|
|
var GSDEFL = "/instrumentation/nav/gs-needle-deflection-norm";
|
2007-12-22 23:37:14 +00:00
|
|
|
var BC = "/instrumentation/nav/back-course-btn";
|
|
|
|
|
|
|
|
var HDG = props.globals.getNode("/autopilot/locks/heading",1);
|
|
|
|
var ALT = props.globals.getNode("/autopilot/locks/altitude",1);
|
|
|
|
var SPD = props.globals.getNode("/autopilot/locks/speed",1);
|
|
|
|
var SRVC = 0;
|
2007-04-28 05:40:25 +00:00
|
|
|
|
2007-03-26 03:32:24 +00:00
|
|
|
setlistener("/sim/signals/fdm-initialized", func {
|
2007-04-22 23:59:13 +00:00
|
|
|
fdprop.getNode("serviceable",1).setBoolValue(1);
|
2007-12-22 23:37:14 +00:00
|
|
|
fdprop.getNode("armed",1).setBoolValue(0);
|
|
|
|
fdprop.getNode("cpld",1).setBoolValue(0);
|
|
|
|
fdprop.getNode("pitch-trim",1).setIntValue(0);
|
|
|
|
fdprop.getNode("alt-trim",1).setIntValue(0);
|
2007-04-22 23:59:13 +00:00
|
|
|
fdprop.getNode("fd-on",1).setBoolValue(0);
|
2007-12-22 23:37:14 +00:00
|
|
|
fdprop.getNode("gs-arm",1).setBoolValue(0);
|
|
|
|
fdprop.getNode("lnav",1).setValue(0);
|
|
|
|
fdprop.getNode("vnav",1).setValue(0);
|
|
|
|
fdprop.getNode("alt-preset",1).setDoubleValue(0.0);
|
2007-04-22 23:59:13 +00:00
|
|
|
fdprop.getNode("alt-alert",1).setBoolValue(0);
|
2007-12-22 23:37:14 +00:00
|
|
|
fdprop.getNode("dh-alert",1).setBoolValue(0);
|
|
|
|
DH = getprop("/autopilot/route-manager/min-lock-altitude-agl-ft");
|
2007-04-22 23:59:13 +00:00
|
|
|
alt_select = 0;
|
2007-12-22 23:37:14 +00:00
|
|
|
ALT.setValue(V_list[vnav]);
|
|
|
|
HDG.setValue(L_list[lnav]);
|
|
|
|
settimer(update,5);
|
|
|
|
print("KFC-200 ... Check");
|
2007-03-26 03:32:24 +00:00
|
|
|
});
|
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
setlistener("/instrumentation/kfc200/fd-on", func(fd){
|
|
|
|
var fdON = fd.getBoolValue();
|
2007-04-01 18:20:23 +00:00
|
|
|
clear_ap();
|
2007-12-22 23:37:14 +00:00
|
|
|
},0,0);
|
2007-04-01 18:20:23 +00:00
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
setlistener("/autopilot/locks/passive-mode", func(ap){
|
|
|
|
if(!ap.getBoolValue()){
|
|
|
|
setprop("autopilot/settings/target-pitch-deg",getprop("/orientation/pitch-deg"));
|
|
|
|
}
|
|
|
|
},0,0);
|
2007-03-26 03:32:24 +00:00
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
setlistener("/instrumentation/kfc200/serviceable", func(srv){
|
|
|
|
if(srv.getBoolValue()){SRVC=1;
|
|
|
|
}else{
|
|
|
|
SRVC=0;
|
|
|
|
}
|
|
|
|
},0,0);
|
|
|
|
|
|
|
|
setlistener("/autopilot/settings/target-altitude-ft",func(at){
|
|
|
|
alt_select = at.getValue();
|
|
|
|
},0,0);
|
|
|
|
|
|
|
|
setlistener("/autopilot/route-manager/min-lock-altitude-agl-ft",func(dh){
|
|
|
|
DH = dh.getValue();
|
|
|
|
},0,0);
|
2007-03-29 05:27:16 +00:00
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
setlistener("/instrumentation/kfc200/lnav",func(ln){
|
|
|
|
if(SRVC == 0)return;
|
|
|
|
lnav = ln.getValue();
|
2007-03-26 03:32:24 +00:00
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
if(lnav == 4){
|
|
|
|
if(!getprop(NAVLOC)){
|
|
|
|
lnav=2;
|
|
|
|
setprop("/instrumentation/kfc200/lnav",lnav);
|
|
|
|
}else{
|
|
|
|
if(getprop(HASGS)){
|
|
|
|
if(!getprop(BC)){
|
|
|
|
setprop("/instrumentation/kfc200/gs-arm",1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-22 23:59:13 +00:00
|
|
|
}
|
2007-12-22 23:37:14 +00:00
|
|
|
HDG.setValue(L_list[lnav]);
|
|
|
|
},0,0);
|
2007-03-26 03:32:24 +00:00
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
setlistener("/instrumentation/kfc200/vnav", func(vn){
|
|
|
|
if(SRVC == 0)return;
|
|
|
|
vnav = vn.getValue();
|
|
|
|
ALT.setValue(V_list[vnav]);
|
|
|
|
},0,0);
|
|
|
|
|
|
|
|
var clear_ap = func {
|
2007-04-22 23:59:13 +00:00
|
|
|
setprop("/autopilot/settings/target-pitch-deg",getprop("/orientation/pitch-deg"));
|
2007-12-22 23:37:14 +00:00
|
|
|
vnav = 0;
|
|
|
|
lnav=0;
|
|
|
|
setprop("/instrumentation/kfc200/lnav",lnav);
|
|
|
|
setprop("/instrumentation/kfc200/vnav",vnav);
|
|
|
|
HDG.setValue(L_list[lnav]);
|
|
|
|
ALT.setValue(V_list[vnav]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#### PITCH TRIM = 1 degree per second ####
|
|
|
|
var pitch_trim = func {
|
|
|
|
var temp_pitch = getprop("autopilot/settings/target-pitch-deg");
|
|
|
|
var FR =getprop("sim/frame-rate");
|
|
|
|
if(FR > 0){
|
|
|
|
var trim = (1/FR) * arg[0];
|
|
|
|
setprop("autopilot/settings/target-pitch-deg",temp_pitch + trim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#### ALTITUDE TRIM = 600 fpm ####
|
|
|
|
var alt_trim = func {
|
|
|
|
var temp_alt = getprop("autopilot/settings/target-altitude-ft");
|
|
|
|
var FR =getprop("sim/frame-rate");
|
|
|
|
if(FR > 0){
|
|
|
|
var trim = (10/FR) * arg[0];
|
|
|
|
setprop("autopilot/settings/target-altitude-ft",temp_alt + trim);
|
2007-04-22 23:59:13 +00:00
|
|
|
}
|
2007-12-22 23:37:14 +00:00
|
|
|
}
|
2007-03-26 03:32:24 +00:00
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var update_nav = func {
|
|
|
|
if(SRVC == 1){
|
|
|
|
var inrange= getprop(NAVRNG);
|
|
|
|
|
|
|
|
if(inrange){
|
|
|
|
|
|
|
|
if(lnav == 2 or lnav == 4){
|
|
|
|
setprop("instrumentation/kfc200/armed",1);
|
|
|
|
setprop("instrumentation/kfc200/cpld",0);
|
|
|
|
var DF = getprop(HDEFL);
|
|
|
|
if(DF > -9 and DF < 9){
|
|
|
|
setprop("/instrumentation/kfc200/lnav",lnav + 1);
|
|
|
|
setprop("instrumentation/kfc200/armed",0);
|
|
|
|
setprop("instrumentation/kfc200/cpld",1);
|
2007-04-22 23:59:13 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-22 23:37:14 +00:00
|
|
|
|
|
|
|
if(lnav ==5){
|
|
|
|
if(getprop("instrumentation/kfc200/gs-arm")){
|
|
|
|
if(getprop("instrumentation/nav/gs-distance") < 25000){
|
|
|
|
var GS1 = getprop(GSDEFL);
|
2009-09-09 10:49:36 +00:00
|
|
|
if( GS1< 0.5 and GS1 > -0.5){vnav = 4;
|
2007-12-22 23:37:14 +00:00
|
|
|
setprop("/instrumentation/kfc200/vnav",vnav);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-22 23:59:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
if(vnav == 1){
|
|
|
|
var offset = get_altoffset();
|
2007-04-22 23:59:13 +00:00
|
|
|
if(offset > -990 and offset < 990){
|
2007-12-22 23:37:14 +00:00
|
|
|
setprop("/instrumentation/kfc200/vnav",vnav + 1);
|
|
|
|
}
|
2007-04-22 23:59:13 +00:00
|
|
|
}
|
|
|
|
|
2007-04-28 05:40:25 +00:00
|
|
|
}
|
2007-12-22 23:37:14 +00:00
|
|
|
}
|
2007-03-26 03:32:24 +00:00
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
var get_altoffset = func(){
|
|
|
|
current_alt = getprop("/instrumentation/altimeter/pressure-alt-ft");
|
2007-04-22 23:59:13 +00:00
|
|
|
var offset = (current_alt - alt_select);
|
|
|
|
var alert =0;
|
2007-12-22 23:37:14 +00:00
|
|
|
if(offset > -1000 and offset < -1000){
|
|
|
|
if(offset < -300 and offset > 300)alert = 1;
|
|
|
|
}
|
2007-04-22 23:59:13 +00:00
|
|
|
fdprop.getNode("alt-alert").setBoolValue(alert);
|
2007-12-22 23:37:14 +00:00
|
|
|
return(offset);
|
2007-04-22 23:59:13 +00:00
|
|
|
}
|
2007-03-26 03:32:24 +00:00
|
|
|
|
2007-12-22 23:37:14 +00:00
|
|
|
var update = func {
|
|
|
|
var PT = getprop("instrumentation/kfc200/pitch-trim");
|
|
|
|
var AT = getprop("instrumentation/kfc200/alt-trim");
|
|
|
|
if(PT !=0)pitch_trim(PT);
|
|
|
|
if(AT!=0)alt_trim(AT);
|
|
|
|
if(getprop("/position/altitude-agl-ft") < DH){
|
|
|
|
props.globals.getNode("/autopilot/locks/passive-mode").setBoolValue(1);
|
|
|
|
setprop("instrumentation/kfc200/dh-alert",1);
|
|
|
|
}else{
|
|
|
|
setprop("instrumentation/kfc200/dh-alert",0);
|
|
|
|
}
|
2007-03-26 03:32:24 +00:00
|
|
|
update_nav();
|
|
|
|
settimer(update, 0);
|
2007-04-28 05:40:25 +00:00
|
|
|
}
|
2007-03-26 03:32:24 +00:00
|
|
|
|