1
0
Fork 0

display frequency when USE or DSP button pressed...

This commit is contained in:
sydadams 2007-04-26 04:12:42 +00:00
parent 2e2c30f424
commit dec26c8b12
3 changed files with 939 additions and 938 deletions

View file

@ -61,241 +61,243 @@ init = func {
var updateRNAV = func{ var updateRNAV = func{
# check to see if we are in-range # check to see if we are in-range
if( NAV1_IN_RANGE.getValue()==0) { if( NAV1_IN_RANGE.getValue()==0) {
return; return;
} }
var dme_valid=DME1_IN_RANGE.getValue(); var dme_valid=DME1_IN_RANGE.getValue();
if( dme_valid == 0) { if( dme_valid == 0) {
return; return;
} }
if( dme_valid == nil) { if( dme_valid == nil) {
return; return;
} }
#### 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(); use =KNS80.getNode("use").getValue();
distance=getprop("/instrumentation/dme/indicated-distance-nm"); distance=getprop("/instrumentation/dme/indicated-distance-nm");
selected_radial = NAV1_RADIAL.getValue(); selected_radial = NAV1_RADIAL.getValue();
radial = NAV1_ACTUAL.getValue(); radial = NAV1_ACTUAL.getValue();
rho = KNS80.getNode("wpt[" ~ use ~ "]/distance").getValue(); rho = KNS80.getNode("wpt[" ~ use ~ "]/distance").getValue();
theta = KNS80.getNode("wpt[" ~ use ~ "]/radial").getValue(); theta = KNS80.getNode("wpt[" ~ use ~ "]/radial").getValue();
fangle = 0; fangle = 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 ); x1 = distance * math.cos( radial*D2R );
y1 = distance * math.sin( radial*D2R ); y1 = distance * math.sin( radial*D2R );
x2 = rho * math.cos( theta*D2R ); x2 = rho * math.cos( theta*D2R );
y2 = rho * math.sin( theta*D2R ); y2 = rho * math.sin( theta*D2R );
range = math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ); range = math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
bearing = math.atan2 (( y1-y2), (x1-x2))*R2D; 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; abearing = bearing > 180 ? bearing - 180 : bearing + 180;
if( mode == 0){ if( mode == 0){
# print("KNS-80 VOR"); # print("KNS-80 VOR");
needle_deflection = (NAV1_HEADING_NEEDLE_DEFLECTION.getValue()); needle_deflection = (NAV1_HEADING_NEEDLE_DEFLECTION.getValue());
range = distance; range = distance;
# return; # return;
} }
if ( mode == 1){ if ( mode == 1){
# print("KNS-80 VOR/PAR"); # print("KNS-80 VOR/PAR");
fangle = math.abs(selected_radial - radial); fangle = math.abs(selected_radial - radial);
needle_deflection = math.sin((selected_radial - radial) * D2R) * distance * 2; needle_deflection = math.sin((selected_radial - radial) * D2R) * distance * 2;
} }
if ( mode == 2){ if ( mode == 2){
# print("KNS-80 RNAV/ENR"); # print("KNS-80 RNAV/ENR");
fangle = math.abs(selected_radial - bearing); fangle = math.abs(selected_radial - bearing);
needle_deflection = math.sin((selected_radial - bearing) * D2R) * range * 2; needle_deflection = math.sin((selected_radial - bearing) * D2R) * range * 2;
} }
if ( mode == 3){ if ( mode == 3){
# print("KNS-80 RNAV/APR"); # print("KNS-80 RNAV/APR");
fangle = math.abs(selected_radial - bearing); fangle = math.abs(selected_radial - bearing);
needle_deflection = math.sin((selected_radial - bearing) * D2R) * range * 8; needle_deflection = math.sin((selected_radial - bearing) * D2R) * range * 8;
} }
if ( needle_deflection > 10) needle_deflection = 10; if ( needle_deflection > 10) needle_deflection = 10;
if ( needle_deflection < -10) needle_deflection =-10; if ( needle_deflection < -10) needle_deflection =-10;
if (fangle < 90 or fangle >270){ if (fangle < 90 or fangle >270){
from_flag=1; from_flag=1;
to_flag =0; to_flag =0;
} else { } else {
from_flag=0; from_flag=0;
to_flag =1; to_flag =1;
} }
# valid=1; # valid=1;
RNAV.getNode("heading-needle-deflection", 1).setValue(needle_deflection); RNAV.getNode("heading-needle-deflection", 1).setValue(needle_deflection);
CDI_NEEDLE.setValue(needle_deflection); CDI_NEEDLE.setValue(needle_deflection);
TO_FLAG.setValue(to_flag); TO_FLAG.setValue(to_flag);
FROM_FLAG.setValue(from_flag); FROM_FLAG.setValue(from_flag);
setprop("/instrumentation/rnav/indicated-distance-nm", range); setprop("/instrumentation/rnav/indicated-distance-nm", range);
setprop("/instrumentation/rnav/reciprocal-radial-deg", abearing); setprop("/instrumentation/rnav/reciprocal-radial-deg", abearing);
setprop("/instrumentation/rnav/actual-deg", bearing); setprop("/instrumentation/rnav/actual-deg", bearing);
##debugging ##debugging
## setprop("/instrumentation/rnav/debug-angle-deg", angle*R2D); ##setprop("/instrumentation/rnav/debug-angle-deg", angle*R2D);
## setprop("/instrumentation/rnav/debug-anglef-deg", fangle); ##setprop("/instrumentation/rnav/debug-anglef-deg", fangle);
## setprop("/instrumentation/rnav/debug-theta-deg",theta); ##setprop("/instrumentation/rnav/debug-theta-deg",theta);
## setprop("/instrumentation/rnav/debug-rho", rho); ##setprop("/instrumentation/rnav/debug-rho", rho);
} }
_setlistener("/sim/signals/fdm-initialized", func { _setlistener("/sim/signals/fdm-initialized", func {
KNS80.getNode("serviceable",1).setBoolValue(1); KNS80.getNode("serviceable",1).setBoolValue(1);
KNS80.getNode("volume-adjust",1).setValue(0); KNS80.getNode("volume-adjust",1).setValue(0);
KNS80.getNode("data-adjust",1).setValue(0); KNS80.getNode("data-adjust",1).setValue(0);
KNS80.getNode("volume",1).setValue(0.5); KNS80.getNode("volume",1).setValue(0.5);
KNS80.getNode("display",1).setValue(0); KNS80.getNode("display",1).setValue(0);
KNS80.getNode("use",1).setValue(0); KNS80.getNode("use",1).setValue(0);
KNS80.getNode("data-mode",1).setValue(0); KNS80.getNode("data-mode",1).setValue(0);
KNS80.getNode("nav-mode",1).setValue(0); KNS80.getNode("nav-mode",1).setValue(0);
KNS80.getNode("dme-hold",1).setBoolValue(0); KNS80.getNode("dme-hold",1).setBoolValue(0);
KNS80.getNode("displayed-frequency",1).setValue(NAV1.getValue()* 100); KNS80.getNode("displayed-frequency",1).setValue(NAV1.getValue()* 100);
KNS80.getNode("displayed-distance",1).setValue(0); KNS80.getNode("displayed-distance",1).setValue(0);
KNS80.getNode("displayed-radial",1).setValue(NAV1_RADIAL.getValue()); KNS80.getNode("displayed-radial",1).setValue(NAV1_RADIAL.getValue());
KNS80.getNode("wpt[0]/frequency",1).setValue(NAV1.getValue()* 100); KNS80.getNode("wpt[0]/frequency",1).setValue(NAV1.getValue()* 100);
KNS80.getNode("wpt[0]/radial",1).setValue(NAV1_RADIAL.getValue()); KNS80.getNode("wpt[0]/radial",1).setValue(NAV1_RADIAL.getValue());
KNS80.getNode("wpt[0]/distance",1).setValue(0.0); KNS80.getNode("wpt[0]/distance",1).setValue(0.0);
KNS80.getNode("wpt[1]/frequency",1).setValue(11570); KNS80.getNode("wpt[1]/frequency",1).setValue(11570);
KNS80.getNode("wpt[1]/radial",1).setValue(120); KNS80.getNode("wpt[1]/radial",1).setValue(120);
KNS80.getNode("wpt[1]/distance",1).setValue(7.2); KNS80.getNode("wpt[1]/distance",1).setValue(7.2);
KNS80.getNode("wpt[2]/frequency",1).setValue(11570); KNS80.getNode("wpt[2]/frequency",1).setValue(11570);
KNS80.getNode("wpt[2]/radial",1).setValue(270); KNS80.getNode("wpt[2]/radial",1).setValue(270);
KNS80.getNode("wpt[2]/distance",1).setValue(5.8); KNS80.getNode("wpt[2]/distance",1).setValue(5.8);
KNS80.getNode("wpt[3]/frequency",1).setValue(10800); KNS80.getNode("wpt[3]/frequency",1).setValue(10800);
KNS80.getNode("wpt[3]/radial",1).setValue(0); KNS80.getNode("wpt[3]/radial",1).setValue(0);
KNS80.getNode("wpt[3]/distance",1).setValue(0.0); KNS80.getNode("wpt[3]/distance",1).setValue(0.0);
props.globals.getNode("/instrumentation/nav/ident").setBoolValue(0); props.globals.getNode("/instrumentation/nav/ident").setBoolValue(0);
FDM_ON = 1; FDM_ON = 1;
init(); init();
print("KNS-80 Nav System ... OK"); print("KNS-80 Nav System ... OK");
},1); },1);
setlistener("/instrumentation/kns-80/volume-adjust", func { setlistener("/instrumentation/kns-80/volume-adjust", func {
if(FDM_ON != 0){ if(FDM_ON != 0){
var amnt = cmdarg().getValue() * 0.05; var amnt = cmdarg().getValue() * 0.05;
cmdarg().setValue(0); cmdarg().setValue(0);
var vol = KNS80.getChild("volume").getValue(); var vol = KNS80.getChild("volume").getValue();
vol+= amnt; vol+= amnt;
if(vol > 1.0){vol = 1.0;} if(vol > 1.0){vol = 1.0;}
if(vol < 0.0){vol = 0.0;KNS80.getNode("serviceable").setBoolValue(0);} if(vol < 0.0){vol = 0.0;KNS80.getNode("serviceable").setBoolValue(0);}
if(vol > 0.0){KNS80.getNode("serviceable").setBoolValue(1);} if(vol > 0.0){KNS80.getNode("serviceable").setBoolValue(1);}
KNS80.getNode("volume").setValue(vol); KNS80.getNode("volume").setValue(vol);
KNS80.getNode("volume-adjust").setValue(0); KNS80.getNode("volume-adjust").setValue(0);
} }
}); });
setlistener("/instrumentation/kns-80/data-adjust", func { setlistener("/instrumentation/kns-80/data-adjust", func {
if(FDM_ON != 0){ if(FDM_ON != 0){
var dmode = KNS80.getNode("data-mode").getValue(); var dmode = KNS80.getNode("data-mode").getValue();
var num = cmdarg().getValue(); var num = cmdarg().getValue();
cmdarg().setValue(0); cmdarg().setValue(0);
if(dmode == 0){ if(dmode == 0){
if(num == -1 or num ==1 ){num = num *5;}else{num = num *10;} if(num == -1 or num ==1 ){num = num *5;}else{num = num *10;}
var newfreq = KNS80.getNode("displayed-frequency").getValue(); var newfreq = KNS80.getNode("displayed-frequency").getValue();
newfreq += num; newfreq += num;
if(newfreq > 11895){newfreq -= 1100;} if(newfreq > 11895){newfreq -= 1100;}
if(newfreq < 10800){newfreq += 1100;} if(newfreq < 10800){newfreq += 1100;}
KNS80.getNode("displayed-frequency").setValue(newfreq); KNS80.getNode("displayed-frequency").setValue(newfreq);
return; return;
} }
if(dmode == 1){ if(dmode == 1){
var newrad = KNS80.getNode("displayed-radial").getValue(); var newrad = KNS80.getNode("displayed-radial").getValue();
newrad += num; newrad += num;
if(newrad > 359){newrad -= 360;} if(newrad > 359){newrad -= 360;}
if(newrad < 0){newrad += 360;} if(newrad < 0){newrad += 360;}
KNS80.getNode("displayed-radial").setValue(newrad); KNS80.getNode("displayed-radial").setValue(newrad);
return; return;
} }
if(dmode == 2){ if(dmode == 2){
var newdist = KNS80.getNode("displayed-distance").getValue(); var newdist = KNS80.getNode("displayed-distance").getValue();
newdist += num; newdist += num;
if(newdist > 99){newdist -= 100;} if(newdist > 99){newdist -= 100;}
if(newdist < 0){newdist += 100;} if(newdist < 0){newdist += 100;}
KNS80.getNode("displayed-distance").setValue(newdist); KNS80.getNode("displayed-distance").setValue(newdist);
return; return;
} }
} }
}); });
setlistener("/instrumentation/kns-80/displayed-frequency", func { setlistener("/instrumentation/kns-80/displayed-frequency", func {
if(FDM_ON != 0){ if(FDM_ON != 0){
var freq = cmdarg().getValue(); var freq = cmdarg().getValue();
var num = KNS80.getNode("display").getValue(); var num = KNS80.getNode("display").getValue();
var use = KNS80.getNode("use").getValue(); var use = KNS80.getNode("use").getValue();
KNS80.getNode("wpt[" ~ num ~ "]/frequency").setValue(freq); KNS80.getNode("wpt[" ~ num ~ "]/frequency").setValue(freq);
NAV1.setValue(KNS80.getNode("wpt[" ~ use ~ "]/frequency").getValue() * 0.01); NAV1.setValue(KNS80.getNode("wpt[" ~ use ~ "]/frequency").getValue() * 0.01);
} }
}); });
setlistener("/instrumentation/kns-80/displayed-radial", func { setlistener("/instrumentation/kns-80/displayed-radial", func {
if(FDM_ON != 0){ if(FDM_ON != 0){
var rad = cmdarg().getValue(); var rad = cmdarg().getValue();
var num = KNS80.getNode("display").getValue(); var num = KNS80.getNode("display").getValue();
var radial = KNS80.getNode("use").getValue(); var radial = KNS80.getNode("use").getValue();
KNS80.getNode("wpt[" ~ num ~ "]/radial").setValue(rad); KNS80.getNode("wpt[" ~ num ~ "]/radial").setValue(rad);
} }
}); });
setlistener("/instrumentation/kns-80/displayed-distance", func { setlistener("/instrumentation/kns-80/displayed-distance", func {
if(FDM_ON != 0){ if(FDM_ON != 0){
var dis = cmdarg().getValue(); var dis = cmdarg().getValue();
var num = KNS80.getNode("display").getValue(); var num = KNS80.getNode("display").getValue();
KNS80.getNode("wpt[" ~ num ~ "]/distance").setValue(dis); KNS80.getNode("wpt[" ~ num ~ "]/distance").setValue(dis);
} }
}); });
setlistener("/instrumentation/kns-80/serviceable", func { setlistener("/instrumentation/kns-80/serviceable", func {
if(FDM_ON != 0){ if(FDM_ON != 0){
setprop("/instrumentation/nav/serviceable",cmdarg().getValue()); setprop("/instrumentation/nav/serviceable",cmdarg().getValue());
setprop("/instrumentation/dme/serviceable",cmdarg().getValue()); setprop("/instrumentation/dme/serviceable",cmdarg().getValue());
} }
}); });
setlistener("/instrumentation/kns-80/volume", func { setlistener("/instrumentation/kns-80/volume", func {
if(FDM_ON == 0){return;} if(FDM_ON == 0){return;}
setprop("/instrumentation/nav/volume",cmdarg().getValue()); setprop("/instrumentation/nav/volume",cmdarg().getValue());
setprop("/instrumentation/dme/volume",cmdarg().getValue()); setprop("/instrumentation/dme/volume",cmdarg().getValue());
}); });
setlistener("/instrumentation/kns-80/use", func { setlistener("/instrumentation/kns-80/use", func {
if(FDM_ON == 0){return;} if(FDM_ON == 0){return;}
var freq = cmdarg().getValue(); var freq = cmdarg().getValue();
KNS80.getNode("flash").setValue(0); KNS80.getNode("flash").setValue(0);
NAV1.setValue(KNS80.getNode("wpt[" ~ freq ~ "]/frequency").getValue()* 0.01); KNS80.getNode("data-mode",1).setValue(0);
}); NAV1.setValue(KNS80.getNode("wpt[" ~ freq ~ "]/frequency").getValue()* 0.01);
});
setlistener("/instrumentation/kns-80/display", func { setlistener("/instrumentation/kns-80/display", func {
if(FDM_ON == 0){return;} if(FDM_ON == 0){return;}
var freq = cmdarg().getValue(); var freq = cmdarg().getValue();
var test = KNS80.getNode("use").getValue(); var test = KNS80.getNode("use").getValue();
var wpt = KNS80.getNode("wpt[" ~ freq ~ "]/frequency").getValue(); var wpt = KNS80.getNode("wpt[" ~ freq ~ "]/frequency").getValue();
KNS80.getNode("displayed-frequency").setValue(wpt); KNS80.getNode("displayed-frequency").setValue(wpt);
KNS80.getNode("displayed-distance").setValue(KNS80.getNode("wpt[" ~ freq ~ "]/distance").getValue()); KNS80.getNode("displayed-distance").setValue(KNS80.getNode("wpt[" ~ freq ~ "]/distance").getValue());
KNS80.getNode("displayed-radial").setValue(KNS80.getNode("wpt[" ~ freq ~ "]/radial").getValue()); KNS80.getNode("displayed-radial").setValue(KNS80.getNode("wpt[" ~ freq ~ "]/radial").getValue());
if(test != freq){ KNS80.getNode("data-mode",1).setValue(0);
KNS80.getNode("flash").setValue(1); if(test != freq){
}else{ KNS80.getNode("flash").setValue(1);
KNS80.getNode("flash").setValue(0); }else{
} KNS80.getNode("flash").setValue(0);
}); }
});
setlistener("/instrumentation/kns-80/dme-hold", func { setlistener("/instrumentation/kns-80/dme-hold", func {
if(FDM_ON == 0){return;} if(FDM_ON == 0){return;}
if(cmdarg().getBoolValue()){ if(cmdarg().getBoolValue()){
props.globals.getNode("instrumentation/dme/frequencies/selected-mhz").setValue(NAV1.getValue()); props.globals.getNode("instrumentation/dme/frequencies/selected-mhz").setValue(NAV1.getValue());
props.globals.getNode("instrumentation/dme/frequencies/source").setValue("/instrumentation/dme/frequencies/selected-mhz"); props.globals.getNode("instrumentation/dme/frequencies/source").setValue("/instrumentation/dme/frequencies/selected-mhz");
}else{ }else{
props.globals.getNode("instrumentation/dme/frequencies/selected-mhz").setValue(""); props.globals.getNode("instrumentation/dme/frequencies/selected-mhz").setValue("");
props.globals.getNode("instrumentation/dme/frequencies/source").setValue("/instrumentation/nav[0]/frequencies/selected-mhz"); props.globals.getNode("instrumentation/dme/frequencies/source").setValue("/instrumentation/nav[0]/frequencies/selected-mhz");
} }
}); });
# ]]></script></PropertyList> # ]]></script></PropertyList>

View file

@ -220,7 +220,7 @@
<binding> <binding>
<command>property-adjust</command> <command>property-adjust</command>
<property>instrumentation/kns-80/displayed-distance</property> <property>instrumentation/kns-80/displayed-distance</property>
<step>-1</step> <step>-0.1</step>
<min>0</min> <min>0</min>
<max>100</max> <max>100</max>
<wrap>true</wrap> <wrap>true</wrap>
@ -266,7 +266,7 @@
<binding> <binding>
<command>property-adjust</command> <command>property-adjust</command>
<property>instrumentation/kns-80/displayed-distance</property> <property>instrumentation/kns-80/displayed-distance</property>
<step>1</step> <step>0.1</step>
<min>0</min> <min>0</min>
<max>100</max> <max>100</max>
<wrap>true</wrap> <wrap>true</wrap>

File diff suppressed because it is too large Load diff