1
0
Fork 0

Extend MFDPageController to handle Emesary register

This commit is contained in:
Stuart Buchanan 2018-01-08 21:39:39 +00:00
parent 2ef9f0f98f
commit ab8774a3e0
12 changed files with 228 additions and 248 deletions

View file

@ -24,7 +24,7 @@ var AirportInfoController =
new : func (page, svg)
{
var obj = { parents : [ AirportInfoController ] };
var obj = { parents : [ AirportInfoController, MFDPageController.new(page)] };
obj.airport = "";
obj.runway = "";
obj.runwayIdx = -1;
@ -69,7 +69,7 @@ var AirportInfoController =
zoomOut : func() {
me.setZoom(me.current_zoom +1);
},
zoom : func(val)
handleRange : func(val)
{
var incr_or_decr = (val > 0) ? 1 : -1;
me.setZoom(me.current_zoom + incr_or_decr);
@ -133,44 +133,6 @@ var AirportInfoController =
return emesary.Transmitter.ReceiptStatus_NotProcessed;
}
},
RegisterWithEmesary : func(transmitter = nil){
if (transmitter == nil)
transmitter = emesary.GlobalTransmitter;
if (me._recipient == nil){
me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me.page.device.designation);
var pfd_obj = me.page.device;
var controller = me;
me._recipient.Receive = func(notification)
{
if (notification.Device_Id == pfd_obj.device_id
and notification.NotificationType == notifications.PFDEventNotification.DefaultType) {
if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed
and notification.EventParameter != nil)
{
var id = notification.EventParameter.Id;
var value = notification.EventParameter.Value;
#printf("Button pressed " ~ id ~ " " ~ value);
if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR();
if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value);
if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value);
if (id == fg1000.FASCIA.RANGE) return controller.zoom(value);
if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value);
if (id == fg1000.FASCIA.CLR) return controller.handleClear(value);
}
}
return emesary.Transmitter.ReceiptStatus_NotProcessed;
};
}
transmitter.Register(me._recipient);
me.transmitter = transmitter;
},
DeRegisterWithEmesary : func(transmitter = nil){
# remove registration from transmitter; but keep the recipient once it is created.
if (me.transmitter != nil)
me.transmitter.DeRegister(me._recipient);
me.transmitter = nil;
},
# Reset controller if required when the page is displayed or hidden
ondisplay : func() {

View file

@ -9,6 +9,7 @@ io.include("constants.nas");
var nasal_dir = getprop("/sim/fg-root") ~ "/Aircraft/Instruments-3d/FG1000/Nasal/";
io.load_nasal(nasal_dir ~ '/MFDPage.nas', "fg1000");
io.load_nasal(nasal_dir ~ '/MFDPageController.nas', "fg1000");
var MFDPages = [
"Surround",
@ -67,7 +68,7 @@ var MFD =
parents : [ MFD ],
EIS : nil,
NavigationMap: nil,
Surround : nil,
Surround : nil,
};
obj._svg = myCanvas.createGroup("softkeys");

View file

@ -51,7 +51,6 @@ addTextElements : func(symbols) {
getTextElement : func(symbolName) {
return me._symbols[symbolName];
assert(sym != nil, "Unknown text element " ~ symbolName ~ " (check your addTextElements call?)");
},
getTextValue : func(symbolName) {

View file

@ -0,0 +1,167 @@
# Standard MFDPage Controller
#
# This should be extended by specific page controllers and the handle...()
# methods over-ridden to provide specific functions for the MFD buttons.
var MFDPageController = {
new : func (page)
{
var obj = { parents : [ MFDPageController ] };
# Emesary
obj._recipient = nil;
obj._page = page;
obj._transmitter = emesary.GlobalTransmitter;
obj._registered = 0;
return obj;
},
# Default handlers for all the Fascia hardkeys. These should be over-ridden
# as required by specific page function.
handleNavVol : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleNavVolToggle : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleNavFreqTransfer : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleNavOuter : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleNavInner : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleToggle : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleHeading : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleHeadingPress : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
# Joystick
handleRange : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleJoystickHorizontal : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleJoystickHorizontal : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
#CRS/BARO
handleBaro : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleCRS : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleCRSCenter : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleComOuter : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleComInner : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleComToggle : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleFreqTransfer : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleFreqTransferHold : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; }, # Auto-tunes to 121.2 when pressed for 2 seconds
handleComVol : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleComVolToggle : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },,
handleDTO : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleFPL : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleCLR : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleCLRHold : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
# By default, the FMS knobs will select a new page.
handleFMSOuter : func (value) { return me.page.mfd._pageGroupController.handleFMSOuter(value); },
handleFMSOuter : func (value) { return me.page.mfd._pageGroupController.handleFMSInner(value); },
handleCRSR : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleMenu : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleProc : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleEnter : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleAltOuter : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
handleAltInner : func (value) { return emesary.Transmitter.ReceiptStatus_NotProcessed; },
RegisterWithEmesary : func()
{
if (me._recipient == nil){
me._recipient = emesary.Recipient.new("MFDPageController_" ~ me.page.device.designation);
var pfd_obj = me.page.device;
var controller = me;
me._recipient.Receive = func(notification)
{
if (notification.Device_Id == pfd_obj.device_id
and notification.NotificationType == notifications.PFDEventNotification.DefaultType) {
if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed
and notification.EventParameter != nil)
{
var id = notification.EventParameter.Id;
var value = notification.EventParameter.Value;
#printf("Button pressed " ~ id ~ " " ~ value);
if (id == fg1000.FASCIA.NAV_VOL) return controller.handleNavVol(value);
if (id == fg1000.FASCIA.NAV_VOL_TOGGLE) return controller.handleNavVolToggle(value);
if (id == fg1000.FASCIA.NAV_FREQ_TRANSFER) return controller.handleNavFreqTransfer(value);
if (id == fg1000.FASCIA.NAV_OUTER) return controller.handleNavOuter(value);
if (id == fg1000.FASCIA.NAV_INNER) return controller.handleNavInner(value);
if (id == fg1000.FASCIA.NAV_TOGGLE) return controller.handleToggle(value);
if (id == fg1000.FASCIA.HEADING) return controller.handleHeading(value);
if (id == fg1000.FASCIA.HEADING_PRESS) return controller.handleHeadingPress(value);
# Joystick
if (id == fg1000.FASCIA.RANGE) return controller.handleRange(value);
if (id == fg1000.FASCIA.JOYSTICK_HORIZONTAL) return controller.handleJoystickHorizontal(value);
if (id == fg1000.FASCIA.JOYSTICK_VERTICAL) return controller.handleJoystickHorizontal(value);
#CRS/BARO
if (id == fg1000.FASCIA.BARO) return controller.handleBaro(value);
if (id == fg1000.FASCIA.CRS) return controller.handleCRS(value);
if (id == fg1000.FASCIA.CRS_CENTER) return controller.handleCRSCenter(value);
if (id == fg1000.FASCIA.COM_OUTER) return controller.handleComOuter(value);
if (id == fg1000.FASCIA.COM_INNER) return controller.handleComInner(value);
if (id == fg1000.FASCIA.COM_TOGGLE) return controller.handleComToggle(value);
if (id == fg1000.FASCIA.COM_FREQ_TRANSFER) return controller.handleFreqTransfer(value);
if (id == fg1000.FASCIA.COM_FREQ_TRANSFER_HOLD) return controller.handleFreqTransferHold(value); # Auto-tunes to 121.2 when pressed for 2 seconds
if (id == fg1000.FASCIA.COM_VOL) return controller.handleComVol(value);
if (id == fg1000.FASCIA.COM_VOL_TOGGLE) return controller.handleComVolToggle(value);
if (id == fg1000.FASCIA.DTO) return controller.handleDTO(value);
if (id == fg1000.FASCIA.FPL) return controller.handleFPL(value);
if (id == fg1000.FASCIA.CLR) return controller.handleClear(value);
if (id == fg1000.FASCIA.CLR_HOLD) return controller.handleClearHold(value);
if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value);
if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value);
if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR(value);
if (id == fg1000.FASCIA.MENU) return controller.handleMenu(value);
if (id == fg1000.FASCIA.PROC) return controller.handleProc(value);
if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value);
if (id == fg1000.FASCIA.ALT_OUTER) return controller.handleAltOuter(value);
if (id == fg1000.FASCIA.ALT_INNER) return controller.handleAltInner(value);
# Autopilot controls - ignore for now as like to be handled elsewhere
#if (id == fg1000.FASCIA.AP ) return controller.handle(value);
#if (id == fg1000.FASCIA.HDG) return controller.handle(value);
#if (id == fg1000.FASCIA.NAV) return controller.handle(value);
#if (id == fg1000.FASCIA.APR) return controller.handle(value);
#if (id == fg1000.FASCIA.VS ) return controller.handle(value);
#if (id == fg1000.FASCIA.FLC) return controller.handle(value);
#if (id == fg1000.FASCIA.FD ) return controller.handle(value);
#if (id == fg1000.FASCIA.ALT) return controller.handle(value);
#if (id == fg1000.FASCIA.VNV) return controller.handle(value);
#if (id == fg1000.FASCIA.BC ) return controller.handle(value);
#if (id == fg1000.FASCIA.NOSE_UP) return controller.handle(value);
#if (id == fg1000.FASCIA.NOSE_DOWN) return controller.handle(value);
}
}
return emesary.Transmitter.ReceiptStatus_NotProcessed;
};
}
me._transmitter.Register(me._recipient);
me._registered = 1;
},
DeRegisterWithEmesary : func()
{
# remove registration from transmitter; but keep the recipient once it is created.
if (me._registered == 1) me._transmitter.DeRegister(me._recipient);
me._registered = 0;
},
};

