Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,724
  • Joined

  • Days Won

    77

Everything posted by Paul Henty

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. Thanks. What information does the flight plan contain for the navaids?
  18. Yes, but what information is already in the flight plan? I don't think I understand what you want to do. Can you confirm the following is correct? Your software has a flight plan loaded. The flight plan has a list of navaids to follow While flying, you want to show the user the next navaid and the distance to it. If that's wrong please explain what you need. Do mean mean the millisecond value? 10000 Paul
  19. Pete, can you move this into my subforum? Either way I'll take a look at it... Thanks, Paul
  20. Okay. What information does it have for each navaid? Does it have the Lon/Lat for the navaid? Or just frequency and name? It doesn't need to be quick. I would think every 10 seconds would be fine. Paul
  21. I'm not sure what you are trying to do. It looks like you want to show the distances to way points (beacons) in a flight plan. Does your software have a flight plan? Or do your users load a flight plan in Flight Sim? No need for a timer. You only need to call this once, just after the connection is open. It takes about 2-3 seconds. You don't need to call this again. FSUIPCConnection.Open() FSUIPCConnection.AirportsDatabase.Load() Paul
  22. I can't really help with that specifically. I don't know those databases and I don't know SQLite. I can only give you a general method of how it's done. I can't write the code for this, sorry. Yes, that's a good way of doing it. FSUIPC has offsets that give you the Lat/Lon of the ADF and VOR beacons tuned to the radios. Here is an example of getting the Lat/Lon of the beacons on the ADF1 and VOR1 radios: Dim adf1Lat As Offset(Of FsLatitude) = New Offset(Of FsLatitude)("beacons", &H1124, 4) Dim adf1Lon As Offset(Of FsLongitude) = New Offset(Of FsLongitude)("beacons", &H1128, 4) Dim vor1Lat As Offset(Of FsLatitude) = New Offset(Of FsLatitude)("beacons", &H85C, 4) Dim vor1Lon As Offset(Of FsLongitude) = New Offset(Of FsLongitude)("beacons", &H864, 4) FSUIPCConnection.Process("beacons") ' get FsLatLonPoint for the beacon tuned on ADF1 Dim adf1Location As FsLatLonPoint = New FsLatLonPoint(Me.adf1Lat.Value, Me.adf1Lon.Value) ' get FsLatLonPoint for the beacon tuned on VOR1 Dim vor1Location As FsLatLonPoint = New FsLatLonPoint(Me.vor1Lat.Value, Me.vor1Lon.Value) Me.TextBox1.Text = adf1Location.ToString() Me.TextBox2.Text = vor1Location.ToString() Here is a VB example of using the new Airports Database to do this. You must have the makerunways.exe files in the main Flight Sim folder. After making the connection to FSUIPC you must load the database using: FSUIPCConnection.AirportsDatabase.Load() Then you can use this code to get the airports within 40nm and find the active runways according to the AI Traffic. The results are displayed in a listbox called lstActiveRunways. Private Sub getActiveRunwayForNearbyAirport() ' Clear current items in results listbox Me.lstActiveRunways.Items.Clear() ' Refresh the AI traffic FSUIPCConnection.AITrafficServices.RefreshAITrafficInformation() ' get the closest airport using the database Dim db As AirportsDatabase = FSUIPCConnection.AirportsDatabase ' Set the reference position to the current player position ' This will calculate the distance from the player to the airports db.SetReferencePosition() ' Find the airports within 40nm (Closest will be first in the list) Dim within40 As FsAirportCollection = db.Airports.InRangeOfNauticalMiles(40) If within40.Count > 0 Then ' Loop through each airport For Each ap As FsAirport In within40 ' find the active arrival runway for this airport Dim runways As List(Of FsRunwayID) = FSUIPCConnection.AITrafficServices.GetArrivalRunwaysInUse(ap.ICAO) If runways.Count > 0 Then Me.lstActiveRunways.Items.Add(ap.ICAO & " (" & ap.DistanceNauticalMiles.ToString("F0") & "nm): " & runways(0).ToString()) Else Me.lstActiveRunways.Items.Add(ap.ICAO & " (" & ap.DistanceNauticalMiles.ToString("F0") & "nm): No active runway") End If Next Else Me.lstActiveRunways.Items.Add("No airports within 40nm") End If End Sub Not at the moment. I'm writing the examples for the proper release of 3.0. It's all in C# as the project is very large. Writing it twice would be too much work. I'm hoping to automatically translate it to VB when it's finished. It will take a long time to do it manually. I've attached the latest DLL. Paul FSUIPCClient3.0_RC7.zip
  23. Hi Fred, The distance between the aircraft and the navaid can be calculated using two FsLatLonPoint classes. One for the aircraft and one for the NAVAID. Something like: beaconLocation.DistanceFromInMetres(aircraftLocation) The aircraftLocation you can get from offsets 0560/0568 or 6010/6018 The location of the navaid is more of a problem. If you have a flight plan with the locations of the navaids then just check against all of them to see which is the closest. Or, you can just test them in the order they come in the flight plan. Start with the first navaid, then when the player has crossed that one, move on to the next one. You might consider that the aircraft has 'crossed' a navaid when it comes within a set distance (e.g. 1km). If you just have a database of navaids and no set route to follow then it's more difficult. It's probably not practical to measure the distance to every navaid in the database. So first you'll need to filter those navaids which are in a set range of latitude and longitude. For example you might first select navaids from the database which are 0.5 degree of latitude and longitude either side of the aircraft. This way you have fewer navaids to calculate the distance for. You can find the active runways used by the AI Traffic by passing the ICAO code of the airport to GetArrivalRunwaysInUse() or GetDepartureRunwaysInUse(). AITrafficServices ts = FSUIPCConnection.AITrafficServices; ts.RefreshAITrafficInformation(); List<FsRunwayID> arrivalRunways = ts.GetArrivalRunwaysInUse("EGLL"); if (arrivalRunways.Count > 0) { MessageBox.Show("Arrival runway for EGLL is " + arrivalRunways[0].ToString()); } else { // No information available } This only works for airports in range of the player because it needs active AI traffic at that airport, or inbound to the airport. For departure runways, ground AI is required. The player must be at the airport. For arrival runways, airborne AI is required. The player must be within 40nm of the airport. HOWEVER: As far as I know, IVAO traffic does not have assigned runways filled in. So the result is only for the normal AI Traffic. If IVAO traffic is using a different runway than the AI Traffic then there is no way to tell this. Paul
  24. Great, thanks for testing MoveAircraft(). The documentation for the use of the AiTrafficServices (including AiPlaneInfo) is in the 2.4 package. See the example application and the user guide pdf: http://forum.simflight.com/topic/74848-fsuipc-client-dll-for-net-version-24/ For using the new airports database see this post: http://forum.simflight.com/topic/78224-cant-read-nearest-icao-in-c/?do=findComment&comment=511147 For details about the interaction between the the database and AI traffic see this post: http://forum.simflight.com/topic/78224-cant-read-nearest-icao-in-c/?do=findComment&comment=511259 Paul
  25. Hi, Here's some code that will get both Zulu and Local into a .net DateTime. (This works with FSUIPC3 as well as it doesn't use any of the new date/time fields in FSUIPC4). private Offset<ushort> zuluYear = new Offset<ushort>("DateTime", 0x0240); private Offset<ushort> zuluDayNumber = new Offset<ushort>("DateTime", 0x023E); private Offset<byte> zuluHour = new Offset<byte>("DateTime", 0x023B); private Offset<byte> zuluMin = new Offset<byte>("DateTime", 0x023C); private Offset<byte> zuluSec = new Offset<byte>("DateTime", 0x023A); private Offset<short> localOffset = new Offset<short>("DateTime", 0x0246); FSUIPCConnection.Process("DateTime"); // Create datetime for Zulu DateTime zuluDateTime = new DateTime(zuluYear.Value, 1, 1, zuluHour.Value, zuluMin.Value, zuluSec.Value).AddDays((double)(zuluDayNumber.Value - 1)); // Create datetime for Local DateTime localDateTime = zuluDateTime.AddMinutes(localOffset.Value * -1); Paul
×
×
  • 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.