Re: [Flightgear-devel] MP chat BUGs

2008-02-15 Thread Csaba Halász
On Wed, Dec 26, 2007 at 3:13 AM, Csaba Halász <[EMAIL PROTECTED]> wrote:
>
>  - not sure how to properly handle the case when no transmitter is found

Added a timer to close the dialog.

Anybody interested in this?

-- 
Csaba/Jester
Index: gui/dialogs/chat-menu.xml
===
RCS file: /var/cvs/FlightGear-0.9/data/gui/dialogs/chat-menu.xml,v
retrieving revision 1.2
diff -u -r1.2 chat-menu.xml
--- gui/dialogs/chat-menu.xml   11 Dec 2007 15:20:00 -  1.2
+++ gui/dialogs/chat-menu.xml   15 Feb 2008 17:51:51 -
@@ -160,9 +160,18 @@
 # something appropriate, such as "Cessna", "Boeing".
 type = split(" ", type)[0];
   }
+  
+  # Get the tuned-in station
+  var transmitter = 
findtransmitter(getprop("/instrumentation/comm/frequencies/selected-mhz"));
+  if (transmitter == nil) {
+gui.popupTip("No station in range.");
+settimer(func { fgcommand("dialog-close", 
props.Node.new({"dialog-name": "chat-menu"})); }, 0);
+
+return;
+  }
 
   # Get the nearest airport.
-  var airport = airportinfo();
+  var airport = airportinfo(transmitter.lat, transmitter.lon);
   
   # Get the complement of each runway to create a full set.
   foreach (var rwy; keys(airport.runways)) {
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] MP chat BUGs

2007-12-25 Thread Csaba Halász
On Dec 18, 2007 9:10 PM, Stuart Buchanan <[EMAIL PROTECTED]> wrote:
> Csaba wrote:
> > On Dec 18, 2007 6:53 PM, AnMaster  wrote:
> > >
> > > Much better would be getting the closest airport with a
> > matching
> >
>  tower frequency
> > > than just using the nearest airport.
> >
> > Excellent idea, I second that.
>
>
> Unfortunately this is a limitation of the Nasal interface to the airport 
> information. At the moment, we can only retrieve the closest airport.
>
> It is a nice idea, and I will see whether the interface can be enhanced to 
> include search criteria.

Attached patches (can be applied to both branches) expose a radio
transmitter search function for Nasal and update the chat-menu to use
it.

Known problems/limitations:
- not sure how to properly handle the case when no transmitter is found
- hardcoded to first comm frequency, should make that selectable or something
- the underlying FGCommList::FindByFreq function is not guaranteed to
return the nearest/strongest station (see comment there). Probably not
an issue.
- very limited number of approach and ground frequencies under data/ATC
- Nasal function could take more arguments for more detailed search
- the function name is a little misleading, any suggestions?

Comments welcome.

-- 
Csaba/Jester
Index: src/Scripting/NasalSys.cxx
===
RCS file: /var/cvs/FlightGear-0.9/source/src/Scripting/NasalSys.cxx,v
retrieving revision 1.97
diff -u -r1.97 NasalSys.cxx
--- src/Scripting/NasalSys.cxx  5 Dec 2007 10:57:51 -   1.97
+++ src/Scripting/NasalSys.cxx  26 Dec 2007 01:51:10 -
@@ -30,6 +30,8 @@
 #include 
 #include 
 
+#include 
+
 #include "NasalSys.hxx"
 
 static FGNasalSys* nasalSys = 0;
@@ -581,6 +583,46 @@
 return aptdata;
 }
 
