Jump to content
The simFlight Network Forums
idoen

Cant read nearest icao in c#

Recommended Posts

On 11/26/2017 at 11:26 PM, BenBaron said:

So this looks quite similar in unreliability to me like using SimConnect's RequestFacilitiesList with the SIMCONNECT_FACILITY_LIST_TYPE.AIRPORT parameter which I was testingbefore.

Benny, with reference to the above, have you by any chance got a small simple program which demonstrated the unreliability of the returns from that SimConnect function?  If so, would you be willing to share the source and EXE so that I can supply it by way of demonstration to both DoveTail (for FSX-SE -- they've already responded to my requests and would like some way of getting into it), and probably L-M (from whom I'm still awaiting a response).

These larger developers do tend to like these things handed to them on a plate! ;-)

If not I'll see if I can knock something up, by it won't be for a while as I'm pretty well tied up.  It would be nice to be able to get back earlier whilst they are in the mood to look at it.

Maybe there's an SDK example of this call? I only just thought of that, so I'll go look tomorrow.

Thanks,
Pete

 

Share this post


Link to post
Share on other sites
9 hours ago, Pete Dowson said:

Benny, with reference to the above, have you by any chance got a small simple program which demonstrated the unreliability of the returns from that SimConnect function?  If so, would you be willing to share the source and EXE so that I can supply it by way of demonstration to both DoveTail (for FSX-SE -- they've already responded to my requests and would like some way of getting into it), and probably L-M (from whom I'm still awaiting a response).

These larger developers do tend to like these things handed to them on a plate! ;-)

If not I'll see if I can knock something up, by it won't be for a while as I'm pretty well tied up.  It would be nice to be able to get back earlier whilst they are in the mood to look at it.

Maybe there's an SDK example of this call? I only just thought of that, so I'll go look tomorrow.

Thanks,
Pete

 

Hi Pete,

at the instant, I don't have something quick to show, either, because I did all my testing for a certain project on one demonstrator which is full of crap, now ;). Would need to declutter it first. In the end, it is only a simple listbox which is showing the nearest airports on a button click. Hard to believe that quite a huge developer isn't capable of producing this theirself ;). But if you think something simple as this would prove useful, I could scramble the above together, again and send it to you.

Although I didn't test it on P3D myself, as I only run FSX:SE on my development Notebook, this was the relevant part of the P3D SDK sample documentation I used to educate myself on the facility.

Greets, Benny

Share this post


Link to post
Share on other sites
18 minutes ago, BenBaron said:

Although I didn't test it on P3D myself, as I only run FSX:SE on my development Notebook, this was the relevant part of the P3D SDK sample documentation I used to educate myself on the facility.

Thanks. I found the C++ version of the MS-provided example now, in the SDK. That should be sufficient. i'll test with that here.

Pete

 

Share this post


Link to post
Share on other sites

The SDK example here:
    Core Utilities Kit\SimConnect SDK\Samples\FacilitiesData
works very well and demonstrates the problem easily.

I wonder if any of the other Facilities lists obtained by this function are also incomplete? 

Pete

 

Share this post


Link to post
Share on other sites
4 hours ago, Pete Dowson said:

The SDK example here:
    Core Utilities Kit\SimConnect SDK\Samples\FacilitiesData
works very well and demonstrates the problem easily.

I wonder if any of the other Facilities lists obtained by this function are also incomplete? 

Pete

 

Well, I don't know for sure, but in this thread the last post describes that all of those lists seem to be unreliable at one point or another. He connects it with subscribing to more than 2 different types of facilities.

Benny

Share this post


Link to post
Share on other sites
1 hour ago, BenBaron said:

Well, I don't know for sure, but in this thread the last post describes that all of those lists seem to be unreliable at one point or another. He connects it with subscribing to more than 2 different types of facilities.

Well, currently I only subscribe to the one, so that's not really the case.

