Jump to content
The simFlight Network Forums

Paul Henty

  • Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by Paul Henty

  1. Profiles in FSUIPC4

    Hi José, You have posted in a sub-forum about programming for FSUIPC using .NET languages. You should repost your question in the main FSUIPC support forum. http://forum.simflight.com/forum/30-fsuipc-support-pete-dowson-modules/ It's unlikely to be answered here. Paul
  2. Help with my simple program

    Hi Luke, Welcome to the Sub-forum. The best way to start is to download the full V2.4 package for my .NET FSUIPC Client DLL from here: http://forum.simflight.com/topic/74848-fsuipc-client-dll-for-net-version-24/ in that Zip you will find my DLL that you can use in your VB.NET applications. This makes it much easier to work with FSUIPC in .NET languages. Included in the Docs folder is a UserGuide.PDF that explains everything you need to know about connecting and reading/writing data. There is also a Sample Project in VB (and C#) that is a simple working application that reads data on a timer. It also shows the connection/disconnection logic. That should be your first starting point to get familiar with everything. You also need to refer to Pete's list of Offsets that is found in the Modules\FSUIPC Documentation folder in the main P3D install folder. For FSUIPC4 it's called "FSUIPC4 Offset Status.pdf". I don't know what the equivalent is for FSUIPC5 but I'm sure it'll be obvious. I am soon (hopefully in February) releasing version 3 which has all sorts of new features, and much better and more extensive code examples. All your 2.4 knowledge will still apply however. Paul
  3. Vb.NET Closest NAVAIDS SQlite

    Still not enough info. I've attached the latest DLL with a debug file (.pdb). Please use this latest DLL - make sure you copy the .pdb into the same folder. With this new file, the exception report should be different, paste the new one. Paul FSUIPCClient3.0_RC7.zip
  4. Vb.NET Closest NAVAIDS SQlite

    Hi Fred, That code runs fine here. No problems. I can't really see what's going wrong without the exception details and the call stack. In the openFSUIPC() method, can you comment out the lines: Try Catch messagebox(... End Try Then run it again. You need to get the exception details and show me the call stack. Use the 'Copy Details' link and paste it here. Paul
  5. Vb.NET Closest NAVAIDS SQlite

    There should only be one place where you call Open(). It should be when your application starts. If you have added these two lines somewhere else then you should remove them. Find the original place where you call Open() and add the Load() after it. Paul
  6. Vb.NET Closest NAVAIDS SQlite

    I can't see how the disconnection would be related to reading the surface for the runway. You'll need to trace the code and set break points to see how and why the disconnection is happening. Paul
  7. PMDG events via Visual Basic 6

    Yes, I'm quite sure it's possible. I don't have VB6 any more, so I can only tell you the method, I can't give you any working code. 1. You'll need to use two offsets: &H3114 - This should be 4 bytes and an integer (Long in VB6) - This is the 'Parameter Value' &H3110 - This should also be 4 bytes and an Integer - This is the 'Control (or Event) Number' You MUST write 3114 first, then 3110. You can write both in the same process() call, just make sure 3114 goes first. To send an event to PMDG, you need the list of events from the .h file in the SDK. (PMDG_NGX_SDK.h I think) 2. If I remember correctly, the parameter is set to one of the codes for the mouse buttons. Here is an example line from the .h file #define MOUSE_FLAG_LEFTSINGLE 0x20000000 So, to send a single left mouse click you set the value of 3114 to &H20000000 3. The control (or Event) number is also in the .h file: To get the full number you need to add the event number to the value of THIRD_PARTY_EVENT_ID_MIN (69632) Here is another example line from that file... #define EVT_MCP_CMD_A_SWITCH (THIRD_PARTY_EVENT_ID_MIN + 402) To send the event for the MCP autopilot CMD A switch you need 69632 + 402 = 70034 In summary: To send a single left mouse click to the CMD A autopilot button on the MCP: Write &H20000000 to offset &H3114 Write 70034 to offset &H3110 Process(). Paul
  8. Vb.NET Closest NAVAIDS SQlite

    The code looks okay. Please check the following: a. The airport code must be all upper case. So maybe use this: Dim surfaceType As FsSurface = db.Airports(lblArrival.Text.ToUpper()).Runways(Getrunaway(lblDeparture.Text)).Surface b. The runway code must be two digits e.g. "09". "9" will not work. Plus an optional suffix of L, C or R (capitals). e.g. 09L. No spaces. These will NOT work: 9 (only one digit) 9L (only one digit) 09 L (space between 9 and L) 09l (Lower case L) These WILL work 09 36 27L 09R If you can't get it working I'll need to know more information: 1. What is the problem? Is there an error? Does it return the wrong surface, or nothing? 2. Which airport and runway are you trying? 3. What's being returned from the GetRunway() function? 4. Maybe show me the GetRunway() function. I can't really help any more with that. I can write code for something that complicated that you can just paste directly into your application. The code I wrote there is just an example or how it could be done. It shows you a strategy for achieving what you want. I've no idea how to integrate it into your application because I don't know your application. I can give general advice but you need to write your own code. Paul
  9. C# Get correct pitch and bank values

    These offsets are 4-byte integers so should be declared as 'int' Offset<int> playerPitch = new Offset<int>(0x0578); Offset<int> playerBank = new Offset<int>(0x057C); Here's the conversion that I use in the DLL to calculate the pitch/roll in degrees. This works fine. snapshot.PitchDegrees = ((double)playerPitch.Value * 360d) / (65536d * 65536d); snapshot.BankDegrees = ((double)playerBank.Value * 360d) / (65536d * 65536d); Paul
  10. You should really ask Dovetail (or ask on their support forums if they have any). I don't know anything about FSW. But, looking at the files you've listed, none of them look like managed libraries. Certainly .lib and .h files are for C or C++. I can't see anything there that would be any use to .NET programmers. Paul
  11. Hi Gilles, My DLL doesn't use simconnect at all. It's only an interface to FSUIPC. If FSUIPC5 ever becomes compatible with FSW then my DLL will work with that new version of FSUIPC5 without any changes. If FSUIPC5 is never compatible then my DLL will never be compatible either. I have no plans to add direct SimConnect features to the DLL. The Flight Sim developers already provide managed .NET libraries for SimConnect. Paul
  12. Reading the documentation again, I see there is sometimes a problem after reloading the 737. It's fixed by forcing FSUIPC to reconnect to SimConnect. You can do this from your code by calling: FSUIPCConnection.SendControlToFS(FSUIPCControl.ReSimConnect, 0); Try calling this after loading the 737. Other than that I have no more ideas. I've tested your code with normal offsets and it's fine. It seems the problem is with the link to PMDG, but I can't help you with that. Pete might have some suggestions if you ask up in the main forum. Or maybe he'll see this. Paul
  13. The codes look okay to me. I can't test it though because I don't have any PMDG aircraft. Have you followed these instructions in the docs to enable the interface? Paul
  14. You cannot read controls. They are write-only. To read data from the PMDG 737 you need to use the offsets provided. See the document called "Offset Mapping for PMDG 737NGX.pdf" in "Modules\FSUIPC Documents". This has a list of PMDG offsets with instructions for enabling the interface. These offsets are used just like any other. Paul
  15. Vb.NET Closest NAVAIDS SQlite

    Hi Fred, I can't think of any other ways than those I've already suggested: 1. Get back the Lon/Lat of the navaids in the flight plan from your server. 2. Get the Lon/Lat of the navaids from a database. 3. Get the Lon/Lat of the vor/adf beacon tuned on the radios. 4. Get the distance to the next navaid from the GPS offsets (but this requires a flight plan loaded). Paul
  16. Top-Down View Zoom value

    It's meant to be 0x8336, but the documentation says that SimConnect doesn't provide that information so it's not available. I've checked and it's not working with FSX:SE. You can however set a new zoom value using a 'control' if that's any use: FSUIPCConnection.SendControlToFS(FsControl.MAP_ZOOM_SET, 64); This will set the map zoom to 64. The values match the zoom readout on the screen when zooming the top-down view. Note that the other zoom controls have different units. For example, in the normal view you send 64 for 1x; 128 for 2x; 32 for 0.5x etc. Paul
  17. Vb.NET Closest NAVAIDS SQlite

    You can get the surface type (asphalt, grass etc) from the airports database: example is for Runway 09 at EGJJ. Dim db As AirportsDatabase = FSUIPCConnection.AirportsDatabase Dim surfaceType As FsSurface = db.Airports("EGJJ").Runways("09").Surface Me.txtSurface.Text = surfaceType.ToString() Dim db As AirportsDatabase = FSUIPCConnection.AirportsDatabase Dim surfaceType As FsSurface = db.Airports("EGJJ").Runways("09").Surface Me.txtSurface.Text = surfaceType.ToString() The surface wet/dry/icy/snow is available from offset 0x346, BUT it only updates when on the runway. Not in the air. Paul
  18. Vb.NET Closest NAVAIDS SQlite

    If you make your users load a flight plan (pln) in FS it will be much easier. There is lots of data available from the 'GPS' offsets starting at 0x6000. See the offsets list. e.g. there is distance to next way point (0x60EC). In this case there is no need to track the offsets yourself, it's all done by the Flight Sim. So just access the required offsets directly and display the result. What do you mean by the 'status' of a runway? Paul
  19. Vb.NET Closest NAVAIDS SQlite

    The flight plan does not need to be loaded into the simulator. Does your program have access to the lat/lat for the Navaids? Or are they are only on the server? If so, you'll need to rely on the radios being tuned and get the lat/lon from offsets 1124/1128 etc. See post #4 earlier in this thread. Otherwise just take them directly from the flight plan. Any time between the user entering the flight plan and starting the flight. If you send the flight plan to a server then that would be a good time to count the number of waypoints and set this variable. Paul
  20. Thanks for the project. I found the problem. The FSUIPCConnection.Close() method was not synchronised with the Process() method. So, while Process() was running on one thread, another thread sometimes ran Close() at the same time and unallocated the memory Process() was using. I've ran your example, connecting and disconnecting many times, and I couldn't get the error any more. Attached is version 3.0.18009.241 Let me know how it goes... Paul FSUIPCClient3.0_RC7.zip
  21. I think that's what I did: 1. I pressed Connect 2. I pressed Start UDP Then in the cockpit of the plane in FSX I switched the autoplot on. Your program turned it off. I clicked the Autopilot button quickly and it still worked with no problems. I can't make it error. Is there anything else I should do? Can you check the DLL being used with: FSUIPC.FSUIPCConnection.DLLVersion.ToString(); in the code. Make sure it returns 3.0.18004.210 Paul
  22. Hi Primo, I got it to run. I had to comment out the UDP receive code because I don't have Matlab or time to write a UDP server program. However, the multi-threaded code was still active. I stopped the code waiting for receive from UDP and just had this instead: private void XpcValueDataProcessing() { if (commDataFSUIPC.airPlaneAutoPilot_Read == "1") { commDataFSUIPC.WriteFSUIPC(0); } } It ran fine for a good few minutes. Every time I turned the autopilot on, your program turned it off again instantly. I wonder if it's the version of the DLL you are using. I've attached the latest version (the one that I tested with). Maybe this will fix things. (Note that it targets the full 4.0 framework). If you still have problems, I think you'll need to get some simpler code that shows the problem so I can reproduce it here. Paul FSUIPCClient3.0_RC7.zip
  23. Hi Primo, I can't run this code because I don't have a serial port with anything connected. I see you're using a background worker thread. It's likely that this is causing the problem. I'm not sure exactly how. If you can give me some example code that I can run that shows the problem I might be able to find what's going wrong and offer a solution. Just one comment about your code... you should not have separate offsets for reading and writing. You can use the same offset. Paul
  24. Vb.NET Closest NAVAIDS SQlite

    Okay, I understand. You need to just keep track of which navaid is next. Then monitor the distance and show the user. When the distance is under a certain number (maybe 0.5nm) then move to the next navaid. I can't write the exact code because I don't know about your flight plans. But this is a framework that you can adapt: Form level variables: Public playerLatitude As Offset(Of FsLatitude) = New Offset(Of FsLatitude)("playerPos", &H560, 8) Public playerLongitude As Offset(Of FsLongitude) = New Offset(Of FsLongitude)("playerPos", &H568, 8) Dim nextNavaidIndex As Integer = -1 Dim numberOfNavaids As Integer ' SET THIS WHEN THE FLIGHT PLAN IS LOADED Dim nextNavaidLocation As FsLatLonPoint Dim nextNavaidID As String Subs: Private Sub displayNextNavaid() If nextNavaidIndex = -1 Then getNextNavaid() End If If nextNavaidIndex < numberOfNavaids Then FSUIPCConnection.Process("playerPos") Dim playerPos As FsLatLonPoint = New FsLatLonPoint(playerLatitude.Value, playerLongitude.Value) Dim distanceNM = playerPos.DistanceFromInNauticalMiles(nextNavaidLocation) ' display on the form Me.txtNextNavaid.Text = nextNavaidID Me.txtNextNavaidDistance.Text = distanceNM.ToString("F2") ' check is player is overhead If distanceNM < 0.5 Then ' You might need to adjust this distance ' player is overhead, move to the next navaid getNextNavaid() End If Else ' No more navaids left End If End Sub Private Sub getNextNavaid() nextNavaidIndex = nextNavaidIndex + 1 ' REPLACE NEXT THREE LINES - I don't know how your flight plan is stored ' You need to get the ID and Lon/Lat of the navaid from your flight plan. ' You should use the nextNavAidIndex to tell you which navaid to get. nextNavaidID = "ID" ' Dim navaidLat As Double = "45.123456" Dim navaidLon As Double = "-2.123456" nextNavaidLocation = New FsLatLonPoint(navaidLat, navaidLon) End Sub You need to call displayNextNavaid whenever you want this information to be updated. Every 1 second (1000ms) should be fine. Paul
  25. Vb.NET Closest NAVAIDS SQlite

    Thanks. What information does the flight plan contain for the navaids?