EIS-SR22T.nas 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Copyright 2018 Stuart Buchanan
  2. # This file is part of FlightGear.
  3. #
  4. # FlightGear is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # FlightGear is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with FlightGear. If not, see <http://www.gnu.org/licenses/>.
  16. #
  17. # SR22T EIS - Copyright 2020 Julio Santa Cruz (Barta)
  18. var EIS =
  19. {
  20. new : func (mfd, myCanvas, device, svg)
  21. {
  22. var obj = {
  23. parents : [
  24. EIS,
  25. MFDPage.new(mfd, myCanvas, device, svg, "EIS", "")
  26. ],
  27. };
  28. obj.setController(fg1000.EISController.new(obj, svg));
  29. obj.addTextElements(["PowerDisplay", "RPMDisplay", "ManDisplay", "FuelFlowDisplay", "OilTempDisplay", "OilPressureDisplay", "Batt1Display", "ESSDisplay","CHTDisplay","EGTDisplay" ]);
  30. obj._PowerPointer = PFD.RotatingElement.new(obj.pageName, svg, "PowerPointer", 0, 1.15, 160, [300,100]);
  31. obj._fuelFlowPointer = PFD.PointerElement.new(obj.pageName, svg, "FuelFlowPointer", 0.0, 38.0, 135);
  32. obj._oilPressurePointer = PFD.PointerElement.new(obj.pageName, svg, "OilPressurePointer", 0.0, 115.0, 135);
  33. obj._oilTempPointer = PFD.PointerElement.new(obj.pageName, svg, "OilTempPointer", 0.0, 245.0, 135);
  34. obj._ampBattAPointer = PFD.PointerElement.new(obj.pageName, svg, "Batt1Pointer", 0.0, 6, 135);
  35. obj._EssBusPointer = PFD.PointerElement.new(obj.pageName, svg, "ESSPointer", 0.0, 30, 135);
  36. #obj._EGTPointer = PFD.PointerElement.new(obj.pageName, svg, "EGTPointer", 0.0, 1.0, 135);
  37. #obj._EGTCylinder = PFD.PointerElement.new(obj.pageName, svg, "EGTCylinder", 0.0, 1.0, 135);
  38. #obj._leftFuelPointer = PFD.PointerElement.new(obj.pageName, svg, "LeftFuelPointer", 0.0, 40.0, 135);
  39. #obj._rightFuelPointer = PFD.PointerElement.new(obj.pageName, svg, "RightFuelPointer", 0.0, 40.0, 135);
  40. return obj;
  41. },
  42. updateEngineData : func(engineData) {
  43. #var power = math.max(math.min(math.round((engineData.Man -8) / 0.205),100), 0);
  44. #var power = math.max(math.min(math.round((engineData.Man -8) / 0.28),115), 0);
  45. me.setTextElement("RPMDisplay", sprintf("%i", engineData.RPM));
  46. me.setTextElement("ManDisplay", sprintf("%.1f", engineData.Man));
  47. me.setTextElement("FuelFlowDisplay", sprintf("%.1f", engineData.FuelFlowGPH));
  48. me.setTextElement("OilTempDisplay", sprintf("%.1f", engineData.OilTemperatureF));
  49. me.setTextElement("OilPressureDisplay", sprintf("%.1f", engineData.OilPressurePSI));
  50. me.setTextElement("EGTDisplay", sprintf("%.1f", engineData.EGTDegF));
  51. me.setTextElement("CHTDisplay", sprintf("%.1f", engineData.CHTDegF));
  52. # me.setTextElement("MBusVolts", sprintf("%.01f", engineData.MBusVolts));
  53. me.setTextElement("ESSDisplay", sprintf("%.01f", engineData.MBusVolts)); # TODO: Include Emergency Bus
  54. me._fuelFlowPointer.setValue(engineData.FuelFlowGPH);
  55. me._oilPressurePointer.setValue(engineData.OilPressurePSI);
  56. me._oilTempPointer.setValue(engineData.OilTemperatureF);
  57. me._ampBattAPointer.setValue(0);
  58. me._EssBusPointer.setValue(engineData.MBusVolts); # TODO: use ESS
  59. # From http://www.kineticlearning.com/pilots_world/cmpp/03_06/displayarticle.aspx
  60. # Percent Power – The MFD uses the RPM, fuel flow, manifold pressure, and
  61. # outside air temperature to determine the percentage of rated power
  62. # being produced.
  63. #
  64. # From the POH
  65. # The digital percent power value is displayed in white numerals below the gage.
  66. # The display units calculate the percentage of maximum engine power
  67. # produced by the engine based on an algorithm employing manifold pressure,
  68. # indicated air speed, outside air temperature, pressure altitude, engine
  69. # speed, and fuel flow.
  70. me.setTextElement("PowerDisplay", sprintf("%i", engineData.PowerPCT * 100));
  71. me._PowerPointer.setValue(engineData.PowerPCT);
  72. },
  73. updateFuelData : func(fuelData) {
  74. #me._leftFuelPointer.setValue(fuelData.LeftFuelUSGal);
  75. #me._rightFuelPointer.setValue(fuelData.RightFuelUSGal);
  76. },
  77. # Menu tree . engineMenu is referenced from most pages as softkey 0:
  78. # pg.addMenuItem(0, "ENGINE", pg, pg.mfd.EISPage.engineMenu);
  79. engineMenu : func(device, pg, menuitem) {
  80. pg.clearMenu();
  81. pg.resetMenuColors();
  82. pg.addMenuItem(0, "ENGINE", pg, pg.mfd.EIS.engineMenu);
  83. pg.addMenuItem(1, "LEAN", pg, pg.mfd.EIS.leanMenu);
  84. pg.addMenuItem(2, "SYSTEM", pg, pg.mfd.EIS.systemMenu);
  85. pg.addMenuItem(8, "BACK", pg, pg.topMenu);
  86. device.updateMenus();
  87. },
  88. leanMenu : func(device, pg, menuitem) {
  89. pg.clearMenu();
  90. pg.resetMenuColors();
  91. pg.addMenuItem(0, "ENGINE", pg, pg.mfd.EIS.engineMenu);
  92. pg.addMenuItem(1, "LEAN", pg, pg.mfd.EIS.leanMenu);
  93. pg.addMenuItem(2, "SYSTEM", pg, pg.mfd.EIS.systemMenu);
  94. pg.addMenuItem(3, "CYL SELECT", pg);
  95. pg.addMenuItem(4, "ASSIST", pg);
  96. pg.addMenuItem(9, "BACK", pg, pg.mfd.EIS.engineMenu);
  97. device.updateMenus();
  98. },
  99. systemMenu : func(device, pg, menuitem) {
  100. pg.clearMenu();
  101. pg.resetMenuColors();
  102. pg.addMenuItem(0, "ENGINE", pg, pg.mfd.EIS.engineMenu);
  103. pg.addMenuItem(1, "LEAN", pg, pg.mfd.EIS.leanMenu);
  104. pg.addMenuItem(2, "SYSTEM", pg, pg.mfd.EIS.systemMenu);
  105. pg.addMenuItem(3, "RST FUEL", pg, func(dev, pg, mi) { pg.mfd.EIS.getController().setFuelQuantity(0); });
  106. pg.addMenuItem(4, "GAL REM", pg, pg.mfd.EIS.galRemMenu);
  107. pg.addMenuItem(5, "BACK", pg, pg.mfd.EIS.engineMenu);
  108. device.updateMenus();
  109. },
  110. galRemMenu : func(device, pg, menuitem) {
  111. pg.clearMenu();
  112. pg.resetMenuColors();
  113. pg.addMenuItem(0, "ENGINE", pg, pg.mfd.EIS.engineMenu);
  114. pg.addMenuItem(1, "LEAN", pg, pg.mfd.EIS.leanMenu);
  115. pg.addMenuItem(2, "SYSTEM", pg, pg.mfd.EIS.systemMenu);
  116. pg.addMenuItem(3, "-10 GAL", pg, func(dev, pg, mi) { pg.mfd.EIS.getController().updateFuelQuantity(-10); } );
  117. pg.addMenuItem(4, "-1 GAL", pg, func(dev, pg, mi) { pg.mfd.EIS.getController().updateFuelQuantity(-1); });
  118. pg.addMenuItem(5, "+1 GAL", pg, func(dev, pg, mi) { pg.mfd.EIS.getController().updateFuelQuantity(1); });
  119. pg.addMenuItem(6, "+10 GAL", pg, func(dev, pg, mi) { pg.mfd.EIS.getController().updateFuelQuantity(10); });
  120. pg.addMenuItem(7, "44 GAL", pg, func(dev, pg, mi) { pg.mfd.EIS.getController().setFuelQuantity(44); });
  121. pg.addMenuItem(8, "BACK", pg, pg.mfd.EIS.engineMenu);
  122. device.updateMenus();
  123. },
  124. offdisplay : func() {
  125. me._group.setVisible(0);
  126. # Reset the menu colours. Shouldn't have to do this here, but
  127. # there's not currently an obvious other location to do so.
  128. for(var i = 0; i < 12; i +=1) {
  129. var name = sprintf("SoftKey%d",i);
  130. me.device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0);
  131. me.device.svg.getElementById(name).setColor(1.0,1.0,1.0);
  132. }
  133. me.getController().offdisplay();
  134. },
  135. ondisplay : func() {
  136. me._group.setVisible(1);
  137. me.getController().ondisplay();
  138. },
  139. };