<Gauge Name="GPWS" Version="4.0">
<Comment>
This GPWS gauge is for FSX ONLY ! See README for operation details.

Added in 2.1:
- Mode 1 - 7 is disabled when aircraft is below 20 feet corrected RadioAltitude instead of OnGround.
- Mode 1 now has two sets of threshold values: one for above and one for below 10000 ft RadioAltitude

Added in 3.0:
- When the sound in Mode 1 - 6 is disabled, is it automatically enabled again when the warning condition
  is removed; hence, sound can only be temporarily disabled for the duration of a warning period.
  Effectively, this means that modestate 2 is not possible anymore.
- Added a clicksound to all clickspots.

Added in 3.1:
- Each mode (1 - 6) has it's own repetition timer; this means that if the sound of an Active mode
  is disabled, the aural warning of a lower-priority Active mode is immediately started.
- The standard FS2004 variable for DH can now be made visible/changed.
- Night lighting added, dependant on Panel Light switch: seperate colored bitmaps for Background, SwitchOff
  and ModeS4 (off)

Added in 3.2:
- Removed nightlight bitmap (too complicated)
- Solved: no more Windshear callouts above Upper_RALT. 

Added in V3.3: editorials only; functionally the same as V3.2.

Added in V3.4:
- Change in Mode-2: only activated when RA is decreasing with more then 500 ft/min.
  (to prevent this callout as a result of altitude "jitter" when the aircraft is flying on AP AltitudeHold
   at low level over a flat terrain).
- Sets FS9 DecisionHeight (read as "number") to 200 ft as default.

Added in V4.0 (FSX)
- Added "Approaching minimums" callout; see Initialise.
- Altitude callouts are suppressed when flaps are fully retracted.
- Now sets/uses the FSX variable DecisionHeight instead of a local variable.

The values of the main GPWS parameters can be adapted to your own preference (c.q.
to your aircraft) by editing their values in the ******-marked box below.
USE NOTEPAD IN MAXIMISED WINDOW FOR GOOD OVERVIEW !

COPYRIGHT STATEMENT: 
This gauge is freeware, NOT public domain.
Other then editing for your personal use, it may NOT be renamed, copied, modified, 
or bundled in another archive without my prior consent.
Rob Barendregt, 1 July 2009
Email: rc.barendregt@planet.nl
</Comment>

<Update Frequency="6"/>

<Image Name="GPWS_Background.bmp" ImageSizes="82,31"/>

