Archived

This topic is now archived and is closed to further replies.

Recommended Posts

I am trying to get the airport ICAO to show on my takeoff data card. I am able to get XML A:var etc via the execute_calculator_code but getting information via the fs9_gps is proving difficult. I know it is something I am doing wrong, but what ?The CodePCSTRINGZ icao;FLOAT64 FSAPI icao_string_cb (PELEMENT_STRING pelement ){ execute_calculator_code("(C:fs9gps:WaypointAirportICAO,string)",NULL,NULL,&icao); sprintf (pelement->string,"%04.0f", icao); return icao;}This then gives me one compile error: C2440: 'return' : cannot convert from 'PCSTRINGZ' to 'FLOAT64'Take the icao from return adding 0 and it compiles but as expected returns 0 in FS. I have tried different sprintf ie "%s", declaring the varibale as different types ie CHAR etc to no avail.:-zhelp

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

> sprintf (pelement->string,"%04.0f", icao);>> return icao;>}Your return should be either zero or false...Try:PCSTRINGZ icao;case PANEL_SERVICE_PRE_UPDATE:execute_calculator_code("(C:fs9gps:WaypointAirportICAO,string)",NULL,NULL,&icao);break;FLOAT64 FSAPI icao_string_cb( PELEMENT_STRING pelement){sprintf(pelement->string,"%s", icao );return 0;}Also, the return from the call to fs9gps may well be nothing if you haven't first told fs9gps where you're a/c is currently located. IOW, you need to send it your current lat/lon position... ;)

Share this post


Link to post
Share on other sites

Already tried the code you posted Bill, and get 0. Reading the rest of the post I can see why. I have not sent lat/lon position, which seems wierd as I am asking fs to tell me where I am, but I have to tell it first :-roll

Share this post


Link to post
Share on other sites

