Jump to content
The simFlight Network Forums

Recommended Posts

Posted

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()

 

Posted
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

 

Posted

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.

Posted
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

 

Posted
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

 

Posted

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

Posted

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

Posted

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()

 

Posted

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

Posted

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

Posted

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

 

Posted

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

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.