<!-- State INITIAL and State-Independant -->
<Element>
  <Select>
    <Value>
      (G:Var1) 0 ==
      if{
        (G:Var2) 0 == 
        if{

(******************************** GPWS parameters **************************************)
(***************************************************************************************)
(*********************!!!!!  ONLY CHANGE THE VALUES,  NOTHING ELSE  !!!!!! *************)
(***************************************************************************************)
(***************************************************************************************)
10     (&gt;L:GPWS_BasicRALT,number)     (* Basic R-Alt when aircraft on ground (feet) *)
35     (&gt;L:GPWS_BankAngle,number)     (* Max. bankangle for "BankAngle" (degrees)   *)
30     (&gt;L:GPWS_LandingFlaps,number)  (* Min. landing position flaps (%)            *)
15     (&gt;L:GPWS_WindChange,number)    (* Max. wind change for "Windshear" (knots)   *)
4      (&gt;L:GPWS_SoundRepTime,number)  (* Sound repetition time (sec.)               *)
900    (&gt;L:GPWS_UpperAlt,number)      (* Upper R-ALT threshold (feet)               *)
250    (&gt;L:GPWS_LowerAlt,number)      (* Lower R-ALT threshold (feet)               *)
-1500  (&gt;L:GPWS_UpperVS_L,number)     (* Upper V/S threshold (ft/min) below UpperAlt*)
-2000  (&gt;L:GPWS_LowerVS_L,number)     (* Lower V/S threshold (ft/min) below UpperAlt*)
-2500  (&gt;L:GPWS_UpperVS_H,number)     (* Upper V/S threshold (ft/min) over UpperAlt *)
-4000  (&gt;L:GPWS_LowerVS_H,number)     (* Lower V/S threshold (ft/min) over UpperAlt *)
-70    (&gt;L:GPWS_GSDev,number)         (* Max. angle below "Glideslope" (0 - -119)   *)
1      (&gt;L:GPWS_DS,number)            (* Master startup state (0: Off  1: On        *)
4      (&gt;L:GPWS_DM1,number)           (* Startup state for Mode-1 warnings:         *)
                                         (*   0: Permanently disabled and invisible    *)
                                         (*   1: Off                                   *)
                                         (*   4: On                                    *)
4      (&gt;L:GPWS_DM2,number)           (* Idem, for Mode-2                           *)
4      (&gt;L:GPWS_DM3,number)           (* Idem, for Mode-3                           *)
4      (&gt;L:GPWS_DM4,number)           (* Idem, for Mode-4                           *)
4      (&gt;L:GPWS_DM5,number)           (* Idem, for Mode-5                           *)
4      (&gt;L:GPWS_DM6,number)           (* Idem, for Mode-6                           *)
4      (&gt;L:GPWS_DM7,number)           (* Idem, for Mode-7                           *)
4      (&gt;L:GPWS_DM8,number)           (* Idem, for Mode-8                           *)
1      (&gt;L:GPWS_DH,bool)              (* Use DecisionHeight callouts  0: No  1: Yes *)
100    (&gt;L:GPWS_DHA,number)           (* Altitude (feet) above DH for "Approaching Minimums" callout   *)
(***************************************************************************************)
(***************************************************************************************)
(***************************************************************************************)
          (P:ABSOLUTE TIME,seconds) 1.0 + (&gt;G:Var2)
        }
        els{
          (P:ABSOLUTE TIME,seconds) (G:Var2) &gt;
          if{
            (L:GPWS_DS,number) 0 ==
            if{ 1 (&gt;G:Var1) }
            els{
              3 (&gt;G:Var1) 
              1 (&gt;G:Var3)
              (G:Var9) (&gt;G:Var4)
              (A:RADIO HEIGHT,feet) (L:GPWS_BasicRALT,number) - (&gt;G:Var5)
              (A:AIRCRAFT WIND Z,knots) (&gt;G:Var6)
              (GEAR HANDLE POSITION,percent) (&gt;G:Var7)
              (L:GPWS_DM1,number) (&gt;L:GPWS_AM1,number)
              (L:GPWS_DM2,number) (&gt;L:GPWS_AM2,number)
              (L:GPWS_DM3,number) (&gt;L:GPWS_AM3,number)
              (L:GPWS_DM4,number) (&gt;L:GPWS_AM4,number)
              (L:GPWS_DM5,number) (&gt;L:GPWS_AM5,number)
              (L:GPWS_DM6,number) (&gt;L:GPWS_AM6,number)
              (L:GPWS_DM7,number) (&gt;L:GPWS_AM7,number) 
              (L:GPWS_DM8,number) (&gt;L:GPWS_AM8,number)
            }
            (P:ABSOLUTE TIME,seconds) (&gt;L:GPWS_STM1,number)
            (P:ABSOLUTE TIME,seconds) (&gt;L:GPWS_STM2,number)
            (P:ABSOLUTE TIME,seconds) (&gt;L:GPWS_STM3,number)
            (P:ABSOLUTE TIME,seconds) (&gt;L:GPWS_STM4,number)
            (P:ABSOLUTE TIME,seconds) (&gt;L:GPWS_STM5,number)
            (P:ABSOLUTE TIME,seconds) (&gt;L:GPWS_STM6,number)
          }
        }
      }
      (A:RADIO HEIGHT,feet) (L:GPWS_BasicRALT,number) - sp0
      l0 20 &gt;
      if{ 0 } els{ 1 } (&gt;G:Var9)
      l0 (L:GPWS_UpperAlt,number) &gt; 
      if{ (L:GPWS_UpperVS_H,number) (&gt;L:GPWS_UpperVS,number) (L:GPWS_LowerVS_H,number) (&gt;L:GPWS_LowerVS,number) }
      els{ (L:GPWS_UpperVS_L,number) (&gt;L:GPWS_UpperVS,number) (L:GPWS_LowerVS_L,number) (&gt;L:GPWS_LowerVS,number) }
    </Value>
  </Select>
</Element>

<!-- State TEST, finished ? -->
<Element>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_Sound_WWG,number) 0 == &amp;&amp;
      if{ 
        3 (&gt;G:Var1) 
        1 (&gt;G:Var3)
        (G:Var9) (&gt;G:Var4)
        (A:RADIO HEIGHT,feet) (L:GPWS_BasicRALT,number) - (&gt;G:Var5)
        (A:AIRCRAFT WIND Z,knots) (&gt;G:Var6)
        (GEAR HANDLE POSITION,percent) (&gt;G:Var7)
        (L:GPWS_DM1,number) (&gt;L:GPWS_AM1,number)
        (L:GPWS_DM2,number) (&gt;L:GPWS_AM2,number)
        (L:GPWS_DM3,number) (&gt;L:GPWS_AM3,number)
        (L:GPWS_DM4,number) (&gt;L:GPWS_AM4,number)
        (L:GPWS_DM5,number) (&gt;L:GPWS_AM5,number)
        (L:GPWS_DM6,number) (&gt;L:GPWS_AM6,number)
        (L:GPWS_DM7,number) (&gt;L:GPWS_AM7,number) 
        (L:GPWS_DM8,number) (&gt;L:GPWS_AM8,number)
      }
    </Value>
  </Select>
</Element>

<!-- State ON, mode-independant calculations -->
<Element>
  <Select>
    <Value>
      (G:Var1) 3 ==
      if{
        l0 (L:GPWS_UpperAlt,number) &gt;
        if{ 1 (&gt;G:Var3) }
        els{
          (G:Var9) ! (G:Var4) &amp;&amp;
          (A:GEAR HANDLE POSITION,percent) 50 &lt; (G:Var7) 50 &gt; &amp;&amp; ||
          if{ 2 (&gt;G:Var3) }
        }
      }
    </Value>
  </Select>
</Element>

