Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,724
  • Joined

  • Days Won

    77

Everything posted by Paul Henty

  1. Thanks, I just had to make a slight change. Attached is a new DLL. It should now detect if the multiplayer IVAO traffic is at a gate. For the FsGate object, IsAIPlaneAtGate will be true and AIPlaneAssigned will contain the AIPlaneInfo for the IVAO plane. For the AIPlaneInfo object, the IsAtGate property will be true and the GateInfo will be the FsGate object where it's at. Note that the other gate info such as GateName, GateNumber and ID will not be filled in. These are the assigned gates from the FSUIPC traffic table so will still be blank. Let me know if there are any problems. I can't test it on IVAO but it did work with a plane I manually injected. Here is the change log from RC6: (Please note the breaking change). Version 3.0 RC7 ================ * Added new contructor to FsLatLonPoint to accept Lat and Lon in DecimalDegrees * Added new FsAltitide class to convert between Feet, Metres and FS Altitude Units * Added FSUIPCConnection.MoveAircraft() method. This will move the plane to the specified location, an optionally set a new Altitiude, Speed, Pitch and Bank if specified. Can also accept a Runway, Gate or Helipad from the FsDatabase, or an FsPositionSnapshot object. * Added method MoveAircraftHere() to FsRunway, FsGate and FsHelipad objects in the database. * Added property IsOnGround to AiPlaneInfo object. This lets you know if the AI Plane is on the ground or not. * BREAKING CHANGE: AiPlaneInfo - properties beginning with 'Destination' changed to 'Arrival' * Added FsPositionSnaphot class that holds information about the position of the player aircraft. This includes lon/lat/ias/bank/pitch/altitude/onground/heading This can be used manually or generated automatically by using the FSUIPCConnection.GetPositionSnaphot() method. * Injected AI Traffic (e.g. IVAO multiplayer traffic) will now have thier gate information filled in if they are at a gate. (And the Airport Database is loaded). Paul FSUIPCClient3.0_RC7.zip
  2. Yes it's done, but only for FSX and above. New version attached: RC7 Here are the changes from RC6: Version 3.0 RC7 ================ * Added new contructor to FsLatLonPoint to accept Lat and Lon in DecimalDegrees * Added new FsAltitide class to convert between Feet, Metres and FS Altitude Units * Added FSUIPCConnection.MoveAircraft() method. This will move the plane to the specified location, an optionally set a new Altitiude, Speed, Pitch and Bank is specified. Can also accept a Runway, Gate or Helipad from the FsDatabase, or an FsPositionSnapshot object. * Added method MoveAircraftHere() to FsRunway, FsGate and FsHelipad objects in the database. * Added property IsOnGround to AiPlaneInfo object. This lets you know if the AI Plane is on the ground or not. * BREAKING CHANGE: AiPlaneInfo - properties beginning with 'Destination' changed to 'Arrival' * Added FsPositionSnaphot class that hold information about the position of the player aircraft. This includes lon/lat/ias/bank/pitch/altitude/onground/heading This can be used manually or generated automatically by using the FSUIPCConnection.GetPositionSnaphot() method. Here is some example code for using the new MoveAicraft() feature: Basic Use: // Basic use: Pass the new position information. // Some parameters are nullable. Pass null to keep the current values // (e.g. to keep the current heading pass null for the heading.) // When setting the onGround flag, the new altitude and IAS values are ignored. // Example of moving the aircraft to final approach for runway 09 at EGJJ: FsLatLonPoint newLocation = new FsLatLonPoint(49.193896, -2.320686); FsAltitude newAltitude = FsAltitude.FromFeet(2000); double newHeading = 79; double newPitch = 0; double newBank = 0; double newIAS = 90; bool onGround = false; bool leavePaused = false; FSUIPCConnection.MoveAircraft(newLocation, onGround, newAltitude, newHeading, newPitch, newBank, newIAS, leavePaused); Position Snapshots: // Using Position Snapshots: // You can also pass a FsPositionSnapshot object to the move aircraft method. // This can be created manually, or automatically using the GetPositionSnapshot method. // Using this feature you can automatically save the players postion and restore it later: // To save: FsPositionSnapshot newSnapshot = FSUIPCConnection.GetPositionSnapshot(); // Later, you can restore this postion (including the IAS, Bank, Pitch, Heading and Alt) FSUIPCConnection.MoveAircraft(newSnapshot, leavePaused); Airport Database Objects: // Using Airport Database objects: // You can also pass FsGate, FsRunway and FsHelipad objects. // The database must be loaded for this to work. // This is an example of moving to Gate 1 at EGJJ FsGate gate = FSUIPCConnection.AirportsDatabase.Airports["EGJJ"].Gates["1"]; FSUIPCConnection.MoveAircraft(gate, leavePaused); Let me know if there are any problems, or you need any more help. Paul FSUIPCClient3.0_RC7.zip
  3. The code is done, but I just want to check one thing... for the IVAO traffic are the ID's of the AiPlaneInfos positive or negative? Let me know, and I'll make the final adjustments and post a new DLL for you. Thanks, Paul
  4. I've been looking at moving the Player Aircraft. For FSX and above, FSUIPC provides a good way of doing this. It's very reliable. If I don't use this special feature then it's very messy. Sometimes the altitude isn't set properly, sometimes the plane falls out of the sky etc. So I can only do this for FSX and above. For FS9, developers will need to do their own moving using the normal offsets and calling for scenery refreshes etc. I don't have FS9 so I can't come up with a method that works for both. Paul
  5. Hi Benny, Happy New Year to you too. That all sounds great. I can make the changes based on that information. Paul
  6. It might be better to ask on Just-Flight forums. Each third-party aircraft has different ways to control them so you really need to ask the manufacturer or see if there's anything in the documentation. Some aircraft just cannot be controlled because the authors have not provided any method for doing do. The most common methods of controlling third-party aircraft are: Custom FS Controls (aka Events) Local Panel Variables (aka L:Vars) Special Software Interfaces (aka SDKs) Key presses FSUIPC Mouse Macros You'll need to find out if that aircraft has any of those available to use. Paul
  7. I don't think it's possible to move AI traffic with FSUIPC, but I'll look into it. I will add the player move at least. Paul
  8. Do you mean just to move the player's aircraft? What is the Aircraft_ID? Paul
  9. Yes, I can use the position to check if they are at the gate. It would just need a slight change in the code as I only check one gate at the moment - the one the AI aircraft is assigned. If the onlines planes don't have a gate assigned then I'll need to search a number of gates to see if they are there. Paul
  10. Hi Benny, I don't know anything about online traffic (I've never use it) so I'm not too sure about this. If the online planes appear in FSUIPC's AI traffic table then it would be possible. If they don't have an airport/runway/gate assigned then the current code won't show them at a gate, even if they are. But, I could change the code to handle this. When you get time, can you check if the online planes do in fact appear in the AI Traffic table, and if so, tell me what info is filled in for them. I can then simulate this by injecting my own entry and then see if I can change the code to detect these planes at gates/runways. At the moment the code relies on the assigned runway/gate so if they are missing for online traffic I'll need a new strategy. Thanks, Paul
  11. Yes, you should call SetReferencePosition() regularly if the player is moving. This sounds similar to a problem I found and fixed recently. Can you please try the version attached; I think it will fix it. If it's still a problem I'll look into it some more. Paul FSUIPCClient3.0_RC6.zip
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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 shortcut to the database AirportsDatabase db = FSUIPCConnection.AirportsDatabase; // 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
×
×
  • 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.