diff --git a/Aircraft/Instruments-3d/FG1000/MFDPages/IntersectionInfo.svg b/Aircraft/Instruments-3d/FG1000/MFDPages/IntersectionInfo.svg new file mode 100644 index 000000000..f3773500f --- /dev/null +++ b/Aircraft/Instruments-3d/FG1000/MFDPages/IntersectionInfo.svg @@ -0,0 +1,426 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + Zoom nm + + NORTH UP + + + + KSFOF + + INTERSECTION + K + S + F + F + F + + + INFORMATION + N 56 45.29 + + + NEAREST VOR + VOR + E 56 45.78 + 123 + 23nm + N CEN USA + RAD + DIS + + + diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/NavDataInterface.nas b/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/NavDataInterface.nas index 22efbfe63..03aac063a 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/NavDataInterface.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/Interfaces/NavDataInterface.nas @@ -65,7 +65,7 @@ getNearestAirports : func() }, # Find the nearest nav aids of a given type within 200nm, to a maximum of 25. -getNavDataWithinRange: func(type) +getNavDataWithinRange: func(params) { # To make this more efficient for areas with a high density of fixes, we'll try # a small radius first and expand until we have reached 200nm or have 25 nav aids. @@ -74,7 +74,12 @@ getNavDataWithinRange: func(type) while ((radius <= 200) and (size(navdata) < 25)) { radius = radius + 50; - navdata = findNavaidsWithinRange(radius, type); + if ((params["lat"] == nil) and (params["lon"] == nil)) { + navdata = findNavaidsWithinRange(radius, params.type); + } else { + navdata = findNavaidsWithinRange(params.lat, params.lon, radius, params.type); + + } } if (size(navdata) > 25) { diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas index 557cf1611..2c2e49350 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPage.nas @@ -130,11 +130,10 @@ setTextElement : func(symbolName, value) { }, setTextElementLat : func(symbolName, value) { - var degrees_part = int(value); - - if (degrees_part == nil) { + if ((value == nil) or (int(value) == nil)) { me.setTextElement(symbolName, "_ __°__.__'"); } else { + var degrees_part = int(value); var minutes_part = 100.0 * (value - degrees_part); if (value < 0.0) { me.setTextElement(symbolName, sprintf("S %2d°%.2f'", -degrees_part, -minutes_part)); @@ -145,11 +144,10 @@ setTextElementLat : func(symbolName, value) { }, setTextElementLon : func(symbolName, value) { - var degrees_part = int(value); - - if (degrees_part == nil) { + if ((value == nil) or (int(value) == nil)) { me.setTextElement(symbolName, "____°__.__'"); } else { + var degrees_part = int(value); var minutes_part = 100.0 * (value - degrees_part); if (value < 0.0) { me.setTextElement(symbolName, sprintf("W%3d°%.2f'", -degrees_part, -minutes_part)); @@ -159,6 +157,21 @@ setTextElementLon : func(symbolName, value) { } }, +setTextElementBearing : func(symbolName, brg) { + if ((brg == nil) or (brg == "")) { + me.setTextElement(symbolName, "___°"); + } else { + me.setTextElement(symbolName, sprintf("%i°", brg)); + } +}, + +setTextElementDistance : func(symbolName, dst) { + if ((dst == nil) or (dst == "")) { + me.setTextElement(symbolName, "___nm"); + } else { + me.setTextElement(symbolName, sprintf("%.1fnm", dst)); + } +}, # Function to undo any colors set by display_toggle when loading a new menu resetMenuColors : func() { diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfo.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfo.nas index 03a818fbe..55e062dc2 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfo.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfo.nas @@ -26,12 +26,78 @@ var IntersectionInfo = ], }; + obj.crsrIdx = 0; + + # Dynamic text elements in the SVG file. In the SVG these have an "IntersectionInfo" prefix. + textelements = [ + "ID", + "Region", + "Lat", + "Lon", + "VORID", + "VORCRS", + "VORDST" + ]; + + obj.addTextElements(textelements); + + # Data Entry information. Keyed from the name of the element, which must + # be one of the textelements above. Each data element maps to a set of + # text elements in the SVG of the form [PageName][TextElement]{0...n}, each + # representing a single character for data entry. + # + # .size is the number of characters of data entry + # .chars is the set of characters, used to scroll through using the small + # FMS knob. + obj.dataEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + + obj.Map = fg1000.NavMap.new( + obj, + obj.getElement("NavMap"), + #[360, 275], + #[fg1000.MAP_PARTIAL.CENTER.X, fg1000.MAP_PARTIAL.CENTER.Y], + [860,400], + #"rect(345, 233, -345, -233)", + "", + -50, + 0, + 1); + obj.topMenu(device, obj, nil); obj.setController(fg1000.IntersectionInfoController.new(obj, svg)); + obj.update(nil,nil); return obj; }, + + update : func(navdata, vordata) { + if (navdata != nil) { + me.setTextElementLat("Lat", navdata.lat); + me.setTextElementLon("Lon", navdata.lon); + me.setTextElement("ID", navdata.id); + + me.Map.getController().setPosition(navdata.lat, navdata.lon); + me.Map.show(); + } else { + me.setTextElementLat("Lat", nil); + me.setTextElementLon("Lon", nil); + me.setTextElement("ID", "#####"); + me.Map.hide(); + } + + if (vordata != nil) { + var crsAndDst = courseAndDistance(navdata, vordata); + me.setTextElement("VORID", vordata.id); + me.setTextElementBearing("VORCRS", vordata.crs); + me.setTextElementDistance("VORDST", vordata.dst); + } else { + me.setTextElement("VORID", ""); + me.setTextElement("VORCRS", ""); + me.setTextElement("VORDST", ""); + } + }, + offdisplay : func() { me._group.setVisible(0); @@ -42,11 +108,16 @@ var IntersectionInfo = me.device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0); me.device.svg.getElementById(name).setColor(1.0,1.0,1.0); } + me.getElement("NavMap").setVisible(0); + me.Map.setVisible(0); me.getController().offdisplay(); }, ondisplay : func() { me._group.setVisible(1); me.mfd.setPageTitle(me.title); + + me.getElement("NavMap").setVisible(1); + me.Map.setVisible(1); me.getController().ondisplay(); }, topMenu : func(device, pg, menuitem) { @@ -54,6 +125,4 @@ var IntersectionInfo = pg.resetMenuColors(); device.updateMenus(); }, - - }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfoController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfoController.nas index 9273324b6..8f81cd931 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfoController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfoController.nas @@ -29,40 +29,101 @@ var IntersectionInfoController = return obj; }, - # Input Handling handleCRSR : func() { me._crsrToggle = (! me._crsrToggle); if (me._crsrToggle) { + me._page.dataEntry.highlightElement(); } else { - me._page.hideCRSR(); + me._page.dataEntry.unhighlightElement(); } return emesary.Transmitter.ReceiptStatus_Finished; }, handleFMSInner : func(value) { if (me._crsrToggle == 1) { - # Scroll through whatever is the current list + me._page.dataEntry.incrSmall(value); return emesary.Transmitter.ReceiptStatus_Finished; } else { - # Pass to the page group controller to display and scroll through the page group menu return me._page.mfd.SurroundController.handleFMSInner(value); } }, handleFMSOuter : func(value) { if (me._crsrToggle == 1) { + me._page.dataEntry.incrLarge(value); return emesary.Transmitter.ReceiptStatus_Finished; } else { - # Pass to the page group controller to display and scroll through the page group menu return me._page.mfd.SurroundController.handleFMSOuter(value); } }, handleEnter : func(value) { if (me._crsrToggle == 1) { + var id = me._page.dataEntry.enterElement(); + me.getIntersection(id); return emesary.Transmitter.ReceiptStatus_Finished; } else { return emesary.Transmitter.ReceiptStatus_NotProcessed; } }, + handleClear : func(value) { + if (me._crsrToggle == 1) { + me._page.dataEntry.clearElement(); + return emesary.Transmitter.ReceiptStatus_Finished; + } else { + return emesary.Transmitter.ReceiptStatus_NotProcessed; + } + }, + 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. + getIntersection : func(id) { + var navdata = nil; + var vordata = nil; + + # Use Emesary to get the intersection + var notification = notifications.PFDEventNotification.new( + "MFD", + me.getDeviceID(), + notifications.PFDEventNotification.NavData, + {Id: "NavAidByID", Value: { id: id, type : "fix" } } ); + + 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. Should handle duplicates. + navdata = retval[0]; + + # Get the nearest VOR to the intersection + var params = { lat: navdata.lat, + lon: navdata.lon, + type : "vor" }; + + 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]); + vordata = {}; + vordata.id = retval[0].id; + vordata.crs = crsAndDst[0]; + vordata.dst = crsAndDst[1]; + } + } + + # Display the retrieved data. + me._page.update(navdata, vordata); + }, # Reset controller if required when the page is displayed or hidden ondisplay : func() { @@ -72,4 +133,6 @@ var IntersectionInfoController = me.DeRegisterWithEmesary(); }, + + }; diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestIntersections/NearestIntersectionsController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestIntersections/NearestIntersectionsController.nas index fac71458c..710afd9f3 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestIntersections/NearestIntersectionsController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestIntersections/NearestIntersectionsController.nas @@ -99,7 +99,7 @@ var NearestIntersectionsController = "MFD", me.getDeviceID(), notifications.PFDEventNotification.NavData, - {Id: "NavDataWithinRange", Value: type}); + {Id: "NavDataWithinRange", Value: { type: type } }); var response = me._transmitter.NotifyAll(notification); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestNDB/NearestNDBController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestNDB/NearestNDBController.nas index d87781948..2e8173dac 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestNDB/NearestNDBController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestNDB/NearestNDBController.nas @@ -99,7 +99,7 @@ var NearestNDBController = "MFD", me.getDeviceID(), notifications.PFDEventNotification.NavData, - {Id: "NavDataWithinRange", Value: type}); + {Id: "NavDataWithinRange", Value: { type : type } }); var response = me._transmitter.NotifyAll(notification); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestVOR/NearestVORController.nas b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestVOR/NearestVORController.nas index e185a1348..2a9ad6775 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestVOR/NearestVORController.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/NearestVOR/NearestVORController.nas @@ -140,7 +140,7 @@ var NearestVORController = "MFD", me.getDeviceID(), notifications.PFDEventNotification.NavData, - {Id: "NavDataWithinRange", Value: type}); + {Id: "NavDataWithinRange", Value: { type: type } }); var response = me._transmitter.NotifyAll(notification); diff --git a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap.nas b/Aircraft/Instruments-3d/FG1000/Nasal/NavMap.nas index 9207ecc00..816bf49d2 100644 --- a/Aircraft/Instruments-3d/FG1000/Nasal/NavMap.nas +++ b/Aircraft/Instruments-3d/FG1000/Nasal/NavMap.nas @@ -266,7 +266,7 @@ var NavMap = { me._map.show(); }, hide : func() { - me._map.hide(); + if (me._map != nil) me._map.hide(); if (NavMap.LAZY_LOADING) me._map = nil; }, setVisible : func(visible) { @@ -274,7 +274,7 @@ var NavMap = { if (NavMap.LAZY_LOADING) me.createMapElement(); me._map.setVisible(visible); } else { - me._map.setVisible(visible); + if (me._map != nil) me._map.setVisible(visible); if (NavMap.LAZY_LOADING) me._map = nil; } },