I have got both DoveTail and L-M looking at it, probably at quite a low priority (after all, it's been like this since the function was added in FSX-SP2). But I'll keep track of it.

Even if L-M do fix it, I think it will be for P3D4 only. I doubt whether they'll do anything more now with P3D3.

Pete

 

Share this post


Link to post
Share on other sites
On 29.11.2017 at 6:18 PM, Pete Dowson said:

Well, currently I only subscribe to the one, so that's not really the case.

I have got both DoveTail and L-M looking at it, probably at quite a low priority (after all, it's been like this since the function was added in FSX-SP2). But I'll keep track of it.

Even if L-M do fix it, I think it will be for P3D4 only. I doubt whether they'll do anything more now with P3D3.

Pete

 

Interested to see, if they do anything about it, at all.

Did some further tests with P3Dv3 at my home computer. The result is definately different than what I am seeing in FSX:SE and also "somehow" more reliable. At least EDDC, EDDT and EGLL are now in the list that is returned by SimConnect when I am positioned at those airports. KJFK on the other hand, is still not :-/.

Greets, Benny

Share this post


Link to post
Share on other sites
1 hour ago, BenBaron said:

Did some further tests with P3Dv3 at my home computer. The result is definately different than what I am seeing in FSX:SE and also "somehow" more reliable. At least EDDC, EDDT and EGLL are now in the list that is returned by SimConnect when I am positioned at those airports.

Well, they are usually not included here, in P3D4. They seem to be much more reliably included if they are loaded at the start-up menu, not via the "go to airport" menu entry.

Pete

 

Share this post


Link to post
Share on other sites
On 28.11.2017 at 11:20 PM, Paul Henty said:

Hi Benny,

The database is just in-memory, internal the the DLL. There are no external files produced...

Hi Paul,

did some quick tests with my demonstrator and works like a charm, so far. A huge thumbs up for such great work!

I have got two "feature questions", if they are possible and not to hard to implement.

The first one could  be fairly easy to implement, for my understanding, given the already in-place files-to-database-algorithm for the makerunways files:

 In the g5.csv file, the last values can be the airlines those Gates are typically allocated for, looking like this, for example:

LSZH,E,64,47.461383,8.551179,23.0,64.7,8,7G_,BAW,UAL,AAL,EZY,AWE,USA,QTR,SIA,AUI,ELY,CYP,AFL,MGX,DAL,PGT,RJA,ACA,UAE,SIA,SAA,THA,UAL

 I didn't find anything about it in an instance of the FSGates class, or maybe I overlooked it? If not, maybe you could add a list with an "FSAirlinesCollection" class for each FSGate and split the airline strings as class "FSAirline" into this list?

The second one might be harder to implement and I don't know if it is doable at all: would it be possible to add a reference to the relevant AIPlaneInfo class object to the FSGate class, if a gate is occupied by AI-Traffic?  

Thanks in advance for your considerations and hard work.

All the best, Benny

Share this post


Link to post
Share on other sites

Hi Benny,

Thanks for trying it out.

I saw the airline info in the documentation. but for some reason my G5.csv doesn't have any airlines listed at all. So I didn't bother with them. Maybe I don't have the right kind of scenery or traffic add-on. But since they do get populated, I will add them. They are just strings so I'll probably make it a list of strings rather than create a new airline class.

Adding the AIPlane object to the gate is certainly possible and a good idea. I'll add that as well.

If the database is loaded, I will also make it link the other way - from AIPlane to the FsAirport (origin/destination) and FsGate.

I'll post a new version here for you to try; I should be able to do this at the weekend.

Paul

 

 

Share this post


Link to post
Share on other sites
8 hours ago, Paul Henty said:

Hi Benny,

Thanks for trying it out.

I saw the airline info in the documentation. but for some reason my G5.csv doesn't have any airlines listed at all. So I didn't bother with them. Maybe I don't have the right kind of scenery or traffic add-on.

 

 

Yes..it depends on the used scenery. Normally, most good Addon sceneries have those gate assignments. But I guess the default ones don't.

Very nice that you are going to implement my suggestions. Looking forward to it.

Greets, Benny

Share this post


Link to post
Share on other sites

Hi Benny,

Attached is the updated DLL.

The FsGate now has an Airlines property which is just a List<string> of the airline codes.

The AITraffic is now integrated with the database.

If the database has been loaded then the all of the new properties (described below) will be updated when you call AITrafficServices.RefreshAITrafficInformation(). You don't ever need to reload the database.
 

New Properties...

AiPlaneInfo

DepartureAirportInfo - Holds the FsAirport object for the plane's departure aiport
DestinationAirportInfo - Holds the FsAirport object for the plane's destination airport
RunwayAssignedInfo - Holds the FsRunway object for the runway assigned for takeoff/landing (Null if none assigned)
GateInfo - Holds the FsGate object assigned to the AIPlane (Null if none assigned)
IsOnRunway - bool - True if AIPlane is currently on its assigned runway
IsAtGate - bool - True if AIPlane is currently at its assigned gate
FsAirport

AiTrafficDepartures - A collection of all AIPlanes which have this airport as their departure airport
AiTrafficArrivals - A collection of all AIPlanes which have this airport as their arrival airport
FsRunway

AiTrafficDepartures - A collection of all departing AIPlanes assigned to this runway
AiTrafficArivals - A collection of all arriving AIPlanes assigned to this runway
AiPlaneOnRunway - If an AIPlane is on this runway its AIPlaneInfo object will be here or else null
FsGate

AIPlaneAssigned - The AIPlaneInfo object of the AI Plane assigned to this gate. Null if no plane assigned.
IsAIPlaneAtGate - bool - True if the assigned AI Plane is currently at this gate.

 

Paul

 

Edited by Paul Henty
Deleted DLL, later version below

Share this post


Link to post
Share on other sites
15 hours ago, Paul Henty said:

Hi Benny,

Attached is the updated DLL.

The FsGate now has an Airlines property which is just a List<string> of the airline codes.

The AITraffic is now integrated with the database.

If the database has been loaded then the all of the new properties (described below) will be updated when you call AITrafficServices.RefreshAITrafficInformation(). You don't ever need to reload the database.
 

New Properties...

Hi Paul,

awesome...thanks for your work. I will let you know, how it goes when I had time to work with it. 

You and Pete, have a nice first advent.

All the best, Benny  

Share this post


Link to post
Share on other sites

Hi Paul,

I noticed one thing: once I call FSUIPCConnection.AirportsDatabase.Load(), my RAM usage jumps by around 120 MB. I guess, this is to be expected as there are a lot of strings involved which are loaded into memory. Apart from the fact that we have enough memory available nowadays, so this shouldn't be a huge problem, let me make one suggestion for improvement efficiency-wise:

As, at least for my application, I am only going to use a fraction of all available airports, maybe you could add an overload for FSUIPCConnection.AirportsDatabase.Load(), which takes a list of strings as parameter containing all the ICAO codes you are interested in during this session and then only include those into the database? This way, the memory consumption could be reduced considerably, most probably. 

But I don't know your dlls architecture...so if this was too much of a hassle, no urgent need to bother with it ;-).

Plus, I don't know if the airport database is supposed to be freed on FSUIPCConnection.Close(). If not, maybe you could add an explicit call to unload the database, so you are clearing all the internal references to the datatables making them eligible for garbage collection.

Greets, Benny 

Edited by BenBaron

Share this post


Link to post
Share on other sites

Hi Benny,

Here's a new version with the requested changes.

There is now a Clear() method on the AirportsDatabase object. You can call that if your app no longer needs the database to free up the memory. (It'll be marked for GC so it won't be instant).

There is now an overload of Load() that takes a Hashset<string>. Populate this hashset with the ICAO codes (all CAPS) of the airports you are interested in. These will be the only airports that will be loaded.

I've also optimised the parsing of the large runways.xml file, so it should be a bit quicker. On my machine it's down from 3 seconds to 2.

Paul

FSUIPCClient3.0_RC6.zip

  • Thanks 1

Share this post


Link to post
Share on other sites

Hi Paul,

so far, everything is working quite well, but I noticed one weird thing:

Upon calling FSUIPCConnection.AirportsDatabase.SetReferencePosition() in a timer I get some sort of spontaneous horizontal aircraft shifts within the simulator where the plane suddenly seems to be relocated some meters left or right. If I don't call it, the shifts disappear and the shorter the timer intervall, the more shifts do occur. They also occur in slew mode. This is in P3Dv3. 

I am supposed to call this before every call to FSUIPCConnection.AirportsDatabase.Airports.InRangeOfNauticalMiles(), right?

Maybe you got an idea what might be causing this as I don't know what SetReferencePosition() does in the background :-).

Greets, Benny

Share this post


Link to post
Share on other sites

Yes, you should call SetReferencePosition() regularly if the player is moving.

This sounds similar to a problem I found and fixed recently. Can you please try the version attached; I think it will fix it.

If it's still a problem I'll look into it some more.

Paul

FSUIPCClient3.0_RC6.zip

Share this post


Link to post
Share on other sites
15 hours ago, Paul Henty said:

Yes, you should call SetReferencePosition() regularly if the player is moving.

This sounds similar to a problem I found and fixed recently. Can you please try the version attached; I think it will fix it.

If it's still a problem I'll look into it some more.

Paul

FSUIPCClient3.0_RC6.zip

Very nice, Paul. Thank you very much...this seems to have fixed it. No position shift occured during my last testing.

Greets, Benny

Share this post


Link to post
Share on other sites

Hi Paul,

so here comes a new question :) :

I simply wasn't able to test this out yet, but wanted to ask you beforehand:

The facility to check, if a parking spot is occupied by AI, does it also take online traffic into account? Please correct me if I am wrong, but I guess no, as you might be using the internal AI table to query for the relevant information like departure airport, arrival airport etc, which, of course, cannot be filled in for online traffic. But as the online traffic is normally injected as AI and thus should be generally visible, maybe you could check them the same way like you do with the player? I guess, you are doing a check with a rectangle there to determine if the player is at a specific gate or not... . Thanks in advance.

Greets, Benny

Share this post


Link to post
Share on other sites

Hi Benny,

I don't know anything about online traffic (I've never use it) so I'm not too sure about this.

