1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Custom fuel selectors

Discussion in 'Modeling' started by euroastar350, 10 Aug 2017.

  1. euroastar350

    euroastar350 Resource contributor

    Joined:
    28 Jul 2010
    Messages:
    611
    Country:
    puertorico
    Hi guys,

    I'm in the process of coding my FSX Trislander and I'm getting to the fuel selectors next. The real airplane has 3 selectors which has 2 functions, as tank selectors and cross feed functions. Quoted from a real world pilot that is helping me with the project:

    I have the selectors animated, but don't have a working code as of yet. What would be the best way to approach this? Much of systems are written into an external logic gauge, but an internal script would work just as well. Any help is appreciated

    Trislander_fuel.jpg
     
  2. Heretic

    Heretic Resource contributor

    Joined:
    1 Feb 2007
    Messages:
    5,242
    Country:
    germany
    First, the Aircraft.cfg should reflect the number of available fuel selectors (number_of_tank_selectors=3).

    Second, the selector logic is a simple comparison of the animation code with the current state of the associated FSX-internal fuel selector and a subsequent, appropriate action.

    In less teutonic language (and assuming 0 = off, 1 = right/left, 2 = xfeed/both, 3 = left):
    Code:
    (L:Fuel Selector 1, number) 0 == (A:FUEL TANK SELECTOR:1,enum) 0 != if{ 0 (>K:FUEL_SELECTOR_SET) }
    (L:Fuel Selector 1, number) 1 == (A:FUEL TANK SELECTOR:1,enum) 3 != if{ 3 (>K:FUEL_SELECTOR_SET) }
    (L:Fuel Selector 1, number) 2 == (A:FUEL TANK SELECTOR:1,enum) 2 != if{ 2 (>K:FUEL_SELECTOR_SET) }
    
    (L:Fuel Selector 2, number) 0 == (A:FUEL TANK SELECTOR:2,enum) 0 != if{ 0 (>K:FUEL_SELECTOR_2_SET) }
    (L:Fuel Selector 2, number) 1 == (A:FUEL TANK SELECTOR:2,enum) 2 != if{ 2 (>K:FUEL_SELECTOR_2_SET) }
    (L:Fuel Selector 2, number) 2 == (A:FUEL TANK SELECTOR:2,enum) 3 != if{ 3 (>K:FUEL_SELECTOR_2_SET) }
    
    (L:Fuel Selector 3, number) 0 == (A:FUEL TANK SELECTOR:3,enum) 0 != if{ 0 (>K:FUEL_SELECTOR_3_SET) }
    (L:Fuel Selector 3, number) 1 == (A:FUEL TANK SELECTOR:3,enum) 3 != if{ 3 (>K:FUEL_SELECTOR_3_SET) }
    (L:Fuel Selector 3, number) 2 == (A:FUEL TANK SELECTOR:3,enum) 16 != if{ 16 (>K:FUEL_SELECTOR_3_SET) }
    (L:Fuel Selector 3, number) 3 == (A:FUEL TANK SELECTOR:3,enum) 2 != if{ 2 (>K:FUEL_SELECTOR_3_SET) }
    
     
    antaris likes this.
  3. euroastar350

    euroastar350 Resource contributor

    Joined:
    28 Jul 2010
    Messages:
    611
    Country:
    puertorico

    Hmmm, tried the above code which I added to my logic gauge and no dice. All engines can be started, even if the selectors are in the off position. Not sure if that's the way they are supposed to work, also updated my aircraft cfg to reflect 3 selectors. Am I missing something?
     
  4. Heretic

    Heretic Resource contributor

    Joined:
    1 Feb 2007
    Messages:
    5,242
    Country:
    germany
    Yep, it won't work as I've posted it because I'm dumb. Since it's a glaringly obvious error, I leave you to figure it out before I'll correct it. ;)
     
  5. euroastar350

    euroastar350 Resource contributor

    Joined:
    28 Jul 2010
    Messages:
    611
    Country:
    puertorico
    I've tried the combination of the following "K" events with no luck. I'm completely dumbfounded as I've never had to write a fuel system for an aircraft since I've only used default variables in all my models :p

    Code:
    FUEL_SELECTOR_2_ALL
    FUEL_SELECTOR_2_OFF
    FUEL_SELECTOR_2_RIGHT
    
    
    FUEL_SELECTOR_3_ALL
    FUEL_SELECTOR_3_LEFT
    FUEL_SELECTOR_3_OFF
    FUEL_SELECTOR_3_RIGHT
    
    
    FUEL_SELECTOR_ALL
    FUEL_SELECTOR_LEFT
    FUEL_SELECTOR_OFF
    
     
  6. Heretic

    Heretic Resource contributor

    Joined:
    1 Feb 2007
    Messages:
    5,242
    Country:
    germany
    The bug isn't in the key events, but in the condition to trigger them. Keep looking...
     
    antaris likes this.
  7. antaris

    antaris

    Joined:
    8 Feb 2008
    Messages:
    817
    Country:
    mexico
    Hi lads

    Perhaps is where the error resides; use "number" instead. Björn helped me with this in the 429 garmin suite:

    HTML:
    (L:Fuel Selector 1, number) 0 == (A:FUEL TANK SELECTOR:1,number) 0 != if{ 0 (>K:FUEL_SELECTOR_SET) }
    (L:Fuel Selector 1, number) 1 == (A:FUEL TANK SELECTOR:1,number) 3 != if{ 3 (>K:FUEL_SELECTOR_SET) }
    (L:Fuel Selector 1, number) 2 == (A:FUEL TANK SELECTOR:1,number) 2 != if{ 2 (>K:FUEL_SELECTOR_SET) }
    
    (L:Fuel Selector 2, number) 0 == (A:FUEL TANK SELECTOR:2,number) 0 != if{ 0 (>K:FUEL_SELECTOR_2_SET) }
    (L:Fuel Selector 2, number) 1 == (A:FUEL TANK SELECTOR:2,number) 2 != if{ 2 (>K:FUEL_SELECTOR_2_SET) }
    (L:Fuel Selector 2, number) 2 == (A:FUEL TANK SELECTOR:2,number) 3 != if{ 3 (>K:FUEL_SELECTOR_2_SET) }
    
    (L:Fuel Selector 3, number) 0 == (A:FUEL TANK SELECTOR:3,number) 0 != if{ 0 (>K:FUEL_SELECTOR_3_SET) }
    (L:Fuel Selector 3, number) 1 == (A:FUEL TANK SELECTOR:3,number) 3 != if{ 3 (>K:FUEL_SELECTOR_3_SET) }
    (L:Fuel Selector 3, number) 2 == (A:FUEL TANK SELECTOR:3,number) 16 != if{ 16 (>K:FUEL_SELECTOR_3_SET) }
    (L:Fuel Selector 3, number) 3 == (A:FUEL TANK SELECTOR:3,number) 2 != if{ 2 (>K:FUEL_SELECTOR_3_SET) }
     
    Last edited: 11 Aug 2017
  8. euroastar350

    euroastar350 Resource contributor

    Joined:
    28 Jul 2010
    Messages:
    611
    Country:
    puertorico
    Investigating the DC3 Enhanced gauges, I see the fuel tank levels have to do their part for the selectors to work. The engines run off of the main wings tanks and only get filled from the tip tanks which has no part of the selectors at all. Am I close?
     
  9. Heretic

    Heretic Resource contributor

    Joined:
    1 Feb 2007
    Messages:
    5,242
    Country:
    germany
    Come on, guys. You're very close to totally disappoint me.

    You've got two conditions that need to be logically connected to trigger a command. But with the buggy code above, only one condition will trigger a command. Why?
     
    antaris likes this.
  10. Roy Holmes

    Roy Holmes Resource contributor

    Joined:
    20 Feb 2011
    Messages:
    1,306
    Country:
    us-virginia
    Bjorn, I admire your patience. It is excruciatingly obvious,
    Roy
     
    euroastar350 and EduHir like this.
  11. kalong

    kalong

    Joined:
    19 Dec 2009
    Messages:
    332
    Country:
    indonesia
    I'm poor in XML, code above is have 1 condition, 1 checker condition and a command. I do this on Osprey fuel transfer automation in C++ language with few more condition
     
    antaris likes this.
  12. euroastar350

    euroastar350 Resource contributor

    Joined:
    28 Jul 2010
    Messages:
    611
    Country:
    puertorico
    Does it have to do with the fuel tank variables?
     
  13. kalong

    kalong

    Joined:
    19 Dec 2009
    Messages:
    332
    Country:
    indonesia
    the number "16" is fuel tank variable which fuel tank would be use, please read SDK section variable -> Fuel Tank Selection, for more info
     
    Last edited: 12 Aug 2017
  14. Heretic

    Heretic Resource contributor

    Joined:
    1 Feb 2007
    Messages:
    5,242
    Country:
    germany
    There is an "and" missing in every line, which is required to evaluate both the L: var and the A: var condition and not just the A: var one. :rolleyes:


    I'm especially disappointed in George, who isn't new to the entire XML thing by any means.
     
  15. euroastar350

    euroastar350 Resource contributor

    Joined:
    28 Jul 2010
    Messages:
    611
    Country:
    puertorico
    I had the "and" added which had no affect, I will try again. In the meantime, this is what I came up with:

    Code:
    (L:BN2A_fuel_selector_01, number) 0 == (A:FUEL TANK SELECTOR:1,enum) 0 != and if{ 0 (>K:FUEL_SELECTOR_SET) }
                (L:BN2A_fuel_selector_01, number) 1 == (A:FUEL TANK SELECTOR:1,enum) 2 != and if{ 2 (>K:FUEL_SELECTOR_SET) }
                (L:BN2A_fuel_selector_01, number) 2 == (A:FUEL TANK SELECTOR:1,enum) 14 != and if{ 14 (>K:FUEL_SELECTOR_SET) }
    
                (L:BN2A_fuel_selector_02, number) 0 == (A:FUEL TANK SELECTOR:2,enum) 0 != and if{ 0 (>K:FUEL_SELECTOR_SET) }
                (L:BN2A_fuel_selector_02, number) 1 == (A:FUEL TANK SELECTOR:2,enum) 3 != and if{ 3 (>K:FUEL_SELECTOR_SET) }
                (L:BN2A_fuel_selector_02, number) 2 == (A:FUEL TANK SELECTOR:2,enum) 14 != and if{ 14 (>K:FUEL_SELECTOR_SET) }
    
                (L:BN2A_fuel_selector_03, number) 0 == (A:FUEL TANK SELECTOR:3,enum) 0 != and if{ 0 (>K:FUEL_SELECTOR_SET) }
                (L:BN2A_fuel_selector_03, number) 1 == (A:FUEL TANK SELECTOR:3,enum) 3 != and if{ 3 (>K:FUEL_SELECTOR_SET) }
                (L:BN2A_fuel_selector_03, number) 2 == (A:FUEL TANK SELECTOR:3,enum) 16 != and if{ 16 (>K:FUEL_SELECTOR_SET) }
                (L:BN2A_fuel_selector_03, number) 3 == (A:FUEL TANK SELECTOR:3,enum) 2 != and if{ 2 (>K:FUEL_SELECTOR_SET) }
    
                (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 1 < (A:FUEL TANK SELECTOR:1, enum) 0 != and if{ 0 (>K:FUEL_SELECTOR_SET) }
                (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 1 < (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 0 > and (A:FUEL TANK SELECTOR:1, enum) 2 != and if{ 2 (>K:FUEL_SELECTOR_SET) }
                (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 1 > (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 1 < and (A:FUEL TANK SELECTOR:1, enum) 14 != and if{ 14 (>K:FUEL_SELECTOR_SET) } }     
     
                (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 1 < (A:FUEL TANK SELECTOR:2, enum) 0 != and if{ 0 (>K:FUEL_SELECTOR_SET) }
                (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 1 < (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 0 > and (A:FUEL TANK SELECTOR:2, enum) 3 != and if{ 3 (>K:FUEL_SELECTOR_SET) }
                (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 1 > (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 1 < and (A:FUEL TANK SELECTOR:2, enum) 14 != and if{ 14 (>K:FUEL_SELECTOR_SET) } }
    
                (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 1 < (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 1 < (A:FUEL TANK SELECTOR:3, enum) 0 != and if{ 0 (>K:FUEL_SELECTOR_SET) }
                (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 1 < (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 0 > and (A:FUEL TANK SELECTOR:3, enum) 2 != and if{ 2 (>K:FUEL_SELECTOR_SET) }
                (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 1 < (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 0 > and (A:FUEL TANK SELECTOR:3, enum) 3 != and if{ 3 (>K:FUEL_SELECTOR_SET) }
                (A:FUEL TANK RIGHT MAIN CAPACITY, gallons) 1 > (A:FUEL TANK LEFT MAIN CAPACITY, gallons) 1 < and (A:FUEL TANK SELECTOR:3, enum) 16 != and if{ 16 (>K:FUEL_SELECTOR_SET) } }
    This can be entirely incorrect as I tried to replicate OFF-LEFT-XFEED (E1), OFF-RIGHT-XFEED (E2) and OFF-LEFT-BOTH-RIGHT (E3).
     
    antaris likes this.
  16. taguilo

    taguilo Resource contributor

    Joined:
    20 Oct 2006
    Messages:
    1,474
    Country:
    argentina
    First of all, you are using K:FUEL_SELECTOR_SET event in all of your assignments. Change that with K:FUEL_SELECTOR_2_SET and K:FUEL_SELECTOR_3_SET when appropriate.

    Second, fuel tank quantity and capacity values should not automatically affect the position of a fuel selector (unless you are coding a custom fuel system)

    Third, scripts less verbosed are easier to maintain and debug, for example:

    Code:
       (L:BN2A_fuel_selector_01, number) 0 == (A:FUEL TANK SELECTOR:1,enum) 0 != and if{ 0 }
       (L:BN2A_fuel_selector_01, number) 1 == (A:FUEL TANK SELECTOR:1,enum) 2 != and if{ 2 }
       (L:BN2A_fuel_selector_01, number) 2 == (A:FUEL TANK SELECTOR:1,enum) 14 != and if{ 14 }
       (>K:FUEL_SELECTOR_SET)
    
    Even I would use registers with repetitive var names, but it's something not everyone find comfortable.

    Tom
     
    euroastar350 and antaris like this.
  17. euroastar350

    euroastar350 Resource contributor

    Joined:
    28 Jul 2010
    Messages:
    611
    Country:
    puertorico
    Ok so I managed to get the code to work somewhat, but the No.3 engine will not start, no matter which position the third selector is placed in. Here is the modified code I'm using:

    Code:
    <Element>
          <Select>
             <Value>
                (L:BN2A_fuel_selector_01, number) 0 == (A:FUEL TANK SELECTOR:1,enum) 0 != and if{ 0 }
                (L:BN2A_fuel_selector_01, number) 1 == (A:FUEL TANK SELECTOR:1,enum) 2 != and if{ 2 }
                (L:BN2A_fuel_selector_01, number) 2 == (A:FUEL TANK SELECTOR:1,enum) 14 != and if{ 14 }
                (>K:FUEL_SELECTOR_SET)
    
                (L:BN2A_fuel_selector_02, number) 0 == (A:FUEL TANK SELECTOR:2,enum) 0 != and if{ 0 }
                (L:BN2A_fuel_selector_02, number) 1 == (A:FUEL TANK SELECTOR:2,enum) 3 != and if{ 3 }
                (L:BN2A_fuel_selector_02, number) 2 == (A:FUEL TANK SELECTOR:2,enum) 14 != and if{ 14 }
                (>K:FUEL_SELECTOR_2_SET)
    
                (L:BN2A_fuel_selector_03, number) 0 == (A:FUEL TANK SELECTOR:3,enum) 0 != and if{ 0 }
                (L:BN2A_fuel_selector_03, number) 1 == (A:FUEL TANK SELECTOR:3,enum) 2 != and if{ 2 }
                (L:BN2A_fuel_selector_03, number) 2 == (A:FUEL TANK SELECTOR:3,enum) 16 != and if{ 16 }
                (L:BN2A_fuel_selector_03, number) 3 == (A:FUEL TANK SELECTOR:3,enum) 3 != and if{ 3 }
                (>K:FUEL_SELECTOR_3_SET)
             </Value>
          </Select>
       </Element>
    Of course none of the engines will start up when the selectors are placed in crossfeed. Any ideas on what's causing the third engine not to start?
     
  18. tgibson

    tgibson

    Joined:
    22 Sep 2006
    Messages:
    6,771
    Country:
    us-california
    First, if you are going to use 14 on one wing, you probably need to use 15 on the other. From the SDK:

    14 Crossfeed left to right
    15 Crossfeed right to left

    but the only crossfeed I could get to work reliably was 13. I don't know how to use 14, 15, and 16.
     

Share This Page