+// Returns information about the nearest transmitter for the given frequency
+// or nil if none in range.
+static naRef f_findtransmitter(naContext c, naRef me, int argc, naRef* args)
+{
+if (argc != 1 || !naIsNum(args[0])) naRuntimeError(c, "findtransmitter() 
expects 1 argument: freq");
+
+double lat = fgGetDouble("/position/latitude-deg");
+double lon = fgGetDouble("/position/longitude-deg");
+double elev = fgGetDouble("/position/altitude-ft");
+double freq = args[0].num;
+
+ATCData data;
+bool found = current_commlist->FindByFreq(lon, lat, elev, freq, &data); 
+
+if (!found) {
+return naNil();
+}
+
+naRef result = naNewHash(c);
+
+#define HASHSET(s,l,n) naHash_set(result, naStr_fromdata(naNewString(c),s,l),n)
+HASHSET("ident", 4, naStr_fromdata(naNewString(c),
+const_cast(data.ident.c_str()), data.ident.length()));
+HASHSET("name", 4, naStr_fromdata(naNewString(c),
+const_cast(data.name.c_str()), data.name.length()));
+
+static const char* type_strings[] = { "invalid", "atis", "ground", 
"tower", "approach", "departure", "enroute", "unknown" };
+const int type_strings_count = sizeof(type_strings) / sizeof(const char*);
+const char* type_string = data.type >= type_strings_count ? 
type_strings[type_strings_count - 1] : type_strings[data.type];
+
+HASHSET("type", 4, naStr_fromdata(naNewString(c),
+const_cast(type_string), strlen(type_string)));
+   
+HASHSET("lat", 3, naNum(data.lat));
+HASHSET("lon", 3, naNum(data.lon));
+HASHSET("elevation", 9, naNum(data.elev));
+#undef HASHSET
+
+return result;
+}
 
 // Table of extension functions.  Terminate with zeros.
 static struct { const char* name; naCFunction func; } funcs[] = {
@@ -602,6 +644,7 @@
 { "geodtocart", f_geodtocart },
 { "geodinfo", f_geodinfo },
 { "airportinfo", f_airportinfo },
+{ "findtransmitter", f_findtransmitter },
 { 0, 0 }
 };
 
Index: gui/dialogs/chat-menu.xml
===
RCS file: /var/cvs/FlightGear-0.9/data/gui/dialogs/chat-menu.xml,v
retrieving revision 1.2
diff -u -r1.2 chat-menu.xml
--- gui/dialogs/chat-menu.xml   11 Dec 2007 15:20:00 -  1.2
+++ gui/dialogs/chat-menu.xml   26 Dec 2007 01:54:28 -
@@ -160,9 +160,16 @@
 # something appropriate, such as "Cessna", "Boeing".
 type = split(" ", type)[0];
   }
+  
+  # Get the tuned-in station
+  var transmitter = 
findtransmitter(getprop("/instrumentation/comm/frequencies/selected-mhz"));
+  if (transmitter == nil) {
+gui.popupTip("No station in range.");
+return;
+  }
 
   # Get the nearest airport.
-  var airport = airportinfo();
+  var airport = airportinfo(transmitter.lat, transmitter.lon);
   
   # Get the complement of each runway to create a full set.
   foreach (var rwy; keys(airport.runways)) {
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direc

Re: [Flightgear-devel] MP chat BUGs

2007-12-18 Thread Stuart Buchanan
Csaba wrote:
> On Dec 18, 2007 6:53 PM, AnMaster  wrote:
> >
> > Much better would be getting the closest airport with a
> matching
> 
 tower frequency
> > than just using the nearest airport.
> 
> Excellent idea, I second that.


Unfortunately this is a limitation of the Nasal interface to the airport 
information. At the moment, we can only retrieve the closest airport.

It is a nice idea, and I will see whether the interface can be enhanced to 
include search criteria.

-Stuart



  __
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com


-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] MP chat BUGs

2007-12-18 Thread Csaba Halász
On Dec 18, 2007 6:53 PM, AnMaster <[EMAIL PROTECTED]> wrote:
>
> Much better would be getting the closest airport with a matching tower 
> frequency
> than just using the nearest airport.

Excellent idea, I second that.

-- 
Csaba/Jester

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


[Flightgear-devel] MP chat BUGs

2007-12-18 Thread AnMaster
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Using the new feature that allows pre-made lines to be said using the - key is
often impossible:
For example when I was on an approach to runway 28R of KSFO it suggested an
airport that was behind me, though closer. Screenshot:

Much better would be getting the closest airport with a matching tower frequency
than just using the nearest airport.

Screenshot of the above mentioned approach:
http://rage.kuonet.org/~anmaster/flightgear/screenshots/bugs/mp-chat-20071218/fgfs-screen-010.png

As a result this function is unusable in areas with many close airport (like
around KSFO, the default airport)
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFHaAkkWmK6ng/aMNkRCjPWAKCGPOmO+ZUYO8OmcjRqyiFxKxpcBgCgycIz
Sio3OnvLciofju8Y0x2OIyQ=
=MQh1
-END PGP SIGNATURE-

-
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel