FlyingCoder Posted May 2, 2019 Report Posted May 2, 2019 Hello, i am trying to get the G-Force of my plane. Im using Aerosoft A320 and my form showed me my G is 1 when im on the runway and not moving. When i took off, the G doesnt make much different tbh. I am using VB.NET to develop. Hope to get some help :) This is my code Private gForce As New Offset(Of UInteger)(&H11BA) Dim getGForce As Single = (gForce.Value / 625) GForceTxt.Text = getGForce.ToString()
Pete Dowson Posted May 2, 2019 Report Posted May 2, 2019 3 hours ago, FlyingCoder said: Private gForce As New Offset(Of UInteger)(&H11BA) The offsets list actually suggests dividing by 625. And by dividing an integer by an integer you will get an integer, losing the fractional part, so even if it is 1.99 you will be getting 1. Copy to a floating point variable before dividing, to retain the fractional part. But offset 11BA is the original one dating from FS98 days (I think). If you are using FSX or later try the double floating point value at offset 1140. You won't get any better, and that needs no conversion. Pete
FlyingCoder Posted May 3, 2019 Author Report Posted May 3, 2019 Hi pete, i modified the code Dim getGForce As Double = CDbl(gForce.Value) / 625 I tested and there is float point. But the thing is , when my G goes below zero, it will be 103 or 104 which is very very weird.
Pete Dowson Posted May 3, 2019 Report Posted May 3, 2019 4 hours ago, FlyingCoder said: Hi pete, i modified the code Dim getGForce As Double = CDbl(gForce.Value) / 625 I tested and there is float point. But the thing is , when my G goes below zero, it will be 103 or 104 which is very very weird. But you are still reading offset 11BA, as as an UNSIGNED integer (UInteger). Why haven't you switched to offset 1140, which is already a Double, and doesn't need the /625. Pete
FlyingCoder Posted May 3, 2019 Author Report Posted May 3, 2019 Okay i will try this. By the way, how am i able to check if i am at an airport?
Pete Dowson Posted May 3, 2019 Report Posted May 3, 2019 20 minutes ago, FlyingCoder said: By the way, how am i able to check if i am at an airport? Not easily. The standard way is by checking your Lat/Lon/Alt against the database of airports (e.g one of those generated by MakeRunways). Or you could check the surface type (there's an offset for that). Tarmac or concrete or other hard-standings might be a clue, unless you've landed on a road. But this won't tell you which airport it is. Maybe others can help here. Possibly there are other ways. Ask on the AVSIM forums. Pete
FlyingCoder Posted May 3, 2019 Author Report Posted May 3, 2019 I just found out using Paul Henty's guide. Thanks anyway! Pete. Appreciate you help
FlyingCoder Posted May 3, 2019 Author Report Posted May 3, 2019 Hey pete, how do i check or get the Lat/Lon against the database of airport. I generated using makerunway already
Paul Henty Posted May 3, 2019 Report Posted May 3, 2019 Hi, This is fairly easy if you're using version 3.x of my DLL. Have a look at the Example Code application, under "Airports Database", form "DB003_FindingAirportsInRange". If you don't have the Example Code application you can download it from the website: http://fsuipc.paulhenty.com/#downloads You can amend this example easily to find if an airport close enough so that the player is 'at' the airport. For example within 5km. (And check if the player is on the ground). Paul
FlyingCoder Posted May 3, 2019 Author Report Posted May 3, 2019 Hi Paul, i am using your example now. I'm trying to get the airport like without the gate and without having me to put the ICAO itself.
Paul Henty Posted May 3, 2019 Report Posted May 3, 2019 Yes. Just use the code in DB003_FindingAirportsInRange. Ask for airports within 5km airports.InRangeOfKilometres(5). If you get any back and the aircraft is on the ground then you can assume that the player is at that airport. Paul
FlyingCoder Posted May 3, 2019 Author Report Posted May 3, 2019 Got ya. I did what you said but this is what i got FSUIPC.FsAirportCollection This is my code. Is there a way for me get just the value? Like just one value. Dim airports As FsAirportCollection = FSUIPCConnection.AirportsDatabase.Airports airports = airports.InRangeOfNauticalMiles(2) getAirport = airports.ToString()
FlyingCoder Posted May 3, 2019 Author Report Posted May 3, 2019 Update, paul i did this airports(0).ToString() and i got this XWSS: WSSS Dummy
Paul Henty Posted May 3, 2019 Report Posted May 3, 2019 Is your plane at Singapore Changi airport? Do you have third-party scenery (add-on) for that airport? If 'yes' then It looks like the scenery developer has put a fake airport in. Is there anything at index 1? airports(1).ToString() If that has the correct airport then you'll need to go through each runway in the array and look for the first one that doesn't begin with an X. Paul
FlyingCoder Posted May 3, 2019 Author Report Posted May 3, 2019 Managed to sort it out! I did below to get the icao of the airport instead of WSSS: Changi. Now it works perfect airport(1).icao
Paul Henty Posted May 3, 2019 Report Posted May 3, 2019 Okay but the fake XWSS airport is still in index 0. If you use index 1 for other airports it won't work. That's why you need to search through the array to get the first ICAO that doesn't start with X. Paul
FlyingCoder Posted May 4, 2019 Author Report Posted May 4, 2019 Hi paul, i just realised that. Anyway, im trying what you asked to do. Search through the array but im not sure if im doing it the right way. This is how i did it but i kept getting Not in any airport. For Each item As FsAirport In airports If item.ICAO = getDeptICAO Then Noairportlbl.Text = "" arrdebuglbl.Text = "" GreenText1.Value = "You are at your departure location!" GreenText2.Value = 10 ElseIf item.ICAO = getArrivalICAO Then Noairportlbl.Text = "" deptdebuglbl.Text = "" GreenText1.Value = "You are at your destination location!" GreenText2.Value = 10 'ElseIf airports(0).ICAO = "" Then ' deptdebuglbl.Text = "" ' arrdebuglbl.Text = "" ' Noairportlbl.Text = "Not in any airport" Else deptdebuglbl.Text = "" arrdebuglbl.Text = "" Noairportlbl.Text = "Not in any airport" End If Next
Paul Henty Posted May 5, 2019 Report Posted May 5, 2019 You're searching through the entire list, overwriting the results for each one. So you end up with the results for the last item every time. This might work if you only have one airport in range, but if there are more it won't work. You need to do something like this: ' Find Closest Airport that doesn't start with X Dim closestAiport As FsAirport = airports.Find(Function(ap) Not ap.ICAO.StartsWith("X")) ' Test if this is the Dept or Arrival Noairportlbl.Text = "Not in any airport" If (closestAiport IsNot Nothing) Then If closestAiport.ICAO = getDeptICAO Then Noairportlbl.Text = "" GreenText1.Value = "You are at your departure location!" GreenText2.Value = 10 ElseIf closestAiport.ICAO = getArrivalICAO Then Noairportlbl.Text = "" GreenText1.Value = "You are at your destination location!" GreenText2.Value = 10 End If End If Paul
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now