<!-- State ON, mode 1 ? -->
<Element>
  <Select>
    <Value>
      (G:Var1) 3 == (G:Var9) ! &amp;&amp; (G:Var3) 1 == &amp;&amp; (L:GPWS_AM1,number) 2 &gt;= &amp;&amp;
      if{
        (A:VERTICAL SPEED, feet per minute) (L:GPWS_LowerVS,number) &lt;
        if{
          (L:GPWS_AM1,number) 4 == if{ 5 (&gt;L:GPWS_AM1,number) }
          (P:ABSOLUTE TIME,seconds) (L:GPWS_STM1,number) &gt; (L:GPWS_AM1,number) 4 &gt;= &amp;&amp;
          if{ 
            1 (&gt;L:GPWS_SOUND_WWP,number)
            (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM1,number)
          }
        }
        els{
          (A:VERTICAL SPEED, feet per minute) (L:GPWS_UpperVS,number) &lt;
          if{
            (L:GPWS_AM1,number) 4 == if{ 5 (&gt;L:GPWS_AM1,number) }
            (P:ABSOLUTE TIME,seconds) (L:GPWS_STM1,number) &gt; (L:GPWS_AM1,number) 4 &gt;= &amp;&amp;
            if{ 
              1 (&gt;L:GPWS_SOUND_S,number)
              (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM1,number)
            }
          }
          els{ 4 (&gt;L:GPWS_AM1,number) }
        }
      }
      els{ (L:GPWS_AM1,number) 3 == (L:GPWS_AM1,number) 5 == || if{ 4 (&gt;L:GPWS_AM1,number) } }
    </Value>
  </Select>
</Element>

<!-- State ON, mode 2 ? -->
<Element>
  <Select>
    <Value>
      (* Due to "spikes" in the FS9 variable RadioHeight, when it's in-/decreasing, this mode uses a
         2-sec average to detect RadioHeight decrease of more than 500 ft/min (= 8.33 ft/sec) *)
      (L:GPWS_RA_AV_COUNT,number) 6 ==
      if{
        0 (&gt;L:GPWS_RA_AV_COUNT,number)
        (L:GPWS_RA_AV_CUR,number) (&gt;L:GPWS_RA_AV_PREV,number)
        l0 (&gt;L:GPWS_RA_AV_CUR,number)
      }
      (L:GPWS_RA_AV_COUNT,number) ++ (&gt;L:GPWS_RA_AV_COUNT,number) 
      (L:GPWS_RA_AV_PREV,number) (L:GPWS_RA_AV_CUR,number) - 8.33 &gt;
      if{ 1 } els{ 0 } sp4

      (G:Var1) 3 == (G:Var9) ! &amp;&amp; (G:Var3) 1 == &amp;&amp;  (L:GPWS_AM2,number) 2 &gt;= &amp;&amp;
      (A:GEAR HANDLE POSITION,percent) 50 &lt; &amp;&amp;
      (A:FLAPS HANDLE PERCENT,percent) (L:GPWS_LandingFlaps,number) &lt; &amp;&amp;
      if{
        l0 (L:GPWS_LowerAlt,number) &lt; l4 &amp;&amp;
        if{
          (L:GPWS_AM2,number) 4 == if{ 5 (&gt;L:GPWS_AM2,number) }
          (P:ABSOLUTE TIME,seconds) (L:GPWS_STM2,number) &gt; (L:GPWS_AM2,number) 4 &gt;= &amp;&amp;
          (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
          if{ 
            1 (&gt;L:GPWS_SOUND_WWP,number)
            (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM2,number)
          }
        }
        els{
          l0 (L:GPWS_UpperAlt,number) &lt; l4 &amp;&amp;
          if{
            (L:GPWS_AM2,number) 4 == if{ 5 (&gt;L:GPWS_AM2,number) }
            (P:ABSOLUTE TIME,seconds) (L:GPWS_STM2,number) &gt; (L:GPWS_AM2,number) 4 &gt;= &amp;&amp;
            (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
            if{ 
              1 (&gt;L:GPWS_SOUND_TT,number)
              (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM2,number)
            }
          }
          els{ 4 (&gt;L:GPWS_AM2,number) }
        }
      }
      els{ (L:GPWS_AM2,number) 3 == (L:GPWS_AM2,number) 5 == || if{ 4 (&gt;L:GPWS_AM2,number) } }
    </Value>
  </Select>
</Element>

<!-- State ON, mode 3 ? -->
<Element>
  <Select>
    <Value>
      (G:Var1) 3 == (G:Var9) ! &amp;&amp; (G:Var3) 2 == &amp;&amp; (L:GPWS_AM3,number) 2 &gt;= &amp;&amp;
      l0 (L:GPWS_UpperAlt,number) &lt;  &amp;&amp;
      if{
        (A:VERTICAL SPEED, feet per minute) 0 &lt;
        if{
          (L:GPWS_AM3,number) 4 == if{ 5 (&gt;L:GPWS_AM3,number) }
          (P:ABSOLUTE TIME,seconds) (L:GPWS_STM3,number) &gt; (L:GPWS_AM3,number) 4 &gt;= &amp;&amp;
          (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
          (L:GPWS_AM2,number) 5 &lt; &amp;&amp;
          if{ 
            1 (&gt;L:GPWS_SOUND_DS,number)
            (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM3,number)
          }
        }
        els{
          l0 (G:Var5) &lt;
          if{
            (L:GPWS_AM3,number) 4 == if{ 5 (&gt;L:GPWS_AM3,number) }
            (P:ABSOLUTE TIME,seconds) (L:GPWS_STM3,number) &gt; (L:GPWS_AM3,number) 4 &gt;= &amp;&amp;
            (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
            (L:GPWS_AM2,number) 5 &lt; &amp;&amp;
            if{ 
              1 (&gt;L:GPWS_SOUND_TT,number)
              (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM3,number)
            }
          }
          els{ 4 (&gt;L:GPWS_AM3,number) }
        }
      }
      els{ (L:GPWS_AM3,number) 3 == (L:GPWS_AM3,number) 5 == || if{ 4 (&gt;L:GPWS_AM3,number) } }
    </Value>
  </Select>
</Element>

<!-- State ON, mode 4 ? -->
<Element>
  <Select>
    <Value>
      (G:Var1) 3 == (G:Var9) ! &amp;&amp; (G:Var3) 1 == &amp;&amp; (L:GPWS_AM4,number) 2 &gt;= &amp;&amp;
      l0 (L:GPWS_UpperAlt,number) &lt; &amp;&amp;
      if{
        (A:GEAR HANDLE POSITION,percent) 50 &lt;
        if{
          (L:GPWS_AM4,number) 4 == if{ 5 (&gt;L:GPWS_AM4,number) }
          (A:FLAPS HANDLE PERCENT,percent) (L:GPWS_LandingFlaps,number) &lt;
          if{
            (P:ABSOLUTE TIME,seconds) (L:GPWS_STM4,number) &gt; (L:GPWS_AM4,number) 4 &gt;= &amp;&amp;
            (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
            (L:GPWS_AM2,number) 5 &lt; &amp;&amp;
            (L:GPWS_AM3,number) 5 &lt; &amp;&amp;
            if{ 
              1 (&gt;L:GPWS_SOUND_TLT,number)
              (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM4,number)
            }
          }
          els{
            (P:ABSOLUTE TIME,seconds) (L:GPWS_STM4,number) &gt; (L:GPWS_AM4,number) 4 &gt;= &amp;&amp;
            (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
            (L:GPWS_AM2,number) 5 &lt; &amp;&amp;
            (L:GPWS_AM3,number) 5 &lt; &amp;&amp;
            if{ 
              1 (&gt;L:GPWS_SOUND_TLG,number)
              (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM4,number)
            }
          }
        }
        els{
          (A:FLAPS HANDLE PERCENT,percent) (L:GPWS_LandingFlaps,number) &lt;
          if{
            (L:GPWS_AM4,number) 4 == if{ 5 (&gt;L:GPWS_AM4,number) }
            (P:ABSOLUTE TIME,seconds) (L:GPWS_STM4,number) &gt; (L:GPWS_AM4,number) 4 &gt;= &amp;&amp;
            (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
            (L:GPWS_AM2,number) 5 &lt; &amp;&amp;
            (L:GPWS_AM3,number) 5 &lt; &amp;&amp;
            if{ 
              1 (&gt;L:GPWS_SOUND_TLF,number)
              (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM4,number)
            }
          }
          els{ 4 (&gt;L:GPWS_AM4,number) }
        }
      }
      els{ (L:GPWS_AM4,number) 3 == (L:GPWS_AM4,number) 5 == || if{ 4 (&gt;L:GPWS_AM4,number) } }
    </Value>
  </Select>
</Element>

<!-- State ON, mode 5 ? -->
<Element>
  <Select>
    <Value>
      (G:Var1) 3 == (G:Var9) ! &amp;&amp; (G:Var3) 1 == &amp;&amp; (L:GPWS_AM5,number) 2 &gt;= &amp;&amp;
      l0 (L:GPWS_UpperAlt,number) &lt; &amp;&amp;
      (A:NAV1 GSI,number) (L:GPWS_GSDev,number) &lt; &amp;&amp;
      (A:NAV1 GS FLAG, bool) &amp;&amp;
      (A:GEAR HANDLE POSITION,percent) 50 &gt; &amp;&amp;
      (A:FLAPS HANDLE PERCENT,percent) (L:GPWS_LandingFlaps,number) &gt; &amp;&amp;
      if{
        (L:GPWS_AM5,number) 4 == if{ 5 (&gt;L:GPWS_AM5,number) }
        (P:ABSOLUTE TIME,seconds) (L:GPWS_STM5,number) &gt; (L:GPWS_AM5,number) 4 &gt;= &amp;&amp;
        (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
        (L:GPWS_AM2,number) 5 &lt; &amp;&amp;
        (L:GPWS_AM3,number) 5 &lt; &amp;&amp;
        (L:GPWS_AM4,number) 5 &lt; &amp;&amp;
        if{ 
          1 (&gt;L:GPWS_SOUND_G,number)
          (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM5,number)
        }
      }
      els{ (L:GPWS_AM5,number) 3 == (L:GPWS_AM5,number) 5 == || if{ 4 (&gt;L:GPWS_AM5,number) } }
    </Value>
  </Select>
</Element>

<!-- State ON, mode 6 ? -->
<Element>
  <Select>
    <Value>
      (G:Var1) 3 == (G:Var9) ! &amp;&amp;  (L:GPWS_AM6,number) 2 &gt;= &amp;&amp;
      (A:ATTITUDE INDICATOR BANK DEGREES,degrees) abs (L:GPWS_BankAngle,number) &gt; &amp;&amp;
      if{
        (L:GPWS_AM6,number) 4 == if{ 5 (&gt;L:GPWS_AM6,number) }
        (P:ABSOLUTE TIME,seconds) (L:GPWS_STM6,number) &gt; (L:GPWS_AM6,number) 4 &gt;= &amp;&amp;
        (L:GPWS_AM1,number) 5 &lt; &amp;&amp;
        (L:GPWS_AM2,number) 5 &lt; &amp;&amp;
        (L:GPWS_AM3,number) 5 &lt; &amp;&amp;
        (L:GPWS_AM4,number) 5 &lt; &amp;&amp;
        (L:GPWS_AM5,number) 5 &lt; &amp;&amp;
        if{ 
          1 (&gt;L:GPWS_SOUND_BA,number)
          (P:ABSOLUTE TIME,seconds) (L:GPWS_SoundRepTime,number) + (&gt;L:GPWS_STM6,number)
        }
      }
      els{ (L:GPWS_AM6,number) 3 == (L:GPWS_AM6,number) 5 == || if{ 4 (&gt;L:GPWS_AM6,number) } }
    </Value>
  </Select>
</Element>

<!-- State ON, mode 7 ? -->
<Element>
  <Select>
    <Value>
      (G:Var1) 3 == (G:Var9) ! &amp;&amp; (L:GPWS_AM7,number) 4 == &amp;&amp;
      l0 (L:GPWS_UpperAlt,number) &lt; &amp;&amp;
      (A:AIRCRAFT WIND Z,knots) (G:Var6) - abs (L:GPWS_WindChange,number) &gt; &amp;&amp;
      if{ 1 (&gt;L:GPWS_Sound_W,number) }
    </Value>
  </Select>
</Element>

<!-- State ON, mode 8 ? -->
<Element>
  <Select>
    <Value>
      (G:Var1) 3 == (L:GPWS_AM8,number) 2 &gt;= &amp;&amp;
      if{
        (A:DECISION HEIGHT,feet) s3 (L:GPWS_DHA,number) + sp4
        (A:FLAPS HANDLE PERCENT,percent) 0.1 &lt;
        (G:Var5) l0 - 20 &gt; || (G:Var5) l0 &lt;= ||  (L:GPWS_AM8,number) 3 &lt;=  ||
        if{ }
        els{ l0   l3 &lt; (G:Var5)   l3 &gt; &amp;&amp; (L:GPWS_DH,bool) &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_M,number) }
        els{ l0   l4 &lt; (G:Var5)   l4 &gt; &amp;&amp; (L:GPWS_DH,bool) &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_AM,number) }
        els{ l0   10 &lt; (G:Var5)   10 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_10,number) }
        els{ l0   20 &lt; (G:Var5)   20 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_20,number) }
        els{ l0   30 &lt; (G:Var5)   30 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_30,number) }
        els{ l0   40 &lt; (G:Var5)   40 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_40,number) }
        els{ l0   50 &lt; (G:Var5)   50 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_50,number) }
        els{ l0  100 &lt; (G:Var5)  100 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_100,number) }
        els{ l0  200 &lt; (G:Var5)  200 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_200,number) }
        els{ l0  300 &lt; (G:Var5)  300 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_300,number) }
        els{ l0  400 &lt; (G:Var5)  400 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_400,number) }
        els{ l0  500 &lt; (G:Var5)  500 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_500,number) }
        els{ l0 1000 &lt; (G:Var5) 1000 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_1000,number) }
        els{ l0 2500 &lt; (G:Var5) 2500 &gt; &amp;&amp; if{ 1 (&gt;L:GPWS_Sound_2500,number) }
        } } } } } } } } } } } } } }
      }
    </Value>
  </Select>
