Jump to content
The simFlight Network Forums

Some questions...and a bug?


pepelotte
 Share

Recommended Posts

Hi,

i have some questions an maybe found two bugs. Fist, i attached two screenshots.

Screenshot from X-Plane

Screenshot from Software

 

as we can see, there are two problems.

1. i get only on fueltank

2. the max weight is not right

 

and now the question

1. how can i get the "flight time"?

 

My runtime:

- Windows 10

- Visual Studio 2015 / VB.net

- .net DLL 3.0 RC4

- X-Plane 11 with XPUIPC 2.0

 

here my code to get the fuel tanks:

    Public Sub GetTanks()
        ps.RefreshData()

        If ps.FuelTanks(FSFuelTanks.Centre_Main).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Center Main")
            frmMain.lvTanks.Items(0).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(0).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Center Main")
            frmMain.lvTanks.Items(0).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_Main).CapacityLitres))
            frmMain.lvTanks.Items(0).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_Main).LevelLitres))
            frmMain.lvTanks.Items(0).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_Main).WeightKgs))
        End If

        If ps.FuelTanks(FSFuelTanks.Centre_2).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Center 2")
            frmMain.lvTanks.Items(1).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(1).SubItems.Add("0")
            frmMain.lvTanks.Items(1).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Center 2")
            frmMain.lvTanks.Items(1).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_2).CapacityLitres))
            frmMain.lvTanks.Items(1).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_2).LevelLitres))
            frmMain.lvTanks.Items(1).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_2).WeightKgs))
        End If

        If ps.FuelTanks(FSFuelTanks.Centre_3).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Center 3")
            frmMain.lvTanks.Items(2).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(2).SubItems.Add("0")
            frmMain.lvTanks.Items(2).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Center 3")
            frmMain.lvTanks.Items(2).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_3).CapacityLitres))
            frmMain.lvTanks.Items(2).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_3).LevelLitres))
            frmMain.lvTanks.Items(2).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Centre_3).WeightKgs))
        End If

        If ps.FuelTanks(FSFuelTanks.Left_Main).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Left Main")
            frmMain.lvTanks.Items(3).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(3).SubItems.Add("0")
            frmMain.lvTanks.Items(3).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Left Main")
            frmMain.lvTanks.Items(3).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Main).CapacityLitres))
            frmMain.lvTanks.Items(3).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Main).LevelLitres))
            frmMain.lvTanks.Items(3).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Main).WeightKgs))
        End If

        If ps.FuelTanks(FSFuelTanks.Left_Aux).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Left Aux")
            frmMain.lvTanks.Items(4).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(4).SubItems.Add("0")
            frmMain.lvTanks.Items(4).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Left Aux")
            frmMain.lvTanks.Items(4).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Aux).CapacityLitres))
            frmMain.lvTanks.Items(4).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Aux).LevelLitres))
            frmMain.lvTanks.Items(4).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Aux).WeightKgs))
        End If

        If ps.FuelTanks(FSFuelTanks.Left_Tip).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Left Tip")
            frmMain.lvTanks.Items(5).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(5).SubItems.Add("0")
            frmMain.lvTanks.Items(5).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Left Tip")
            frmMain.lvTanks.Items(5).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Tip).CapacityLitres))
            frmMain.lvTanks.Items(5).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Tip).LevelLitres))
            frmMain.lvTanks.Items(5).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Left_Tip).WeightKgs))
        End If

        If ps.FuelTanks(FSFuelTanks.Right_Main).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Right Main")
            frmMain.lvTanks.Items(6).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(6).SubItems.Add("0")
            frmMain.lvTanks.Items(6).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Right Main")
            frmMain.lvTanks.Items(6).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Main).CapacityLitres))
            frmMain.lvTanks.Items(6).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Main).LevelLitres))
            frmMain.lvTanks.Items(6).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Main).WeightKgs))
        End If

        If ps.FuelTanks(FSFuelTanks.Right_Aux).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Right Aux")
            frmMain.lvTanks.Items(7).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(7).SubItems.Add("0")
            frmMain.lvTanks.Items(7).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Right Aux")
            frmMain.lvTanks.Items(7).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Aux).CapacityLitres))
            frmMain.lvTanks.Items(7).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Aux).LevelLitres))
            frmMain.lvTanks.Items(7).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Aux).WeightKgs))
        End If

        If ps.FuelTanks(FSFuelTanks.Right_Tip).CapacityLitres = 0 Then
            frmMain.lvTanks.Items.Add("Right Tip")
            frmMain.lvTanks.Items(8).SubItems.Add("Not availible")
            frmMain.lvTanks.Items(8).SubItems.Add("0")
            frmMain.lvTanks.Items(8).SubItems.Add("0")
        Else
            frmMain.lvTanks.Items.Add("Right Tip")
            frmMain.lvTanks.Items(8).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Tip).CapacityLitres))
            frmMain.lvTanks.Items(8).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Tip).LevelLitres))
            frmMain.lvTanks.Items(8).SubItems.Add(CInt(ps.FuelTanks(FSFuelTanks.Right_Tip).WeightKgs))
        End If
    End Sub

 

