1
0
Fork 0

updates from Ron Jensen

This commit is contained in:
sydadams 2008-05-22 02:30:49 +00:00
parent 205675455c
commit 5b020a450a
2 changed files with 81 additions and 35 deletions

View file

@ -8,9 +8,9 @@
#### Nav Modes 0 = VOR ; 1 = VOR/PAR ; 2 = RNAV/ENR ; 3 = RNAV/APR ; #### Nav Modes 0 = VOR ; 1 = VOR/PAR ; 2 = RNAV/ENR ; 3 = RNAV/APR ;
#### ####
KNS80 = props.globals.getNode("/instrumentation/kns-80",1); var KNS80 = props.globals.getNode("/instrumentation/kns-80",1);
NAV1 = props.globals.getNode("/instrumentation/nav/frequencies/selected-mhz",1); var NAV1 = props.globals.getNode("/instrumentation/nav/frequencies/selected-mhz",1);
NAV1_RADIAL = props.globals.getNode("/instrumentation/nav/radials/selected-deg",1); var NAV1_RADIAL = props.globals.getNode("/instrumentation/nav/radials/selected-deg",1);
KNS80.getNode("serviceable",1).setBoolValue(1); KNS80.getNode("serviceable",1).setBoolValue(1);
KNS80.getNode("volume-adjust",1).setDoubleValue(0); KNS80.getNode("volume-adjust",1).setDoubleValue(0);
KNS80.getNode("data-adjust",1).setDoubleValue(0); KNS80.getNode("data-adjust",1).setDoubleValue(0);
@ -35,40 +35,40 @@ KNS80.getNode("wpt[2]/distance",1).setDoubleValue(5.8);
KNS80.getNode("wpt[3]/frequency",1).setDoubleValue(11000); KNS80.getNode("wpt[3]/frequency",1).setDoubleValue(11000);
KNS80.getNode("wpt[3]/radial",1).setDoubleValue(0); KNS80.getNode("wpt[3]/radial",1).setDoubleValue(0);
KNS80.getNode("wpt[3]/distance",1).setDoubleValue(0.0); KNS80.getNode("wpt[3]/distance",1).setDoubleValue(0.0);
FDM_ON = 0; var FDM_ON = 0;
dsp_flash = props.globals.getNode("instrumentation/kns-80/flash", 1); var dsp_flash = props.globals.getNode("instrumentation/kns-80/flash", 1);
aircraft.light.new("instrumentation/kns-80/dsp-state", [0.5, 0.5],dsp_flash); aircraft.light.new("instrumentation/kns-80/dsp-state", [0.5, 0.5],dsp_flash);
# Properties # Properties
NAV1_ACTUAL = props.globals.getNode("/instrumentation/nav/radials/actual-deg",1); var NAV1_ACTUAL = props.globals.getNode("/instrumentation/nav/radials/actual-deg",1);
NAV1_TO_FLAG = props.globals.getNode("/instrumentation/nav[0]/to-flag",1); var NAV1_TO_FLAG = props.globals.getNode("/instrumentation/nav[0]/to-flag",1);
NAV1_FROM_FLAG = props.globals.getNode("/instrumentation/nav[0]/from-flag",1); var NAV1_FROM_FLAG = props.globals.getNode("/instrumentation/nav[0]/from-flag",1);
NAV1_HEADING_NEEDLE_DEFLECTION = props.globals.getNode("/instrumentation/nav[0]/heading-needle-deflection",1); var NAV1_HEADING_NEEDLE_DEFLECTION = props.globals.getNode("/instrumentation/nav[0]/heading-needle-deflection",1);
NAV1_IN_RANGE = props.globals.getNode("/instrumentation/nav[0]/in-range",1); var NAV1_IN_RANGE = props.globals.getNode("/instrumentation/nav[0]/in-range",1);
DME1_IN_RANGE = props.globals.getNode("/instrumentation/dme[0]/in-range",1); var DME1_IN_RANGE = props.globals.getNode("/instrumentation/dme[0]/in-range",1);
# outputs # outputs
CDI_NEEDLE = props.globals.getNode("/instrumentation/gps/cdi-deflection",1); var CDI_NEEDLE = props.globals.getNode("/instrumentation/gps/cdi-deflection",1);
TO_FLAG = props.globals.getNode("/instrumentation/gps/to-flag",1); var TO_FLAG = props.globals.getNode("/instrumentation/gps/to-flag",1);
FROM_FLAG = props.globals.getNode("/instrumentation/gps/from-flag",1); var FROM_FLAG = props.globals.getNode("/instrumentation/gps/from-flag",1);
RNAV = props.globals.getNode("/instrumentation/rnav",1); var RNAV = props.globals.getNode("/instrumentation/rnav",1);
# distance, radial from VOR Station # distance, radial from VOR Station
# rho, theta: distance and radial for phantom station # rho, theta: distance and radial for phantom station
# range, bearing: distance and radial from phantom station # range, bearing: distance and radial from phantom station
PI=3.14159265; var PI=3.14159265;
D2R=PI/180; var D2R=PI/180;
R2D=180/PI; var R2D=180/PI;
var unnil = func(n) { n == nil ? 0 : n } var unnil = func(n) { n == nil ? 0 : n }
# 0.1 second cron # 0.1 second cron
sec01cron = func { var sec01cron = func {
updateRNAV(); updateRNAV();
# schedule the next call # schedule the next call
@ -77,7 +77,7 @@ sec01cron = func {
# general initialization # general initialization
init = func { var init = func {
# schedule the 1st call # schedule the 1st call
settimer(sec01cron,1); settimer(sec01cron,1);
} }
@ -98,29 +98,33 @@ var updateRNAV = func{
#### Nav Modes 0 = VOR ; 1 = VOR/PAR ; 2 = RNAV/ENR ; 3 = RNAV/APR ; #### Nav Modes 0 = VOR ; 1 = VOR/PAR ; 2 = RNAV/ENR ; 3 = RNAV/APR ;
var mode = KNS80.getNode("nav-mode").getValue(); var mode = KNS80.getNode("nav-mode").getValue();
use =KNS80.getNode("use").getValue(); var use =KNS80.getNode("use").getValue();
distance=getprop("/instrumentation/dme/indicated-distance-nm"); var distance=getprop("/instrumentation/dme/indicated-distance-nm");
selected_radial = NAV1_RADIAL.getValue(); var selected_radial = NAV1_RADIAL.getValue();
radial = NAV1_ACTUAL.getValue(); var radial = NAV1_ACTUAL.getValue();
rho = KNS80.getNode("wpt[" ~ use ~ "]/distance").getValue(); var rho = KNS80.getNode("wpt[" ~ use ~ "]/distance").getValue();
theta = KNS80.getNode("wpt[" ~ use ~ "]/radial").getValue(); var theta = KNS80.getNode("wpt[" ~ use ~ "]/radial").getValue();
fangle = 0; var fangle = 0;
var needle_deflection = 0;
var from_flag=1;
var to_flag =0;
radial = unnil(radial); radial = unnil(radial);
theta = unnil(theta); theta = unnil(theta);
rho = unnil(rho); rho = unnil(rho);
distance=unnil(distance); distance=unnil(distance);
x1 = distance * math.cos( radial*D2R ); var x1 = distance * math.cos( radial*D2R );
y1 = distance * math.sin( radial*D2R ); var y1 = distance * math.sin( radial*D2R );
x2 = rho * math.cos( theta*D2R ); var x2 = rho * math.cos( theta*D2R );
y2 = rho * math.sin( theta*D2R ); var y2 = rho * math.sin( theta*D2R );
range = math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ); var range = math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
bearing = math.atan2 (( y1-y2), (x1-x2))*R2D; var bearing = math.atan2 (( y1-y2), (x1-x2))*R2D;
if(bearing < 0) bearing += 360; if(bearing < 0) bearing += 360;
abearing = bearing > 180 ? bearing - 180 : bearing + 180; var abearing = bearing > 180 ? bearing - 180 : bearing + 180;
if( mode == 0){ if( mode == 0){
# print("KNS-80 VOR"); # print("KNS-80 VOR");

View file

@ -779,4 +779,46 @@ Syd Adams
</action> </action>
</animation> </animation>
</PropertyList> <animation>
<type>pick</type>
<object-name>VOR.btn</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>
var test = getprop("/instrumentation/kns-80/nav-mode");
if(test != 0){
setprop("/instrumentation/kns-80/nav-mode",0);
setprop("/instrumentation/nav/slaved-to-gps", 0);
}else{
setprop("/instrumentation/kns-80/nav-mode",1);
setprop("/instrumentation/nav/slaved-to-gps", 1);
}
</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>RNAV.btn</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>
var test = getprop("/instrumentation/kns-80/nav-mode");
if(test != 2){setprop("/instrumentation/kns-80/nav-mode",2);
}else{setprop("/instrumentation/kns-80/nav-mode",3);}
setprop("/instrumentation/nav/slaved-to-gps", 1);
</script>
</binding>
</action>
</animation>
</PropertyList>