<Gauge Name="VSTOL Controller IPC, Functional part " Version="1.9">
<Comment>
FSX VERSION !!

This gauge emulates a VTOL controller for Libardo Guzman's Thunderbird-2, 
using Doug Dawson's xml2ipc gauge (FSUIPC required !!).

V1.3:
- Smoothed V/S at transition from VTOL to flight
- Smoothed V/S on transition from flight to VTOL (sink dependant on throttle AND airspeed)
- No windsensitivity during VTOL
- L:Var for FS9/FSX choice (reducing roll, yaw and pitch sensitivities by 3.14 in FSX)
- Common init time for FS9 and FSX: 10 sec.

V1.4
- Sonic cloud effect now coupled to Smokesystem

V1.5
- Added pitch compensation during VTOL

V1.6
- Smoke effects now only switched On during daytime
- Flame down effects now coupled to Cabin lights.
- Flame back effects now coupled to Recognition lights.

V1.7
- Adds elevator trim down when Final is on

V1.8
- All Smoke effects enabled again for dawn/dusk/night (new smoke effects)

V1.9
- Strobes (external light effects) are forced Off when Exit is open
- Reduced Sonic Boom sound delay to 2 sec.

COPYRIGHT STATEMENT
==================
Although this gauge is freeware, it may NOT be renamed, copied, re-uploaded,
modified, or bundled in an other archive, without my prior consent.
Rob Barendregt, 4 March 2011
Email: rc.barendregt@planet.nl

</Comment>

<Update Frequency="0"/>

<Macro Name="VSTOLThresholdRH">
  (L:VSTOLGroundRH,number)  0.5 +
</Macro>
<Macro Name="WindSpeedLon">
  (A:AMBIENT WIND DIRECTION,degrees) (A:PLANE HEADING DEGREES TRUE,degrees) - 
  dnor dgrd cos (A:AMBIENT WIND VELOCITY,knots) * (L:VSTOLWindOn,bool) *
</Macro>
<Macro Name="WindSpeedLat">
  (A:AMBIENT WIND DIRECTION,degrees) (A:PLANE HEADING DEGREES TRUE,degrees) - 
  dnor dgrd sin (A:AMBIENT WIND VELOCITY,knots) * (L:VSTOLWindOn,bool) *
</Macro>
<Macro Name="CenterThrust">
   (A:TURB ENG1 N1,percent) 75 -                              (* Trust-dependant V/S
   (A:GROUND VELOCITY,knots) 50 - 0 max 200 min 200 / 40 * +  (* Airspeed-dependant V/S *) 
</Macro>
<Macro Name="EnginesOn">
  (A:TURB ENG1 N1,percent) 15 &gt;
</Macro>
<Macro Name="SimRunning">
  (A:IS SLEW ACTIVE,bool) !
  (P:ABSOLUTE TIME,seconds) (L:VSTOL_Time,number) &gt; &amp;&amp;
  (L:VSTOLInit,number) 200 &gt; &amp;&amp;
</Macro>

<Element>
  <Select>
    <Value>
      (L:VSTOLInit,number) ++ d (&gt;L:VSTOLInit,number) 200 ==
      if{
        24.5 (&gt;L:VSTOLGroundRH,number)         (* in feet, IMPORTANT VALUE !!! *)
        0 (&gt;L:VSTOLGroundPitch,number)         (* in degrees *)
        0 (&gt;L:VSTOLWindOn,bool)                (* No windsensitivity in VTOL *)
        3.14 (&gt;L:VSTOLfsx,number)              (* 1.00: FS9   3.14: FSX *)
        1.44 (&gt;L:VSTOLNoseWheelRadius,number)  (* in feet (as in aircraft.cfg) *)
        (P:ABSOLUTE TIME,seconds) (&gt;L:VSTOL_Time,number)
        (P:ABSOLUTE TIME,seconds) (&gt;L:ExitTimer,number) 
        (P:ABSOLUTE TIME,seconds) (&gt;L:TailhookTimer,number) 
        (P:ABSOLUTE TIME,seconds) 11 - (&gt;L:SonicBoomTimer,number) 
      }
    </Value>
  </Select>
</Element>

<Element>
  <Select>
    <Value>
      @SimRunning
      if{
        (A:BRAKE PARKING POSITION,bool) ! (A:RADIO HEIGHT,feet) @VSTOLThresholdRH &lt; &amp;&amp; (L:VSTOLEnabled,bool) ! &amp;&amp;
        (A:EXIT OPEN:0,percent) 5 &gt; ||
        if{ 0 (&gt;K:THROTTLE_SET) }

        (L:VSTOLFinal,bool) (A:RADIO HEIGHT,feet) @VSTOLThresholdRH 5 + &gt; || (A:BRAKE PARKING POSITION,bool) &amp;&amp;
        if{ (&gt;K:PARKING_BRAKES) }

        (L:VSTOLFinal,bool)
        if{
          (A:AIRSPEED INDICATED,knots) 200 &gt; 
          if{ 0 (&gt;L:VSTOLFinal,bool) 0 (&gt;L:VSTOLEnabled,bool) 0 (&gt;L:vertical_velocity_value,number) }
          els{ 1 (&gt;L:VSTOLEnabled,bool) }
        }
        els{
          (A:FLAPS HANDLE INDEX,number) 1 ==
          if{
            @CenterThrust 0 &gt; (A:BRAKE PARKING POSITION,bool) &amp;&amp;
            (A:RADIO HEIGHT,feet) @VSTOLThresholdRH &gt; (L:VSTOLPrevEnabled,bool) &amp;&amp; ||
            (A:RADIO HEIGHT,feet) @VSTOLThresholdRH 5 + &gt; ||
            if{ 1 } els{ 0 } (&gt;L:VSTOLEnabled,bool)
          }
          els{
            (L:VSTOLPrevEnabled,bool) (L:VSTOLPrevFHI,number) 1 == &amp;&amp;
            (A:BRAKE PARKING POSITION,bool) (A:TURB ENG1 N1,percent) 90 &gt; &amp;&amp; ||
            if{ 1 (&gt;L:VSTOLFinal,bool) 1 (&gt;L:VSTOLEnabled,bool) 1600 (&gt;K:AXIS_ELEV_TRIM_SET) }
          }
        }
      }
    </Value>
  </Select>
</Element>

<Element>
  <Select>
    <Value>
      @SimRunning
      if{
        0 d d d d d
        (&gt;L:longitudinal_velocity_control,number) (&gt;L:lateral_velocity_control,number) (&gt;L:yaw_velocity_control,number)
        (&gt;L:vertical_velocity_control,number) (&gt;L:pitch_velocity_control,number) (&gt;L:roll_velocity_control,number)

        (L:VSTOLEnabled,bool)
        if{
          (A:AUTOPILOT MASTER,bool) if{ (&gt;K:AP_MASTER) }
          (A:AUTOPILOT AIRSPEED HOLD,bool) if{ (&gt;K:AP_AIRSPEED_OFF) }
          (A:AUTOPILOT MACH HOLD,bool) if{ (&gt;K:AP_MACH_OFF) }
          (L:longitudinal_velocity_value,number) 1.688 / sp10

          @WindSpeedLon neg
          (L:VSTOLFinal,bool)
          if{
            1000 +
            l10 - 1.1 min
          }
          els{
            (A:ATTITUDE INDICATOR PITCH DEGREES,degrees) (L:VSTOLGroundPitch,number) - 6.0 * 160 min -80 max +
            l10 - 0.5 min l10 80 &gt; if{ -0.7 } els{ -0.5 } max
          }  l10 + 1.688 * (&gt;L:longitudinal_velocity_value,number)
          2 (&gt;L:longitudinal_velocity_control,number)

          (A:FLAPS HANDLE INDEX,number) 1 ==
          (A:RADIO HEIGHT,feet) @VSTOLThresholdRH &gt; ||
          if{
            (A:RUDDER POSITION,number) 0.4 * (L:VSTOLfsx,number) / (&gt;L:yaw_velocity_value,number)
            2 (&gt;L:yaw_velocity_control,number)
            (A:AILERON POSITION,number)  d abs * -0.2 * (L:VSTOLfsx,number) / (&gt;L:roll_velocity_value,number)
            2 (&gt;L:roll_velocity_control,number)
            (A:ELEVATOR POSITION,number) d abs * -0.14 * 0.005 + (L:VSTOLfsx,number) / (&gt;L:pitch_velocity_value,number)
            2 (&gt;L:pitch_velocity_control,number)
            (A:ATTITUDE INDICATOR BANK DEGREES,degrees) -2.0 * @WindSpeedLat 1.688 * - (&gt;L:lateral_velocity_value,number)
            2 (&gt;L:lateral_velocity_control,number)
            (L:VSTOLFinal,bool)
            if{ 0 } els{ @CenterThrust 2.0 * }
            (L:vertical_velocity_value,number) - 1 min -1 max (L:vertical_velocity_value,number) + (&gt;L:vertical_velocity_value,number)
            2 (&gt;L:vertical_velocity_control,number)
          }
        }
      }
    </Value>
  </Select>
</Element>

<Element>
  <Select>
    <Value>
      @SimRunning
      if{
        (A:RADIO HEIGHT,feet) @VSTOLThresholdRH &lt; (L:VSTOLEnabled,bool) ! &amp;&amp;
        if{
          2 (&gt;L:longitudinal_velocity_control,number)
          (A:SIM ON GROUND,bool) !
          if{ 0 }
          els{
            (A:BRAKE PARKING POSITION,bool) @EnginesOn ! ||
            if{ 0 } els{ (A:ELEVATOR POSITION,number) d abs * neg (L:VSTOLNoseWheelRadius,number) 6.28 * / 60 * 50 * }
            (A:CENTER WHEEL RPM,RPM) - 200 / sp10
            l10 0 &gt;
            if{ l10 1.0 min 0.05 max } els{ l10 -0.05 min -1.0 max }
          }
          (L:longitudinal_velocity_value,number) + (&gt;L:longitudinal_velocity_value,number)
        }
      }
    </Value>
  </Select>
</Element>

<Element>
  <Select>
    <Value>
      (A:EXIT OPEN:0,percent) 5 &gt; (A:LIGHT STROBE,bool) &amp;&amp;
      if{ (&gt;K:STROBES_OFF) }

      (A:TURB ENG1 N1,percent) 50 &gt; (A:FLAPS HANDLE INDEX, number) 1 == &amp;&amp;
      if{ (A:LIGHT WING,bool) ! if{ (&gt;K:TOGGLE_WING_LIGHTS) } }
      els{ (A:LIGHT WING,bool) if{ (&gt;K:TOGGLE_WING_LIGHTS) } }

      (A:TURB ENG1 N1,percent) 50 &gt; (A:FLAPS HANDLE INDEX, number) 0 == &amp;&amp;
      if{ (A:LIGHT LOGO,bool) ! if{ (&gt;K:TOGGLE_LOGO_LIGHTS) } }
      els{ (A:LIGHT LOGO,bool) if{ (&gt;K:TOGGLE_LOGO_LIGHTS) } }

      (A:TURB ENG1 N1,percent) 50 &gt; (A:FLAPS HANDLE INDEX, number) 1 == &amp;&amp;
      if{ (A:LIGHT CABIN,bool) ! if{ (&gt;K:TOGGLE_CABIN_LIGHTS) } }
      els{ (A:LIGHT CABIN,bool) if{ (&gt;K:TOGGLE_CABIN_LIGHTS) } }

      (A:TURB ENG1 N1,percent) 50 &gt; (A:FLAPS HANDLE INDEX, number) 0 == &amp;&amp;
      if{ (A:LIGHT RECOGNITION,bool) ! if{ (&gt;K:TOGGLE_RECOGNITION_LIGHTS) } }
      els{ (A:LIGHT RECOGNITION,bool) if{ (&gt;K:TOGGLE_RECOGNITION_LIGHTS) } }

      (A:AIRSPEED MACH, number) 0.97 &gt; (L:PrevMach,number) 0.97 &lt; &amp;&amp;
      if{
        (&gt;K:SMOKE_ON)
        (P:ABSOLUTE TIME,seconds) (&gt;L:SonicBoomTimer,number) }
      }
      (P:ABSOLUTE TIME,seconds) (L:SonicBoomTimer,number) - 10 &gt;
      if{ (A:SMOKE ENABLE,bool) if{ (&gt;K:SMOKE_OFF) } }
      els{
        (P:ABSOLUTE TIME,seconds) (L:SonicBoomTimer,number) - 2 &gt; (L:VSTOL_Time,number) (L:SonicBoomTimer,number) - 2 &lt; &amp;&amp;
        if{ 1 (&gt;L:SonicBoomSound,enum) }
      }
    </Value>
  </Select>
