Jump to content
The simFlight Network Forums

FSUIPCClient.dll v3.0 - AI Traffic - Extended Plane Identifiers


Recommended Posts

FSUIPCClient.dll  3.0.6156.10

I'm struggling with the function 'UpdateExtendedPlaneIndentifiers()'. From the description (which is still version 2.0)  I know that this might be a time consuming function, therefore it runs in a background thread to not block the UI-thread. The reference to the AITrafficServices is provided via the ParameterizedThreadStart.

The troubles that I'm faced with are that every now and then the extended identifier values are returned quite messy (e.g. for 'Type' I'm getting the tail number, or for the 'Model' I'm getting 'n/a'). The 'normal' values which are updated using the function RefreshAITrafficInformation() are all correct.

Both function calls, UpdateExtendedPlaneIndentifiers() and RefreshAITrafficInformation() are called in a loop which is executed once per second. Maybe there is a required sequence when calling these functions? Maybe the function UpdateExtendedPlaneIndentifiers() should only be called once? Is there any code snippet around which can be used for tests?

Here's the code:

private void AiTrafficThread(object obj)
    var trafficServices = (AITrafficServices)obj;

    while (true)
        if (stopAiTraffic)    // set from 'outside' to regularly stop this thread

        if (isPaused)         // if simulator is paused ...

        trafficServices.UpdateExtendedPlaneIndentifiers(true, true, true, false);

        // 'canProcessAi' is an AutoResetEvent object which allows to securely access
        // the 'aiList' object from another thread
        if (!canProcessAi.WaitOne(1000, false)) continue;

        foreach (var plane in trafficServices.AirbourneTraffic)
            aiList.AddItem(CreateAiAircraftData(plane, true));

        foreach (var plane in trafficServices.GroundTraffic)
            aiList.AddItem(CreateAiAircraftData(plane, false));


Thanks for any help.


Link to comment
Share on other sites

Hi Urs.

I've checked this here and everything is returned correctly. I also ran the code that get the traffic on a separate thread.

Here are some thoughts/comments...

1.  trafficServices.UpdateExtendedPlaneIndentifiers() is badly named. This doesn't actually get the information. It tells the DLL to get this information when RefreshAITrafficInformation() is called. So you only need to call this once when your app starts.

2. If you have extended information turned on, it's only slow for the first time you call RefreshAITrafficInformation(). For subsequent calls the dll uses cached data. There will be a slight delay for any new AI that comes into range but it shouldn't be too bad.

3. If you are using a 3rd party traffic generator, try just using the default FS traffic and see if that's okay. Maybe its bad info from the traffic package?

4. For GA aircraft the Flight Number will be the same as the Tail Number.

5. Check the info coming from the DLL directly - maybe there's something going wrong in your code in CreateAiAircraftData().

6. Try running the traffic update on the main thread. If that fixes it then you have some kind of timing issue or thread clashing that is messing things up.


This is the code I used to check this:

I have a timer on the form updating two sliders (trackbars) for pitch and bank:

        private Offset<int> pitch = new Offset<int>(0x0578);
        private Offset<int> bank = new Offset<int>(0x57C);

        private void timer1_Tick(object sender, EventArgs e)
            this.tbPitch.Value = (int)((double)pitch.Value * 360d / (65536d * 65536d));
            this.tbBank.Value = (int)((double)bank.Value * 360d / (65536d * 65536d));

I also started a new thread for the AI traffic similar to yours:

           Thread newThread = new Thread(this.getAI);


        private void getAI(object data)
            AITrafficServices ts = (AITrafficServices)data;
            while (true)

        private void populateTraffic()
            traffic = FSUIPCConnection.AITrafficServices.AllTraffic;
            foreach (AIPlaneInfo nextPlane in traffic)
                this.dataGridView1.Rows.Add(nextPlane.ID, nextPlane.ATCIdentifier.ToString(), nextPlane.TailNumber, nextPlane.Airline, nextPlane.FlightNumber, nextPlane.AircraftType, nextPlane.AircraftModel, nextPlane.AircraftTitle);


Let me know if you need more help.



Link to comment
Share on other sites

Hi Paul,

thank you for your reply and your helpful tips.

Today I did some further tests, considering your thoughts. Unfortunately I have not yet figured out the pattern to reproduce it every time, but every now and then it still happens that some values are not set with a meaningful value.

I have created a video (duration some 5 minutes) which shows situations when it works OK, and also when it doesn't. I have also created a small test program, which is used in this video, and I would like to send the source code (C#) to you, so you can reproduce it on your system. Can you send me a PM with an email address to where I can send the download links from the video and the source code? Many thanks.


Link to comment
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
  • Create New...

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.