Saturday, April 11, 2015

Traffic Optimizer for FSX/P3D

Traffic Optimizer and FSX-SE

Some people have reported issues while running the optimizer with FSX-SE. While I did buy the SE, I haven't got around to install it and test. Till I get around to that, please search the original FSX and P3D threads over at avsim for possible solutions.

The most common solution was reinstalling SP1 Simconnect from:

...\Lockheed Martin\Prepar3D v2\redist\Interface\FSX-SP1\retail\lib

or from the FSX SDK folder:

...\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Core Utilities Kit\SimConnect SDK\LegacyInterfaces\FSX-SP1

Also some people reported that they could not access the link:


This link does work. Some companies, including where I work, block mediafire website. So that might be the issue. I would suggest accessing it from your home network.

I do have a minor update which gives better AI distribution in large airports, but I have got around to releasing it. I hope soon...

I'd be happy to answer any questions here directly. 

32 comments:

  1. Hi,

    Hoping you can help with my issue--posted on Avsim several months ago but no one was able to come up with a solution. Yours is a fantastic utility and I'm really missing it, but I'm not going to go back to regular FSX from FSX-SE as it's just too much of an improvement in every other way...

    I'm having a problem using this with FSX-SE (side by side installation)--I'm getting a Simconnect error as though FSX isn't running, even though Simconnect is installed:

    > Failed to connect - System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
    at Microsoft.FlightSimulator.SimConnect.SimConnect..ctor(String szName, IntPtr hWnd, UInt32 UserEventWin32, WaitHandle hEventHandle, UInt32 ConfigIndex)
    at AirTrafficManager.Main.openConnection()


    In fact, all legacy simconnects are installed, and I tried reinstalling. I also tried running it through WideFS but no luck, same exact error message.

    Any chance it's related to the issues in this thread? http://www.fsdeveloper.com/forum/threads/simconnect-dll-versions.11059/

    Thanks,
    James

    ReplyDelete
    Replies
    1. Hi James,

      I have uploaded a new version, maybe that helps. Use the same link to download again. You should see version 1.9.1.2 in the title bar.

      Apart from that the most common solution was reinstalling SP1 Simconnect from:

      ...\Lockheed Martin\Prepar3D v2\redist\Interface\FSX-SP1\retail\lib

      or from the FSX SDK folder:

      ...\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Core Utilities Kit\SimConnect SDK\LegacyInterfaces\FSX-SP1

      Have you tried that?

      Delete
    2. Also try re-installing .Net 4 from here:

      https://www.microsoft.com/en-us/download/details.aspx?id=17851

      Delete
    3. Tried reinstalling both SP1 Simconnect from the SDK folder and .Net 4. Still not working on FSX-SE, sadly.

      Forgot to mention: the Optimizer works with no problem on my original FSX boxed installation (still installed side-by-side on the same computer). This is the log for that:

      > Connection request sent ...
      > Connected to Microsoft Flight Simulator X - 10.0.61637.0
      > Connected to SimConnect - 10.0.61259.0

      So as you can see, SimConnect is indeed installed (think that's SP2, though?).

      Any other ideas? Sorry, super frustrating since this is a killer app that I'm desperately missing on my FSX-SE--makes flying out of large hubs almost impossible not to have it...

      Thanks,
      James

      Delete
    4. Can you try running it as administrator?

      Also hopefully you placed it outside of Program Files directory.

      What OS are you on and which P3D version?

      Delete
    5. Can you continue here the conversation here - http://www.flightsim.com/vbfs/showthread.php?289251-Traffic-Optimizer-for-FSX-P3D-with-FSX-SE

      Delete
    6. You mean continue the conversation here (not at flightsim.com), right? Just want to be clear.

      I always run everything as administrator, including this (it's a habit). It's not in my program files directory. And the OS is Windows 7 64-bit. Finally, it's not P3D, it's FSX-SE.

      Really appreciate all your help. Sorry for the frustrating problem...

      James

      Delete
    7. With "Here" I meant "There" on flightsim ;) Its much easier to follow on a forum.

      Which version of P3D? I am just thinking of making a P3D only version to see if solves some problems.

      Delete
    8. Sorry to have not been clearer: I'm using FSX Steam ("FSX-SE"), not P3D, so unfortunately the new version won't be much help...

      Delete
    9. Oops> Please try this one http://www.mediafire.com/download/vf6l30n9ht2nxd2/AirTrafficManagerFSX_Radar.zip

      You will need to copy the Microsoft.FlightSimulator.SimConnect.dll into the program directory. You can get it by installing the Sp1 SDK from here: http://www.fsdeveloper.com/wiki/index.php?title=SDK_Installation_(FSX)#FSX_Deluxe_SP1_users

      Delete
    10. No worries, and thanks again for working so hard to help me!

      I put the Microsoft.FlightSimulator.SimConnect.dll file from SDK\Core Utilities Kit\SimConnect SDK\lib\managed into the AirTrafficManagerFSX_Radar directory, but I'm getting the same error as before (> Failed to connect - System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.)

      Just to check, I also tried running this different (FSX_Radar) version, with the SimConnect.dll in the directory, with my old FSX boxed installation on the same drive, and it (again) works without any errors, showing it connected to Simconnect.

      Delete
    11. I just installed FSX-SE to test, but it works fine for me.

      For trial, I made a new build with the FSX-SE simconnect. Try this - http://www.mediafire.com/download/d6b10dn3mqkc70h/AirTrafficManagerFSXSE_Radar.zip

      Delete
    12. It works! Brilliant. Thank you SO much for taking the time to help. I'll put the link to the new download and an explanation in the Avsim thread on this if you don't mind--might still be others looking for a solution.

      Delete
    13. Yay! Finally one issue major issue solved. Thank you too for patiently trying this out. Please feel free to post.

      Delete
    14. Hi Duke,

      I've installed AirTrafficManager 1.9.1.3, which seems to be the latest (?), It is on a clent PC and works okay for a while, but crashes. It never lasts for a full session. I reload it and it continues for a while, then crashes. When it is working, it works well. I like the fact it remembers the settings now. Could you also make it remember it's last non-minimised Window placement and restores than next time?

      I append the crash details. Hope you can fix this!

      Thanks,
      Pete

      Problem signature:
      Problem Event Name: APPCRASH
      Application Name: AirTrafficManager.exe
      Application Version: 1.9.1.3
      Application Timestamp: 569bd51d
      Fault Module Name: MSVCR100_CLR0400.dll
      Fault Module Version: 10.0.30319.1
      Fault Module Timestamp: 4ba1dbf2
      Exception Code: c0000005
      Exception Offset: 00001b07
      OS Version: 6.1.7601.2.1.0.256.1
      Locale ID: 2057
      Additional Information 1: 0a9e
      Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
      Additional Information 3: 0a9e
      Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

      Delete
    15. Will keep in mind about the last non-min state for next release.

      Do you see a exception dialog with details button when it crashes? Or does it just dis-appear? If there is an exception dialog, then please let me know the "details" content?

      Delete
    16. The details from the exception report were included at the end of my last message. Do you not see them there, beginning "Problem signature"? I see them above.

      Here they are again:

      Problem signature:
      Problem Event Name: APPCRASH
      Application Name: AirTrafficManager.exe
      Application Version: 1.9.1.3
      Application Timestamp: 569bd51d
      Fault Module Name: MSVCR100_CLR0400.dll
      Fault Module Version: 10.0.30319.1
      Fault Module Timestamp: 4ba1dbf2
      Exception Code: c0000005
      Exception Offset: 00001b07
      OS Version: 6.1.7601.2.1.0.256.1
      Locale ID: 2057
      Additional Information 1: 0a9e
      Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
      Additional Information 3: 0a9e
      Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

      Pete

      Delete
    17. Hi Pete,

      Yes, I saw that, but it does not tell me much. What I meant was that do you see a dialog this - http://i.stack.imgur.com/i37Sc.jpg ? This has a details button to see where the exception occurred.

      Also is it P3D or FSX? And which version?

      Delete
    18. No, it is a crash into Windows, an access violation in MCVR100_CLR0400.DLL at offset 00001B07 in that module. A library routine being called with bad parameters I'd guess.

      That's the sort of dialog and details I always get if software crashes. The one in your jpg looks like something from managed code, I guess. The crash is evidently occurring in an unmanaged part? (Mind you, I've never used any form of managed code, only native code, so I probably don't know what I'm talking about).

      Both P3D 3.2 and FSX-SE (not at the same time of course). I have several things on the client PC talking to either. The PC has FSX RTM, SP1 and SP2 SimConnects installed.

      I don't have my development tools on that PC else I'd try and trap the error and give you a stack analysis. If you've no idea where to look, I'll see if it happens on one of the PCs where I do have my tools.

      Pete

      Delete
    19. BTW what on Earth IS "MSVCR100_CLR0400.dll". It looks too small to be a collection of liray functions, and analysing it using PE Explorer shows no exports! Some sort of stub for the real llibrary? All to do with managed code (which I equate almost to "interpreted code").

      Delete
    20. I also don't know. I guess its something to do with bridging between C-runtime and .Net runtime.

      Delete
    21. Hi Pete,

      I have a new version with the last window position restored, and error handling in few places to re-start the app.

      But I am afraid that this new error handling is just a shot in the dark without knowing the actual fault you are experiencing, and hence may not show any better results.

      Do you know if there are boats being deleted during the optimization? I had disabled boat optimization some time back due to random crashes, but recently re-enabled it.

      Delete
    22. Hi Duke,

      Where do I get the new version to try?

      If the error keeps recurring I'll try to install a debugger to trap it, on the PC where it happens. You really need a stack trace I'd guess.

      I don't think any boats ever got deleted during my trials. I certainly didn't notice, and I was no where near anywhere they may have been any. I'll try whacking up the boat and ship sliders and lowering the limit in your program. Not today, though. Out all day, soon ...

      Pete

      Delete
    23. Here's the new version:

      http://www.mediafire.com/download/7m5rbep2aj4f1cb/AirTrafficManagerFSX-P3D_Radar_1914.zip

      Delete
    24. Also FYI - http://thingsrandom2014.blogspot.com/2016/05/various-versions-of-traffic-optimizer.html

      Delete
    25. Thanks Duke. I shall try the 1.9.1.4 version tomorrow (Monday).

      Pete

      Delete
    26. I've now been using version 1.9.1.4 on several flights, and so far, so good -- no crashes. Mind you, I have mostly been in areas with less than my set limit of traffic.

      Never seen any boats counted or deleted yet. Maybe I need to whack up the boat sliders, or add that third party package of ships and their routes.

      One odd thing. Occasionally the automatic inclusion of the departure and arrival airports, from a loaded plan in FS, are listed by the first 4 characters of the airport name, rather than the ICAO. One instance today was a flight from Bucharest (Henri Coanda Airport) to Varna, ICAOs LROP and LBWN, and the fields were filled in as HENR and VARN.

      Pete

      Delete
    27. Thanks for the update.

      Before 1914, I did get a couple of crashes in the same location as you mentioned, this was one of the call stacks:

      > mscorlib.dll!System.Runtime.InteropServices.Marshal.PtrToStructure(System.IntPtr ptr, System.Type structureType) + 0x7d bytes
      Microsoft.FlightSimulator.SimConnect.dll!Microsoft.FlightSimulator.SimConnect.SimConnect.MarshalRegisteredPtrToObject(System.Type RecvType, uint dwID, void* pData) + 0x15 bytes
      Microsoft.FlightSimulator.SimConnect.dll!Microsoft.FlightSimulator.SimConnect.SimConnect.MarshalRECVPtrToObject(uint dwID, void* pData) + 0x1b7 bytes
      Microsoft.FlightSimulator.SimConnect.dll!.Microsoft.FlightSimulator.SimConnect.CSignalProcDelegateMarshaler.CallSignalProc(SIMCONNECT_RECV* pData, uint cbData = 44, void* pContext) + 0x47 bytes
      [Native to Managed Transition]
      [Managed to Native Transition]
      Microsoft.FlightSimulator.SimConnect.dll!Microsoft.FlightSimulator.SimConnect.SimConnect.ReceiveDispatch(Microsoft.FlightSimulator.SimConnect.SignalProcDelegate pfcnSignal) + 0xa9 bytes
      Microsoft.FlightSimulator.SimConnect.dll!Microsoft.FlightSimulator.SimConnect.SimConnect.ReceiveMessage() + 0x38 bytes
      AirTrafficManager.exe!AirTrafficManager.Main.DefWndProc(ref System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0x4b bytes
      System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0xa71 bytes
      System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) + 0x58 bytes

      ...

      I think you may know more about this.

      Notice that my VB call is AirTrafficManager.exe!AirTrafficManager.Main.DefWndProc, which calls SimConnect.ReceiveMessage(). And then finally access violation at the top. Is it possible that I have declared one of structures which receives data from simmconnet in-correctly? (Most likely the boat structure)

      So I had earlier a catch for access violation around this code:

      Catch exAccess As System.AccessViolationException

      But I read few days back that this will not normally catch access violations from non-user code. To catch those I had declare an extra vb attribute HandleProcessCorruptedStateExceptionsAttribute. So I did that and in the catch handler I issue application re-start in 1914.

      So what you may notice is, that in same scenario as you reported earlier, now the application will re-start itself. Which is fine, I guess.

      About the ICAO issues, were these flight-plans created using built-in flight-planner or an external tool? And did you notice that the program was actually preserving traffic as per the codes it was showing?

      Delete
    28. Actually, all that stuff with managed code and languages other than straight C or C++ defeats me. Sorry. If you were able to express it in the same terms and the calls and callbacks documented in the SimConnect SDK I might stand a chance. I'm a very low level programmer really -- machine code, ASM and C. C++ is okay as long as it doesn't get too buried in Classes, like all that horrible COM stuff.

      I have the original ICAO plans, but it looks like ProaTC/X makes its own and loads those -- a CLR one after Clearance, and an ARR one for arrival. It seems to delete those when the flight ends, so I've lost access to them. Next time I get the oddity with the names in AirTrafficManager I'll remember to loo at the plan at the time.

      Pete

      Delete
    29. Ah, I see that C++ equivalent is calling SimConnect_CallDispatch.

      In managed code, you need to listen for WM_USER_SIMCONNECT, which is called by SimConnect when is ready to send data to you and you need to call ReceiveMessage to actually get the data.

      // Simconnect client will send a win32 message when there is
      // a packet to process. ReceiveMessage must be called to
      // trigger the events. This model keeps simconnect processing on the main thread.

      protected override void DefWndProc(ref Message m)
      {
      if (m.Msg == WM_USER_SIMCONNECT)
      {
      if (simconnect != null)
      {
      simconnect.ReceiveMessage();
      }
      }
      else
      {
      base.DefWndProc(ref m);
      }
      }

      I'll also have a try with ProATC/X on the same routes. (What matters is what codes the AI planes are flying from/to.)

      Delete
    30. Yes, it is similar in FSUIPC, receiving a user-pre-defined message when new data is available. The data is in different formatted structures depending what it is, so the next step is Switching on the message type and casting the pointer provided in the data to the appropriate type. (I don't know if "casting" applies in the language you are using).

      This way, each entry in the data is "typed" correctly by the structure it is cast as part of, so the only way this can cause an access violation is if the casting is somehow to the wrong type, OR the structure has changed and you are using an out-of-date definition of the structures. (Or, of course, the unlikely event that data has been corrupted en route).

      Pete

      Delete
  2. I have a new version to try out, please see/follow-up here:

    http://www.flightsim.com/vbfs/showthread.php?295351-Traffic-Optimizer-for-P3D

    ReplyDelete