2007-03-26 03:32:24 +00:00
|
|
|
#### Bendix-King KFC-200 Flight Director ####
|
|
|
|
|
|
|
|
# off - Off: v-bars hidden
|
|
|
|
# hdg - Heading: v-bars command a turn to the heading bug
|
|
|
|
# appr - Approach: bank and pitch commands capture and track LOC and GS
|
|
|
|
# bc - Reverse Localizer: bank command to caputre and track a reverse LOC
|
2007-04-22 23:59:13 +00:00
|
|
|
#course.GS is locked out.
|
2007-03-26 03:32:24 +00:00
|
|
|
# arm - Standby mode to compute capture point for nav, appr, or bc.
|
|
|
|
# cpld - Coupled: Active mode for nav, appr, or bc.
|
|
|
|
# ga - Go Around: commands wings level and missed approach attitude.
|
|
|
|
# alt - Altitude hold: commands pitch to hold altitude
|
|
|
|
# vertical trim - pitch command to adjust altitude at 500 fpm while in alt hold
|
2007-04-22 23:59:13 +00:00
|
|
|
#or pitch attitude at rate of 1 deg/sec when not in alt hold
|
2007-03-26 03:32:24 +00:00
|
|
|
# yd - Yaw Damper: system senses motion around ayw axis and moves rudder to
|
2007-04-22 23:59:13 +00:00
|
|
|
# oppose yaw.
|
2007-03-26 03:32:24 +00:00
|
|
|
|
|
|
|
fdprop = props.globals.getNode("/instrumentation/kfc200",1);
|
|
|
|
fdmode = "off";
|
|
|
|
fdmodeV = "off";
|
|
|
|
fdmode_last = "off";
|
|
|
|
current_alt=0.0;
|
2007-04-01 18:20:23 +00:00
|
|
|
alt_select = 0.0;
|
2007-03-26 03:32:24 +00:00
|
|
|
alt_offset = 0.0;
|
2007-04-21 23:16:56 +00:00
|
|
|
V_pitch=0.0;
|
|
|
|
V_roll=0.0;
|
2007-03-29 05:27:16 +00:00
|
|
|
DH = 0;
|
2007-04-22 23:59:13 +00:00
|
|
|
NAVGS = props.globals.getNode("/instrumentation/nav/has-gs",1);
|
|
|
|
NAVGS_RANGE = props.globals.getNode("/instrumentation/nav/gs-distance",1);
|
|
|
|
NAVBC = props.globals.getNode("/instrumentation/nav/back-course-btn",1);
|
|
|
|
NAV_IN_RANGE = props.globals.getNode("/instrumentation/nav/in-range",1);
|
|
|
|
HDG_DEFLECTION = props.globals.getNode("/instrumentation/nav/heading-needle-deflection",1);
|
|
|
|
GS_DEFLECTION = props.globals.getNode("/instrumentation/nav/gs-needle-deflection",1);
|
2007-04-01 18:20:23 +00:00
|
|
|
HDG = props.globals.getNode("/autopilot/locks/heading",1);
|
|
|
|
ALT = props.globals.getNode("/autopilot/locks/altitude",1);
|
|
|
|
SPD = props.globals.getNode("/autopilot/locks/speed",1);
|
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-04-28 05:40:25 +00:00
|
|
|
fdprop.getNode("vbar-pitch",1).setDoubleValue(0.0);
|
|
|
|
fdprop.getNode("vbar-roll",1).setDoubleValue(0.0);
|
2007-04-22 23:59:13 +00:00
|
|
|
fdprop.getNode("fd-on",1).setBoolValue(0);
|
|
|
|
fdprop.getNode("fdmode",1).setValue("off");
|
|
|
|
fdprop.getNode("fdmodeV",1).setValue("off");
|
2007-04-28 05:40:25 +00:00
|
|
|
fdprop.getNode("alt-offset",1).setDoubleValue(0.0);
|
2007-04-22 23:59:13 +00:00
|
|
|
fdprop.getNode("alt-alert",1).setBoolValue(0);
|
2007-04-01 18:20:23 +00:00
|
|
|
DH = props.globals.getNode("/autopilot/route-manager/min-lock-altitude-agl-ft").getValue();
|
2007-04-22 23:59:13 +00:00
|
|
|
alt_select = 0;
|
2007-04-28 05:40:25 +00:00
|
|
|
update();
|
2007-03-26 03:32:24 +00:00
|
|
|
print("KFC-200 ... OK");
|
|
|
|
});
|
|
|
|
|
2007-04-06 18:54:28 +00:00
|
|
|
setlistener("/instrumentation/kfc200/fd-on", func {
|
2007-04-22 23:59:13 +00:00
|
|
|
var fdON = cmdarg().getValue();
|
|
|
|
if(!fdprop.getNode("serviceable").getBoolValue()){return;}
|
2007-04-01 18:20:23 +00:00
|
|
|
clear_ap();
|
|
|
|
});
|
|
|
|
|
2007-04-22 23:59:13 +00:00
|
|
|
setlistener("/autopilot/settings/target-altitude-ft",func{
|
|
|
|
if(!fdprop.getNode("serviceable").getBoolValue()){return;}
|
|
|
|
alt_select = cmdarg().getValue();
|
2007-03-26 03:32:24 +00:00
|
|
|
});
|
|
|
|
|
2007-04-22 23:59:13 +00:00
|
|
|
setlistener("/autopilot/route-manager/min-lock-altitude-agl-ft",func{
|
|
|
|
if(!fdprop.getNode("serviceable").getBoolValue()){return;}
|
|
|
|
DH = cmdarg().getValue();
|
2007-03-29 05:27:16 +00:00
|
|
|
});
|
|
|
|
|
2007-03-26 03:32:24 +00:00
|
|
|
|
2007-04-22 23:59:13 +00:00
|
|
|
setlistener("/instrumentation/kfc200/fdmode",func{
|
|
|
|
if(!fdprop.getNode("serviceable").getBoolValue()){return;}
|
|
|
|
fdmode = cmdarg().getValue();
|
|
|
|
NAVBC.setBoolValue(0);
|
2007-04-01 18:20:23 +00:00
|
|
|
if(fdmode == "off"){HDG.setValue("wing-leveler");return;}
|
2007-03-26 03:32:24 +00:00
|
|
|
if(fdmode == "hdg"){
|
2007-04-22 23:59:13 +00:00
|
|
|
HDG.setValue("dg-heading-hold");
|
|
|
|
return;}
|
2007-03-26 03:32:24 +00:00
|
|
|
if(fdmode == "appr"){
|
2007-04-22 23:59:13 +00:00
|
|
|
HDG.setValue("nav1-hold");
|
|
|
|
if(NAVGS.getBoolValue()){
|
|
|
|
fdprop.getNode("fdmodeV").setValue("gs-arm");
|
|
|
|
}
|
|
|
|
return;}
|
2007-04-01 18:20:23 +00:00
|
|
|
|
2007-03-26 03:32:24 +00:00
|
|
|
if(fdmode == "nav-arm"){
|
2007-04-22 23:59:13 +00:00
|
|
|
HDG.setValue("dg-heading-hold");
|
|
|
|
return;}
|
2007-03-26 03:32:24 +00:00
|
|
|
if(fdmode == "nav-cpld"){
|
2007-04-22 23:59:13 +00:00
|
|
|
HDG.setValue("nav1-hold");
|
|
|
|
return;}
|
2007-03-26 03:32:24 +00:00
|
|
|
if(fdmode == "bc"){
|
2007-04-22 23:59:13 +00:00
|
|
|
HDG.setValue("nav1-hold");
|
|
|
|
NAVBC.setBoolValue(1);
|
|
|
|
return;}
|
|
|
|
});
|
2007-03-26 03:32:24 +00:00
|
|
|
|
|
|
|
setlistener("/instrumentation/kfc200/fdmodeV", func {
|
2007-04-22 23:59:13 +00:00
|
|
|
if(!fdprop.getNode("serviceable").getBoolValue()){return;}
|
|
|
|
altmode = cmdarg().getValue();
|
|
|
|
if(altmode == "off"){
|
|
|
|
setprop("/autopilot/settings/target-pitch-deg",getprop("/orientation/pitch-deg"));
|
2007-04-01 18:20:23 +00:00
|
|
|
ALT.setValue("pitch-hold");
|
2007-04-22 23:59:13 +00:00
|
|
|
return;}
|
2007-04-01 18:20:23 +00:00
|
|
|
if(altmode == "alt-arm"){
|
2007-04-22 23:59:13 +00:00
|
|
|
ALT.setValue("pitch-hold");
|
|
|
|
return;}
|
2007-04-01 18:20:23 +00:00
|
|
|
if(altmode == "alt"){
|
2007-04-22 23:59:13 +00:00
|
|
|
ALT.setValue("altitude-hold");
|
|
|
|
return;}
|
2007-04-01 18:20:23 +00:00
|
|
|
if(altmode == "gs-arm"){
|
2007-04-22 23:59:13 +00:00
|
|
|
ALT.setValue("pitch-hold");
|
|
|
|
return;}
|
|
|
|
if(altmode == "gs"){
|
|
|
|
ALT.setValue("gs1-hold");
|
|
|
|
return;}
|
2007-03-26 03:32:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
clear_ap = func {
|
2007-04-22 23:59:13 +00:00
|
|
|
setprop("/autopilot/settings/target-pitch-deg",getprop("/orientation/pitch-deg"));
|
|
|
|
HDG.setValue("wing-leveler");
|
|
|
|
ALT.setValue("pitch-hold");
|
|
|
|
}
|
2007-03-26 03:32:24 +00:00
|
|
|
|
|
|
|
update_nav = func {
|
2007-04-22 23:59:13 +00:00
|
|
|
if(fdprop.getNode("serviceable").getBoolValue()){
|
|
|
|
var APmode = fdprop.getNode("fdmode").getValue();
|
|
|
|
var VNAV = fdprop.getNode("fdmodeV").getValue();
|
2007-03-26 03:32:24 +00:00
|
|
|
if(APmode == "nav-arm"){
|
2007-04-22 23:59:13 +00:00
|
|
|
if(NAV_IN_RANGE.getBoolValue()){
|
|
|
|
var offset = HDG_DEFLECTION.getValue();
|
|
|
|
if(offset < 5 or offset > -5){
|
|
|
|
fdprop.getChild("fdmode").setValue("nav-cpld");
|
|
|
|
}else{
|
|
|
|
fdprop.getChild("fdmode").setValue("nav-arm");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(VNAV == "gs-arm"){
|
|
|
|
if(NAVGS_RANGE.getValue()< 30000){
|
|
|
|
test = GS_DEFLECTION.getValue();
|
|
|
|
if(test < 1 ){fdprop.getNode("fdmodeV").setValue("gs");}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(VNAV == "alt-arm"){
|
|
|
|
var offset = fdprop.getNode("alt-offset").getValue();
|
|
|
|
if(offset > -990 and offset < 990){
|
|
|
|
fdprop.getNode("fdmodeV").setValue("alt");}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(VNAV == "alt"){
|
|
|
|
offset = fdprop.getNode("alt-offset").getValue();
|
|
|
|
if(offset < -990 and offset > 990){
|
|
|
|
fdprop.getNode("fdmodeV").setValue("alt-arm");}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
V_pitch=props.globals.getNode("autopilot/settings/target-pitch-deg").getValue();
|
|
|
|
V_pitch-=props.globals.getNode("orientation/pitch-deg").getValue();
|
|
|
|
if(V_pitch > 30){V_pitch = 30;}
|
|
|
|
if(V_pitch < -30){V_pitch = -30;}
|
|
|
|
fdprop.getNode("vbar-pitch",1).setValue(V_pitch);
|
|
|
|
V_roll=props.globals.getNode("autopilot/internal/target-roll-deg").getValue();
|
|
|
|
if(V_roll == nil){V_roll = 0.0;}
|
|
|
|
V_roll -=props.globals.getNode("orientation/roll-deg").getValue();
|
|
|
|
if(V_roll > 30){V_roll = 30;}
|
|
|
|
if(V_roll < -30){V_roll = -30;}
|
|
|
|
fdprop.getNode("vbar-roll",1).setValue(V_roll);
|
2007-04-28 05:40:25 +00:00
|
|
|
}
|
2007-03-26 03:32:24 +00:00
|
|
|
|
2007-04-01 18:20:23 +00:00
|
|
|
get_altoffset = func{
|
2007-04-22 23:59:13 +00:00
|
|
|
current_alt = props.globals.getNode("/instrumentation/altimeter/indicated-altitude-ft").getValue();
|
|
|
|
var offset = (current_alt - alt_select);
|
|
|
|
var alert =0;
|
|
|
|
fdprop.getNode("alt-offset").setValue(offset);
|
|
|
|
if(offset > -1000 and offset < -300){alert = 1;}
|
|
|
|
if(offset < 1000 and offset > 300){alert = 1;}
|
|
|
|
fdprop.getNode("alt-alert").setBoolValue(alert);
|
|
|
|
if(getprop("/position/altitude-agl-ft") < DH){props.globals.getNode("/autopilot/locks/passive-mode").setBoolValue(1);}
|
|
|
|
}
|
2007-03-26 03:32:24 +00:00
|
|
|
|
|
|
|
update = func {
|
2007-04-22 23:59:13 +00:00
|
|
|
get_altoffset();
|
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
|
|
|
|