1
0
Fork 0

Direct To Page - configure GPS from Direct To page

This commit is contained in:
Stuart Buchanan 2018-01-29 21:43:43 +00:00
parent 183f5e2112
commit 902cac4dd6
6 changed files with 136 additions and 45 deletions

View file

@ -102,7 +102,6 @@ var DirectTo =
if (destination != nil) {
# Display a given location
#debug.dump(destination);
me.DirectToChart.setVisible(1);
me.DirectToChart.getController().setPosition(destination.lat,destination.lon);
me.setTextElement("Name", string.uc(destination.name));

View file

@ -41,7 +41,7 @@ var DirectToController =
var obj = { parents : [ DirectToController, MFDPageController.new(page)] };
obj.id = "";
obj.page = page;
obj.current_zoom = 7;
obj.current_zoom = 13;
obj.setZoom(obj.current_zoom);
@ -55,8 +55,7 @@ var DirectToController =
obj._activateIndex = size(obj._cursorElements) - 1;
# -1 indicates nothing selected at present
obj._selectedElement = -1;
obj._selectedElement = 0;
# Whether the WaypointSubmenuGroup is enabled
obj._waypointSubmenuVisible = 0;
@ -181,6 +180,23 @@ var DirectToController =
}
},
setNavData : func(type, value=nil) {
# Use Emesary to set a piece of data in the NavData system, using the provided
# type and value;
var notification = notifications.PFDEventNotification.new(
"MFD",
1,
notifications.PFDEventNotification.NavData,
{Id: type, Value: value});
var response = me._transmitter.NotifyAll(notification);
if (me._transmitter.IsFailed(response)) {
print("DirectToController.setNavData() : Failed to set Nav Data " ~ value);
debug.dump(value);
}
},
handleFMSInner : func(value) {
if (me._waypointSubmenuVisible) {
@ -190,22 +206,15 @@ var DirectToController =
me.page.WaypointSubmenuSelect.incrSmall(value);
# Now update the Scroll group with the new type of waypoints
me.updateWaypointSubmenu();
} else if (me._selectedElement == -1) {
if (value == -1) {
# The WaypointSubmenuGroup group is displayed if the small FMS knob is rotated
# anti-clockwise as an initial rotation.
me._cursorElements[0].unhighlightElement();
} else if ((me._selectedElement == 0) and (! me.page.IDEntry.isInEdit()) and (value == -1)) {
# The WaypointSubmenuGroup group is displayed if the small FMS knob is rotated
# anti-clockwise as an initial rotation where the ID Entry is not being editted.
me._cursorElements[0].unhighlightElement();
me.page.WaypointSubmenuGroup.setVisible(1);
me.page.WaypointSubmenuSelect.highlightElement();
me._waypointSubmenuVisible = 1;
me.updateWaypointSubmenu();
} else {
# If the user rotates clockwise, then they simply start editing
# the cursor element
me.nextCursorElement(1);
me._cursorElements[me._selectedElement].incrSmall(value);
}
me.page.WaypointSubmenuGroup.setVisible(1);
me.page.WaypointSubmenuSelect.highlightElement();
me._waypointSubmenuVisible = 1;
me.updateWaypointSubmenu();
} else {
# We've already got something selected, and we're not in the
# WaypointSubmenuGroup, so increment it.
@ -220,9 +229,6 @@ var DirectToController =
# selects between the different waypoints in the Waypoint Submenu.
me.page.WaypointSubmenuSelect.unhighlightElement();
me.page.WaypointSubmenuScroll.incrLarge(value);
} else if (me._selectedElement == -1) {
# If no element is selected, then the Outer FMS knob has no effect
return emesary.Transmitter.ReceiptStatus_Finished;
} else if (me._cursorElements[me._selectedElement].isInEdit()) {
# If we're editing an element, then get on with it!
me._cursorElements[me._selectedElement].incrLarge(value);
@ -243,14 +249,16 @@ var DirectToController =
# Select the activate ACTIVATE item.
me.setCursorElement(me._activateIndex);
} else if (me._selectedElement == -1) {
# If no element is selected, then the ENT key has no effect
return emesary.Transmitter.ReceiptStatus_Finished;
} else {
# If we're on the Activate button, then set up the DirectTo and hide the
# page. We're finished
if (me._selectedElement == me._activateIndex) {
# If we're on the Activate button, then set up the DirectTo and hide the
# page. We're finished
var params = {};
params.id = me.page.IDEntry.getValue();
params.alt_ft = me.page.VNVAltEntry.getValue();
params.offset_nm = me.page.VNVOffsetEntry.getValue();
me.setNavData("SetDirectTo", params);
var mappage = me._page.getMFD().getPage("NavigationMap");
assert(mappage != nil, "Unable to find NavigationMap page");
me._page.getDevice().selectPage(mappage);
@ -285,7 +293,7 @@ var DirectToController =
# If we're in the Waypoint Submenu, then this clears it.
me.page.WaypointSubmenuGroup.setVisible(0);
me._waypointSubmenuVisible = 0;
} else if ((me._selectedElement != -1) and me._cursorElements[me._selectedElement].isInEdit()) {
} else if (me._cursorElements[me._selectedElement].isInEdit()) {
me._cursorElements[me._selectedElement].clearElement();
} else {
# Cancel the entire Direct To page, and go back to the Navigation Map.
@ -299,16 +307,13 @@ var DirectToController =
# Reset controller if required when the page is displayed or hidden
ondisplay : func() {
me.RegisterWithEmesary();
for (var i = 0; i < size(me._cursorElements); i = i+1) {
me._cursorElements[i].unhighlightElement();
}
me._selectedElement = -1;
# Find the current DTO target, which may have been set by the page the
# use was on.
var id = me.getNavData("CurrentDTO");
me.page.IDEntry.setValue(id);
me.loadDestination(id);
me.setCursorElement(0);
},
offdisplay : func() {
me.DeRegisterWithEmesary();

View file

@ -18,7 +18,45 @@ var DirectToStyles =
loadStyles : func() {
me. clearStyles();
me.Styles.XXX = {};
me.Styles.DME = {};
me.Styles.DME.debug = 1; # HACK for benchmarking/debugging purposes
me.Styles.DME.animation_test = 0; # for prototyping animated symbols
me.Styles.DME.scale_factor = 0.4; # 40% (applied to whole group)
me.Styles.DME.line_width = 3.0;
me.Styles.DME.color_tuned = [0,1,0]; #rgb
me.Styles.DME.color_default = [1,1,0]; #rgb
me.Styles.APT = {};
me.Styles.APT.scale_factor = 0.4; # 40% (applied to whole group)
me.Styles.APT.line_width = 3.0;
me.Styles.APT.color_default = [0,0.6,0.85]; #rgb
me.Styles.APT.label_font_color = me.Styles.APT.color_default;
me.Styles.APT.label_font_size=28;
me.Styles.TFC = {};
me.Styles.TFC.scale_factor = 0.4; # 40% (applied to whole group)
me.Styles.WPT = {};
me.Styles.WPT.scale_factor = 0.5; # 50% (applied to whole group)
me.Styles.RTE = {};
me.Styles.RTE.line_width = 2;
me.Styles.FLT = {};
me.Styles.FLT.line_width = 3;
me.Styles.FIX = {};
me.Styles.FIX.color = [1,0,0];
me.Styles.FIX.scale_factor = 0.4; # 40%
me.Styles.VOR = {};
me.Styles.VOR.range_line_width = 2;
me.Styles.VOR.radial_line_width = 1;
me.Styles.VOR.scale_factor = 0.6; # 60%
me.Styles.APS = {};
me.Styles.APS.scale_factor = 0.25;
},
clearStyles : func() {

View file

@ -119,13 +119,58 @@ getUserWaypoints : func()
return [];
},
# Set up a DirectTo a given ID, with optional VNAV altitude offset.
# There are multiple cases here:
# 1) If there's no flightplan, create one to the DTO location.
# 2) If there's a flightplan and the ID matches a waypoint on the flightplan,
# then skip to that waypoint on the flightplan.
# 3) If the ID matches an airway on the current leg of the flightplan, then
# create an additional leg to the top of the flightplan to that airway waypoint.
# (TODO)
setDirectTo : func(param)
{
var id = param.id;
var alt_ft = param.alt_ft;
var offset_nm = param.offset_nm;
var fp = flightplan();
var wp_idx = -1;
if (fp != nil) {
# We've already got a flightplan, so see if this WP already exists.
for (var i = 0; i < fp.getPlanSize(); i = i + 1) {
var wp = fp.getWP(i);
if ((wp.wp_name != nil) and (wp.wp_name == id)) {
# OK, we're assuming that if the names actually match, then
# they refer to the same ID. So jump to that index.
wp_idx = i;
break;
}
}
}
if (wp_idx != -1) {
# Found the waypoint in the plan, so skip to it.
fp.current = idx;
} else {
# No flightplan, or waypoint not found, so use the GPS DTO function.
# Hokey property-based interface.
setprop("/instrumentation/gps/scratch/ident", id);
setprop("/instrumentation/gps/scratch/altitude-ft", 0);
setprop("/instrumentation/gps/scratch/latitude-deg", 0);
setprop("/instrumentation/gps/scratch/longitude-deg", 0);
setprop("/instrumentation/gps/command", "direct");
}
},
# Return the current DTO location to use
getCurrentDTO : func()
{
return me._currentDTO;
},
# Set the current DTO location to use
# Set the current DTO location to use
setCurrentDTO : func(id)
{
me._currentDTO = id;
@ -182,6 +227,10 @@ RegisterWithEmesary : func()
notification.EventParameter.Value = controller.getCurrentDTO();
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "SetDirectTo") {
controller.setDirectTo(notification.EventParameter.Value);
return emesary.Transmitter.ReceiptStatus_Finished;
}
}
}
return emesary.Transmitter.ReceiptStatus_NotProcessed;

View file

@ -10,6 +10,12 @@ var NavigationMap =
],
};
# Center the map's origin, modified to take into account the surround.
obj._group.setTranslation(
fg1000.MAP_FULL.CENTER.X - (1024/2),
fg1000.MAP_FULL.CENTER.Y - (768/2)
);
obj.MFDMap = obj._group.createChild("map");
obj.MFDMap.setScreenRange(689/2.0);
@ -47,15 +53,9 @@ var NavigationMap =
# Make it move with our aircraft:
obj.MFDMap.setController("Aircraft position", "current-pos"); # from aircraftpos.controller
# Center the map's origin, modified to take into account the surround.
obj.MFDMap.setTranslation(
fg1000.MAP_FULL.CENTER.X,
fg1000.MAP_FULL.CENTER.Y
);
var r = func(name,vis=1,zindex=nil) return caller(0)[0];
# TODO: we'll need some z-indexing here, right now it's just random
foreach(var type; [r('GRID'),r('DTO',0),r('TFC',0),r('APT'),r('DME'),r('VOR'),r('NDB'),r('FIX',0),r('RTE'),r('WPT'),r('FLT'),r('WXR',0),r('APS')] ) {
foreach(var type; [r('GRID'),r('DTO',0),r('TFC',0),r('APT'),r('DME'),r('VOR'),r('NDB'),r('FIX',0),r('GPS'),r('RTE'),r('WPT'),r('FLT'),r('WXR',0),r('APS')] ) {
obj.MFDMap.addLayer(
factory: canvas.SymbolLayer,
type_arg: type.name,

View file

@ -84,7 +84,7 @@ var NavigationMapController =
new : func (page, svg)
{
var obj = { parents : [ NavigationMapController, MFDPageController.new(page) ] };
obj.current_zoom = 8;
obj.current_zoom = 13;
obj.declutter = 0;
obj.airways = 0;
obj.page = page;