| 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 |
# Air Data Computer Driver using Emesary to publish data such as |
| 18 |
# |
| 19 |
# Airspeed |
| 20 |
# Orientation |
| 21 |
# Rate of turn |
| 22 |
# Heading |
| 23 |
# Air Temperature |
| 24 |
# |
| 25 |
# |
| 26 |
# For the moment these are just taken directly from the raw properties. They |
| 27 |
# should probably come from aircraft-specific instrumentation. |
| 28 |
|
| 29 |
var GenericADCPublisher = |
| 30 |
{ |
| 31 |
new : func () { |
| 32 |
|
| 33 |
# Update frequency can be controlled by a property. |
| 34 |
var frequency = getprop("/instrumentation/FG1000/adc-update-frequency"); |
| 35 |
if (frequency == nil) frequency = 10; |
| 36 |
|
| 37 |
var obj = { |
| 38 |
parents : [ |
| 39 |
GenericADCPublisher, |
| 40 |
PeriodicPropertyPublisher.new(notifications.PFDEventNotification.ADCData, 1.0/frequency) |
| 41 |
], |
| 42 |
}; |
| 43 |
|
| 44 |
# Air data comes from the airspeed indicator as for a non-glass panel aircraft. |
| 45 |
obj.addPropMap("ADCTrueAirspeed", "/instrumentation/airspeed-indicator/true-speed-kt", 1); |
| 46 |
obj.addPropMap("ADCIndicatedAirspeed", "/instrumentation/airspeed-indicator/indicated-speed-kt", 0.2); |
| 47 |
|
| 48 |
# Assume an accurate solid-state magnetometer |
| 49 |
obj.addPropMap("ADCPitchDeg", "/orientation/pitch-deg", 0.2); |
| 50 |
obj.addPropMap("ADCRollDeg", "/orientation/roll-deg", 0.2); |
| 51 |
|
| 52 |
# TODO: Replace these with real values - shouldn't rely on steam-powered gauges. |
| 53 |
obj.addPropMap("ADCTurnRate", "/instrumentation/turn-indicator/indicated-turn-rate", 1); |
| 54 |
obj.addPropMap("ADCSlipSkid", "/instrumentation/slip-skid-ball/indicated-slip-skid", 0.1); |
| 55 |
|
| 56 |
# Assume an accurate solid-state magnetometer |
| 57 |
obj.addPropMap("ADCHeadingMagneticDeg", "/orientation/heading-magnetic-deg", 1); |
| 58 |
obj.addPropMap("ADCMagneticVariationDeg", "/environment/magnetic-variation-deg", 0.1); |
| 59 |
|
| 60 |
obj.addPropMap("ADCAltitudeFT", "/instrumentation/altimeter/indicated-altitude-ft", 1); |
| 61 |
obj.addPropMap("ADCPressureSettingInHG", "/instrumentation/altimeter/setting-inhg", 0.0); |
| 62 |
|
| 63 |
obj.addPropMap("ADCVerticalSpeedFPM", "/instrumentation/vertical-speed-indicator/indicated-speed-fpm", 10); |
| 64 |
|
| 65 |
obj.addPropMap("ADCOutsideAirTemperatureC", "/environment/temperature-degc", 1); |
| 66 |
obj.addPropMap("ADCWindHeadingDeg", "/environment/wind-from-heading-deg", 1); |
| 67 |
obj.addPropMap("ADCWindSpeedKt", "/environment/wind-speed-kt", 1); |
| 68 |
obj.addPropMap("ADCTimeLocalSec", "/sim/time/local-day-seconds", 1); |
| 69 |
obj.addPropMap("ADCTimeUTCSec", "/sim/time/utc/day-seconds", 1); |
| 70 |
return obj; |
| 71 |
}, |
| 72 |
}; |