2018-02-09 18:55:53 +00:00
|
|
|
# Copyright 2018 Stuart Buchanan
|
|
|
|
# This file is part of FlightGear.
|
|
|
|
#
|
|
|
|
# Foobar is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# FlightGear is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with FlightGear. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
2017-12-10 22:15:21 +00:00
|
|
|
# VORInfo
|
|
|
|
var VORInfo =
|
|
|
|
{
|
|
|
|
new : func (mfd, myCanvas, device, svg)
|
|
|
|
{
|
|
|
|
var obj = {
|
2017-12-27 19:51:54 +00:00
|
|
|
parents : [
|
|
|
|
VORInfo,
|
|
|
|
MFDPage.new(mfd, myCanvas, device, svg, "VORInfo", "WPT - VOR INFORMATION")
|
|
|
|
],
|
2017-12-10 22:15:21 +00:00
|
|
|
};
|
|
|
|
|
2018-04-16 12:38:41 +00:00
|
|
|
# Dynamic text elements in the SVG file. In the SVG these have an "NDBInfo" prefix.
|
|
|
|
textelements = [
|
|
|
|
"ID",
|
|
|
|
"Type",
|
|
|
|
"Facility",
|
|
|
|
"NearestCity",
|
|
|
|
"Class", # Low Altitude / High Altitude / Terminal
|
|
|
|
"MagVar",
|
|
|
|
"Region",
|
|
|
|
"Lat",
|
|
|
|
"Lon",
|
|
|
|
"Freq",
|
|
|
|
"AirportID",
|
|
|
|
"AirportCRS",
|
|
|
|
"AirportDST"
|
|
|
|
];
|
|
|
|
|
|
|
|
obj.addTextElements(textelements);
|
|
|
|
|
|
|
|
# Data Entry information. Keyed from the name of the element, which must
|
|
|
|
# be one of the textelements above. Each data element maps to a set of
|
|
|
|
# text elements in the SVG of the form [PageName][TextElement]{0...n}, each
|
|
|
|
# representing a single character for data entry.
|
|
|
|
#
|
|
|
|
# .size is the number of characters of data entry
|
|
|
|
# .chars is the set of characters, used to scroll through using the small
|
|
|
|
# FMS knob.
|
|
|
|
obj.dataEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 3, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
|
|
|
|
|
|
|
obj.Map = fg1000.NavMap.new(
|
|
|
|
obj,
|
|
|
|
obj.getElement("NavMap"),
|
|
|
|
[860,400],
|
|
|
|
"",
|
|
|
|
-50,
|
|
|
|
0,
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
2018-01-13 18:53:06 +00:00
|
|
|
obj.topMenu(device, obj, nil);
|
2018-04-16 12:38:41 +00:00
|
|
|
obj.update(nil, nil);
|
2017-12-10 22:15:21 +00:00
|
|
|
|
2018-01-26 19:06:06 +00:00
|
|
|
obj.setController(fg1000.VORInfoController.new(obj, svg));
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
return obj;
|
|
|
|
},
|
2018-04-16 12:38:41 +00:00
|
|
|
|
|
|
|
update : func(navdata, aptdata) {
|
|
|
|
if (navdata != nil) {
|
|
|
|
me.setTextElement("ID", navdata.id);
|
|
|
|
|
|
|
|
var type = "VOR";
|
|
|
|
if (navdata.vortac) type = "VORTAC";
|
|
|
|
if (navdata.dme) type = "VOR-DME";
|
|
|
|
|
|
|
|
me.setTextElement("Type", type);
|
|
|
|
me.setTextElement("Facility", "");
|
|
|
|
me.setTextElement("NearestCity", "");
|
|
|
|
me.setTextElement("Class", "");
|
|
|
|
me.setTextElementMagVar("MagVar", navdata.magvar);
|
|
|
|
me.setTextElement("Region", "");
|
|
|
|
|
|
|
|
me.setTextElementLat("Lat", navdata.lat);
|
|
|
|
me.setTextElementLon("Lon", navdata.lon);
|
|
|
|
me.setTextElementNavFreq("Freq", navdata.frequency / 100.0);
|
|
|
|
|
|
|
|
me.Map.getController().setPosition(navdata.lat, navdata.lon);
|
|
|
|
me.Map.show();
|
|
|
|
} else {
|
|
|
|
me.setTextElement("ID", "###");
|
|
|
|
me.setTextElement("Type", "_______");
|
|
|
|
me.setTextElement("Facility", "_______");
|
|
|
|
me.setTextElement("NearestCity", "_______");
|
|
|
|
me.setTextElement("Class", "_______");
|
|
|
|
me.setTextElement("MagVar", "");
|
|
|
|
me.setTextElement("Region", "_______");
|
|
|
|
|
|
|
|
me.setTextElementLat("Lat", nil);
|
|
|
|
me.setTextElementLon("Lon", nil);
|
|
|
|
me.setTextElementNavFreq("Freq", "");
|
|
|
|
me.Map.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aptdata != nil) {
|
|
|
|
var crsAndDst = courseAndDistance(navdata, aptdata);
|
|
|
|
me.setTextElement("AirportID", aptdata.id);
|
|
|
|
me.setTextElementBearing("AirportCRS", aptdata.crs);
|
|
|
|
me.setTextElementDistance("AirportDST", aptdata.dst);
|
|
|
|
} else {
|
|
|
|
me.setTextElement("AirportID", "____");
|
|
|
|
me.setTextElementBearing("AirportCRS", "");
|
|
|
|
me.setTextElementDistance("AirportDST", "");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
offdisplay : func() {
|
|
|
|
me._group.setVisible(0);
|
|
|
|
|
|
|
|
# Reset the menu colours. Shouldn't have to do this here, but
|
|
|
|
# there's not currently an obvious other location to do so.
|
|
|
|
for(var i = 0; i < 12; i +=1) {
|
|
|
|
var name = sprintf("SoftKey%d",i);
|
|
|
|
me.device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0);
|
|
|
|
me.device.svg.getElementById(name).setColor(1.0,1.0,1.0);
|
|
|
|
}
|
2018-04-16 12:38:41 +00:00
|
|
|
me.getElement("NavMap").setVisible(0);
|
|
|
|
me.Map.setVisible(0);
|
2018-01-26 19:06:06 +00:00
|
|
|
me.getController().offdisplay();
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
|
|
|
ondisplay : func() {
|
|
|
|
me._group.setVisible(1);
|
|
|
|
me.mfd.setPageTitle(me.title);
|
2018-04-16 12:38:41 +00:00
|
|
|
me.getElement("NavMap").setVisible(1);
|
|
|
|
me.Map.setVisible(1);
|
2018-01-26 19:06:06 +00:00
|
|
|
me.getController().ondisplay();
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
2018-01-13 18:53:06 +00:00
|
|
|
topMenu : func(device, pg, menuitem) {
|
|
|
|
pg.clearMenu();
|
|
|
|
pg.resetMenuColors();
|
2018-04-16 12:38:41 +00:00
|
|
|
pg.addMenuItem(0, "ENGINE", pg.mfd.EIS, pg.mfd.EIS.engineMenu);
|
|
|
|
pg.addMenuItem(2, "MAP", pg.mfd.NavigationMap, pg.mfd.NavigationMap.mapMenu);
|
2018-01-13 18:53:06 +00:00
|
|
|
device.updateMenus();
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
};
|