• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

P3D v4 Fuel selectors

DragonflightDesign

Resource contributor
Messages
1,369
Country
northernireland
The fuel tank selectors are listed as enum with a data run of zero to twenty. I thought (incorrectly) that the enum for each selector would return a zero or one (off or on). Consequently, I declared the datatype as Int32 .
Code:
p3d_simconnect.AddToDataDefinition(P3Data.DEFINE_FUEL_SELECTORS, "FUEL TANK SELECTOR", "enum", LockheedMartin.Prepar3D.SimConnect.SIMCONNECT_DATATYPE.INT32, 0, 26)
The structure is registered:-
Code:
    Structure Fuel_Selectors

        Public off As Integer
        Public all As Integer
        Public left As Integer
        Public right As Integer
        Public left_aux As Integer
        Public right_aux As Integer
        Public center As Integer
        Public center2 As Integer
        Public center3 As Integer
        Public external1 As Integer
        Public external2 As Integer
        Public right_tip As Integer
        Public left_tip As Integer
        Public crossfeed As Integer
        Public crossfeedLeftToRight As Integer
        Public crossfeedRightToLeft As Integer
        Public both As Integer
        Public external As Integer
        Public isolate As Integer
        Public left_main As Integer
        Public right_main As Integer

    End Structure
Code:
p3d_simconnect.RegisterDataDefineStruct(Of Fuel_Selectors)(P3Data.DEFINE_FUEL_SELECTORS)
It's being checked at 1Sec intervals (CLIENT_1SEC).
Code:
    Friend Sub p3d_simconnect_OnRecvSimobjectDataBytype(ByVal sender As SimConnect, ByVal data As SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE)
        Select Case data.dwRequestID
            Case P3Data.REQUEST_FUEL_SELECTORS
                    ' Fuel selectors
                    Dim fuel_selector As Fuel_Selectors = CType(data.dwData(0), Fuel_Selectors)
                    ' Data
                    frmMain.lvDisplay.Items.Add("Off")
                    frmMain.lvDisplay.Items(0).SubItems.Add(fuel_selector.off.ToString)
                    frmMain.lvDisplay.Items.Add("All")
                    frmMain.lvDisplay.Items(1).SubItems.Add(fuel_selector.all.ToString)
                    frmMain.lvDisplay.Items.Add("Left")
                    frmMain.lvDisplay.Items(2).SubItems.Add(fuel_selector.left.ToString)
{etc.}
The return is garbage (I'm good at getting returns full of garbage :p)

fuel_selectors.jpg


Although this is an external module written in vb.Net, I'm pretty sure that my foul-up is language-independant. Anyone any idea what I should be displaying the fuel selector enumeration as?

Thank you :)
 
as far as my basic C++ learning, if value variable not declare, a value can be any number.
Don't know if any other program language have zeroed value.
 
That wouldn't be it because even if the values are initialised, they would be immediately overwritten by the garbage data coming from the sim. Good idea though :)
 
I don't catch up what your target for fuel selector.
because I working on fuel system couple days ago, I can read and write fuel selector enum value. but it just little portion using fuel selector. big portion is on filling and sucking fuel to and from tanks.
 
Dai, IIRC, all A:vars are FLOAT64 type, regardless of what they are "defined" as by their XML "unit" type. This variable also requires an :index to indicate which of four possible engines they are plumbed to...

Edit: I forgot to add that the return will be a whole number from 0 to 20 per the chart in the SDK.
 
Bill/Maryadi: I have a working fuel system that pumps fuel where I want it, but the tanks that being used to supply fuel to the engines are not necessarily the tanks that I want to be used. I'm being overridden by the sim. The aircraft has main, auxiliary and center tanks (six in total). If I set Left Main to supply engine one and engine two, the sim is overriding me and drawing fuel from Left Aux. I can see it happening and no, it's not a bug in my code. That's why I wanted to see which tank selectors are active at any one time but it looks like it may not be possible.
 
You can easily control which tanks feed using XML. For example:
Code:
<Gauge Name="Typhoon Tanks">
    <!-- ====Transfer Centerline first, CFTs next then select All WHICH WILL FEED EXT,AUX AND MAINS,IN THAT ORDER===================== -->
    <Update Hidden="Yes">
    (P:Absolute time,seconds) 1 % 1 > !
    if{
         (A:fuel tank center quantity,gallons) 1 &gt;
         if{ 6 (>K:FUEL_SELECTOR_SET) 6 (>K:FUEL_SELECTOR_2_SET)
             }
         els{
                 (A:fuel tank center2 quantity,gallons) 1 &gt;
                 if{
                     7 (>K:FUEL_SELECTOR_SET)
                     }
                (A:fuel tank center3 quantity,gallons) 1 &gt;
                 if{
                     8 (>K:FUEL_SELECTOR_2_SET)
                     }    
                     els{ (A:fuel tank selector, enum) 1 !=
                         if{
                         1 (>K:FUEL_SELECTOR_ALL) }
                       
                         (A:fuel tank selector:2, enum) 1 !=
                         if{
                         1 (>K:FUEL_SELECTOR_2_ALL) }
                }

            }
      }
    </Update>
</Gauge>
This is for a twin engined airplane with two fuel selectors. With hindsight I could have done more testing for the selection setting and avoided repeat selection when that selection already existed.
Roy
 
Last edited:
Thanks Roy. You've just confirmed something I was thinking; I'm going to have to use center tanks, tip tanks and then ext/aux/main.
 
Update: using Center and Center2 as the tanks that actually feed the engines solved the problem. I used LeftTip, RightTip, LeftMain and RightMain for the tanks that just store fuel before it is pumped to Center/Center2.
 
The structure you defined is actually nonsense. According to the SDK the Fuel Tank Selection (you listed the possible tanks in your struct) is a enumeration of values from 0 to 20.


Code:
0    Off
1    All
2    Left
3    Right
4    Left Aux
5    Right Aux
6    Center
7    Center2
8    Center3
9    External 1
10    External 2
11    Right Tip
12    Left Tip

13    Crossfeed
14    Crossfeed Left to Right
15    Crossfeed Right to Left
16    Both
17    External
18    Isolate
19    Left Main
20    Right Main

The values 0 through 12 are used as an index value for FUEL TANK SELECTOR:Index. I have never messed with the values of 13-20.
 
Back
Top