Results 1 to 7 of 7

Thread: gauge - can I simply Group all these elements together? Or must be separate elements?

  1. #1
    Join Date
    Feb 2011
    Posts
    8,095
    Blog Entries
    1

    Default gauge - can I simply Group all these elements together? Or must be separate elements?

    Hi all. Hope you're well.

    A little question. I'm working on a gauge but iot is not finished yet. It is an "invisible gauge" that listens for A:variables and does things according to what those A:variables are.
    That means it is a gauge with only elements like so:
    <Element>
    <Select>
    <Value>
    </Value>
    </Select>
    </Element>

    And I am now wondering if I can combine all those elements into one. (As the gauge is not finished yet I can't simply try and see the result..)

    Below is just a small example of what I mean. It's not the actual gauge. Only parts of it and with A: and L:Vars completely chosen random for this example only.

    --- This is generally what the gauge elements look like now: -------
    <Gauge Name="abcdefgh.xml" version="001" />
    <Image= "abcdefgh_background.bmp" />
    <Element>
    <Select>
    <Value>
    (L:INIT) 0 ==
    if { 0 (>L:12345) 0 (>L:32A56) }
    </Value>
    </Select>
    </Element>

    <Element>
    <Select>
    <Value>
    (A:bbbbbb) &&
    if { 1 (>L:12345) }
    els { 0 (>L:12345) }
    </Value>
    </Select>
    </Element>

    <Element>
    <Select>
    <Value>
    (L:INIT) 0 ==
    if { 0 (>L:12345) 0 (>L:32A56) }
    </Value>
    </Select>
    </Element>
    </gauge>

    --- I would like to combine them as :-----(same code, just fewer tags) -------
    <Gauge Name="abcdefgh.xml" version="001" />
    <Image= "abcdefgh_background.bmp" />
    <Element>
    <Select>
    <Value>
    (L:INIT) 0 ==
    if { 0 (>L:12345) }

    (A:bbbbbb) &&
    if { 1 (>L:12345) }
    els { 0 (>L:12345) }

    (L:12345)
    if { 1 (>K:ABCDE) 0 (>L:INIT) }
    </Value>
    </Select>
    </Element>
    </gauge>
    --------------------------------------------------------------------------

    I my gauge there are more elements, but all elements are like the ones above. So:
    <Element> <Select> <Value> CODE </Value> </Select> </Element>
    and all have the same type of Code in them:
    (A:var) or (L:var) value ==
    if { do one thing }
    els { do some other thing }
    many only have an if { **** } option and no els { #### } part.


    Thanks for reading, hope you know the answer.
    Thanks in advance. il.
    Last edited by il88pp; 06-21-2020 at 03:03 PM.

  2. #2

    Default

    Hello,
    Yes you can merge it into one element but without spaces between "if" or "els":


    Code:
      <Element>
        <Select>
          <Value>
              (A:AAA,percent) 10 &gt; if{ 1 (>L:CCC,number) } els{ 2 (>L:CCC,number) }
              (L:DDD,number) 1 == (L:EEE,number) 1 == AND if{ 3 (>L:FFF,number) } els{ 4 (>L:FFF,number) }
          </Value>
        </Select>
      </Element>
    There are restrictions on the maximum of lines in an element, but I don't know the number or size!

  3. #3
    Join Date
    Feb 2011
    Posts
    8,095
    Blog Entries
    1

    Default

    Thanks!!

    Just to make sure, when you say "no space between "if" and "els""
    I assume you mean: nospace between if and {
    yes? (and between els and { of course)

    so you meant:
    if{
    instead of:
    if {
    Yes?

    Also, is it be OK to keep my hard returns in there or do they also need to go?
    For example, is the following OK:
    Code:
      <Element>
        <Select>
          <Value>
              (A:AAA,percent) 10 &gt; 
              if{ 1 (>L:CCC,number) } 
              els{ 2 (>L:CCC,number) }
                (L:DDD,number) 1 == (L:EEE,number) 1 == AND
                 if{ 3 (>L:FFF,number) } 
                 els{ 4 (>L:FFF,number) }
          </Value>
        </Select>
      </Element>
    Or does it have to be like you posted:
    Code:
      <Element>
        <Select>
          <Value>
              (A:AAA,percent) 10 &gt; if{ 1 (>L:CCC,number) } els{ 2 (>L:CCC,number) }
              (L:DDD,number) 1 == (L:EEE,number) 1 == AND if{ 3 (>L:FFF,number) } els{ 4 (>L:FFF,number) }
          </Value>
        </Select>
      </Element>

  4. #4

    Default

    Yes, right! No space between "if,els" and "{"!

    I personally try to have as few paragraphs as possible in a block of code but your partitions should also work!

  5. #5
    Join Date
    Feb 2011
    Posts
    8,095
    Blog Entries
    1

    Default

    Thank you very much for the (quick) reply!
    I like keeping things in their own lines to keep the overview while creating and editing.

    Thanks again,
    il.

  6. #6
    Join Date
    Mar 2005
    Location
    Hammond, IN USA
    Posts
    4,796

    Default

    A few comments regarding your scheme. I would suggest using an <Update> ... </Update> instead of the scheme you have. It's less verbose and uses the section as it was intended to be used.

    Also, AND in XML is all lower-case "and" or &&

    Here is an example of what I use as a "C310R Logic.xml" where I initialize many, many variables in a Do Once loop, and keep other variables updated on ever sim cycle (18 Hz):

    Code:
    <GaugeName="C310_Logic"Version="1.0">      <ImageName="GTX 330_rect.bmp"ImageSizes="500,128" />   
    
      <!-- CHECK IN THE DME.XML FOR THESE -> Fuel Flow and CHT (L:vars) -->
    
      <UpdateFrequency="1">
    
        (L:DoOnce,bool) ! if{
    
          <!-- COLD AND DARK -->
          (L:C310_ColdDark, bool) (L:FirstLoad,bool) ! and (A:SIM ON GROUND,bool) and
          if{
             1 (>K:PARKING_BRAKES,bool)
             1 (>L:C310_Pilot,bool)
             1 (>L:C310_Chocks,bool)
             1 (>L:C310_Covers,bool)
             0 (>L:SwitchLL,enum)
             (A:LIGHT TAXI,bool) if{ (>K:TOGGLE_TAXI_LIGHTS) }
             0 (>L:LeftMag_Left, number)
             0 (>L:LeftMag_Right, number)
             0 (>L:RightMag_Left, number)
             0 (>L:RightMag_Right, number)
             0 (>K:MIXTURE1_SET)
             0 (>K:MIXTURE2_SET)
             0 (>K:COWLFLAP1_SET)
             0 (>K:COWLFLAP2_SET)
             (>K:PANEL_LIGHTS_OFF)
             0 (>L:SwitchEngLts, enum)
             0 (>L:SwitchRadioLts, enum)
             0 (>L:SwitchFLTLts, enum)
             0 (>L:SwitchPNLLts, enum)
             (A:LIGHT BEACON,bool) if{ (>K:TOGGLE_BEACON_LIGHTS) }
             (A:LIGHT STROBE,bool) if{ (>K:STROBES_TOGGLE) }
             (A:LIGHT NAV,bool) if{ (>K:TOGGLE_NAV_LIGHTS) }
             (A:AVIONICS MASTER SWITCH,bool) if{ (>K:TOGGLE_AVIONICS_MASTER) }
             (A:ELECTRICAL MASTER BATTERY,bool) if{ (>K:TOGGLE_MASTER_BATTERY) }
             (A:GENERAL ENG MASTER ALTERNATOR:1,bool) if{ (>K:TOGGLE_ALTERNATOR1) }
             (A:GENERAL ENG MASTER ALTERNATOR:2,bool) if{ (>K:TOGGLE_ALTERNATOR2) }
             0 (&gt;K:FUEL_SELECTOR_SET)
             0 (>L:FuelSelectLeft, enum)
             0 (&gt;K:FUEL_SELECTOR_2_SET)
             0 (>L:FuelSelectRight, enum)
             (>K:ENGINE_AUTO_SHUTDOWN)
             1 (>L:FirstLoad,bool)
          }
    
        <!-- Flip Magnetos if Engines are Running when loaded  -->
        (L:C310_ColdDark, bool) ! (L:FirstLoad,bool) ! and (A:SIM ON GROUND,bool) ! or
        if{
           16384 (>K:MIXTURE1_SET)
           16384 (>K:MIXTURE2_SET)
           1 (>L:LeftMag_Left, number)
           1 (>L:LeftMag_Right, number)
           1 (>L:RightMag_Left, number)
           1 (>L:RightMag_Right, number)
           (>K:TOGGLE_STARTER1)
           (>K:TOGGLE_STARTER2)
           0 (>L:C310_Pilot,bool)
           0 (>L:C310_Chocks,bool)
           0 (>L:C310_Covers,bool)
    
           0 (&gt;K:FUEL_SELECTOR_SET)
           2 (&gt;K:FUEL_SELECTOR_SET)
           1 (>L:FuelSelectLeft, enum)
           0 (&gt;K:FUEL_SELECTOR_2_SET)
           3 (&gt;K:FUEL_SELECTOR_2_SET)
           1 (>L:FuelSelectRight, enum)
    
           (A:CIRCUIT AVIONICS ON,bool) if{ 0 (>L:Avionics_On_Init,enum) }
           (A:ANTISKID BRAKES ACTIVE,bool) 0 == if{ (>K:ANTISKID_BRAKES_TOGGLE) }
           (A:LIGHT LANDING,bool) if{ 2 (>L:SwitchLL,enum) }
           (>K:PANEL_LIGHTS_OFF)
           (A:LIGHT BEACON,bool) ! if{ (>K:TOGGLE_BEACON_LIGHTS) }
           (A:LIGHT STROBE,bool) ! if{ (>K:STROBES_TOGGLE) }
           (A:LIGHT NAV,bool) ! if{ (>K:TOGGLE_NAV_LIGHTS) }
    
           16383 (>K:COWLFLAP1_SET)
           16383 (>K:COWLFLAP2_SET)
           (A:ELECTRICAL MASTER BATTERY,bool) ! if{ (>K:TOGGLE_MASTER_BATTERY) }
           (A:GENERAL ENG MASTER ALTERNATOR:1,bool) ! if{ (>K:TOGGLE_ALTERNATOR1) }
           (A:GENERAL ENG MASTER ALTERNATOR:2,bool) ! if{ (>K:TOGGLE_ALTERNATOR2) }
           (A:AVIONICS MASTER SWITCH,bool) ! if{ (>K:TOGGLE_AVIONICS_MASTER) }
           (>K:ENGINE_AUTO_START)
           1 (>L:FirstLoad,bool)
           }
    
          1 (>L:DoOnce,bool)
          }
    
        (A:GENERAL ENG PROPELLER LEVER POSITION:1,percent) 0 > (L:Prop1_Feathered,bool) and 
            if{ 0 >L:Prop1_Feathered,bool) }
        (A:GENERAL ENG PROPELLER LEVER POSITION:2,percent) 0 > (L:Prop2_Feathered,bool) and 
            if{ 0 >L:Prop2_Feathered,bool) }
    
        (L:LeftMag_Left, number) ! (L:LeftMag_Right, number) !  and   if{ (>K:MAGNETO1_OFF) }     
        (L:LeftMag_Left, number)   (L:LeftMag_Right, number) !  and   if{ (>K:MAGNETO1_LEFT) }
        (L:LeftMag_Left, number) ! (L:LeftMag_Right, number)    and   if{ (>K:MAGNETO1_RIGHT) }
        (A:RECIP ENG LEFT MAGNETO:1,bool) ! (L:LeftMag_Left, number)  (L:LeftMag_Right, number) and and 
            if{ (>K:MAGNETO1_BOTH) }
    
        (L:RightMag_Left, number) ! (L:RightMag_Right, number) !  and   if{ (>K:MAGNETO2_OFF) }
        (L:RightMag_Left, number)   (L:RightMag_Right, number) !  and   if{ (>K:MAGNETO2_LEFT) } 
        (L:RightMag_Left, number) ! (L:RightMag_Right, number)    and   if{ (>K:MAGNETO2_RIGHT) }
        (A:RECIP ENG RIGHT MAGNETO:2,bool) ! (L:RightMag_Left, number) (L:RightMag_Right, number) and and 
            if{ (>K:MAGNETO2_BOTH) }
    
        (A:ELECTRICAL MASTER BATTERY,bool)
        if{
        (L:MB_On_Init,enum) 0 == if{ 1 (>L:XMLSND10,bool) 1 (>L:MB_On_Init,enum) }
        (L:MB_On_Init,enum) 1 == if{ 2 (>L:XMLSND11,bool) }
        }
    
        (A:ELECTRICAL MASTER BATTERY,bool) ! (L:MB_On_Init,enum) 1 == and
        if{ 3 (>L:XMLSND11,bool) 1 (>L:XMLSND12,bool) 0 (>L:MB_On_Init,enum) }
    
        (A:ELECTRICAL AVIONICS BUS VOLTAGE,volts) 0 > (A:ELECTRICAL MASTER BATTERY,bool) and
        if{
        (L:Avionics_On_Init,enum) 0 == if{ 1 (>L:XMLSND13,bool) 1 (>L:Avionics_On_Init,enum) }
        (L:Avionics_On_Init,enum) 1 == if{ 2 (>L:XMLSND14,bool) }
        }
    
        (A:ELECTRICAL AVIONICS BUS VOLTAGE,volts) 0 ==
        (A:ELECTRICAL MASTER BATTERY,bool) !
        or
        (L:Avionics_On_Init,enum) 1 == and
        if{ 3 (>L:XMLSND14,bool) 1 (>L:XMLSND15,bool) 0 (>L:Avionics_On_Init,enum) }
    
        (L:Primer,enum) 0 != (A:ELECTRICAL MASTER BATTERY,bool) and if{  2 (>L:XMLSND16,bool) } 
            els{  3 (>L:XMLSND16,bool) }
        (A:ELECTRICAL MASTER BATTERY,bool) (L:DoorSeal, number) 0 == and    if{
        (P:Absolute time,seconds) 30 % 1 > !
        if{ 1 (>L:XMLSND18,bool) }
        }
    
        (A:EXIT OPEN:0,percent) 0 &gt; (L:CabinLtsOvd, enum) 0 == and if{ 1 (>L:SwitchCabinLts, enum) }    
        (A:EXIT OPEN:0,percent) 0 == (L:CabinLtsOvd, enum) 0 == and if{ 0 (>L:SwitchCabinLts, enum) }
        
    
        (A:BRAKE PARKING POSITION,percent) 0 &gt;
        (L:C310_Chocks,bool) 1 == or
        if{ 1 (>K:FREEZE_LATITUDE_LONGITUDE_SET) 1 (>K:FREEZE_ATTITUDE_SET) }
        els{ 0 (>K:FREEZE_LATITUDE_LONGITUDE_SET) 0 (>K:FREEZE_ATTITUDE_SET) }
    
        (L:SND_INVC,bool) !
        (L:SND_MUTE,bool) or
        (L:SND_PAUSE,bool) or
        if{
        1 (>L:SND_GLOBALMUTE,bool)
        }
        els{
        0 (>L:SND_GLOBALMUTE,bool)
        }
    
        (A:ELECTRICAL MAIN BUS VOLTAGE, volts) 5 &gt; sp0    (L:SwitchFLTLts,enum) l0 * (>L:SwitchFLTLtsON,enum)
        (L:SwitchPNLLts,enum) l0 * (>L:SwitchPNLLtsON,enum)
        (L:SwitchEngLts,enum) l0 * (>L:SwitchEngLtsON,enum)
        (L:SwitchRadioLts,bool) l0 * (>L:SwitchRadioLtsON,bool)
        (L:SwitchRadioLtsON,bool) if{ (>K:PANEL_LIGHTS_ON) } els{ (>K:PANEL_LIGHTS_OFF) }
    
        <!-- CHECK IN THE DME.XML FOR THESE -> Fuel Flow and CHT (L:vars) -->
      </Update>
    </Gauge>
    
    Last edited by n4gix; 06-25-2020 at 05:26 PM.
    Bill Leaming
    Gauge Programming - 3d Modeling Military Visualizations
    Flightsim.com Panels & Gauges Forum Moderator
    Flightsim Rig: Intel Core i7-2600K - 8GB DDR3 1333 - EVGA GTX770 4GB - Win7 64bit Home Premium
    Development Rig1: Intel Core i7-3770k - 16GB DDR3 - Dual Radeon HD7770 SLI 1GB - Win7 64bit Professional
    Development Rig2: Intel Core i7-860 - 8GB DDR3 Corsair - GeForce GTS240 1GB - Win7 64bit Home Premium
    NOTE: Unless explicitly stated in the post, everything written by my hand is MY opinion. I do NOT speak for any company, real or imagined...

  7. #7
    Join Date
    Feb 2011
    Posts
    8,095
    Blog Entries
    1

    Default

    Hi n4gix, thanks for that.
    I haven't looked at it closely yet. I feel a bit overwhelmed at the moment by the changes in the covid situation.

    Another reason I haven't looked at it closely is that I have a bum shoulder at the moment so sitting at the pc is out and what you posted was a bit long to pick apart on my phone.

    The gauge I was making (invisible gauge that plays sound when you switch AP on or off) did not work and played both sounds over and over. I did find a thread over do FSDeveloper where someone had the exact same issue with both sounds playing over and over. You posted in that thread a very elegant looking solution.
    I bookmarked that, and when my shoulder is up and running again I'll look at that solution first. If I get it working I'll get back to this and try to get my original solution working as well. (I want to find the fault in my original logic. )

    I did manage to make a Visible lightswitch with clickspot that plays a sound when clicked. That one I did get working. (my first ever attempt at making a sound gauge.)

Similar Threads

  1. Can I put together a flight sim without all the parts?
    By michaelwozniak6 in forum Newcomer Services
    Replies: 6
    Last Post: 01-07-2016, 01:45 AM
  2. Will these components work together?
    By budreiser in forum PC Hardware, Video And Audio Help
    Replies: 8
    Last Post: 04-30-2010, 08:58 PM
  3. Replies: 8
    Last Post: 07-01-2008, 02:50 PM
  4. Replies: 0
    Last Post: 10-14-2007, 10:32 PM
  5. Replies: 2
    Last Post: 09-26-2004, 12:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •