Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,728
  • Joined

  • Days Won

    78

Everything posted by Paul Henty

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. Hi Benny, Happy New Year to you too. That all sounds great. I can make the changes based on that information. Paul
  10. 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
  11. 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
  12. Do you mean just to move the player's aircraft? What is the Aircraft_ID? Paul
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
×
×
  • 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.