View file

@ -132,11 +132,11 @@ var NavigationMap =
me._labelsFull.setVisible(0);
me._labelsPartial.setVisible(1);
me.controller.ondisplayPartial();
#me.controller.ondisplayPartial();
},
offdisplayPartial : func() {
me._group.setVisible(0);
me.controller.offdisplayPartial();
#me.controller.offdisplayPartial();
},
# Softkey assigments. For some pages (notably the NEAREST pages)
@ -199,6 +199,4 @@ var NavigationMap =
svg.setVisible(1); # display function
},
};

View file

@ -83,7 +83,7 @@ var NavigationMapController =
new : func (page, svg)
{
var obj = { parents : [ NavigationMapController ] };
var obj = { parents : [ NavigationMapController, MFDPageController.new(page) ] };
obj.current_zoom = 8;
obj.declutter = 0;
obj.airways = 0;
@ -91,10 +91,6 @@ var NavigationMapController =
obj.setZoom(obj.current_zoom);
obj.setOrientation(obj.ORIENTATIONS[0]);
# Emesary
obj._recipient = nil;
obj._zoomRecipient = nil;
return obj;
},
zoomIn : func() {
@ -103,11 +99,6 @@ var NavigationMapController =
zoomOut : func() {
me.setZoom(me.current_zoom +1);
},
zoom : func(val)
{
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;
@ -186,41 +177,12 @@ var NavigationMapController =
# bottom right of the screen
return me.page.mfd._pageGroupController.handleFMSOuter(value);
},
RegisterWithEmesary : func(transmitter = nil) {
if (transmitter == nil)
transmitter = emesary.GlobalTransmitter;
handleRange : func(val)
{
var incr_or_decr = (val > 0) ? 1 : -1;
me.setZoom(me.current_zoom + incr_or_decr);
},
if (me._recipient == nil){
me._recipient = emesary.Recipient.new("NavMapController_" ~ me.page.device.designation);
var pfd_obj = me.page.device;
var controller = me;
me._recipient.Receive = func(notification)
{
if (notification.Device_Id == pfd_obj.device_id
and notification.NotificationType == notifications.PFDEventNotification.DefaultType) {
if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed
and notification.EventParameter != nil)
{
var id = notification.EventParameter.Id;
var value = notification.EventParameter.Value;
#printf("Button pressed " ~ id ~ " " ~ value);
if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value);
if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value);
if (id == fg1000.FASCIA.RANGE) return controller.zoom(value);
}
}
return emesary.Transmitter.ReceiptStatus_NotProcessed;
};
}
transmitter.Register(me._recipient);
me.transmitter = transmitter;
},
DeRegisterWithEmesary : func(transmitter = nil) {
# remove registration from transmitter; but keep the recipient once it is created.
if (me.transmitter != nil)
me.transmitter.DeRegister(me._recipient);
me.transmitter = nil;
},
# Reset controller if required when the page is displayed or hidden
ondisplay : func() {
me.RegisterWithEmesary();
@ -229,50 +191,4 @@ var NavigationMapController =
me.DeRegisterWithEmesary();
},
# Set controller for cases where the NavigationMap is displayed as part of
# another page, e.g. NearestAirports
#
# In this case we are only interested in a subset of the buttons to control
# the map.
RegisterZoomWithEmesary : func(transmitter = nil) {
if (transmitter == nil)
transmitter = emesary.GlobalTransmitter;
if (me._zoomRecipient == nil){
me._zoomRecipient = emesary.Recipient.new("NavMapController_" ~ me.page.device.designation);
var pfd_obj = me.page.device;
var controller = me;
me._zoomRecipient.Receive = func(notification)
{
if (notification.Device_Id == pfd_obj.device_id
and notification.NotificationType == notifications.PFDEventNotification.DefaultType) {
if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed
and notification.EventParameter != nil)
{
var id = notification.EventParameter.Id;
var value = notification.EventParameter.Value;
#printf("Button pressed " ~ id ~ " " ~ value);
if (id == fg1000.FASCIA.RANGE) return controller.zoom(value);
}
}
return emesary.Transmitter.ReceiptStatus_NotProcessed;
};
}
transmitter.Register(me._zoomRecipient);
me.zoomTransmitter = transmitter;
},
DeRegisterZoomWithEmesary : func(transmitter = nil) {
# remove registration from transmitter; but keep the recipient once it is created.
if (me.zoomTransmitter != nil)
me.zoomTransmitter.DeRegister(me._zoomRecipient);
me.zoomTransmitter = nil;
},
ondisplayPartial : func() {
me.RegisterZoomWithEmesary();
},
offdisplayPartial : func() {
me.DeRegisterZoomWithEmesary();
},
};

