Debian Codegraph @

Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/GenericEISPublisher.nas

raw
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 # EIS Driver using Emesary for a single engined aircraft, e.g. Cessna 172.
18 var GenericEISPublisher =
19 {
20
21 new : func (period=0.25) {
22 var obj = {
23 parents : [
24 GenericEISPublisher,
25 PeriodicPropertyPublisher.new(notifications.PFDEventNotification.EngineData, period)
26 ],
27 };
28
29 # Hack to handle most aircraft not having proper engine hours
30 if (getprop("/engines/engine[0]/hours") == nil) setprop("/engines/engine[0]/hours", 157.0);
31
32 obj.addPropMap("RPM", "/engines/engine[0]/rpm", 10);
33 obj.addPropMap("Man", "/engines/engine[0]/mp-osi", 10);
34 obj.addPropMap("MBusVolts", "/systems/electrical/volts", 1);
35 obj.addPropMap("EBusVolts", "/systems/electrical/volts", 1);
36 obj.addPropMap("MBattAmps", "/systems/electrical/amps", 1);
37 obj.addPropMap("SBattAmps", "/systems/electrical/amps", 1);
38 obj.addPropMap("EngineHours", "/engines/engine[0]/hours", 1);
39 obj.addPropMap("FuelFlowGPH", "/engines/engine[0]/fuel-flow-gph", 0.25);
40 obj.addPropMap("OilPressurePSI", "/engines/engine[0]/oil-pressure-psi", 0.1);
41 obj.addPropMap("OilTemperatureF", "/engines/engine[0]/oil-temperature-degf", 1);
42 obj.addPropMap("EGTNorm", "/engines/engine[0]/egt-norm", 0.5);
43 obj.addPropMap("VacuumSuctionInHG", "/systems/vacuum/suction-inhg", 1);
44
45 return obj;
46 },
47
48 # Custom publish method as we package the values into an array of engines,
49 # in this case, only one!
50 publish : func() {
51 var engineData0 = {};
52
53 foreach (var propmap; me._propmaps) {
54 var name = propmap.getName();
55 engineData0[name] = propmap.getValue();
56 }
57
58 var engineData = [];
59 append(engineData, engineData0);
60
61 var notification = notifications.PFDEventNotification.new(
62 "MFD",
63 1,
64 notifications.PFDEventNotification.EngineData,
65 { Id: "EngineData", Value: engineData } );
66
67 me._transmitter.NotifyAll(notification);
68 },
69 };