a few more updates , cleanups ...
This commit is contained in:
parent
5b020a450a
commit
51344a09ec
1 changed files with 162 additions and 134 deletions
|
@ -11,30 +11,76 @@
|
||||||
var KNS80 = props.globals.getNode("/instrumentation/kns-80",1);
|
var KNS80 = props.globals.getNode("/instrumentation/kns-80",1);
|
||||||
var NAV1 = props.globals.getNode("/instrumentation/nav/frequencies/selected-mhz",1);
|
var NAV1 = props.globals.getNode("/instrumentation/nav/frequencies/selected-mhz",1);
|
||||||
var 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);
|
var KNS80_wpt_freq=[];
|
||||||
KNS80.getNode("volume-adjust",1).setDoubleValue(0);
|
var KNS80_wpt_radial=[];
|
||||||
KNS80.getNode("data-adjust",1).setDoubleValue(0);
|
var KNS80_wpt_distance=[];
|
||||||
KNS80.getNode("volume",1).setDoubleValue(0.5);
|
|
||||||
KNS80.getNode("display",1).setDoubleValue(0);
|
var KNS80_serviceable=KNS80.getNode("serviceable",1);
|
||||||
KNS80.getNode("use",1).setDoubleValue(0);
|
KNS80_serviceable.setBoolValue(1);
|
||||||
KNS80.getNode("data-mode",1).setDoubleValue(0);
|
|
||||||
KNS80.getNode("nav-mode",1).setDoubleValue(0);
|
var KNS80_volume_adjust=KNS80.getNode("volume-adjust",1);
|
||||||
KNS80.getNode("dme-hold",1).setBoolValue(0);
|
KNS80_volume_adjust.setDoubleValue(0);
|
||||||
KNS80.getNode("displayed-distance",1).setDoubleValue(0);
|
|
||||||
KNS80.getNode("displayed-frequency",1).setDoubleValue(0.0);
|
var KNS80_data_adjust=KNS80.getNode("data-adjust",1);
|
||||||
KNS80.getNode("displayed-radial",1).setDoubleValue(0.0);
|
KNS80_data_adjust.setDoubleValue(0);
|
||||||
KNS80.getNode("wpt[0]/frequency",1).setDoubleValue(0.0);
|
|
||||||
KNS80.getNode("wpt[0]/radial",1).setDoubleValue(0.0);
|
var KNS80_volume=KNS80.getNode("volume",1);
|
||||||
KNS80.getNode("wpt[0]/distance",1).setDoubleValue(0.0);
|
KNS80_volume.setDoubleValue(0.5);
|
||||||
KNS80.getNode("wpt[1]/frequency",1).setDoubleValue(11570);
|
|
||||||
KNS80.getNode("wpt[1]/radial",1).setDoubleValue(120);
|
var KNS80_display=KNS80.getNode("display",1);
|
||||||
KNS80.getNode("wpt[1]/distance",1).setDoubleValue(7.2);
|
KNS80_display.setDoubleValue(0);
|
||||||
KNS80.getNode("wpt[2]/frequency",1).setDoubleValue(11570);
|
|
||||||
KNS80.getNode("wpt[2]/radial",1).setDoubleValue(270);
|
var KNS80_use=KNS80.getNode("use",1);
|
||||||
KNS80.getNode("wpt[2]/distance",1).setDoubleValue(5.8);
|
KNS80_use.setDoubleValue(0);
|
||||||
KNS80.getNode("wpt[3]/frequency",1).setDoubleValue(11000);
|
|
||||||
KNS80.getNode("wpt[3]/radial",1).setDoubleValue(0);
|
var KNS80_data_mode=KNS80.getNode("data-mode",1);
|
||||||
KNS80.getNode("wpt[3]/distance",1).setDoubleValue(0.0);
|
KNS80_data_mode.setDoubleValue(0);
|
||||||
|
|
||||||
|
var KNS80_nav_mode=KNS80.getNode("nav-mode",1);
|
||||||
|
KNS80_nav_mode.setDoubleValue(0);
|
||||||
|
|
||||||
|
var KNS80_dme_hold=KNS80.getNode("dme-hold",1);
|
||||||
|
KNS80_dme_hold.setBoolValue(0);
|
||||||
|
|
||||||
|
var KNS80_displayed_distance=KNS80.getNode("displayed-distance",1);
|
||||||
|
KNS80_displayed_distance.setDoubleValue(0);
|
||||||
|
|
||||||
|
var KNS80_displayed_frequency=KNS80.getNode("displayed-frequency",1);
|
||||||
|
KNS80_displayed_frequency.setDoubleValue(0.0);
|
||||||
|
|
||||||
|
var KNS80_displayed_radial=KNS80.getNode("displayed-radial",1);
|
||||||
|
KNS80_displayed_radial.setDoubleValue(0.0);
|
||||||
|
|
||||||
|
append(KNS80_wpt_freq,KNS80.getNode("wpt[0]/frequency",1));
|
||||||
|
append(KNS80_wpt_freq,KNS80.getNode("wpt[1]/frequency",1));
|
||||||
|
append(KNS80_wpt_freq,KNS80.getNode("wpt[2]/frequency",1));
|
||||||
|
append(KNS80_wpt_freq,KNS80.getNode("wpt[3]/frequency",1));
|
||||||
|
|
||||||
|
append(KNS80_wpt_radial,KNS80.getNode("wpt[0]/radial",1));
|
||||||
|
append(KNS80_wpt_radial,KNS80.getNode("wpt[1]/radial",1));
|
||||||
|
append(KNS80_wpt_radial,KNS80.getNode("wpt[2]/radial",1));
|
||||||
|
append(KNS80_wpt_radial,KNS80.getNode("wpt[3]/radial",1));
|
||||||
|
|
||||||
|
append(KNS80_wpt_distance,KNS80.getNode("wpt[0]/distance",1));
|
||||||
|
append(KNS80_wpt_distance,KNS80.getNode("wpt[1]/distance",1));
|
||||||
|
append(KNS80_wpt_distance,KNS80.getNode("wpt[2]/distance",1));
|
||||||
|
append(KNS80_wpt_distance,KNS80.getNode("wpt[3]/distance",1));
|
||||||
|
|
||||||
|
KNS80_wpt_freq[0].setDoubleValue(10950);
|
||||||
|
KNS80_wpt_radial[0].setDoubleValue(280);
|
||||||
|
KNS80_wpt_distance[0].setDoubleValue(0.0);
|
||||||
|
KNS80_wpt_freq[1].setDoubleValue(11570);
|
||||||
|
KNS80_wpt_radial[1].setDoubleValue(120);
|
||||||
|
KNS80_wpt_distance[1].setDoubleValue(7.2);
|
||||||
|
KNS80_wpt_freq[2].setDoubleValue(11570);
|
||||||
|
KNS80_wpt_radial[2].setDoubleValue(270);
|
||||||
|
KNS80_wpt_distance[2].setDoubleValue(5.8);
|
||||||
|
KNS80_wpt_freq[3].setDoubleValue(11000);
|
||||||
|
KNS80_wpt_radial[3].setDoubleValue(0);
|
||||||
|
KNS80_wpt_distance[3].setDoubleValue(0.0);
|
||||||
|
|
||||||
|
var DME_mhz=props.globals.getNode("instrumentation/dme/frequencies/selected-mhz",1);
|
||||||
|
var DME_src=props.globals.getNode("instrumentation/dme/frequencies/source",1);
|
||||||
var FDM_ON = 0;
|
var FDM_ON = 0;
|
||||||
var 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);
|
||||||
|
@ -79,11 +125,10 @@ var sec01cron = func {
|
||||||
# general initialization
|
# general initialization
|
||||||
var init = func {
|
var init = func {
|
||||||
# schedule the 1st call
|
# schedule the 1st call
|
||||||
settimer(sec01cron,1);
|
settimer(sec01cron,5);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -97,17 +142,19 @@ 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_nav_mode.getValue();
|
||||||
var use =KNS80.getNode("use").getValue();
|
var use =KNS80_use.getValue();
|
||||||
var distance=getprop("/instrumentation/dme/indicated-distance-nm");
|
var distance=getprop("/instrumentation/dme/indicated-distance-nm");
|
||||||
var selected_radial = NAV1_RADIAL.getValue();
|
var selected_radial = NAV1_RADIAL.getValue();
|
||||||
var radial = NAV1_ACTUAL.getValue();
|
var radial = NAV1_ACTUAL.getValue();
|
||||||
var rho = KNS80.getNode("wpt[" ~ use ~ "]/distance").getValue();
|
var rho = KNS80_wpt_distance[use].getValue();
|
||||||
var theta = KNS80.getNode("wpt[" ~ use ~ "]/radial").getValue();
|
var theta = KNS80_wpt_radial[use].getValue();
|
||||||
|
# var rho = KNS80.getNode("wpt[" ~ use ~ "]/distance").getValue();
|
||||||
|
# var theta = KNS80.getNode("wpt[" ~ use ~ "]/radial").getValue();
|
||||||
var fangle = 0;
|
var fangle = 0;
|
||||||
var needle_deflection = 0;
|
var needle_deflection = 0;
|
||||||
var from_flag=1;
|
var from_flag=1;
|
||||||
var to_flag =0;
|
var to_flag =0;
|
||||||
|
|
||||||
|
|
||||||
radial = unnil(radial);
|
radial = unnil(radial);
|
||||||
|
@ -176,140 +223,121 @@ var updateRNAV = func{
|
||||||
}
|
}
|
||||||
|
|
||||||
setlistener("/sim/signals/fdm-initialized", func {
|
setlistener("/sim/signals/fdm-initialized", func {
|
||||||
KNS80.getNode("displayed-frequency",1).setDoubleValue(NAV1.getValue()* 100);
|
KNS80_displayed_frequency.setDoubleValue(10955);
|
||||||
KNS80.getNode("wpt[0]/frequency",1).setDoubleValue(NAV1.getValue()* 100);
|
KNS80_displayed_radial.setDoubleValue(NAV1_RADIAL.getValue());
|
||||||
KNS80.getNode("displayed-radial",1).setDoubleValue(NAV1_RADIAL.getValue());
|
KNS80_wpt_radial[0].setDoubleValue(NAV1_RADIAL.getValue());
|
||||||
KNS80.getNode("wpt[0]/radial",1).setDoubleValue(NAV1_RADIAL.getValue());
|
tmp=props.globals.getNode("/instrumentation/nav/ident");
|
||||||
props.globals.getNode("/instrumentation/nav/ident").setBoolValue(0);
|
tmp.setBoolValue(0);
|
||||||
FDM_ON = 1;
|
|
||||||
init();
|
init();
|
||||||
print("KNS-80 Nav System ... OK");
|
print("KNS-80 Nav System ... OK");
|
||||||
});
|
});
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/volume-adjust", func {
|
setlistener(KNS80_volume_adjust, func(voladj){
|
||||||
if(FDM_ON != 0){
|
var amnt = voladj.getValue();
|
||||||
var amnt = cmdarg().getValue();
|
|
||||||
if(amnt == nil){return;}
|
if(amnt == nil){return;}
|
||||||
amnt*=0.05;
|
amnt*=0.05;
|
||||||
cmdarg().setDoubleValue(0);
|
voladj.setDoubleValue(0);
|
||||||
var vol = KNS80.getChild("volume").getValue();
|
var vol = KNS80_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){
|
||||||
if(vol > 0.0){KNS80.getNode("serviceable").setBoolValue(1);}
|
vol = 0.0;
|
||||||
KNS80.getNode("volume").setDoubleValue(vol);
|
KNS80_serviceable.setBoolValue(0);
|
||||||
KNS80.getNode("volume-adjust").setDoubleValue(0);
|
}
|
||||||
}
|
if(vol > 0.0)KNS80_serviceable.setBoolValue(1);
|
||||||
});
|
KNS80_volume.setDoubleValue(vol);
|
||||||
|
KNS80_volume_adjust.setDoubleValue(0);
|
||||||
|
},1,0);
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/data-adjust", func {
|
setlistener(KNS80_data_adjust, func(dtadj){
|
||||||
if(FDM_ON != 0){
|
var dmode = KNS80_data_mode.getValue();
|
||||||
var dmode = KNS80.getNode("data-mode").getValue();
|
var num = dtadj.getValue();
|
||||||
var num = cmdarg().getValue();
|
dtadj.setDoubleValue(0);
|
||||||
cmdarg().setDoubleValue(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_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").setDoubleValue(newfreq);
|
KNS80_displayed_frequency.setDoubleValue(newfreq);
|
||||||
return;
|
}elsif(dmode == 1){
|
||||||
}
|
var newrad = KNS80_displayed_radial.getValue();
|
||||||
if(dmode == 1){
|
|
||||||
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").setDoubleValue(newrad);
|
KNS80_displayed_radial.setDoubleValue(newrad);
|
||||||
return;
|
}elsif(dmode == 2){
|
||||||
}
|
var newdist = KNS80_displayed_distance.getValue();
|
||||||
if(dmode == 2){
|
|
||||||
var newdist = KNS80.getNode("displayed-distance").getValue();
|
|
||||||
if(num == -1 or num ==1 ){num = num *0.1;}
|
if(num == -1 or num ==1 ){num = num *0.1;}
|
||||||
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").setDoubleValue(newdist);
|
KNS80_displayed_distance.setDoubleValue(newdist);
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/displayed-frequency", func {
|
|
||||||
if(FDM_ON != 0){
|
|
||||||
var freq = cmdarg().getValue();
|
|
||||||
var num = KNS80.getNode("display").getValue();
|
|
||||||
var use = KNS80.getNode("use").getValue();
|
|
||||||
KNS80.getNode("wpt[" ~ num ~ "]/frequency").setDoubleValue(freq);
|
|
||||||
NAV1.setDoubleValue(KNS80.getNode("wpt[" ~ use ~ "]/frequency").getValue() * 0.01);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/displayed-radial", func {
|
|
||||||
if(FDM_ON != 0){
|
|
||||||
var rad = cmdarg().getValue();
|
|
||||||
var num = KNS80.getNode("display").getValue();
|
|
||||||
var radial = KNS80.getNode("use").getValue();
|
|
||||||
KNS80.getNode("wpt[" ~ num ~ "]/radial").setDoubleValue(rad);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/displayed-distance", func {
|
|
||||||
if(FDM_ON != 0){
|
|
||||||
var dis = cmdarg().getValue();
|
|
||||||
var num = KNS80.getNode("display").getValue();
|
|
||||||
KNS80.getNode("wpt[" ~ num ~ "]/distance").setDoubleValue(dis);
|
|
||||||
}
|
}
|
||||||
});
|
},1,0);
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/serviceable", func {
|
setlistener(KNS80_displayed_frequency, func(dspfrq){
|
||||||
if(FDM_ON != 0){
|
var freq = dspfrq.getValue();
|
||||||
setprop("/instrumentation/nav/serviceable",cmdarg().getValue());
|
var num = KNS80_display.getValue();
|
||||||
setprop("/instrumentation/dme/serviceable",cmdarg().getValue());
|
var use = KNS80_use.getValue();
|
||||||
}
|
KNS80_wpt_freq[num].setDoubleValue(freq);
|
||||||
});
|
NAV1.setDoubleValue(KNS80_wpt_freq[num].getValue() * 0.01);
|
||||||
|
},1,0);
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/volume", func {
|
setlistener(KNS80_displayed_radial, func(rdl){
|
||||||
if(FDM_ON == 0){return;}
|
var rad = rdl.getValue();
|
||||||
setprop("/instrumentation/nav/volume",cmdarg().getValue());
|
var num = KNS80_display.getValue();
|
||||||
setprop("/instrumentation/dme/volume",cmdarg().getValue());
|
var radial = KNS80_use.getValue();
|
||||||
});
|
KNS80_wpt_radial[num].setDoubleValue(rad);
|
||||||
|
},1,0);
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/use", func {
|
setlistener(KNS80_displayed_distance, func(dst){
|
||||||
if(FDM_ON == 0){return;}
|
var dis = dst.getValue();
|
||||||
var freq = cmdarg().getValue();
|
var num = KNS80_display.getValue();
|
||||||
|
KNS80_wpt_distance[num].setDoubleValue(dis);
|
||||||
|
},1,0);
|
||||||
|
|
||||||
|
setlistener(KNS80_serviceable, func(srv){
|
||||||
|
setprop("/instrumentation/nav/serviceable",srv.getValue());
|
||||||
|
setprop("/instrumentation/dme/serviceable",srv.getValue());
|
||||||
|
},1,0);
|
||||||
|
|
||||||
|
setlistener(KNS80_volume, func(vol){
|
||||||
|
setprop("/instrumentation/nav/volume",vol.getValue());
|
||||||
|
setprop("/instrumentation/dme/volume",vol.getValue());
|
||||||
|
},1,0);
|
||||||
|
|
||||||
|
setlistener(KNS80_use, func(frq){
|
||||||
|
var freq = frq.getValue();
|
||||||
KNS80.getNode("flash").setDoubleValue(0);
|
KNS80.getNode("flash").setDoubleValue(0);
|
||||||
KNS80.getNode("data-mode",1).setDoubleValue(0);
|
KNS80_data_mode.setDoubleValue(0);
|
||||||
NAV1.setDoubleValue(KNS80.getNode("wpt[" ~ freq ~ "]/frequency").getValue()* 0.01);
|
NAV1.setDoubleValue(KNS80_wpt_freq[freq].getValue()* 0.01);
|
||||||
});
|
},1,0);
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/display", func {
|
setlistener(KNS80_display, func(dsp){
|
||||||
if(FDM_ON == 0){return;}
|
var freq = dsp.getValue();
|
||||||
var freq = cmdarg().getValue();
|
if(freq == nil)return;
|
||||||
if(freq == nil){return;}
|
var test = KNS80_use.getValue();
|
||||||
var test = KNS80.getNode("use").getValue();
|
var wpt = KNS80_wpt_freq[freq].getValue();
|
||||||
var wpt = KNS80.getNode("wpt[" ~ freq ~ "]/frequency").getValue();
|
KNS80_displayed_frequency.setDoubleValue(wpt);
|
||||||
KNS80.getNode("displayed-frequency").setDoubleValue(wpt);
|
KNS80_displayed_distance.setDoubleValue(KNS80_wpt_distance[freq].getValue());
|
||||||
KNS80.getNode("displayed-distance").setDoubleValue(KNS80.getNode("wpt[" ~ freq ~ "]/distance").getValue());
|
KNS80_displayed_radial.setDoubleValue(KNS80_wpt_radial[freq].getValue());
|
||||||
KNS80.getNode("displayed-radial").setDoubleValue(KNS80.getNode("wpt[" ~ freq ~ "]/radial").getValue());
|
KNS80_data_mode.setDoubleValue(0);
|
||||||
KNS80.getNode("data-mode",1).setDoubleValue(0);
|
|
||||||
if(test != freq){
|
if(test != freq){
|
||||||
KNS80.getNode("flash").setDoubleValue(1);
|
KNS80.getNode("flash").setDoubleValue(1);
|
||||||
}else{
|
}else{
|
||||||
KNS80.getNode("flash").setDoubleValue(0);
|
KNS80.getNode("flash").setDoubleValue(0);
|
||||||
}
|
}
|
||||||
});
|
},1,0);
|
||||||
|
|
||||||
setlistener("/instrumentation/kns-80/dme-hold", func {
|
setlistener(KNS80_dme_hold, func(hld){
|
||||||
if(FDM_ON == 0){return;}
|
if(hld.getBoolValue()){
|
||||||
if(cmdarg().getBoolValue()){
|
DME_mhz.setDoubleValue(NAV1.getValue());
|
||||||
props.globals.getNode("instrumentation/dme/frequencies/selected-mhz").setDoubleValue(NAV1.getValue());
|
DME_src.setValue("/instrumentation/dme/frequencies/selected-mhz");
|
||||||
props.globals.getNode("instrumentation/dme/frequencies/source").setValue("/instrumentation/dme/frequencies/selected-mhz");
|
}else{
|
||||||
}else{
|
DME_mhz.setDoubleValue(0);
|
||||||
props.globals.getNode("instrumentation/dme/frequencies/selected-mhz").setDoubleValue(0);
|
DME_src.setValue("/instrumentation/nav[0]/frequencies/selected-mhz");
|
||||||
props.globals.getNode("instrumentation/dme/frequencies/source").setValue("/instrumentation/nav[0]/frequencies/selected-mhz");
|
}
|
||||||
}
|
},1,0);
|
||||||
});
|
|
||||||
|
|
||||||
# ]]></script></PropertyList>
|
# ]]></script></PropertyList>
|
||||||
|
|
Loading…
Reference in a new issue