</Element>

<!-- Mode-independant saving of current values -->
<Element>
  <Select>
    <Value>
      (G:Var9) (&gt;G:Var4)
      l0 (&gt;G:Var5)
      (A:AIRCRAFT WIND Z,knots) (&gt;G:Var6)
      (A:GEAR HANDLE POSITION,percent) (&gt;G:Var7)
    </Value>
  </Select>
</Element>


<!-- Handle mouseclick -->
<Mouse>
  <Area Left="27" Top="2" Right="37" Bottom="12">
    <Cursor Type="DownArrow"/>
    <Tooltip ID="">Decrease DecisionHeight (%((A:DECISION HEIGHT,feet))%!d! Ft)</Tooltip>
    <Click Repeat="Yes">(&gt;K:DECREASE_DECISION_HEIGHT) 1 (&gt;L:GPWS_SOUND_CLICK,number)</Click>
  </Area>
  <Area Left="37" Top="2" Right="45" Bottom="12">
    <Tooltip ID="">GPWS V4.0</Tooltip>
  </Area>
  <Area Left="45" Top="2" Right="55" Bottom="12">
    <Cursor Type="UpArrow"/>
    <Tooltip ID="">Increase DecisionHeight (%((A:DECISION HEIGHT,feet))%!d! Ft)</Tooltip>
    <Click Repeat="Yes">(&gt;K:INCREASE_DECISION_HEIGHT) 1 (&gt;L:GPWS_SOUND_CLICK,number)</Click>
  </Area>
  <Area Left="2" Top="2" Right="22" Bottom="9">
    <Cursor Type="Hand"/>
    <Tooltip ID="">TOGA Mode (%('On' 'Off' 'Disabled' 3 (G:Var3) case )%!s!)</Tooltip>
    <Click>
      (G:Var3) 1 ==
      if{ 2 (&gt;G:Var3) 1 (&gt;L:GPWS_SOUND_CLICK,number) }
      els{
        (G:Var3) 2 ==
        if{ 1 (&gt;G:Var3) 1 (&gt;L:GPWS_SOUND_CLICK,number) }
      }
    </Click>
  </Area>
  <Area Left="60" Top="3" Right="78" Bottom="9">
    <Cursor Type="Hand"/>
    <Tooltip ID="">GPWS Master (%('On' 'Test' 'Off' ' ' 4 (G:Var1) case )%!s!)</Tooltip>
    <Click>
      1 (&gt;L:GPWS_SOUND_CLICK,number)
      (G:Var1) 1 == 
      if{
        2 (&gt;G:Var1)
        1 (&gt;L:GPWS_Sound_WWG,number)
      }
      els{
        (G:Var1) 3 == 
        if{
          1 (&gt;G:Var1)
          0 (&gt;G:Var3)
          0 (&gt;L:GPWS_AM1,number)
          0 (&gt;L:GPWS_AM2,number)
          0 (&gt;L:GPWS_AM3,number)
          0 (&gt;L:GPWS_AM4,number)
          0 (&gt;L:GPWS_AM5,number)
          0 (&gt;L:GPWS_AM6,number)
          0 (&gt;L:GPWS_AM7,number)
          0 (&gt;L:GPWS_AM8,number)
        }
      }
    </Click>
  </Area>
  <Area Left="2" Top="15" Right="9" Bottom="28">
    <Cursor Type="Hand"/>
    <Tooltip ID="">MODE-1: Excessive descent rate %('(On)' '(On)' '(On|AuralOff)' '(On|AuralOff)' '(Off)' '(Disabled)' 6 (L:GPWS_AM1,number) case )%!s!</Tooltip>
    <Click>
      (G:Var1) 3 ==
      if{ 
        (L:GPWS_AM1,number) sp3
        (L:GPWS_AM1,number) 1 == if{ 4 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM1,number) 3 == if{ 5 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM1,number) 4 == if{ 1 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM1,number) 5 == if{ 3 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        l3 (&gt;L:GPWS_AM1,number)
      }
    </Click>
  </Area>
  <Area Left="12" Top="15" Right="19" Bottom="28">
    <Cursor Type="Hand"/>
    <Tooltip ID="">MODE-2: Excessive terrain closure rate %('(On)' '(On)' '(On|AuralOff)' '(On|AuralOff)' '(Off)' '(Disabled)' 6 (L:GPWS_AM2,number) case )%!s!</Tooltip>
    <Click>
      (G:Var1) 3 ==
      if{ 
        (L:GPWS_AM2,number) sp3
        (L:GPWS_AM2,number) 1 == if{ 4 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM2,number) 3 == if{ 5 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM2,number) 4 == if{ 1 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM2,number) 5 == if{ 3 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        l3 (&gt;L:GPWS_AM2,number)
      }
    </Click>
  </Area>
  <Area Left="22" Top="15" Right="29" Bottom="28">
    <Cursor Type="Hand"/>
    <Tooltip ID="">MODE-3: Loss of altitude after takeoff %('(On)' '(On)' '(On|AuralOff)' '(On|AuralOff)' '(Off)' '(Disabled)' 6 (L:GPWS_AM3,number) case )%!s!</Tooltip>
    <Click>
      (G:Var1) 3 ==
      if{ 
        (L:GPWS_AM3,number) sp3
        (L:GPWS_AM3,number) 1 == if{ 4 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM3,number) 3 == if{ 5 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM3,number) 4 == if{ 1 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM3,number) 5 == if{ 3 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        l3 (&gt;L:GPWS_AM3,number)
      }
    </Click>
  </Area>
  <Area Left="32" Top="15" Right="39" Bottom="28">
    <Cursor Type="Hand"/>
    <Tooltip ID="">MODE-4: Insufficient terrain clearance %('(On)' '(On)' '(On|AuralOff)' '(On|AuralOff)' '(Off)' '(Disabled)' 6 (L:GPWS_AM4,number) case )%!s!</Tooltip>
    <Click>
      (G:Var1) 3 ==
      if{ 
        (L:GPWS_AM4,number) sp3
        (L:GPWS_AM4,number) 1 == if{ 4 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM4,number) 3 == if{ 5 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM4,number) 4 == if{ 1 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM4,number) 5 == if{ 3 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        l3 (&gt;L:GPWS_AM4,number)
      }
    </Click>
  </Area>
  <Area Left="42" Top="15" Right="49" Bottom="28">
    <Cursor Type="Hand"/>
    <Tooltip ID="">MODE-5: Excessive glideslope deviation %('(On)' '(On)' '(On|AuralOff)' '(On|AuralOff)' '(Off)' '(Disabled)' 6 (L:GPWS_AM5,number) case )%!s!</Tooltip>
    <Click>
      (G:Var1) 3 ==
      if{ 
        (L:GPWS_AM5,number) sp3
        (L:GPWS_AM5,number) 1 == if{ 4 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM5,number) 3 == if{ 5 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM5,number) 4 == if{ 1 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM5,number) 5 == if{ 3 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        l3 (&gt;L:GPWS_AM5,number)
      }
    </Click>
  </Area>
  <Area Left="52" Top="15" Right="59" Bottom="28">
    <Cursor Type="Hand"/>
    <Tooltip ID="">MODE-6: Excessive banking %('(On)' '(On)' '(On|AuralOff)' '(On|AuralOff)' '(Off)' '(Disabled)' 6 (L:GPWS_AM6,number) case )%!s!</Tooltip>
    <Click>
      (G:Var1) 3 ==
      if{ 
        (L:GPWS_AM6,number) sp3
        (L:GPWS_AM6,number) 1 == if{ 4 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM6,number) 3 == if{ 5 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM6,number) 4 == if{ 1 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM6,number) 5 == if{ 3 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        l3 (&gt;L:GPWS_AM6,number)
      }
    </Click>
  </Area>
  <Area Left="62" Top="15" Right="69" Bottom="28">
    <Cursor Type="Hand"/>
    <Tooltip ID="">MODE-7: Windshear %('(On)' '(On)' '(On)' '(On)' '(Off)' '(Disabled)' 6 (L:GPWS_AM7,number) case )%!s!</Tooltip>
    <Click>
      (G:Var1) 3 ==
      if{ 
        (L:GPWS_AM7,number) sp3
        (L:GPWS_AM7,number) 1 == if{ 4 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM7,number) 4 == if{ 1 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        l3 (&gt;L:GPWS_AM7,number)
      }
    </Click>
  </Area>
  <Area Left="72" Top="15" Right="79" Bottom="28">
    <Cursor Type="Hand"/>
    <Tooltip ID="">MODE-8: Altitude warning %('(On)' '(On)' '(On)' '(On)' '(Off)' '(Disabled)' 6 (L:GPWS_AM8,number) case )%!s!</Tooltip>
    <Click>
      (G:Var1) 3 ==
      if{ 
        (L:GPWS_AM8,number) sp3
        (L:GPWS_AM8,number) 1 == if{ 4 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        (L:GPWS_AM8,number) 4 == if{ 1 sp3 1 (&gt;L:GPWS_SOUND_CLICK,number) }
        l3 (&gt;L:GPWS_AM8,number)
      }
    </Click>
  </Area>

</Mouse>

<!-- Display status bitmaps -->
<Element>
<Position X="59" Y="2"/>
  <Select>
    <Value>(G:Var1)</Value>
    <Case Value="1"> <Image Name="GPWS_SwitchRed.bmp" ImageSizes="21,8"/> </Case>
    <Case Value="2"> <Image Name="GPWS_SwitchGreen.bmp" ImageSizes="21,8"/> </Case>
    <Case Value="3"> <Image Name="GPWS_SwitchOff.bmp" ImageSizes="21,8"/> </Case>
  </Select>
</Element>
<Element>
<Position X="2" Y="2"/>
  <Select>
    <Value>
      (G:Var1) 2 ==
      if{ 2 }
      els{ (G:Var3) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_SwitchOff.bmp" ImageSizes="21,8"/> </Case>
    <Case Value="2"> <Image Name="GPWS_SwitchAmber.bmp" ImageSizes="21,8"/> </Case>
  </Select>
</Element>
<Element>
<Position X="2" Y="15"/>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_DM1,number) 0 == ! &amp;&amp;
      if{ 5 }
      els{ (L:GPWS_AM1,number) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_ModeS1.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="2"> <Image Name="GPWS_ModeS2.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="3"> <Image Name="GPWS_ModeS3.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="4"> <Image Name="GPWS_ModeS4.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="5"> <Image Name="GPWS_ModeS5.bmp" ImageSizes="8,14"/> </Case>
  </Select>
</Element>
<Element>
<Position X="12" Y="15"/>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_DM2,number) 0 == ! &amp;&amp;
      if{ 5 }
      els{ (L:GPWS_AM2,number) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_ModeS1.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="2"> <Image Name="GPWS_ModeS2.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="3"> <Image Name="GPWS_ModeS3.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="4"> <Image Name="GPWS_ModeS4.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="5"> <Image Name="GPWS_ModeS5.bmp" ImageSizes="8,14"/> </Case>
  </Select>
</Element>
<Element>
<Position X="22" Y="15"/>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_DM3,number) 0 == ! &amp;&amp;
      if{ 5 }
      els{ (L:GPWS_AM3,number) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_ModeS1.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="2"> <Image Name="GPWS_ModeS2.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="3"> <Image Name="GPWS_ModeS3.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="4"> <Image Name="GPWS_ModeS4.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="5"> <Image Name="GPWS_ModeS5.bmp" ImageSizes="8,14"/> </Case>
  </Select>
</Element>
<Element>
<Position X="32" Y="15"/>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_DM4,number) 0 == ! &amp;&amp;
      if{ 5 }
      els{ (L:GPWS_AM4,number) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_ModeS1.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="2"> <Image Name="GPWS_ModeS2.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="3"> <Image Name="GPWS_ModeS3.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="4"> <Image Name="GPWS_ModeS4.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="5"> <Image Name="GPWS_ModeS5.bmp" ImageSizes="8,14"/> </Case>
  </Select>
</Element>
<Element>
<Position X="42" Y="15"/>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_DM5,number) 0 == ! &amp;&amp;
      if{ 5 }
      els{ (L:GPWS_AM5,number) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_ModeS1.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="2"> <Image Name="GPWS_ModeS2.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="3"> <Image Name="GPWS_ModeS3.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="4"> <Image Name="GPWS_ModeS4.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="5"> <Image Name="GPWS_ModeS5.bmp" ImageSizes="8,14"/> </Case>
  </Select>
</Element>
<Element>
<Position X="52" Y="15"/>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_DM6,number) 0 == ! &amp;&amp;
      if{ 5 }
      els{ (L:GPWS_AM6,number) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_ModeS1.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="2"> <Image Name="GPWS_ModeS2.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="3"> <Image Name="GPWS_ModeS3.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="4"> <Image Name="GPWS_ModeS4.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="5"> <Image Name="GPWS_ModeS5.bmp" ImageSizes="8,14"/> </Case>
  </Select>
</Element>
<Element>
<Position X="62" Y="15"/>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_DM7,number) 0 == ! &amp;&amp;
      (L:GPWS_Sound_W,number) ||
      if{ 5 }
      els{ (L:GPWS_AM7,number) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_ModeS1.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="2"> <Image Name="GPWS_ModeS2.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="3"> <Image Name="GPWS_ModeS3.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="4"> <Image Name="GPWS_ModeS4.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="5"> <Image Name="GPWS_ModeS5.bmp" ImageSizes="8,14"/> </Case>
  </Select>
</Element>
<Element>
<Position X="72" Y="15"/>
  <Select>
    <Value>
      (G:Var1) 2 == (L:GPWS_DM8,number) 0 == ! &amp;&amp;
      (L:GPWS_Sound_M,number) ||
      (L:GPWS_Sound_AM,number) ||
      (L:GPWS_Sound_10,number) ||
      (L:GPWS_Sound_20,number) ||
      (L:GPWS_Sound_30,number) ||
      (L:GPWS_Sound_40,number) ||
      (L:GPWS_Sound_50,number) ||
      (L:GPWS_Sound_100,number) ||
      (L:GPWS_Sound_200,number) ||
      (L:GPWS_Sound_300,number) ||
      (L:GPWS_Sound_400,number) ||
      (L:GPWS_Sound_500,number) ||
      (L:GPWS_Sound_1000,number) ||
      (L:GPWS_Sound_2500,number) ||
      if{ 5 }
      els{ (L:GPWS_AM8,number) }
    </Value>
    <Case Value="1"> <Image Name="GPWS_ModeS1.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="2"> <Image Name="GPWS_ModeS2.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="3"> <Image Name="GPWS_ModeS3.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="4"> <Image Name="GPWS_ModeS4.bmp" ImageSizes="8,14"/> </Case>
    <Case Value="5"> <Image Name="GPWS_ModeS5.bmp" ImageSizes="8,14"/> </Case>
  </Select>
</Element>

<Comment>
Design Info: Used local vars
============================
- Var1: Master State (0:Initial 1:Off 2:Test 3:On)
- Var2: Initial timer
- Var3: TOGA mode (0: Disabled  1: Off  2:On)
- Var4: Previous Var9 state
- Var5: Previous corrected RadioAltitude
- Var6: Previous longitudinal windspeed.
- Var7: Previous gear state.
- Var8: 
- Var9: Own SIM ON GROUND variable (1: when corrected RadioAltitude less then 20 ft)
- s0:   Current corrected RadioAltitude.
- s1:   Current Absolute time
- s3:   TEMP
- s4:   TEMP
- L:GPWS_RA_AV*: variables to determine 1-sec RA difference.
- L:GPWS_STM*: Sound repetition timer for Mode*
- L:GPWS_DM*:  Initial state for Mode*
- L:GPWS_AM*:  Actual state for Mode*  (0: Disabled  1:Off  2:On/NotActive/SoundOff 3:On/Active/SoundOff
                                         4:On/NotAvtive/SoundOn  5:On/Active/SoundOn )  
</Comment>

</Gauge>
