SR22TNavComPublisher.nas 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. # NavCom Interface using Emesary for a simple dual Nav/Com system using standard properties
  18. #
  19. # This maps properties to Emesary Messages that will be published using the
  20. #
  21. # notifications.PFDEventNotification.NavComData
  22. #
  23. var SR22TNavComPublisher =
  24. {
  25. new : func (period=0.5) {
  26. var obj = {
  27. parents : [
  28. SR22TNavComPublisher,
  29. ],
  30. };
  31. # We have two publishers here:
  32. #
  33. # 1) a triggered publisher for properties that will change ocassionally, but which
  34. # we need to update immediately. These are typically settings.
  35. #
  36. # 2) a periodic publisher which triggers every 0.5s to update data values.
  37. obj._triggeredPublisher = TriggeredPropertyPublisher.new(notifications.PFDEventNotification.NavComData);
  38. obj._periodicPublisher = PeriodicPropertyPublisher.new(notifications.PFDEventNotification.NavComData, period);
  39. # Hack to handle cases where there is no selected Com or NAV frequency
  40. if (getprop("/instrumentation/com-selected") == nil) setprop("/instrumentation/com-selected", 1);
  41. if (getprop("/instrumentation/nav-selected") == nil) setprop("/instrumentation/nav-selected", 1);
  42. obj._triggeredPublisher.addPropMap("Comm1SelectedFreq", "/instrumentation/comm/frequencies/selected-mhz");
  43. obj._triggeredPublisher.addPropMap("Comm1StandbyFreq", "/instrumentation/comm/frequencies/standby-mhz");
  44. obj._triggeredPublisher.addPropMap("Comm1AirportID", "/instrumentation/comm/airport-id");
  45. obj._triggeredPublisher.addPropMap("Comm1StationName", "/instrumentation/comm/station-name");
  46. obj._triggeredPublisher.addPropMap("Comm1StationType", "/instrumentation/comm/station-type");
  47. obj._triggeredPublisher.addPropMap("Comm1Volume", "/instrumentation/comm/volume");
  48. obj._triggeredPublisher.addPropMap("Comm1Serviceable", "/instrumentation/comm/serviceable");
  49. obj._triggeredPublisher.addPropMap("Comm2SelectedFreq", "/instrumentation/comm[1]/frequencies/selected-mhz");
  50. obj._triggeredPublisher.addPropMap("Comm2StandbyFreq", "/instrumentation/comm[1]/frequencies/standby-mhz");
  51. obj._triggeredPublisher.addPropMap("Comm2AirportID", "/instrumentation/comm[1]/airport-id");
  52. obj._triggeredPublisher.addPropMap("Comm2StationName", "/instrumentation/comm[1]/station-name");
  53. obj._triggeredPublisher.addPropMap("Comm2StationType", "/instrumentation/comm[1]/station-type");
  54. obj._triggeredPublisher.addPropMap("Comm2Volume", "/instrumentation/comm[1]/volume");
  55. obj._triggeredPublisher.addPropMap("Comm2Serviceable", "/instrumentation/comm[1]/serviceable");
  56. obj._triggeredPublisher.addPropMap("CommSelected", "/instrumentation/com-selected");
  57. obj._triggeredPublisher.addPropMap("Nav1SelectedFreq", "/instrumentation/nav/frequencies/selected-mhz");
  58. obj._triggeredPublisher.addPropMap("Nav1StandbyFreq", "/instrumentation/nav/frequencies/standby-mhz");
  59. obj._periodicPublisher.addPropMap("Nav1ID", "/instrumentation/nav/nav-id");
  60. obj._periodicPublisher.addPropMap("Nav1InRange", "/instrumentation/nav/in-range");
  61. obj._periodicPublisher.addPropMap("Nav1HeadingDeg", "/instrumentation/nav/heading-deg");
  62. obj._periodicPublisher.addPropMap("Nav1RadialDeg", "/instrumentation/nav/radials/selected-deg");
  63. obj._periodicPublisher.addPropMap("Nav1DistanceMeters", "/instrumentation/nav/nav-distance");
  64. obj._periodicPublisher.addPropMap("Nav1CourseDeviationDeg", "/instrumentation/nav/crosstrack-heading-error-deg");
  65. obj._periodicPublisher.addPropMap("Nav1CrosstrackErrorM", "/instrumentation/nav/crosstrack-error-m");
  66. obj._periodicPublisher.addPropMap("Nav1Localizer", "/instrumentation/nav/nav-loc");
  67. obj._periodicPublisher.addPropMap("Nav1Deflection", "/instrumentation/nav/heading-needle-deflection-norm");
  68. obj._periodicPublisher.addPropMap("Nav1GSDeflection", "/instrumentation/nav/gs-needle-deflection-norm");
  69. obj._periodicPublisher.addPropMap("Nav1GSInRange", "/instrumentation/nav/gs-in-range");
  70. obj._periodicPublisher.addPropMap("Nav1From", "/instrumentation/nav/from-flag");
  71. obj._triggeredPublisher.addPropMap("Nav1Volume", "/instrumentation/nav/volume");
  72. obj._triggeredPublisher.addPropMap("Nav1AudioID", "/instrumentation/nav/audio-btn");
  73. obj._triggeredPublisher.addPropMap("Nav1Serviceable", "/instrumentation/nav/operable");
  74. obj._triggeredPublisher.addPropMap("Nav2SelectedFreq", "/instrumentation/nav[1]/frequencies/selected-mhz");
  75. obj._triggeredPublisher.addPropMap("Nav2StandbyFreq", "/instrumentation/nav[1]/frequencies/standby-mhz");
  76. obj._periodicPublisher.addPropMap("Nav2ID", "/instrumentation/nav[1]/nav-id");
  77. obj._periodicPublisher.addPropMap("Nav2InRange", "/instrumentation/nav[1]/in-range");
  78. obj._periodicPublisher.addPropMap("Nav2HeadingDeg", "/instrumentation/nav[1]/heading-deg");
  79. obj._periodicPublisher.addPropMap("Nav2RadialDeg", "/instrumentation/nav[1]/radials/selected-deg");
  80. obj._periodicPublisher.addPropMap("Nav2DistanceMeters", "/instrumentation/nav[1]/nav-distance");
  81. obj._periodicPublisher.addPropMap("Nav2CourseDeviationDeg", "/instrumentation/nav[1]/crosstrack-heading-error-deg");
  82. obj._periodicPublisher.addPropMap("Nav2CrosstrackErrorM", "/instrumentation/nav[1]/crosstrack-error-m");
  83. obj._periodicPublisher.addPropMap("Nav2Localizer", "/instrumentation/nav[1]/nav-loc");
  84. obj._periodicPublisher.addPropMap("Nav2Deflection", "/instrumentation/nav[1]/heading-needle-deflection-norm");
  85. obj._periodicPublisher.addPropMap("Nav2GSDeflection", "/instrumentation/nav[1]/gs-needle-deflection-norm");
  86. obj._periodicPublisher.addPropMap("Nav2GSInRange", "/instrumentation/nav[1]/gs-in-range");
  87. obj._periodicPublisher.addPropMap("Nav2From", "/instrumentation/nav/from-flag");
  88. obj._triggeredPublisher.addPropMap("Nav2Volume", "/instrumentation/nav[1]/volume");
  89. obj._triggeredPublisher.addPropMap("Nav2AudioID", "/instrumentation/nav[1]/audio-btn");
  90. obj._triggeredPublisher.addPropMap("Nav2Serviceable", "/instrumentation/nav[1]/operable");
  91. obj._triggeredPublisher.addPropMap("ADFSelectedFreq", "/instrumentation/adf/frequencies/selected-khz");
  92. obj._periodicPublisher.addPropMap("ADFInRange", "/instrumentation/adf/in-range");
  93. obj._periodicPublisher.addPropMap("ADFHeadingDeg", "/instrumentation/adf/indicated-bearing-deg");
  94. obj._triggeredPublisher.addPropMap("ADFVolume", "/instrumentation/adf/volume-norm");
  95. obj._triggeredPublisher.addPropMap("ADFServiceable", "/instrumentation/adf/operable");
  96. obj._triggeredPublisher.addPropMap("MarkerBeaconInner", "/instrumentation/marker-beacon/inner");
  97. obj._triggeredPublisher.addPropMap("MarkerBeaconMiddle", "/instrumentation/marker-beacon/middle");
  98. obj._triggeredPublisher.addPropMap("MarkerBeaconOuter", "/instrumentation/marker-beacon/outer");
  99. obj._triggeredPublisher.addPropMap("NavSelected", "/instrumentation/nav-selected");
  100. obj._triggeredPublisher.addPropMap("TransponderMode", "/instrumentation/transponder/inputs/knob-mode");
  101. obj._triggeredPublisher.addPropMap("TransponderIdent", "/instrumentation/transponder/inputs/ident-btn");
  102. obj._triggeredPublisher.addPropMap("TransponderCode", "/instrumentation/transponder/id-code");
  103. return obj;
  104. },
  105. start : func() {
  106. me._triggeredPublisher.start();
  107. me._periodicPublisher.start();
  108. },
  109. stop : func() {
  110. me._triggeredPublisher.stop();
  111. me._periodicPublisher.stop();
  112. },
  113. };