2018-02-09 18:55:53 +00:00
|
|
|
# Copyright 2018 Stuart Buchanan
|
|
|
|
# This file is part of FlightGear.
|
|
|
|
#
|
2018-05-28 19:15:57 +00:00
|
|
|
# FlightGear is free software: you can redistribute it and/or modify
|
2018-02-09 18:55:53 +00:00
|
|
|
# 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 Controller
|
|
|
|
var VORInfoController =
|
|
|
|
{
|
|
|
|
new : func (page, svg)
|
|
|
|
{
|
2017-12-27 19:51:54 +00:00
|
|
|
var obj = {
|
2018-01-13 18:53:06 +00:00
|
|
|
parents : [ VORInfoController, MFDPageController.new(page) ],
|
2017-12-27 19:51:54 +00:00
|
|
|
_crsrToggle : 0,
|
|
|
|
_recipient : nil,
|
|
|
|
_page : page,
|
|
|
|
};
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
return obj;
|
|
|
|
},
|
2017-12-27 19:51:54 +00:00
|
|
|
|
|
|
|
# Input Handling
|
|
|
|
handleCRSR : func() {
|
|
|
|
me._crsrToggle = (! me._crsrToggle);
|
|
|
|
if (me._crsrToggle) {
|
2018-04-16 12:38:41 +00:00
|
|
|
me._page.dataEntry.highlightElement();
|
2017-12-27 19:51:54 +00:00
|
|
|
} else {
|
2018-04-16 12:38:41 +00:00
|
|
|
me._page.dataEntry.unhighlightElement();
|
2017-12-27 19:51:54 +00:00
|
|
|
}
|
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
},
|
|
|
|
handleFMSInner : func(value) {
|
|
|
|
if (me._crsrToggle == 1) {
|
2018-04-16 12:38:41 +00:00
|
|
|
me._page.dataEntry.incrSmall(value);
|
2017-12-27 19:51:54 +00:00
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
} else {
|
2018-01-13 18:53:06 +00:00
|
|
|
return me._page.mfd.SurroundController.handleFMSInner(value);
|
2017-12-27 19:51:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
handleFMSOuter : func(value) {
|
|
|
|
if (me._crsrToggle == 1) {
|
2018-04-16 12:38:41 +00:00
|
|
|
me._page.dataEntry.incrLarge(value);
|
2017-12-27 19:51:54 +00:00
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
} else {
|
2018-01-13 18:53:06 +00:00
|
|
|
return me._page.mfd.SurroundController.handleFMSOuter(value);
|
2017-12-27 19:51:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
handleEnter : func(value) {
|
|
|
|
if (me._crsrToggle == 1) {
|
2018-04-16 12:38:41 +00:00
|
|
|
var id = me._page.dataEntry.enterElement();
|
|
|
|
me.getVOR(id);
|
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
} else {
|
|
|
|
return emesary.Transmitter.ReceiptStatus_NotProcessed;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleClear : func(value) {
|
|
|
|
if (me._crsrToggle == 1) {
|
|
|
|
me._page.dataEntry.clearElement();
|
2017-12-27 19:51:54 +00:00
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
} else {
|
|
|
|
return emesary.Transmitter.ReceiptStatus_NotProcessed;
|
|
|
|
}
|
|
|
|
},
|
2018-04-16 12:38:41 +00:00
|
|
|
handleRange : func(val)
|
|
|
|
{
|
|
|
|
# Pass any range entries to the NavMapController
|
|
|
|
me._page.Map.handleRange(val);
|
|
|
|
},
|
|
|
|
|
|
|
|
# Retrieve intersection information for the provided id and display it.
|
|
|
|
getVOR : func(id) {
|
|
|
|
var navdata = nil;
|
|
|
|
var aptdata = nil;
|
|
|
|
|
|
|
|
# Use Emesary to get the intersection
|
|
|
|
var notification = notifications.PFDEventNotification.new(
|
|
|
|
"MFD",
|
|
|
|
me.getDeviceID(),
|
|
|
|
notifications.PFDEventNotification.NavData,
|
|
|
|
{Id: "NavAidByID", Value: { id: id, type : "vor" } } );
|
|
|
|
|
|
|
|
var response = me._transmitter.NotifyAll(notification);
|
|
|
|
var retval = notification.EventParameter.Value;
|
|
|
|
|
|
|
|
if ((!me._transmitter.IsFailed(response)) and (size(retval) > 0)) {
|
|
|
|
# Simply take the first value, which will be the closest.
|
|
|
|
navdata = retval[0];
|
|
|
|
|
|
|
|
# Get the nearest Airport to the intersection
|
|
|
|
var params = { lat: navdata.lat,
|
|
|
|
lon: navdata.lon,
|
|
|
|
type : "airport" };
|
|
|
|
|
|
|
|
notification = notifications.PFDEventNotification.new(
|
|
|
|
"MFD",
|
|
|
|
me.getDeviceID(),
|
|
|
|
notifications.PFDEventNotification.NavData,
|
|
|
|
{Id: "NavDataWithinRange", Value: params });
|
|
|
|
|
|
|
|
response = me._transmitter.NotifyAll(notification);
|
|
|
|
retval = notification.EventParameter.Value;
|
|
|
|
|
|
|
|
if ((!me._transmitter.IsFailed(response)) and (size(retval) > 0)) {
|
|
|
|
var crsAndDst = courseAndDistance(navdata, retval[0]);
|
|
|
|
aptdata = {};
|
|
|
|
aptdata.id = retval[0].id;
|
|
|
|
aptdata.crs = crsAndDst[0];
|
|
|
|
aptdata.dst = crsAndDst[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Display the retrieved data.
|
|
|
|
me._page.update(navdata, aptdata);
|
|
|
|
},
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2019-01-14 22:22:20 +00:00
|
|
|
handleStringInput : func(value) {
|
|
|
|
me._page.dataEntry.clearElement();
|
|
|
|
me._page.dataEntry.setValue(value);
|
|
|
|
me.getVOR(value);
|
|
|
|
me._page.dataEntry.unhighlightElement();
|
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
},
|
|
|
|
|
2017-12-27 19:51:54 +00:00
|
|
|
# Reset controller if required when the page is displayed or hidden
|
|
|
|
ondisplay : func() {
|
|
|
|
me.RegisterWithEmesary();
|
2019-01-14 22:22:20 +00:00
|
|
|
if (me._page.dataEntry.getValue() != "") me.getVOR(me._page.dataEntry.getValue());
|
2017-12-27 19:51:54 +00:00
|
|
|
},
|
|
|
|
offdisplay : func() {
|
|
|
|
me.DeRegisterWithEmesary();
|
|
|
|
},
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
};
|