Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Content count

    813
  • Joined

  • Last visited

  • Days Won

    24

Everything posted by Paul Henty

  1. fsuipcclient for p3d 64bit

    No problem motuslechat, I havn't taken offence at anything you wrote. I really appreciate everyone's enthusiasm for the new version. I'm just keen to let everyone know that improvements are on the way in terms of distribution and keeping track of versions. If there's anything you want to try out, let me know and I'll get you some sample code... Kind Regards, Paul
  2. fsuipcclient for p3d 64bit

    I've updated the post above with the new change log and the latest DLL (RC6). There is no documentation for any of the new features yet, not even on the intellisense. I'm working on a new "example project" which will be the documentation for version 3. It's about 50% done. When this is finished I can release V3. Everything will be on a cloud drive so the latest stable and beta versions will be available in a central place. I should have it done by the end of the year. I know the current situation is a bit of a mess but please bear with it for another month while I sort it all out. Paul
  3. Cant read nearest icao in c#

    Hi Benny, Here's a new version with the requested changes. There is now a Clear() method on the AirportsDatabase object. You can call that if your app no longer needs the database to free up the memory. (It'll be marked for GC so it won't be instant). There is now an overload of Load() that takes a Hashset<string>. Populate this hashset with the ICAO codes (all CAPS) of the airports you are interested in. These will be the only airports that will be loaded. I've also optimised the parsing of the large runways.xml file, so it should be a bit quicker. On my machine it's down from 3 seconds to 2. Paul FSUIPCClient3.0_RC6.zip
  4. FSUIPC direc to or via WIDEFS

    It will be 'OK'. The DLL is still connected to the WideClient.exe which is still sending data to the DLL. (This data will be the last values as it last got from WideServer before the connection was lost.) FSUIPCConnection.IsConnectedToWideClient will still be true. Also FSUIPCConnection.IsConnectionOpen() will also still be true. As long as the DLL can talk to WideClient.exe it will consider that it has a valid connection. When the network connection is lost, your application will still receive data, but it will be 'frozen in time' until the network connection is restored. If you want to check for the network connection being lost, you can monitor offset 0x337E (See the documentation). This is a counter that should change with each Process(). If you get the same number back a few times then you can assume the network connection between WideClient and WideServer has been lost. Paul
  5. Cant read nearest icao in c#

    Hi Benny, Attached is the updated DLL. The FsGate now has an Airlines property which is just a List<string> of the airline codes. The AITraffic is now integrated with the database. If the database has been loaded then the all of the new properties (described below) will be updated when you call AITrafficServices.RefreshAITrafficInformation(). You don't ever need to reload the database. New Properties... AiPlaneInfo DepartureAirportInfo - Holds the FsAirport object for the plane's departure aiport DestinationAirportInfo - Holds the FsAirport object for the plane's destination airport RunwayAssignedInfo - Holds the FsRunway object for the runway assigned for takeoff/landing (Null if none assigned) GateInfo - Holds the FsGate object assigned to the AIPlane (Null if none assigned) IsOnRunway - bool - True if AIPlane is currently on its assigned runway IsAtGate - bool - True if AIPlane is currently at its assigned gate FsAirport AiTrafficDepartures - A collection of all AIPlanes which have this airport as their departure airport AiTrafficArrivals - A collection of all AIPlanes which have this airport as their arrival airport FsRunway AiTrafficDepartures - A collection of all departing AIPlanes assigned to this runway AiTrafficArivals - A collection of all arriving AIPlanes assigned to this runway AiPlaneOnRunway - If an AIPlane is on this runway its AIPlaneInfo object will be here or else null FsGate AIPlaneAssigned - The AIPlaneInfo object of the AI Plane assigned to this gate. Null if no plane assigned. IsAIPlaneAtGate - bool - True if the assigned AI Plane is currently at this gate. Paul
  6. Cant read nearest icao in c#

    Hi Benny, Thanks for trying it out. I saw the airline info in the documentation. but for some reason my G5.csv doesn't have any airlines listed at all. So I didn't bother with them. Maybe I don't have the right kind of scenery or traffic add-on. But since they do get populated, I will add them. They are just strings so I'll probably make it a list of strings rather than create a new airline class. Adding the AIPlane object to the gate is certainly possible and a good idea. I'll add that as well. If the database is loaded, I will also make it link the other way - from AIPlane to the FsAirport (origin/destination) and FsGate. I'll post a new version here for you to try; I should be able to do this at the weekend. Paul
  7. Cant read nearest icao in c#

    Hi Benny, The database is just in-memory, internal the the DLL. There are no external files produced. The airport data is stored in an FsAirport class which are all stored in a single List<FsAirport>. This collection can then be used in the normal ways including filtering with LINQ (either extension methods or the query language). The data is read from the various output files from MakeRunways. These are a mixture of XML and CSV. These are placed in the main FS folder by MakeRunways every time you run it. When you add new scenery you need to rerun Makerunways. I just read those current files from the main FS folder. The initial read and parsing takes about 3 seconds on my machines here, which is quite old now (about 7 years). This only has to be done once when your application starts and after that the operations on the database are instant. I'm still optimising so this parse time might improve. For the 'airports in-range' operations you call a method that sets a reference point. This can be any Lon/Lat, an airport or, if nothing is specified the DLL will read the current player Lon/Lat automatically and use that. When you set the reference point each airport is updated with the distance from that point and its relative bearing. After setting the reference point you can use a helper method or plain LINQ to query all airports within a certain distance, and any other requirements as well. To use the database, call the load() method AFTER the connection is open: (Note, you must have the makerunways files in the main FS folder). FSUIPCConnection.AirportsDatabase.Load(); Then you can get a specific airport or query the database with LINQ. e.g: // Get airport by ICAO FsAirport heathrow = db.Airports["EGLL"]; // get list of airports with 'ranch' in the name and order by name List<FsAirport> ranchList = db.Airports.FindAll(ap => ap.Name.ToLower().Contains("ranch")).OrderBy(ap => ap.Name).ToList(); // Same as above, but done using LINQ Query var ranchListQuery = from ap in db.Airports where ap.Name.ToLower().Contains("ranch") orderby ap.Name select ap; List<FsAirport> ranchList2 = ranchListQuery.ToList(); To use the distance/bearing feature, set a reference position. Here we just use the player position by passing no parameters. // Set reference position to player db.SetReferencePosition(); Now you can get airports in range using the helper method: // Get all airports within 50nm // (InRange method automatically sorts by distance) List<FsAirport> inRange = db.Airports.InRangeOfNauticalMiles(50); You can further narrow down the list using the WithRunway helper method, or a LINQ Query. // Get all airports within 50nm with ILS and has a runway over 1500m. List<FsAirport> inRange2 = db.Airports.InRangeOfNauticalMiles(50).WithRunway(runway => runway.ILSInfo != null && runway.LengthMeters >= 1500); // Save as above but with LINQ Query var inRangeQuery = from ap in db.Airports where ap.DistanceNauticalMiles <= 50 && (from rw in ap.Runways where rw.ILSInfo != null && rw.LengthMeters >= 1500 select rw).Count() > 0 orderby ap.DistanceNauticalMiles select ap; List<FsAirport> inRange3 = inRangeQuery.ToList(); There is a quite a bit of information about airports, runways, helipads, coms frequencies and gates. The property names will appear on the Intellisense, but I haven't added any comments yet. Paul
  8. Cant read nearest icao in c#

    I've recently added a new feature in the DLL that reads various data files from Pete's MakeRunways program. This creates an database in memory of all airports (with runways) which you can query with LINQ. It can also return a list of airports within a certain range of the player. It requires you (and users if you have them) to download and run the MakeRunways program. If you're interesting in trying this out/testing it let me know and I'll post some example code here. Paul
  9. Cant read nearest icao in c#

    I tried here with EDDC and I'm not getting that back in the list. The nearest reported is EDBZ. FSUIPC4 gets most of its data from SimConnect so it's probably using that same call to get this airport list. Paul
  10. Cant read nearest icao in c#

    Hi Benny, It should work. I have the same version of FSX:SE and FSUIPC as you and it's fine here: private Offset<string> nearestICAO = new Offset<string>(0x0658, 4); private Offset<string> secondNearestICAO = new Offset<string>(0x066C, 4); FSUIPCConnection.Process(); MessageBox.Show("Nearest airport is " + this.nearestICAO.Value + ", then " + this.secondNearestICAO.Value); Try monitoring offset 0658 using the logging features of FSUIPC. Display on the FS Window like this... There'll be a few extra characters at the end because the string isn't 0 terminated. But just make sure the first 4 are correct. If the logged value is not okay then you'll need to ask Pete about it in the main support forum. If it is okay, then there is something wrong in your program, or the version of the DLL you're using. I've attached the latest for you to try in this case. Note however that it only targets the .Net 4.0 framework (not Client Profile). It's also okay if your program uses a later version of the framework. Paul FSUIPCClient3.0_RC5.zip
  11. vb.net detect value changes

    The only way is to monitor all the possible offsets and see which one changes. There's no way I know of to get the addresses of offsets that change during a period of time. Paul
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
×