</Element>

<Element>
  <Select>
    <Value>
      0 sp10 0 sp11
      (A:EXIT OPEN:0,percent) 5 &gt; (A:BRAKE PARKING POSITION,bool) ! &amp;&amp;
      if{ (&gt;K:PARKING_BRAKES) }
      els{
        (A:EXIT OPEN:0,percent) 0.001 &gt; (A:EXIT OPEN:0,percent) 50 &lt; &amp;&amp; (A:EXIT OPEN:0,percent) (L:PrevExit0,number) &gt; &amp;&amp;
        (A:BRAKE PARKING POSITION,bool) ! &amp;&amp; (P:ABSOLUTE TIME,seconds) (L:ExitTimer,number) &gt; &amp;&amp;
        if{ (P:ABSOLUTE TIME,seconds) 1.5 + (&gt;L:ExitTimer,number) (&gt;K:TOGGLE_AIRCRAFT_EXIT) (&gt;K:SELECT_1) 1 sp10 }
        els{
          (A:TAILHOOK POSITION,percent) 0.001 &gt; (A:TAILHOOK POSITION,percent) (L:PrevTailhook,number) &gt; &amp;&amp;
          (A:EXIT OPEN:0,percent) 95 &lt; &amp;&amp; (P:ABSOLUTE TIME,seconds) (L:TailhookTimer,number) &gt; &amp;&amp;
          if{ (P:ABSOLUTE TIME,seconds) 1.5 + (&gt;L:TailhookTimer,number) (&gt;K:TOGGLE_TAIL_HOOK_HANDLE) }
          els{
            (A:EXIT OPEN:0,percent) 99.999 &lt; (A:EXIT OPEN:0,percent) 50 &gt; &amp;&amp; (A:EXIT OPEN:0,percent) (L:PrevExit0,number) &lt; &amp;&amp;
            (A:TAILHOOK POSITION,percent) 5 &gt; &amp;&amp; (P:ABSOLUTE TIME,seconds) (L:ExitTimer,number) &gt; &amp;&amp;
            if{ (P:ABSOLUTE TIME,seconds) 1.5 + (&gt;L:ExitTimer,number) (&gt;K:TOGGLE_AIRCRAFT_EXIT) (&gt;K:SELECT_1) 1 sp11 }
          }
        }
      }

      (A:EXIT OPEN:0,percent) 0.001 &gt; (L:PrevExit0,number) 0.001 &lt; &amp;&amp; l10 ! &amp;&amp;
      if{ 1 (&gt;L:TB2_ExitOpen_Sound,number) }
      els{ (A:EXIT OPEN:0,percent) 0.001 &lt; if{ 0 (&gt;L:TB2_ExitOpen_Sound,number) } }

      (A:EXIT OPEN:0,percent) 99.999 &lt; (L:PrevExit0,number) 99.999 &gt; &amp;&amp; l11 ! &amp;&amp;
      if{ 1 (&gt;L:TB2_ExitClose_Sound,number) }
      els{ (A:EXIT OPEN:0,percent) 99.999 &gt; if{ 0 (&gt;L:TB2_ExitClose_Sound,number) } }

      (A:TAILHOOK POSITION,percent) 0.001 &gt; (A:TAILHOOK POSITION,percent) 99.999 &lt; &amp;&amp;
      if{ 2 (&gt;L:TB2_Tailhook_Sound,number) }
      els{ 0 (&gt;L:TB2_Tailhook_Sound,number) }
    </Value>
  </Select>
</Element>

<Element>
  <Select>
    <Value>
      (L:VSTOLEnabled,bool) (&gt;L:VSTOLPrevEnabled,bool)
      (A:FLAPS HANDLE INDEX,number) (&gt;L:VSTOLPrevFHI,number)
      (P:ABSOLUTE TIME,seconds) (&gt;L:VSTOL_Time,number)
      (L:longitudinal_velocity_control,number) 0 == 
      if{ (A:VELOCITY BODY Z,knots) 1.688 * (&gt;L:longitudinal_velocity_value,number) }
      (A:EXIT OPEN:0,percent) (&gt;L:PrevExit0,number)
      (A:TAILHOOK POSITION,percent) (&gt;L:PrevTailhook,number)
      (A:AIRSPEED MACH,number) (&gt;L:PrevMach,number)
    </Value>
  </Select>
</Element>


</Gauge>
