skino Posted April 3, 2017 Report Posted April 3, 2017 I want to fill the standard aircraft in the FSX and P3D with a small VB tool. A value is to be written into a text field and transferred as gallons into the simulator. The necessary functions and declarations, I have not found in the client Dll. How exactly do I get the tanks filled? I am grateful for every note. Of course also for VB code examples.
Paul Henty Posted April 3, 2017 Report Posted April 3, 2017 The fuel tanks are accessed through the PayloadServices module. Here is an example of setting the level of the centre-main tank with a level typed into a text box: Private Sub LoadFuel() ' Connection must already be open Dim ps As PayloadServices = FSUIPCConnection.PayloadServices Dim requestedFuel As Double ' Turn the text into a number If Double.TryParse(Me.txtFuelGallons.Text, requestedFuel) Then ' set the level on the centre main tank ps.FuelTanks(FSFuelTanks.Centre_Main).LevelUSGallons = requestedFuel ' sent new levels to the sim ps.RefreshData() Else ' Not a number in the text box End If End Sub To work with a different tank, just change the value of the FSFuelTanks enum. For example: ps.FuelTanks(FSFuelTanks.Left_Main) All possible fuel tanks are included in the FsFuelTanks enumeration. The popup menu will show you all tanks when you type . after FSFuelTanks. Each fuel tank must be processed separately. You can't specify a level for all tanks globally. If you want your user to be able to enter a level of fuel for all tanks then your program will need to split the fuel across all the available tanks, keeping the aircraft as balanced as possible. To find out which tanks are available on the aircraft you can test the capacity. If the capacity is 0 then this fuel tank does not exist on the loaded aircraft. e.g. If ps.FuelTanks(FSFuelTanks.Centre_Main).CapacityUSGallons = 0 Then ' This aircraft has no centre fuel tank. End If Paul
skino Posted April 3, 2017 Author Report Posted April 3, 2017 Thanks for the comprehensive explanation. That helps a lot. Peter
skino Posted April 28, 2017 Author Report Posted April 28, 2017 Hello Paul, If I use this code I always get an error message Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Dim ps As PayloadServices = FSUIPCConnection.PayloadServices If ps.FuelTanks(FSFuelTanks.Centre_Main).CapacityUSGallons = 0 Then CheckBox6.Checked = True End If Label3.Text = ps.FuelTanks(FSFuelTanks.Centre_Main).LevelUSGallons & " Gal" If ps.FuelTanks(FSFuelTanks.Centre_2).CapacityUSGallons = 0 Then CheckBox7.Checked = True End If If ps.FuelTanks(FSFuelTanks.Centre_3).CapacityUSGallons = 0 Then CheckBox8.Checked = True End If If ps.FuelTanks(FSFuelTanks.Left_Aux).CapacityUSGallons = 0 Then CheckBox11.Checked = True End If If ps.FuelTanks(FSFuelTanks.Left_Main).CapacityUSGallons = 0 Then CheckBox10.Checked = True End If If ps.FuelTanks(FSFuelTanks.Left_Tip).CapacityUSGallons = 0 Then CheckBox9.Checked = True End If If ps.FuelTanks(FSFuelTanks.Right_Aux).CapacityUSGallons = 0 Then CheckBox13.Checked = True End If If ps.FuelTanks(FSFuelTanks.Right_Main).CapacityUSGallons = 0 Then CheckBox12.Checked = True End If If ps.FuelTanks(FSFuelTanks.Right_Tip).CapacityUSGallons = 0 Then CheckBox3.Checked = True End If ps.RefreshData() If My.Settings.NoPanel = 1 Then Form1.Hide() Tank34.Hide() Else Form1.Show() Tank34.Show() End If FSUIPCConnection.Process("AircraftInfo") Label2.Text = aircraftType.Value End Sub
skino Posted April 28, 2017 Author Report Posted April 28, 2017 Found the error. The code can not run in a timer. Have now put it in a button and there is no more error. I also get no tanks displayed (in P3Dv3), no matter which aircraft I choose.
Paul Henty Posted April 28, 2017 Report Posted April 28, 2017 5 hours ago, skino said: I also get no tanks displayed (in P3Dv3), no matter which aircraft I choose. I'm not sure why that would happen. I don't have P3D so I can't test this myself. You could ask Pete on the main support forum. 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