If the online planes appear in FSUIPC's AI traffic table then it would be possible.  If they don't have an airport/runway/gate assigned then the current code won't show them at a gate, even if they are. But, I could change the code to handle this.

When you get time, can you check if the online planes do in fact appear in the AI Traffic table, and if so, tell me what info is filled in for them.

I can then simulate this by injecting my own entry and then see if I can change the code to detect these planes at gates/runways. At the moment the code relies on the assigned runway/gate so if they are missing for online traffic I'll need a new strategy.

Thanks,

Paul

 

Share this post


Link to post
Share on other sites

Ok, I will test this when I get back home to my system where I am also flying online.

I don't know how you are checking if the user plane is at a certain parking spot, but I thought that if the online planes appear in the AI Table (which I think they do as they are only AI objects which were released from the simulator control and are controlled by e.g. the IVAO pilot client software) with just their coordinates you could possibly take those and perform the same check like you do with the user plane. If it works, might definately be a neat feature ;).

Benny

Share this post


Link to post
Share on other sites

Yes, I can use the position to check if they are at the gate. It would just need a slight change in the code as I only check one gate at the moment - the one the AI aircraft is assigned. If the onlines planes don't have a gate assigned then I'll need to search a number of gates to see if they are there.

Paul

Share this post


Link to post
Share on other sites

Hi Paul,

a happy new year to you.

I did some tests regarding online traffic at IVAO: as I expected, the 3 static lists for AI traffic are filled and information like position, altitude, speed, identifier and such are visible.  Of course, there is no information on departure, destination or gates available.

So, maybe you can work from there?

Greets, Benny

Share this post


Link to post
Share on other sites

Hi Benny,

Happy New Year to you too.

That all sounds great. I can make the changes based on that information.

Paul

  • Like 1

Share this post


Link to post
Share on other sites

The code is done, but I just want to check one thing... for the IVAO traffic are the ID's of the AiPlaneInfos positive or negative?

Let me know, and I'll make the final adjustments and post a new DLL for you.

Thanks,

Paul

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.