I am now sending lat and lon positions to the fs9gps.dllcase PANEL_SERVICE_PRE_UPDATE: lat_icao = "(A:Plane Latitude,degrees) (>C:fs9gps:WaypointAirportICAO,string)"; execute_calculator_code(lat_icao,NULL,NULL,NULL); lon_icao = "(A:Plane Longitude,degrees) (>C:fs9gps:WaypointAirportICAO,string)"; execute_calculator_code(lon_icao,NULL,NULL,NULL);then asking for it to show resultsexecute_calculator_code("(C:fs9gps:WaypointAirportICAO,string)",NULL,NULL,&airport_icao);break;then displaying the string in a callbackFLOAT64 FSAPI airport_icao_string_cb (PELEMENT_STRING pelement ){ sprintf (pelement->string,"%s", airport_icao); return 0;}and I get 0.I new I would have problems getting this to work :-(

Share this post


Link to post
Share on other sites

Ok, I'm uncertain what you're actually trying to accomplish... however...WaypointAiportICAO is for airport lookup.You can't send a latitude or a longitude to it. You would send an ICAO value to it and then you would be able to read the rest of the Airport Data variables.

Share this post


Link to post
Share on other sites

EdWhat I am trying to achive is, to be able to show which airport I am sitting at on my takeoff data card. So for example if I am sitting at Gatwick then my data card should display EGKK.How can I send an ICAO value to it when I could be sitting at any number of airports in FS, plus as far as I am aware there is no variable that I can send to the fs9gps.dll which would tell it what airport I am sitting at. As you have properly guessed I am even more confused *:-* Any chance of someone posting a bit of working code showing how to set and get variables from the gps ? I have done a search, and there are few who have had this problem, but unfortunately none of them have ever post a soluition :-(

Share this post


Link to post
Share on other sites

>>Any chance of someone posting a bit of working code showing>how to set and get variables from the gps ? I have done a>search, and there are few who have had this problem, but>unfortunately none of them have ever post a soluition :-(Seems it's not possible to retrieve fs9gps class values from a classic .gau/dll gauge, probably because of instantiation issues.I've been able to work with those vars only when called within a custom DLL preloaded through DLL.XML.Anyway, more tests would be necessary to clear all doubts.Tom

Share this post


Link to post
Share on other sites

>Ed>What I am trying to achive is, to be able to show which>airport I am sitting at on my takeoff data card. So for>example if I am sitting at Gatwick then my data card should>display EGKK.>>How can I send an ICAO value to it when I could be sitting at>any number of airports in FS, plus as far as I am aware there>is no variable that I can send to the fs9gps.dll which would>tell it what airport I am sitting at. As you have properly>guessed I am even more confused *:-* The problem is you're trying to send lat/lon to the wrong variable!See this for a complete list of GPS variables and uses:http://www.fsdeveloper.com/wiki/index.php?...:_How_to_AccessNote carefully that the lat/lon variables for WaypointAirportICAO are NOT SETTABLE... ;)You have the right idea (which I gave you previously) but are simply sending lat/lon incorrectly, and using the wrong "set" of variables. Use these instead for "Nearest Airport" (which of course is the one you're currently at!)NearestAirportCurrentICAONearestAirportCurrentLatitude NearestAirportCurrentLongitude Note that you can either Get or Set the above variables depending on what you need to accomplish! :)

Share this post


Link to post
Share on other sites

case PANEL_SERVICE_PRE_UPDATE: lat_icao = "(A:Plane Latitude,degrees)(>C:fs9gps:NearestAirportCurrentLatitude,degrees)"; execute_calculator_code(lat_icao,NULL,NULL,NULL); lon_icao = "(A:Plane Longitude,degrees)(>C:fs9gps:NearestAirportCurrentLongitude,degrees)"; execute_calculator_code(lon_icao,NULL,NULL,NULL);Now you want to retrieve NearestAirportCurrentICAO... execute_calculator_code("(C:fs9gps:NearestAirportCurrentICAO,string)",NULL,NULL,&airport_icao);break;

Share this post


Link to post
Share on other sites

Thanks for the reply Tom. Pitty you can not read the airport ICAO without a custom .dll. Will have to input it manually, like I do the active runway ;(Thanksedit:Just seen your post Bill, will give it a tryThanks

Share this post


Link to post
Share on other sites

>Thanks for the reply Tom. Pitty you can not read the airport>ICAO without a custom .dll. Will have to input it manually,>like I do the active runway ;(>>Thanks>>edit:>Just seen your post Bill, will give it a tryRefresh. I just updated to correct a boo-boo on my end wrt to 'string' versus 'degrees' in the script!Also, the link I gave to the Wiki article is from an original blog entry from Susan Ashlock. Although the list is "XML Centric" take cheer in knowing that anything available from the GPS.dll is also possible in C code as well......a bit more cumbersome to be sure, but certainly possible! :)

Share this post


Link to post
Share on other sites

Bill, did you ever try calling a gps value from a .gau/dll gauge?I mean, any kind of execute_calculator_code("(C:fs9gps:etc)",etc) ?I've read so many times this should work, but I couldn't suceed in retrieving even the most basic FlightPlanIsActiveFlightPlan...I must be doing something very wrong then. Would like to see a working example on this too!Tom

Share this post


Link to post
Share on other sites

I am sorry to say that I still get 0. I noticed the boo - boo with the string which should have been degrees, so changed that. I copied my gps.dll and put it in the main FS9 folder to see if that was the problem, but still got 0. I think there must be a problem with my computer, I am off to get a hammer :-)PCSTRINGZ lat_icao;PCSTRINGZ lon_icao;PCSTRINGZ airport_icao;FLOAT64 FSAPI airport_icao_string_cb (PELEMENT_STRING pelement ){ sprintf (pelement->string,"%s", airport_icao); return 0;}case PANEL_SERVICE_PRE_UPDATE: lat_icao = "(A:Plane Latitude,degrees) (>C:fs9gps:NearestAirportCurrentLatitude ,degrees)"; execute_calculator_code(lat_icao,NULL,NULL,NULL); lon_icao = "(A:Plane Longitude,degrees) (>C:fs9gps:NearestAirportCurrentLongitude,degrees)"; execute_calculator_code(lon_icao,NULL,NULL,NULL); execute_calculator_code("(C:fs9gps:NearestAirportCurrentICAO,string)",NULL,NULL,&airport_icao);break;Will test some more tomorrow.Thanks

Share this post


Link to post
Share on other sites

The GPS does not return results instantly.You'll have to repeatedly update the lat/lon inputs... and scan the value of NearestAirportItemsNumber until it shows there's a value.

Share this post


Link to post
Share on other sites

>Bill, did you ever try calling a gps value from a .gau/dll>gauge?>I mean, any kind of>execute_calculator_code("(C:fs9gps:etc)",etc) ?>>I've read so many times this should work, but I couldn't>suceed in retrieving even the most basic>FlightPlanIsActiveFlightPlan...>>I must be doing something very wrong then. >>Would like to see a working example on this too!Um, yes... some of the Avidyne's data is retrieved that way. Of course, I cannot share the actual code, but I can certainly attest that the method does work!

Share this post


Link to post
Share on other sites

>I am sorry to say that I still get 0. I noticed the boo - boo>with the string which should have been degrees, so changed>that. I copied my gps.dll and put it in the main FS9 folder to>see if that was the problem, but still got 0. I think there>must be a problem with my computer, I am off to get a hammer>:-)>>PCSTRINGZ lat_icao;>PCSTRINGZ lon_icao;>PCSTRINGZ airport_icao;Er, lat_icao and lon_icao should be float vars since they are in degrees... :)FLOAT64 lat_icao = 0 ;FLOAT64 lon_icao = 0 ;PCSTRINGZ airport_icao;

