Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Content count

    802
  • Joined

  • Last visited

  • Days Won

    22

Paul Henty last won the day on November 14

Paul Henty had the most liked content!

Community Reputation

35 Excellent

1 Follower

About Paul Henty

  • Rank
    Advanced Member
  • Birthday 01/01/1970

Profile Information

  • Gender
    Male
  • Location
    Bristol, UK
  1. Flight Plan loaded in p3D

    Have a look at the many GPS offsets provided from 0x6000 onwards. They provide lots of details about the current flight plan. e.g. Destination, Distance & bearing to next waypoint, lon/lat of next waypoint etc. Paul
  2. Cant read nearest icao in c#

    Dim lat As Double = Double.Parse(currentRow(2), CultureInfo.InvariantCulture) Dim lon As Double = Double.Parse(currentRow(3), CultureInfo.InvariantCulture) Ah, yes. I forgot that European number formats are different. Thanks for the correction. Paul
  3. Cant read nearest icao in c#

    It works fine here on FSX Steam Edition. Private NearestICAO As Offset(Of String) = New Offset(Of String)(&H658, 4) FSUIPCConnection.Process() MessageBox.Show("Nearest Airport is " + NearestICAO.Value) It won't work on FS9 (this feature is not included in FSUIPC3), and the documentation says it doesn't work on FSX earlier than SP2. If you want a solution that will work with all sims including FS9 you will need use the makerunways files. Here is an example of a function that reads the runways.csv file produced by makerunways.exe. It assembles a list of all airports within a requested radius. First you'll need to define this structure (outside any other classes) Public Structure AirportInfo Public ICAO As String Public DistanceNM As Double Public Sub New(ICAO As String, DistanceNM As Double) Me.ICAO = ICAO Me.DistanceNM = DistanceNM End Sub End Structure Then add this function to your normal class/form: Private Function getAirportsInRangeNM(ByVal playerPos As FsLatLonPoint, ByVal radiusNM As Double) As List(Of AirportInfo) Dim AirportsInRange As List(Of AirportInfo) = New List(Of AirportInfo)() ' Search the Runways.csv file Dim foundAirports As Dictionary(Of String, Double) = New Dictionary(Of String, Double)() Dim runwaysFile As String = "E:\SteamLibrary\steamapps\common\FSX\Runways.csv" ' !!CHANGE THIS!! Using MyReader As New FileIO.TextFieldParser(runwaysFile) MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(",") While Not MyReader.EndOfData Try Dim currentRow As String() = MyReader.ReadFields() Dim icao As String = currentRow(0) Dim lat As Double = Double.Parse(currentRow(2)) Dim lon As Double = Double.Parse(currentRow(3)) ' Work out the distance from the player Dim runwayPoint As FsLatLonPoint = New FsLatLonPoint(New FsLatitude(lat), New FsLongitude(lon)) Dim distance As Double = runwayPoint.DistanceFromInNauticalMiles(playerPos) If (distance) <= radiusNM Then If (foundAirports.ContainsKey(icao)) Then ' if this runway is closer we'll use this one If distance < (foundAirports(icao)) Then foundAirports(icao) = distance End If Else foundAirports.Add(icao, distance) End If End If Catch ex As FileIO.MalformedLineException 'MsgBox("Line " & ex.Message & "is not valid and will be skipped.") End Try End While MyReader.Close() MyReader.Dispose() End Using ' Now have all the airports in range ' Add them to the output list and sort by distance For Each icao As String In foundAirports.Keys AirportsInRange.Add(New AirportInfo(icao, foundAirports(icao))) Next AirportsInRange.Sort(Function(x, y) x.DistanceNM.CompareTo(y.DistanceNM)) Return AirportsInRange End Function Note that I've hard-coded my path to the runways.csv file. If your app is not just for you, you'll need to have a variable with the users FS install path in. Here's an example of how it's used: 1. You'll need the current players lon/lat if you haven't got those already: Public playerLatitude As Offset(Of Long) = New Offset(Of Long)(&H560) Public playerLongitude As Offset(Of Long) = New Offset(Of Long)(&H568) 2. This code calls the function and displays all airports within 50nm in a message box: FSUIPCConnection.Process() ' Set up current player position Dim playerPos As FsLatLonPoint = New FsLatLonPoint(New FsLatitude(playerLatitude.Value), New FsLongitude(playerLongitude.Value)) ' get list of airports within 50nm Dim airports As List(Of AirportInfo) = getAirportsInRangeNM(playerPos, 50) ' print them out Dim msg As String = "" For Each airport As AirportInfo In airports msg += airport.ICAO + ": " + airport.DistanceNM.ToString("F0") + "NM" + vbNewLine Next MessageBox.Show(msg) The List of airports is in order of distance, the closest will be index 0. Paul
  4. Check if user is loaded in

    Hi, Some relevant offsets you might consider are: 0x3364: Byte: "Ready to fly". A 0 value here means the sim is loaded and ready to fly. 0x3365: Byte: "In Menu or Dialog": A 0 value here means the user is not in a menu or dialog. 0x0264: Short: "Paused indicator". 0 here means not paused. 0x05DC: Short: "Slew mode". 0 here means slew mode is not engaged. Maybe a combination of these might work for you. For more information on these offsets, check the documentation ( FSUIPC4 Offsets Status.pdf ) Paul
  5. Lat and long offset from the flight plan

    Okay, that looks fine too - although the Javascript wants a space between the lon and lat, not a +. Presumably you change that somewhere else. The next thing to check would be how the objects are drawn on the map. Do you pass them as decimal degrees without further processing? Did you write the map control? If so check for rounding problems (rounding too early) when you're converting the degrees to screen coordinates. Also are you sure the plane is flying on the correct course? Can't really see anything wrong at the moment. The FSUIPC side of things is fine. I'll be happy to check more of the code if you want to post it. (Use PM if you don't want it public). Paul
  6. Lat and long offset from the flight plan

    Thanks - do you process this string first before sending it to the Javascript function? N44° 49' 43.001975",W0° 42' 55.000000",+000166.00 The Javascript won't work properly on that string. Paul
  7. Lat and long offset from the flight plan

    The javascript looks fine as long as the incoming format is correct. Do you have a sample of one of your .pln files? Paul
  8. Lat and long offset from the flight plan

    The code you posted looks good to me. I can see that the .pnl files store the lat/lon as degrees and decimal minutes (e.g. E45* 36.1'). Whereas you're asking for DecimalDegrees from FSUIPC. Are you sure you've converted these two different formats correctly? E45* 36.1' would be 45.6017 in decimal degrees. If you can share some more code it might be helpful. For example, the code that converts the coordinates from the .pln and from the playerData into the values used for the map drawing. Paul
  9. Aircraft Information Offset

    Flight Number is offset 0x3130 Aircraft Types is offset 0x3160 Tail number is offset 0x313C These can all be found by searching the offsets list called "FSUIPC4 Offset Status.pdf" found in the "FSUIPC Documents" folder under the modules folder. This document will also tell you what type data is stored in each offset (these are all strings) and the size. Paul
  10. How to check if P3D is running

    You can use FSUIPCConnection.IsConnectionOpen() e.g.: if (FSUIPCConnection.IsConnectionOpen()) { FSUIPCConnection.Process(); // Process the request to FSUIPC FSUIPCConnection.Process("AircraftInfo"); // For aicraft type } However, you'll need version 3 of the DLL for this. It's not in the 2.4 version. I've attached it here. It requires .NET 4 or later, there is no build for earlier frameworks. If you don't want to upgrade then you'll need to keep track of the connection yourself. In the 2.4 download there is a sample application in C# which tracks the connection status by catching exceptions. Paul FSUIPCClient3.0_RC5.zip
  11. 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) { FSUIPCConnection.Process(); 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); newThread.Start(FSUIPCConnection.AITrafficServices); private void getAI(object data) { AITrafficServices ts = (AITrafficServices)data; while (true) { Thread.Sleep(1000); ts.RefreshAITrafficInformation(); this.Invoke((Action)populateTraffic); } } private void populateTraffic() { traffic = FSUIPCConnection.AITrafficServices.AllTraffic; this.dataGridView1.Rows.Clear(); 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. Paul
  12. It depends on the aircraft. Each will be different. Most are likely to hook into the FS control and act the same as the default aircraft, so those will work fine. However, if they don't then you need to research that particular aircraft and see what external access they provide, if any. Sometimes the manufacturer will provide 'custom controls' (aka Events) that can be sent to FS (e.g. PMDG's 737). Other times manufacturers will provide key presses to operate certain systems. Some use Local Panel Variables (aka L:VARs). Some provide no external access at all. All of these techniques can be accessed via FSUIPC, but the specifics (e.g. which control number, key and L:VAR) are different for each aircraft. You'll need to look at the documentation for the aircraft, research the forums if they have any or ask the developers directly. Paul
  13. All the offsets are documented in "FSUIPC4 Offset Status.pdf". This can be found in the "FSUIPC Documents" folder under the Modules folder. FSinterrogate isn't kept up-to-date so always use this document to find offsets. It also has useful information and comments about each offset which is missing from FSInterrogate. Yes, 0 and 1. (Check the PDF) Paul
  14. The seatbelt offset is 0x341D. Only available on FSUIPC4 & FSUIPC5. You can read and write to this offset. Dim seatbelts As Offset(Of Byte) = New Offset(Of Byte)("Seatbelts", &H341D) This will work with default aircraft but may not work with some 3rd party aircraft because they sometimes implement their own systems. Paul
  15. The code looks fine. This offset brings back the 'atc_model' value from the [General] section of the aircraft.cfg file. e.g. the bold line in the example below for the default Cessna 172: [General] atc_type=Cessna atc_model=C172 editable=0 1. Check what this value is in the aircraft.cfg file for this 787. 2. Also put a breakpoint on this line: lblAircraft.Text = aircraftType.Value and see what the Value is. There may be some strange characters. Or maybe it starts with a line feed or something. Investigating those two things might lead you to see what the problem is. If you need more help please post what you find here. Paul
×