2017-12-10 22:15:21 +00:00
|
|
|
# AirportInfo Controller
|
|
|
|
var AirportInfoController =
|
|
|
|
{
|
|
|
|
# Vertical ranges, and labels.
|
|
|
|
# Unlike some other map displays, we keep the range constant at 4nm an change
|
|
|
|
# the ScreenRange to zoom in. Otherwise as we zoom in, the center of the
|
|
|
|
# runways moves out of the range of the display and they are not drawn.
|
|
|
|
# Ranges are scaled to the display height with range 1 displaying 4nm vertically.
|
|
|
|
# 2000nm = 12,152,000ft.
|
|
|
|
RANGES : [{range: 4/500/6076.12, label: "500ft"},
|
|
|
|
{range: 4/750/6076.12, label: "750ft"},
|
|
|
|
{range: 4/1000/6076.12, label: "1000ft"},
|
|
|
|
{range: 4/1500/6076.12, label: "1500ft"},
|
|
|
|
{range: 4/2000/6076.12, label: "2000ft"},
|
|
|
|
{range: 8, label: "0.5nm"},
|
|
|
|
{range: 5.33, label: "0.75nm"},
|
|
|
|
{range: 4, label: "1nm"},
|
|
|
|
{range: 2, label: "2nm"},
|
|
|
|
{range: 1.33, label: "3nm"},
|
|
|
|
{range: 1, label: "4nm"},
|
|
|
|
{range: 0.66, label: "6nm"},
|
|
|
|
{range: 0.5, label: "8nm"},
|
|
|
|
{range: 0.4, label: "10nm"} ],
|
|
|
|
|
2018-01-13 23:08:30 +00:00
|
|
|
UIGROUP : {
|
|
|
|
APT : 0,
|
|
|
|
RNWY : 1,
|
|
|
|
FREQ : 2,
|
|
|
|
},
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
new : func (page, svg)
|
|
|
|
{
|
2018-01-08 21:39:39 +00:00
|
|
|
var obj = { parents : [ AirportInfoController, MFDPageController.new(page)] };
|
2017-12-10 22:15:21 +00:00
|
|
|
obj.airport = "";
|
|
|
|
obj.runway = "";
|
2017-12-27 19:51:54 +00:00
|
|
|
obj.runwayIdx = -1;
|
2017-12-10 22:15:21 +00:00
|
|
|
obj.info = nil;
|
|
|
|
obj.page = page;
|
2017-12-27 19:51:54 +00:00
|
|
|
obj.crsrToggle = 0;
|
2018-01-13 23:08:30 +00:00
|
|
|
obj._currentGroup = AirportInfoController.UIGROUP.APT;
|
2017-12-10 22:15:21 +00:00
|
|
|
obj.current_zoom = 7;
|
|
|
|
|
2018-01-13 21:07:32 +00:00
|
|
|
obj.setZoom(obj.current_zoom);
|
2017-12-10 22:15:21 +00:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
},
|
2018-01-13 23:08:30 +00:00
|
|
|
|
|
|
|
selectAirport : func() {
|
|
|
|
me.selectGroup(AirportInfoController.UIGROUP.APT)
|
|
|
|
},
|
|
|
|
selectRunways : func() {
|
|
|
|
me.selectGroup(AirportInfoController.UIGROUP.RNWY);
|
|
|
|
},
|
|
|
|
selectFrequencies : func() {
|
|
|
|
me.selectGroup(AirportInfoController.UIGROUP.FREQ);
|
|
|
|
},
|
|
|
|
getSelectedGroup : func() {
|
|
|
|
return me._currentGroup;
|
|
|
|
},
|
|
|
|
selectGroup : func(grp) {
|
|
|
|
me._currentGroup = grp;
|
|
|
|
if (grp == AirportInfoController.UIGROUP.APT) me.page.airportEntry.highlightElement() else me.page.airportEntry.unhighlightElement();
|
|
|
|
if (grp == AirportInfoController.UIGROUP.RNWY) me.page.runwaySelect.highlightElement() else me.page.runwaySelect.unhighlightElement();
|
|
|
|
if (grp == AirportInfoController.UIGROUP.FREQ) me.page.freqSelect.showCRSR() else me.page.freqSelect.hideCRSR();
|
|
|
|
me._crsrToggle = 1;
|
|
|
|
},
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
setAirport : func(id)
|
|
|
|
{
|
|
|
|
if (id == me.airport) return;
|
2018-01-13 21:07:32 +00:00
|
|
|
var apt = me.getAirport(id);
|
2017-12-27 19:51:54 +00:00
|
|
|
|
|
|
|
if (apt != nil) {
|
|
|
|
me.airport = id;
|
2018-01-13 21:07:32 +00:00
|
|
|
me.info = apt;
|
2017-12-27 19:51:54 +00:00
|
|
|
}
|
2017-12-10 22:15:21 +00:00
|
|
|
|
2017-12-27 19:51:54 +00:00
|
|
|
# Reset airport display. We do this irrespective of whether the id
|
|
|
|
# is valid, as it allows us to clear any bad user input from the ID field
|
|
|
|
me.page.displayAirport(me.info);
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
2017-12-27 19:51:54 +00:00
|
|
|
setRunway : func(runwayID)
|
2017-12-10 22:15:21 +00:00
|
|
|
{
|
2017-12-27 19:51:54 +00:00
|
|
|
me.page.displayRunway(me.info.runways[runwayID]);
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
# Control functions for Input
|
|
|
|
zoomIn : func() {
|
|
|
|
me.setZoom(me.current_zoom -1);
|
|
|
|
},
|
|
|
|
zoomOut : func() {
|
|
|
|
me.setZoom(me.current_zoom +1);
|
|
|
|
},
|
2018-01-08 21:39:39 +00:00
|
|
|
handleRange : func(val)
|
2017-12-10 22:15:21 +00:00
|
|
|
{
|
|
|
|
var incr_or_decr = (val > 0) ? 1 : -1;
|
|
|
|
me.setZoom(me.current_zoom + incr_or_decr);
|
|
|
|
},
|
|
|
|
setZoom : func(zoom) {
|
|
|
|
if ((zoom < 0) or (zoom > (size(me.RANGES) - 1))) return;
|
|
|
|
me.current_zoom = zoom;
|
|
|
|
me.page.setZoom(me.RANGES[zoom].range * fg1000.MAP_PARTIAL.HEIGHT, me.RANGES[zoom].label);
|
|
|
|
},
|
|
|
|
handleCRSR : func() {
|
2017-12-27 19:51:54 +00:00
|
|
|
me.crsrToggle = (! me.crsrToggle);
|
|
|
|
if (me.crsrToggle) {
|
2018-01-13 23:08:30 +00:00
|
|
|
me.selectAirport();
|
2017-12-10 22:15:21 +00:00
|
|
|
} else {
|
2018-01-13 23:08:30 +00:00
|
|
|
me.page.resetCRSR();
|
2017-12-10 22:15:21 +00:00
|
|
|
}
|
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
},
|
|
|
|
handleFMSInner : func(value) {
|
2017-12-27 19:51:54 +00:00
|
|
|
if (me.crsrToggle == 1) {
|
2018-01-13 23:08:30 +00:00
|
|
|
if (me._currentGroup == AirportInfoController.UIGROUP.APT) {
|
|
|
|
me.page.airportEntry.incrSmall(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (me._currentGroup == AirportInfoController.UIGROUP.RNWY) {
|
|
|
|
me.page.runwaySelect.incrSmall(value);
|
|
|
|
var val = me.page.runwaySelect.getValue();
|
|
|
|
if (val != nil) {
|
|
|
|
# Selection values are of the form "06L-12R". We need to set the
|
|
|
|
# runway to the left half.
|
|
|
|
var idx = find("-", val);
|
|
|
|
if (idx != -1) {
|
|
|
|
var rwy = substr(val, 0, idx);
|
|
|
|
me.setRunway(rwy);
|
|
|
|
}
|
2017-12-27 19:51:54 +00:00
|
|
|
}
|
2017-12-10 22:15:21 +00:00
|
|
|
}
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2018-01-13 23:08:30 +00:00
|
|
|
if (me._currentGroup == AirportInfoController.UIGROUP.FREQ) {
|
|
|
|
me.page.freqSelect.incrSmall(value);
|
|
|
|
}
|
|
|
|
|
2017-12-10 22:15:21 +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-10 22:15:21 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
handleFMSOuter : func(value) {
|
2017-12-27 19:51:54 +00:00
|
|
|
if (me.crsrToggle == 1) {
|
2018-01-13 23:08:30 +00:00
|
|
|
if ((me._currentGroup == AirportInfoController.UIGROUP.APT) and me.page.airportEntry.isInEdit()) {
|
|
|
|
me.page.airportEntry.incrLarge(value);
|
|
|
|
} else {
|
|
|
|
var incr_or_decr = (value > 0) ? 1 : -1;
|
|
|
|
var idx = math.mod(me._currentGroup + incr_or_decr, size(AirportInfoController.UIGROUP));
|
|
|
|
me.selectGroup(idx);
|
|
|
|
}
|
|
|
|
|
2017-12-10 22:15:21 +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-10 22:15:21 +00:00
|
|
|
}
|
|
|
|
},
|
2017-12-27 19:51:54 +00:00
|
|
|
handleEnter : func(value) {
|
|
|
|
if (me.crsrToggle == 1) {
|
2018-01-13 23:08:30 +00:00
|
|
|
if ((me._currentGroup == AirportInfoController.UIGROUP.APT) and me.page.airportEntry.isInEdit()) {
|
|
|
|
var aptname = me.page.airportEntry.enterElement();
|
|
|
|
me.setAirport(aptname);
|
2018-01-13 19:17:58 +00:00
|
|
|
}
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2018-01-13 23:08:30 +00:00
|
|
|
if (me._currentGroup == AirportInfoController.UIGROUP.FREQ) {
|
|
|
|
me.page.mfd.SurroundController.setStandbyNavComFreq(me.page.freqSelect.getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-27 19:51:54 +00:00
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
|
|
|
} else {
|
|
|
|
return emesary.Transmitter.ReceiptStatus_NotProcessed;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleClear : func(value) {
|
2018-01-13 23:08:30 +00:00
|
|
|
if ((me.crsrToggle == 1) and
|
|
|
|
(me._currentGroup == AirportInfoController.UIGROUP.APT) and
|
|
|
|
me.page.airportEntry.isInEdit()) {
|
|
|
|
me.page.airportEntry.clearElement();
|
|
|
|
return emesary.Transmitter.ReceiptStatus_Finished;
|
2017-12-27 19:51:54 +00:00
|
|
|
} else {
|
|
|
|
return emesary.Transmitter.ReceiptStatus_NotProcessed;
|
|
|
|
}
|
|
|
|
},
|
2017-12-10 22:15:21 +00:00
|
|
|
|
|
|
|
# Reset controller if required when the page is displayed or hidden
|
|
|
|
ondisplay : func() {
|
|
|
|
me.RegisterWithEmesary();
|
2018-01-13 21:07:32 +00:00
|
|
|
|
|
|
|
if (me.airport == "") {
|
|
|
|
# Initial airport is our current location.
|
|
|
|
# Needs to be done here as the data provider may not be set up when
|
|
|
|
# we are created.
|
|
|
|
var current_apt = me.getAirport("airport");
|
|
|
|
me.setAirport(current_apt.id);
|
|
|
|
}
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
|
|
|
offdisplay : func() {
|
|
|
|
me.DeRegisterWithEmesary();
|
|
|
|
},
|
2018-01-13 21:07:32 +00:00
|
|
|
|
|
|
|
getAirport : func(id) {
|
|
|
|
# Use Emesary to get the airport
|
|
|
|
var notification = notifications.PFDEventNotification.new(
|
|
|
|
"MFD",
|
|
|
|
1,
|
|
|
|
notifications.PFDEventNotification.NavData,
|
|
|
|
{Id: "AirportByID", Value: id});
|
|
|
|
|
|
|
|
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
|
|
|
};
|