Share this post


Link to post
Share on other sites

Ok, I have to ask... do you know how to program in C/C++???

Share this post


Link to post
Share on other sites

>>>>PCSTRINGZ lat_icao;>>PCSTRINGZ lon_icao;>>PCSTRINGZ airport_icao;>>Er, lat_icao and lon_icao should be float vars since they are>in degrees... :)>>FLOAT64 lat_icao = 0 ;>FLOAT64 lon_icao = 0 ;>PCSTRINGZ airport_icao;Bill, try to not confuse Russell more than he is by now :-)...take a look again and you'll see that his code is right...Tom

Share this post


Link to post
Share on other sites

You're right Ed, in this case he should make the code a bit different to work, because the return to NearestAirport is asyncronius.Tom

Share this post


Link to post
Share on other sites

>>Um, yes... some of the Avidyne's data is retrieved that way.>Of course, I cannot share the actual code, but I can certainly>attest that the method does work!Well, I have serious doubts that there are calls to execute_calculator_code and fs9gps classes in the way we are discussing here -always speaking of .gau/dll gauges, NOT common dlls-In fact, I've found that not even custom classes (C: ) created by myself work, which tends to make me think this function cannot instantiate classes just by parsing their names on the stack. Notice that the stack is cleaned up after each call, meaning it doesn't work by gauge basis but instead by function basis, which gives a logical reason for this behavior.Unless there is someone that can post or comment a way to overcome with this limitation, I would have to stand on my reasons...but will keep testing indeed!Tom

Share this post


Link to post
Share on other sites

>>>>>>PCSTRINGZ lat_icao;>>>PCSTRINGZ lon_icao;>>>PCSTRINGZ airport_icao;>Bill, try to not confuse Russell more than he is by now>:-)...take a look again and you'll see that his code is>right...Argh! Sorry 'bout that. Of course it is, since the prototype is clearly:BOOL (FSAPI *execute_calculator_code) (PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);I'll go put on my hair-shirt and hang by my thumbs for awhile as penance... :-lol It may well be that the simplest method would be to use the IGaugeCCallback as described in the TrafficInfo.doc file in the FS9 SDK...

Share this post


Link to post
Share on other sites

>>It may well be that the simplest method would be to use the>IGaugeCCallback as described in the TrafficInfo.doc file in>the FS9 SDK...Yeah, I guess that would the simplest way, building a derivated class from fs9gps and retrieving data with ConvertStringToProperty,ConvertPropertyToString or Query. The problem is I don't have a header for the base class :-( Maybe you know somebody who has a copy ?...:-cool Tom

Share this post


Link to post
Share on other sites

>>>>It may well be that the simplest method would be to use the>>IGaugeCCallback as described in the TrafficInfo.doc file in>>the FS9 SDK...>>Yeah, I guess that would the simplest way, building a>derivated class from fs9gps and retrieving data with>ConvertStringToProperty,ConvertPropertyToString or Query. The>problem is I don't have a header for the base class :-( Maybe>you know somebody who has a copy ?...:-cool It is in the FS9 SDK. Here is the .h file though, along with the .doc 'spaining it's usage.For FS9 usage, you also need to place the TrafficInfo.dll in the Modules folder.For FSX, ACES has supplied a new fs-traffic.dll in the FSX root folder which apparently has the same interface inside, but a new name... ;)

Share this post


Link to post
Share on other sites