instruments.nas 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. # set the timer for the selected function
  2. var UPDATE_PERIOD = 0;
  3. var freq = 0;
  4. var formatted = 0;
  5. var digit1 = 0;
  6. var digit2 = 0;
  7. var digit3 = 0;
  8. var digit4 = 0;
  9. var digit5 = 0;
  10. var gps_display = [];
  11. var instrumenttimer = func {
  12. settimer(func {
  13. radiodisplay();
  14. instrumenttimer()
  15. }, UPDATE_PERIOD);
  16. }
  17. # =============================== end timer stuff ===========================================
  18. # ==================== Radio Frequency Display =========================
  19. var displaysegments = func (radio, selected) {
  20. var freq=getprop("/instrumentation/"~radio~"/frequencies/"~selected~"-mhz");
  21. var formatted=sprintf("%.02f",freq);
  22. digit1=substr(formatted,0,1);
  23. digit2=substr(formatted,1,1);
  24. digit3=substr(formatted,2,1);
  25. digit4=substr(formatted,4,1);
  26. digit5=substr(formatted,5,1);
  27. setprop("instrumentation/"~radio~"/"~selected~"/digit1",digit1);
  28. setprop("instrumentation/"~radio~"/"~selected~"/digit2",digit2);
  29. setprop("instrumentation/"~radio~"/"~selected~"/digit3",digit3);
  30. setprop("instrumentation/"~radio~"/"~selected~"/digit4",digit4);
  31. setprop("instrumentation/"~radio~"/"~selected~"/digit5",digit5);
  32. }
  33. var radiodisplay = func() {
  34. displaysegments ("nav[0]", "selected");
  35. displaysegments ("nav[0]", "standby");
  36. displaysegments ("comm[0]", "selected");
  37. displaysegments ("comm[0]", "standby");
  38. displaysegments ("comm[1]", "selected");
  39. displaysegments ("comm[1]", "standby");
  40. }
  41. ####################### Initialise ##############################################
  42. initialize = func {
  43. ### Initialise Radios ###
  44. props.globals.getNode("/instrumentation/uhf/commvol-norm", 1).setDoubleValue(0.0);
  45. props.globals.getNode("/instrumentation/kns80/navvol-norm", 1).setDoubleValue(0.0);
  46. props.globals.getNode("/instrumentation/kx155a/commvol-norm", 1).setDoubleValue(0.0);
  47. props.globals.getNode("/instrumentation/kx155a/navvol-norm", 1).setDoubleValue(0.0);
  48. props.globals.getNode("/instrumentation/kt-70/inputs/func-knob", 1).setDoubleValue(0);
  49. props.globals.getNode("/instrumentation/dme/switch-position", 1).setDoubleValue(0);
  50. instrumenttimer();
  51. # Finished Initialising
  52. print ("Instruments : initialised");
  53. var initialized = 1;
  54. } #end func
  55. ######################### Fire it up ############################################
  56. setlistener("/sim/signals/fdm-initialized",initialize);
  57. ######################### JFS READY ############################################
  58. props.globals.getNode("/controls/APU/ready", 0).setDoubleValue(0.0);
  59. setlistener("/controls/APU/fire-switch",func{interpolate("/controls/APU/ready",1,10)});
  60. ######################### N1 RPM ##########################################
  61. setlistener("/engines/engine[0]/n1",func{interpolate("/instrumentation/rpm/engine-rh",getprop("/engines/engine[0]/n1")/2+50,1)});
  62. setlistener("/engines/engine[1]/n1",func{interpolate("/instrumentation/rpm/engine-lh",getprop("/engines/engine[1]/n1")/2+50,1)});
  63. ######################### REFUEL HATCH ############################################
  64. props.globals.getNode("/consumables/fuel/slip-way-door", 0).setIntValue(0);
  65. props.globals.getNode("/consumables/fuel/refuel-hatch-pos", 0).setDoubleValue(0.0);
  66. setlistener("/consumables/fuel/slip-way-door",func{interpolate("/consumables/fuel/refuel-hatch-pos",getprop("/consumables/fuel/slip-way-door"),2)});
  67. ######################### SWITCH SETTING ############################################
  68. setprop("/controls/switches/taxi-lights",0);
  69. props.globals.getNode("/instrumentation/fuelgauge/selector",0).setIntValue(1);
  70. setprop("instrumentation/fric-knob",0.01);
  71. ######################### FUEL TANK SETTING ############################################
  72. props.globals.getNode("/consumables/fuel/ext-tank-ctr-selected",0).setIntValue(1);
  73. props.globals.getNode("/consumables/fuel/ext-tank-wing-selected",0).setIntValue(1);
  74. #
  75. setlistener("/consumables/fuel/tank/level-lbs",func{interpolate("/consumables/fuel/total-internal-fuel-lbs",getprop("/consumables/fuel/tank/level-lbs")+getprop("/consumables/fuel/tank[1]/level-lbs")+getprop("/consumables/fuel/tank[2]/level-lbs")+getprop("/consumables/fuel/tank[3]/level-lbs")+getprop("/consumables/fuel/tank[4]/level-lbs"),1)});
  76. #
  77. setlistener("/consumables/fuel/tank[5]/selected",func(em){
  78. var epty = em.getValue();
  79. setprop("/consumables/fuel/tank-selector",epty);
  80. });
  81. #
  82. setlistener("/consumables/fuel/tank-selector", func(sw){
  83. var pos0 = sw.getValue()*7;
  84. var pos3 = sw.getValue()+sw.getValue()+3;
  85. var pos4 = sw.getValue()+sw.getValue()+4;
  86. setprop("/consumables/fuel/tank["~pos0~"]/selected",1);
  87. setprop("/consumables/fuel/tank["~pos3~"]/selected",1);
  88. setprop("/consumables/fuel/tank["~pos4~"]/selected",1);
  89. });
  90. #FEED TANK
  91. setlistener("/consumables/fuel/tank[0]/selected",func(tn){
  92. var tnk1 = 1 - tn.getValue() + getprop("/consumables/fuel/tank-selector")*6;
  93. var tnk2 = 2 - tn.getValue()*2 + getprop("/consumables/fuel/tank-selector")*5;
  94. setprop("/consumables/fuel/tank-lower1",tnk1);
  95. setprop("/consumables/fuel/tank-lower2",tnk2);
  96. });
  97. setlistener("/consumables/fuel/tank-lower1", func(la){
  98. var pos1 = la.getValue();
  99. setprop("/consumables/fuel/tank["~pos1~"]/selected",1);
  100. });
  101. setlistener("/consumables/fuel/tank-lower2", func(lb){
  102. var pos2 = lb.getValue();
  103. setprop("/consumables/fuel/tank["~pos2~"]/selected",1);
  104. });
  105. #
  106. setprop("/consumables/fuel/tank[0]/selected",0);
  107. setprop("/consumables/fuel/tank[1]/selected",0);
  108. setprop("/consumables/fuel/tank[2]/selected",0);
  109. setprop("/consumables/fuel/tank[3]/selected",0);
  110. setprop("/consumables/fuel/tank[4]/selected",0);
  111. ######################### CANOPY PARAMETOR ##########################################
  112. #splash
  113. setlistener("/engines/engine[0]/n1",func{
  114. interpolate("/environment/aircraft-effects/splash-vector-x",getprop("/velocities/airspeed-kt")*-0.005,1)});
  115. props.globals.getNode("/environment/aircraft-effects/splash-vector-y", 0).setIntValue(0.01);
  116. props.globals.getNode("/environment/aircraft-effects/splash-vector-z", 0).setIntValue(-1);
  117. #TAT
  118. setlistener("/engines/engine[0]/n1",func{
  119. interpolate("/environment/total-air-temperature-degc",getprop("/environment/temperature-degc")+ ((getprop("/environment/temperature-degc")+ 273) * 0.2 * (getprop("/velocities/mach") * getprop("/velocities/mach"))),5)});
  120. #frost
  121. setprop("/environment/windowheat-level", 1);
  122. setlistener("/engines/engine[0]/n1",func{
  123. interpolate("/environment/aircraft-effects/frost-level",(getprop("/environment/total-air-temperature-degc")+10)*getprop("/environment/windowheat-level")*-0.03,1)});
  124. setlistener("/controls/anti-ice/window-heat",func{
  125. interpolate("/environment/windowheat-level",1-getprop("/controls/anti-ice/window-heat")*0.9,10)});
  126. ######################### HUD NAV BEARING ############################################
  127. props.globals.getNode("/instrumentation/nav/nav-needle-error-deg", 0).setDoubleValue(0.0);
  128. setlistener("/engines/engine[0]/n1",func{interpolate("/instrumentation/nav/nav-needle-error-deg",getprop("/instrumentation/nav/heading-deg")-getprop("/orientation/heading-deg"),0.01)});
  129. ######################### HUD TACAN BEARING ############################################
  130. props.globals.getNode("/instrumentation/tacan/tacan-needle-error-deg", 0).setDoubleValue(0.0);
  131. setlistener("/engines/engine[0]/n1",func{interpolate("instrumentation/tacan/tacan-needle-error-deg",getprop("/instrumentation/tacan/indicated-bearing-true-deg")-getprop("/orientation/heading-deg"),0.01)});