<?xml version="1.0" encoding="UTF-8"?>
<!--
**************************************************************************

Checklist: Before Taxi

Copyright (c) 2015 Richard Senior

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

**************************************************************************
-->

<PropertyList>

  <title>Before Taxi</title>

  <!-- Autopilot - CHECK -->
  <item>
    <name>Autopilot</name>
    <value>CHECK</value>
    <condition>
      <and>
        <not>
          <property>autopilot/locks/active</property>
        </not>
        <greater-than>
          <property>autopilot/sperry/pitch-select</property>
          <value>0.0</value>
        </greater-than>
      </and>
    </condition>
    <binding>
      <command>property-assign</command>
      <property>autopilot/locks/active</property>
      <value>0</value>
    </binding>
    <binding>
      <condition>
        <equals>
          <property>sim/aero</property>
          <value>pup100</value>
        </equals>
      </condition>
      <command>property-interpolate</command>
      <property>autopilot/sperry/pitch-select</property>
      <value>4.5</value>
      <time>1.0</time>
    </binding>
    <binding>
      <condition>
        <not-equals>
          <property>sim/aero</property>
          <value>pup100</value>
        </not-equals>
      </condition>
      <command>property-interpolate</command>
      <property>autopilot/sperry/pitch-select</property>
      <value>6.0</value>
      <time>1.0</time>
    </binding>
  </item>

  <!-- Radios - ON -->
  <item>
    <name>Radios</name>
    <value>ON</value>
    <condition>
      <and>
        <property>instrumentation/adf/power-btn</property>
        <property>instrumentation/comm/power-btn</property>
        <property>instrumentation/dme/power-btn</property>
      </and>
    </condition>
    <binding>
      <command>property-interpolate</command>
      <property>instrumentation/adf/volume-norm</property>
      <value>0.1</value>
      <time>0.5</time>
    </binding>
    <binding>
      <command>property-assign</command>
      <property>instrumentation/adf/power-btn</property>
      <value>1</value>
    </binding>
    <binding>
      <command>property-interpolate</command>
      <property>instrumentation/comm/volume</property>
      <value>0.5</value>
      <time>0.5</time>
    </binding>
    <binding>
      <command>property-assign</command>
      <property>instrumentation/comm/power-btn</property>
      <value>1</value>
    </binding>
    <binding>
      <command>property-assign</command>
      <property>instrumentation/dme/power-btn</property>
      <value>1</value>
    </binding>
  </item>

  <!-- Magnetos - CHECK DEAD CUT -->
  <!-- Suction - CHECK -->
  <item>
    <name>Suction</name>
    <value>MINIMUM 3 INCHES</value>
    <condition>
      <or>
        <property>sim/checklists/auto/active</property>
        <greater-than>
          <property>systems/vacuum/suction-inhg</property>
          <value>3</value>
        </greater-than>
      </or>
    </condition>
  </item>

  <!-- Heading Indicator - ALIGN -->
  <item>
    <name>Heading Indicator</name>
    <value>ALIGN</value>
    <condition>
      <or>
        <property>sim/checklists/auto/active</property>
        <less-than>
          <property>instrumentation/heading-indicator/absolute-heading-error-deg</property>
          <value>5</value>
        </less-than>
      </or>
    </condition>
    <binding>
      <command>nasal</command>
      <script>
        var h = getprop("orientation/heading-deg");
        var m = getprop("orientation/heading-magnetic-deg");
        var o = getprop("instrumentation/heading-indicator/offset-deg");
        var d = (o > 180) ? int(m - h) + 360 : int(m - h);
        interpolate("instrumentation/heading-indicator/offset-deg", d, 1.0);
      </script>
    </binding>
  </item>

  <!-- Altimeter - SET -->
  <item>
    <name>Altimeter</name>
    <value>SET</value>
    <condition>
      <or>
        <property>sim/checklists/auto/active</property>
        <less-than>
          <property>instrumentation/altimeter/absolute-altitude-error-ft</property>
          <value>50</value>
        </less-than>
      </or>
    </condition>
    <binding>
      <command>nasal</command>
      <script>
        var rwx = getprop("environment/realwx/enabled");
        var qnh = getprop("environment/metar/pressure-inhg");
        <!-- This is probably a bug in weather scenarios. If the altimeter
             setting is taken from the METAR string in the scenario, the altitude
             is wrong, but if it is set from sea level pressure, it comes out
             correct. At some point this will be fixed in FG and this fudge will
             need removing.
        -->
        var slp = getprop("environment/pressure-sea-level-inhg");
        var setting = rwx ? qnh : slp;
        setting = math.round(setting * 100) / 100;
        interpolate("instrumentation/altimeter/setting-inhg", setting, 1.0);
      </script>
    </binding>
  </item>

  <!-- Taxi Light - ON -->
  <item>
    <name>Taxi Light</name>
    <value>ON</value>
    <condition>
      <greater-than>
        <property>systems/electrical/outputs/taxi-light</property>
        <value>0</value>
      </greater-than>
    </condition>
    <binding>
      <command>property-assign</command>
      <property>controls/lighting/taxi-light</property>
      <value>1</value>
    </binding>
    <binding>
      <command>nasal</command>
      <script>pup.click();</script>
    </binding>
  </item>

</PropertyList>
