2017-12-10 22:15:21 +00:00
|
|
|
# NearestIntersections Controller
|
|
|
|
var NearestIntersectionsController =
|
|
|
|
{
|
|
|
|
new : func (page, svg)
|
|
|
|
{
|
2018-01-31 22:47:35 +00:00
|
|
|
var obj = { parents : [ NearestIntersectionsController, MFDPageController.new(page) ] };
|
|
|
|
|
|
|
|
obj.page = page;
|
|
|
|
obj._crsrToggle = 0;
|
2017-12-27 19:51:54 +00:00
|
|
|
|
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);
|
2018-02-01 22:28:39 +00:00
|
|
|
if (me._crsrToggle) {
|
|
|
|
me.page.showCRSR();
|
|
|
|
} else {
|
|
|
|
me.page.hideCRSR();
|
|
|
|
}
|
|
|
|
|
2017-12-27 19:51:54 +00:00
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
},
|
|
|
|
handleFMSInner : func(value) {
|
|
|
|
if (me._crsrToggle == 1) {
|
|
|
|
# Scroll through whatever is the current list
|
2018-01-31 22:47:35 +00:00
|
|
|
me.page.select.incrSmall(value);
|
|
|
|
var id = me.page.select.getValue();
|
|
|
|
var data = me.getNavDataItem(id);
|
|
|
|
if ((data != nil) and (size(data) >0)) me.page.updateNavDataItem(data[0]);
|
2017-12-27 19:51:54 +00:00
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
} else {
|
2018-01-31 22:47:35 +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-01-31 22:47:35 +00:00
|
|
|
# Scroll through whatever is the current list
|
|
|
|
me.page.select.incrSmall(value);
|
|
|
|
var id = me.page.select.getValue();
|
|
|
|
var data = me.getNavDataItem(id);
|
|
|
|
if ((data != nil) and (size(data) >0)) me.page.updateNavDataItem(data[0]);
|
2017-12-27 19:51:54 +00:00
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
} else {
|
2018-01-31 22:47:35 +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-01-31 22:47:35 +00:00
|
|
|
me.page.select.incrSmall(value);
|
|
|
|
var id = me.page.select.getValue();
|
|
|
|
var data = me.getNavDataItem(id);
|
|
|
|
if ((data != nil) and (size(data) >0)) me.page.updateNavDataItem(data[0]);
|
2017-12-27 19:51:54 +00:00
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
} else {
|
|
|
|
return emesary.Transmitter.ReceiptStatus_NotProcessed;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-01-31 22:47:35 +00:00
|
|
|
handleRange : func(val)
|
|
|
|
{
|
|
|
|
# Pass any range entries to the NavMapController
|
|
|
|
me.page.mfd.NavigationMap.getController().handleRange(val);
|
|
|
|
},
|
|
|
|
|
2017-12-27 19:51:54 +00:00
|
|
|
# Reset controller if required when the page is displayed or hidden
|
|
|
|
ondisplay : func() {
|
|
|
|
me.RegisterWithEmesary();
|
2018-01-31 22:47:35 +00:00
|
|
|
var fixes = me.getNearestNavData("fix");
|
|
|
|
me.page.updateNavData(fixes);
|
|
|
|
me.page.mfd.NavigationMap.getController().enableDTO(1);
|
2018-02-01 22:28:39 +00:00
|
|
|
me._crsrToggle = 0;
|
|
|
|
me.page.hideCRSR();
|
2017-12-27 19:51:54 +00:00
|
|
|
},
|
|
|
|
offdisplay : func() {
|
2018-01-31 22:47:35 +00:00
|
|
|
me.page.mfd.NavigationMap.getController().enableDTO(0);
|
2017-12-27 19:51:54 +00:00
|
|
|
me.DeRegisterWithEmesary();
|
|
|
|
},
|
|
|
|
|
2018-01-31 22:47:35 +00:00
|
|
|
getNearestNavData : func(type) {
|
|
|
|
var notification = notifications.PFDEventNotification.new(
|
|
|
|
"MFD",
|
|
|
|
1,
|
|
|
|
notifications.PFDEventNotification.NavData,
|
|
|
|
{Id: "NavDataWithinRange", Value: type});
|
|
|
|
|
|
|
|
var response = me._transmitter.NotifyAll(notification);
|
|
|
|
|
|
|
|
if (! me._transmitter.IsFailed(response)) {
|
|
|
|
return notification.EventParameter.Value;
|
|
|
|
} else {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getNavDataItem : func(id) {
|
2018-02-02 16:06:42 +00:00
|
|
|
# Use Emesary to get the Fix
|
2018-01-31 22:47:35 +00:00
|
|
|
var notification = notifications.PFDEventNotification.new(
|
|
|
|
"MFD",
|
|
|
|
1,
|
|
|
|
notifications.PFDEventNotification.NavData,
|
2018-02-02 16:06:42 +00:00
|
|
|
{Id: "NavAidByID", Value: { id: id, type: "fix"} });
|
2018-01-31 22:47:35 +00:00
|
|
|
|
|
|
|
var response = me._transmitter.NotifyAll(notification);
|
|
|
|
|
|
|
|
if (! me._transmitter.IsFailed(response)) {
|
|
|
|
return notification.EventParameter.Value;
|
|
|
|
} else {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
},
|
2017-12-10 22:15:21 +00:00
|
|
|
};
|