tach.nas 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # N2,NR tachimeter needles update, only used by ec145 model
  2. #
  3. #
  4. var tachi = {
  5. init: func() {
  6. me.n2in = [props.globals.getNode("engines/engine[0]/n2-pct", 1),
  7. props.globals.getNode("engines/engine[1]/n2-pct", 1)];
  8. me.n2out = [props.globals.getNode("instrumentation/tachi/indicated-n2-pct[0]", 1),
  9. props.globals.getNode("instrumentation/tachi/indicated-n2-pct[1]", 1)];
  10. me.nRin = props.globals.getNode("rotors/main/rpm-pct", 1);
  11. me.nRout = props.globals.getNode("instrumentation/tachi/indicated-nr-pct", 1);
  12. me.elec = props.globals.getNode("systems/electrical/outputs/tachimeter", 1);
  13. me.elecOld = 0;
  14. me.wait = 0;
  15. },
  16. update: func() {
  17. var haspower = (me.elec.getValue() or 0) > 12;
  18. if (me.wait > 0) {
  19. me.wait += -1;
  20. return;
  21. }
  22. if ((me.elecOld == 0) and haspower) {
  23. # sim. tachi test on power up
  24. interpolate(me.n2out[0], 95, 1.0);
  25. interpolate(me.n2out[1], 100, 1.0);
  26. interpolate(me.nRout, 105, 1.0);
  27. # block update for some cycles to show the test
  28. me.wait = 12;
  29. } else {
  30. if (haspower) {
  31. var nR = me.nRin.getValue() or 0;
  32. var n2 = [(me.n2in[0].getValue() or 0), (me.n2in[1].getValue() or 0)];
  33. } else {
  34. var nR = 0;
  35. var n2 = [0,0];
  36. }
  37. interpolate(me.n2out[0], n2[0], 1);
  38. interpolate(me.n2out[1], n2[1], 1);
  39. interpolate(me.nRout, nR, 1);
  40. }
  41. me.elecOld = haspower;
  42. }
  43. };
  44. setlistener("/sim/signals/fdm-initialized", func {
  45. tachi.init();
  46. var tachitimer = maketimer(0.1, func tachi.update(); );
  47. tachitimer.start();
  48. });