View file

@ -11,16 +11,13 @@ var NearestAirportsController =
new : func (page, svg)
{
var obj = { parents : [ NearestAirportsController ] };
var obj = { parents : [ NearestAirportsController, MFDPageController.new(page) ] };
# Current active UI group.
obj.page = page;
obj._currentGroup = NearestAirportsController.UIGROUP.NONE;
obj._crsrToggle = 0;
# Emesary
obj._recipient = nil;
return obj;
},
@ -33,6 +30,16 @@ var NearestAirportsController =
var radius = 0;
var apts = [];
#
# TODO: Use Emesary to query APT data - allows support for multiple
# data sources / abstraction.
#
#var airportNotification = notifications.PFDEventNotification.new(blah);
#var response = Emesary.GlobalTransmitter.notifyAll(airportNotification);
#if (response.isSuccess()) {
# me.page.updateAirports(airportNotification.value);
#}
while ((radius <= 200) and (size(apts) < 25)) {
radius = radius + 50;
apts = findAirportsWithinRange(radius);
@ -169,43 +176,14 @@ var NearestAirportsController =
return emesary.Transmitter.ReceiptStatus_NotProcessed;
}
},
RegisterWithEmesary : func(transmitter = nil){
if (transmitter == nil)
transmitter = emesary.GlobalTransmitter;
if (me._recipient == nil){
me._recipient = emesary.Recipient.new("AirportInfoController_" ~ me.page.device.designation);
var pfd_obj = me.page.device;
var controller = me;
me._recipient.Receive = func(notification)
{
if (notification.Device_Id == pfd_obj.device_id
and notification.NotificationType == notifications.PFDEventNotification.DefaultType) {
if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed
and notification.EventParameter != nil)
{
var id = notification.EventParameter.Id;
var value = notification.EventParameter.Value;
#printf("Button pressed " ~ id ~ " " ~ value);
if (id == fg1000.FASCIA.FMS_CRSR) return controller.handleCRSR();
if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value);
if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value);
if (id == fg1000.FASCIA.ENT) return controller.handleEnter(value);
}
}
return emesary.Transmitter.ReceiptStatus_NotProcessed;
};
}
transmitter.Register(me._recipient);
me.transmitter = transmitter;
},
DeRegisterWithEmesary : func(transmitter = nil){
# remove registration from transmitter; but keep the recipient once it is created.
if (me.transmitter != nil)
me.transmitter.DeRegister(me._recipient);
me.transmitter = nil;
handleRange : func(val)
{
# Pass any range entries to the NavMapController
me.page.mfd.NavigationMap.controller.handleZoom(val);
},
# Reset controller if required when the page is displayed or hidden
ondisplay : func() {
me._currentGroup = NearestAirportsController.UIGROUP.NONE;

View file

@ -190,6 +190,7 @@ var Surround =
assert(page != nil, "Unable to find page " ~ pageToLoad);
me.device.selectPage(page);
me.hideMenu();
},
incrPageGroup : func(val) {
var incr_or_decr = (val > 0) ? 1 : -1;

View file

@ -41,9 +41,9 @@ var SurroundController =
{
if (me._page.isMenuVisible()) {
# Change page group
me.incrPage(val);
me._page.incrPage(val);
}
me.showMenu();
me._page.showMenu();
return emesary.Transmitter.ReceiptStatus_Finished;
},

View file

@ -13,10 +13,8 @@ var TrafficMap =
obj.mapgroup = obj._group.createChild("map");
# Dynamic text elements
obj.op_label = svg.getElementById("TrafficMapOpMode");
obj.alt_label = svg.getElementById("TrafficMapAltMode");
obj.outer_label = svg.getElementById("TrafficMapOuterRange");
obj.inner_label = svg.getElementById("TrafficMapInnerRange");
var textelements = ["OpMode", "AltMode", "OuterRange", "InnerRange"];
obj.addTextElements(textelements);
# Initialize the controller:
var ctrl_ns = canvas.Map.Controller.get("Aircraft position");
@ -139,14 +137,29 @@ var TrafficMap =
setLayerVisible : func(name,n=1) {
me.mapgroup.getLayer(name).setVisible(n);
},
setOperate : func(enabled) {
if (enabled) {
me.setTextElement("OpMode", "OPERATING");
} else {
me.setTextElement("OpMode", "STANDBY");
}
me.mapgroup.getLayer("TFC").setVisible(enabled);
},
setRange : func(range, inner_label, outer_label) {
me.mapgroup.setRange(range);
me.inner_label.setText(inner_label);
me.outer_label.setText(outer_label);
me.setTextElement("OuterRange", outer_label);
me.setTextElement("InnerRange", inner_label);
},
setScreenRange : func(range) {
me.mapgroup.setScreenRange(range);
},
setAlt : func(floor_ft, ceiling_ft, label) {
me.setTextElement("AltMode", label);
# Update the TFC controller to filter out the correct targets
me.mapgroup.getLayer("TFC").options.floor_ft = floor_ft;
me.mapgroup.getLayer("TFC").options.ceiling_ft = ceiling_ft;
},
offdisplay : func() {
me._group.setVisible(0);

View file

@ -23,7 +23,7 @@ var TrafficMapController =
new : func (page, svg)
{
var obj = { parents : [ TrafficMapController ] };
var obj = { parents : [ TrafficMapController, MFDPageController.new(page) ] };
obj.range = 1;
obj.alt = "NORMAL";
obj.operating = 0;
@ -35,6 +35,8 @@ var TrafficMapController =
obj._recipient = nil;
obj.setZoom(obj.range);
obj.setAlt(obj.alt);
obj.setOperate(obj.operating);
return obj;
},
zoomIn : func() {
@ -43,11 +45,6 @@ var TrafficMapController =
zoomOut : func() {
me.setZoom(me.current_zoom +1);
},
zoom : func(val)
{
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;
@ -58,22 +55,12 @@ var TrafficMapController =
},
setAlt : func(alt) {
if (me.ALTS[alt] == nil) return;
me.page.alt_label.setText(me.ALTS[alt].label);
me.page.setAlt(me.ALTS[alt].floor_ft, me.ALTS[alt].ceiling_ft, me.ALTS[alt].label);
me.alt = alt;
# Update the TFC controller to filter out the correct targets
me.page.mapgroup.getLayer("TFC").options.ceiling_ft = me.ALTS[alt].ceiling_ft;
me.page.mapgroup.getLayer("TFC").options.floor_ft = me.ALTS[alt].floor_ft;
},
setOperate : func(enabled) {
if (enabled) {
me.page.op_label.setText("OPERATING");
me.page.setLayerVisible("TFC", 1);
me.operating = 1;
} else {
me.page.op_label.setText("STANDBY");
me.page.setLayerVisible("TFC", 0);
me.operating = 0;
}
me.page.setOperate(enabled);
me.operating = enabled;
},
setFlightID : func(enabled) {
me.flight_id = enabled;
@ -91,52 +78,10 @@ var TrafficMapController =
if (me.flight_id == 1 and label == "FLT ID") return 1;
return 0;
},
handleFMSInner : func(value) {
# This page has no use for the FMS knob, so we pass all such
# events to the pageGroupController which displays the page menu in the
# bottom right of the screen
return me.page.mfd._pageGroupController.handleFMSInner(value);
},
handleFMSOuter : func(value) {
# This page has no use for the FMS knob, so we pass all such
# events to the pageGroupController which displays the page menu in the
# bottom right of the screen
return me.page.mfd._pageGroupController.handleFMSOuter(value);
},
RegisterWithEmesary : func(transmitter = nil){
if (transmitter == nil)
transmitter = emesary.GlobalTransmitter;
if (me._recipient == nil){
me._recipient = emesary.Recipient.new("TrafficMapController_" ~ me.page.device.designation);
var pfd_obj = me.page.device;
var controller = me;
me._recipient.Receive = func(notification)
{
if (notification.Device_Id == pfd_obj.device_id
and notification.NotificationType == notifications.PFDEventNotification.DefaultType) {
if (notification.Event_Id == notifications.PFDEventNotification.HardKeyPushed
and notification.EventParameter != nil)
{
var id = notification.EventParameter.Id;
var value = notification.EventParameter.Value;
#printf("Button pressed " ~ id ~ " " ~ value);
if (id == fg1000.FASCIA.FMS_OUTER) return controller.handleFMSOuter(value);
if (id == fg1000.FASCIA.FMS_INNER) return controller.handleFMSInner(value);
if (id == fg1000.FASCIA.RANGE) return controller.zoom(value);
}
}
return emesary.Transmitter.ReceiptStatus_NotProcessed;
};
}
transmitter.Register(me._recipient);
me.transmitter = transmitter;
},
DeRegisterWithEmesary : func(transmitter = nil){
# remove registration from transmitter; but keep the recipient once it is created.
if (me.transmitter != nil)
me.transmitter.DeRegister(me._recipient);
me.transmitter = nil;
handleRange : func(val)
{
var incr_or_decr = (val > 0) ? 1 : -1;
me.setZoom(me.current_zoom + incr_or_decr);
},
# Reset controller if required when the page is displayed or hidden

View file

@ -553,7 +553,7 @@ var PFDEventNotification =
ChangeMenuText : 3, #event parameter contains array of { Id: , Text: } tuples
HardKeyPushed : 4, #event parameter contains single { Id: , Value: } tuple
EngineData : 5, #event parameter contains an array of hashes, each containing information about a given engine.
NavComData : 6, #event paramterr contains a hash of updated Nav/Com settings
NavComData : 6, #event parameter contains a hash of updated Nav/Com settings
DefaultType : "PFDEventNotification",