Jump to content
The simFlight Network Forums

Fuel remaining script in VB anybody?


Recommended Posts

Hey!

Just a litle request, if anybody has a script to read the current remaining fuel of an aircraft in Visual Basic i would

be very grateful if you shared it with me.

Well, please share if you have a VB6 script that can read the fuel weight of an aircraft!

Best Regards

Patrik

Link to comment
Share on other sites

Hi BoXon,

this is my version. Might be a littlebit complicated, but it works...

' Left Tanks Quantity
    Dim FQ_gal_LM As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB80)
    Dim FQ_per_LM As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB7C)
    Dim FQ_gal_LA As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB88)
    Dim FQ_per_LA As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB84)
    Dim FQ_gal_LT As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB90)
    Dim FQ_per_LT As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB8C)

    ' Center Tanks Quantity
    Dim FQ_gal_C1 As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB78)
    Dim FQ_per_C1 As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB74)
    Dim FQ_gal_C2 As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H1248)
    Dim FQ_per_C2 As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H1244)
    Dim FQ_gal_C3 As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H1250)
    Dim FQ_per_C3 As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H124C)

    ' Right Tanks Quantity
    Dim FQ_gal_RM As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB98)
    Dim FQ_per_RM As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB94)
    Dim FQ_gal_RA As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HBA0)
    Dim FQ_per_RA As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HB9C)
    Dim FQ_gal_RT As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HBA8)
    Dim FQ_per_RT As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HBA4)

    ' Weights
    Dim weight_lbs_per_gal As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HAF4)

then calculate all together...

' Fuel Density
            Dim weight_kg_per_ltr As Double = weight_lbs_per_gal.Value / 256 / 2.20462262 / 3.78541178


            ' Fuel Quantity Left TANKS in Liter
            Dim FQ_Left_ltr As Double = ((FQ_gal_LM.Value * (FQ_per_LM.Value / 128 / 65536)) + (FQ_gal_LA.Value * (FQ_per_LA.Value / 128 / 65536)) + (FQ_gal_LT.Value * (FQ_per_LT.Value / 128 / 65536))) * 3.785411784 * weight_kg_per_ltr
            Me.txtFQ_Left_ltr.Text = FQ_Left_ltr.ToString("f2")

            ' Fuel Quantity CENTER TANKS in Liter
            Dim FQ_Center_ltr As Double = ((FQ_gal_C1.Value * (FQ_per_C1.Value / 128 / 65536)) + (FQ_gal_C2.Value * (FQ_per_C2.Value / 128 / 65536)) + (FQ_gal_C3.Value * (FQ_per_C3.Value / 128 / 65536))) * 3.785411784 * weight_kg_per_ltr
            Me.txtFQ_Center_ltr.Text = FQ_Center_ltr.ToString("f2")

            ' Fuel Quantity Left TANKS in Liter
            Dim FQ_Right_ltr As Double = ((FQ_gal_RM.Value * (FQ_per_RM.Value / 128 / 65536)) + (FQ_gal_RA.Value * (FQ_per_RA.Value / 128 / 65536)) + (FQ_gal_RT.Value * (FQ_per_RT.Value / 128 / 65536))) * 3.785411784 * weight_kg_per_ltr
            Me.txtFQ_Right_ltr.Text = FQ_Right_ltr.ToString("f2")

            ' Fuel TOTAL Quantity in Liter
            Dim fuelQuantity As Double = FQ_Left_ltr + FQ_Center_ltr + FQ_Right_ltr
            Me.txtFuelQuantity.Text = fuelQuantity.ToString("f2")

I hope you can handle with my data.

Greetings, Tobias

Link to comment
Share on other sites

if anybody has a script to read the current remaining fuel of an aircraft in Visual Basic i would

be very grateful if you shared it with me.

If you only need this for FSX and beyond, there's are new offsets giving Total Fuel in Gallons and Total Fuel Weight in Pounds, now (offsets 1264 and 126C.

I'm afraid I can't help with VB though.

Regards

Pete

Link to comment
Share on other sites

Will try them later this day, where can i find more information about these offsets?

Can't find them in the "FSUIPC for programmers.pdf".

As it actually says in the third line of that reference document, the correct document to use for FSUIPC4 is called "FSUIPC4 Offsets Status.pdf", which has been included in the SDK for some time now, but originally was only supplied in the FSUIPC SDK addendum in the FSX Downloads announcement above.

Maybe you are still using an old copy of the SDK?

Pete

Link to comment
Share on other sites

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.