and my code to get the weight

    Public Sub GetPayLoad()
        ps.RefreshData()
        frmMain.lblGesamtgewicht.Text = CInt(ps.AircraftWeightKgs) & " kg"
        frmMain.lblLeergewicht.Text = (CInt(ps.AircraftZeroFuelWeightKgs) - CInt(ps.PayloadWeightKgs)) & " kg"
        frmMain.lblMTOW.Text = CInt(ps.MaxGrossWeightKgs) & " kg"
    End Sub

 

and in

FSUIPCConnection.Open(FlightSim.Any)

there is as "FlightSim" no xplane. so i used any

 

regards,

pepe

Edited by pepelotte
Link to comment
Share on other sites

Hi Pepe,

The Fuel Tanks problem is caused by VB casting the FsFuelTanks enum into an integer automatically. Doing this in C# wouldn't compile so it was never an issue:

If ps.FuelTanks(FSFuelTanks.Right_Tip).CapacityLitres = 0 Then

Instead you would normally use the GetFuelTank method:

ps.FuelTanks.GetFuelTank(FSFuelTanks.Right_Tip)

However, because VB allows the syntax you've used (and VB programmers would expect that to work) I've changed the DLL so your code will now work the way you've written it. (New DLL attached).

 

The MaxGrossWeight problem was a bug - it was returning the aircraft weight instead. This is also fixed in the new DLL.

 

Quote

there is as "FlightSim" no xplane. so i used any

There isn't a code for XPUIPC (as far as I know), so 'Any' is the correct option for you. I expect XPUIPC just reports as FSX.

 

Quote

1. how can i get the "flight time"

The closest offset I can find is offset 04A8 (Elapsed Time). This might be what you want (if XPUIPC supports it).

Otherwise you can:

1. Declare a form level variable to hold the start time:

Private flightStartTime As DateTime

2. Set the start time when the flight starts:

flightStartTime = DateTime.Now

3. Any time you want to know the current flight time just get the current time and subtract the start time:

Dim flightTime As TimeSpan = DateTime.Now - flightStartTime
Me.lblFlightTime.Text = flightTime.ToString("hh\:mm\:ss")

Paul

 

FSUIPCClient3.0_RC5.zip

Link to comment
Share on other sites

Hello Paul,

first, thank you for the great and fast work!! Where can i make a donation for your dll?

 

I tried the offset for the elapsed time, but i get a empty string. Can you check my code if everything is right?

 

Declaration

    Public FuelFlightTime As Offset(Of String) = New FSUIPC.Offset(Of String)("FuelFlightTime", &H4A8, 256)

 

and the function

    Public Sub GetFuelFlightTime()
        FSUIPCConnection.Process("FuelFlightTime")
        frmMain.lblFlightTime.Text = FuelFlightTime.Value
    End Sub

 

your two fixes in the dll working now. Thank you again!

 

regards,

pepe

Link to comment
Share on other sites

Hi Pepe,

The 04A8 offset is a Double type holding the number of seconds. Declare like this:

    Public FuelFlightTime As Offset(Of Double) = New FSUIPC.Offset(Of Double)("FuelFlightTime", &H4A8)


Then use like this:

        FSUIPCConnection.Process("FuelFlightTime")
        Dim flighttime As TimeSpan = TimeSpan.FromSeconds(FuelFlightTime.Value)
        frmMain.lblFlightTime.Text = flighttime.ToString("hh\:mm\:ss")

This offset seems to be the time since the sim was started. If that's not suitable then you'll need to make your own timer as described in my previous post.

Donations can be made by PayPal using this email address:

paul.henty@unitysoftware.net

 

Paul

Link to comment
Share on other sites

Hello Paul,

i found a new bug. The center main and the left main are wrong.

left main contains the value from center main

center main contains the value from left main

Can you fix that and send me a new dll?

EDIT:

hm.....interesting. i took now a kingair which has only left tank and right tank and the values are right. is there maybe only a problem if center tank exists?

 

greetings

pepe

Link to comment
Share on other sites

I've checked here on FSX (I don't have XPlane) and everything seems to be correct.

Cessna with left and right tanks only:

FuelCessna.png.c426572cf3946074b6d838dec5a76d84.png

(There is a slight discrepancy with the values because FSUIPC reports the tank capacity as an integer gallons. FSX however uses fractions so the maths doesn't quite some out the same).

747 with Left, Right, Centre and others:

737Fuel.png.bc5f969deed224d35cc808e0a08729ac.png

But they are not getting mixed up with FSUIPC.

I can only suggest that either there is a bug in XPUIPC or something is wrong with the design of the aircraft.

Paul

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.