SR22TEISPublisher.nas 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright 2018 Stuart Buchanan
  2. # Copyright 2020 Julio Santa Cruz
  3. # This file is part of FlightGear.
  4. #
  5. # FlightGear is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # FlightGear is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with FlightGear. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. # EIS Driver using Emesary for Cirrus SR22T
  19. var SR22TEISPublisher =
  20. {
  21. new : func (period=0.25) {
  22. var obj = {
  23. parents : [
  24. SR22TEISPublisher,
  25. PeriodicPropertyPublisher.new(notifications.PFDEventNotification.EngineData, period)
  26. ],
  27. };
  28. # Hack to handle most aircraft not having proper engine hours
  29. if (getprop("/engines/engine[0]/hours") == nil) setprop("/engines/engine[0]/hours", 157.0);
  30. obj.addPropMap("RPM", "/engines/engine[0]/rpm");
  31. obj.addPropMap("Man", "/engines/engine[0]/mp-osi");
  32. obj.addPropMap("MBusVolts", "/systems/electrical/volts");
  33. obj.addPropMap("EngineHours", "/engines/engine[0]/hours");
  34. obj.addPropMap("FuelFlowGPH", "/engines/engine[0]/fuel-flow-gph");
  35. obj.addPropMap("OilPressurePSI", "/engines/engine[0]/oil-pressure-psi");
  36. obj.addPropMap("OilTemperatureF", "/engines/engine[0]/oil-temperature-degf");
  37. obj.addPropMap("EGTNorm", "/engines/engine[0]/egt-norm");
  38. obj.addPropMap("EGTDegF", "/engines/engine[0]/egt-degf");
  39. obj.addPropMap("CHTDegF", "/engines/engine[0]/cht-degf");
  40. obj.addPropMap("VacuumSuctionInHG", "/systems/vacuum/suction-inhg");
  41. #TODO: update this to reflect actual power.
  42. obj.addPropMap("PowerPCT", "/controls/engines/engine[0]/throttle");
  43. return obj;
  44. },
  45. # Custom publish method as we package the values into an array of engines,
  46. # in this case, only one!
  47. publish : func() {
  48. var engineData0 = {};
  49. foreach (var propmap; me._propmaps) {
  50. var name = propmap.getName();
  51. engineData0[name] = propmap.getValue();
  52. }
  53. var engineData = [];
  54. append(engineData, engineData0);
  55. var notification = notifications.PFDEventNotification.new(
  56. "MFD",
  57. 1,
  58. notifications.PFDEventNotification.EngineData,
  59. { Id: "EngineData", Value: engineData } );
  60. me._transmitter.NotifyAll(notification);
  61. },
  62. };