| 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 |
# NDBInfo |
| 18 |
var NDBInfo = |
| 19 |
{ |
| 20 |
new : func (mfd, myCanvas, device, svg) |
| 21 |
{ |
| 22 |
var obj = { |
| 23 |
parents : [ |
| 24 |
NDBInfo, |
| 25 |
MFDPage.new(mfd, myCanvas, device, svg, "NDBInfo", "WPT - NDB INFORMATION") |
| 26 |
], |
| 27 |
}; |
| 28 |
|
| 29 |
# Dynamic text elements in the SVG file. In the SVG these have an "NDBInfo" prefix. |
| 30 |
textelements = [ |
| 31 |
"ID", |
| 32 |
"Facility", |
| 33 |
"NearestCity", |
| 34 |
"Type", |
| 35 |
"Region", |
| 36 |
"Lat", |
| 37 |
"Lon", |
| 38 |
"Freq", |
| 39 |
"AirportID", |
| 40 |
"AirportCRS", |
| 41 |
"AirportDST" |
| 42 |
]; |
| 43 |
|
| 44 |
obj.addTextElements(textelements); |
| 45 |
|
| 46 |
# Data Entry information. Keyed from the name of the element, which must |
| 47 |
# be one of the textelements above. Each data element maps to a set of |
| 48 |
# text elements in the SVG of the form [PageName][TextElement]{0...n}, each |
| 49 |
# representing a single character for data entry. |
| 50 |
# |
| 51 |
# .size is the number of characters of data entry |
| 52 |
# .chars is the set of characters, used to scroll through using the small |
| 53 |
# FMS knob. |
| 54 |
obj.dataEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 3, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); |
| 55 |
|
| 56 |
obj.Map = fg1000.NavMap.new( |
| 57 |
obj, |
| 58 |
obj.getElement("NavMap"), |
| 59 |
[860,400], |
| 60 |
"", |
| 61 |
-50, |
| 62 |
0, |
| 63 |
1); |
| 64 |
|
| 65 |
obj.topMenu(device, obj, nil); |
| 66 |
|
| 67 |
obj.setController(fg1000.NDBInfoController.new(obj, svg)); |
| 68 |
obj.update(nil, nil); |
| 69 |
|
| 70 |
return obj; |
| 71 |
}, |
| 72 |
|
| 73 |
update : func(navdata, aptdata) { |
| 74 |
if (navdata != nil) { |
| 75 |
me.setTextElement("ID", navdata.id); |
| 76 |
me.setTextElement("Facility", ""); |
| 77 |
me.setTextElement("NearestCity", ""); |
| 78 |
me.setTextElement("Type", ""); |
| 79 |
me.setTextElement("Region", ""); |
| 80 |
|
| 81 |
me.setTextElementLat("Lat", navdata.lat); |
| 82 |
me.setTextElementLon("Lon", navdata.lon); |
| 83 |
me.setTextElementNavFreq("Freq", navdata.frequency / 100.0); |
| 84 |
|
| 85 |
me.Map.getController().setPosition(navdata.lat, navdata.lon); |
| 86 |
me.Map.show(); |
| 87 |
} else { |
| 88 |
me.setTextElement("ID", "####"); |
| 89 |
me.setTextElement("Facility", "_______"); |
| 90 |
me.setTextElement("NearestCity", "_______"); |
| 91 |
me.setTextElement("Type", "_______"); |
| 92 |
me.setTextElement("Region", "_______"); |
| 93 |
|
| 94 |
me.setTextElementLat("Lat", nil); |
| 95 |
me.setTextElementLon("Lon", nil); |
| 96 |
me.setTextElementNavFreq("Freq", ""); |
| 97 |
me.Map.hide(); |
| 98 |
} |
| 99 |
|
| 100 |
if (aptdata != nil) { |
| 101 |
var crsAndDst = courseAndDistance(navdata, aptdata); |
| 102 |
me.setTextElement("AirportID", aptdata.id); |
| 103 |
me.setTextElementBearing("AirportCRS", aptdata.crs); |
| 104 |
me.setTextElementDistance("AirportDST", aptdata.dst); |
| 105 |
} else { |
| 106 |
me.setTextElement("AirportID", "____"); |
| 107 |
me.setTextElementBearing("AirportCRS", ""); |
| 108 |
me.setTextElementDistance("AirportDST", ""); |
| 109 |
} |
| 110 |
}, |
| 111 |
|
| 112 |
offdisplay : func() { |
| 113 |
me._group.setVisible(0); |
| 114 |
|
| 115 |
# Reset the menu colours. Shouldn't have to do this here, but |
| 116 |
# there's not currently an obvious other location to do so. |
| 117 |
for(var i = 0; i < 12; i +=1) { |
| 118 |
var name = sprintf("SoftKey%d",i); |
| 119 |
me.device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0); |
| 120 |
me.device.svg.getElementById(name).setColor(1.0,1.0,1.0); |
| 121 |
} |
| 122 |
me.getElement("NavMap").setVisible(0); |
| 123 |
me.Map.setVisible(0); |
| 124 |
me.getController().offdisplay(); |
| 125 |
}, |
| 126 |
ondisplay : func() { |
| 127 |
me._group.setVisible(1); |
| 128 |
me.mfd.setPageTitle(me.title); |
| 129 |
|
| 130 |
me.getElement("NavMap").setVisible(1); |
| 131 |
me.Map.setVisible(1); |
| 132 |
me.getController().ondisplay(); |
| 133 |
}, |
| 134 |
topMenu : func(device, pg, menuitem) { |
| 135 |
pg.clearMenu(); |
| 136 |
pg.resetMenuColors(); |
| 137 |
pg.addMenuItem(0, "ENGINE", pg.mfd.EIS, pg.mfd.EIS.engineMenu); |
| 138 |
pg.addMenuItem(2, "MAP", pg.mfd.NavigationMap, pg.mfd.NavigationMap.mapMenu); |
| 139 |
device.updateMenus(); |
| 140 |
}, |
| 141 |
|
| 142 |
|
| 143 |
}; |