<?xml version="1.0" encoding="ISO-8859-1"?>

<PropertyList include="kap140-config.xml">

  <!-- reset all if the AP has now power -->
  <filter>
    <name>unpowered</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <property>autopilot/kap140/powered</property>
        <less-than>
          <property alias="../../../../../params/power-supplied"/>
          <expression>
            <product>
              <property alias="../../../../../../../params/power-nominal"/>
              <value>0.7</value>
            </product>
          </expression>
        </less-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/powered</output>
    <output>autopilot/kap140/bad-condition</output>
    <output>autopilot/kap140/panel/state</output>
    <output>autopilot/kap140/panel/state-old</output>
    <output>autopilot/kap140/sensors/pitch-up</output>
    <output>autopilot/kap140/sensors/pitch-down</output>
    <output>autopilot/kap140/panel/pft-1</output>
    <output>autopilot/kap140/panel/pft-2</output>
    <output>autopilot/kap140/panel/pft-3</output>
    <output>autopilot/kap140/panel/digit</output>
    <output>autopilot/kap140/panel/digit-mode</output>
    <output>autopilot/kap140/panel/digit-timer</output>
    <output>autopilot/kap140/panel/baro-mode</output>
    <output>autopilot/kap140/panel/baro-timer</output>
  </filter>

  <!-- reset default altitude if the AP has now power -->
  <filter>
    <name>default-altitude</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <not><property>autopilot/kap140/powered</property></not>
      </condition>
    </enable>
    <input alias="../../params/default-altitude"/>
    <output>autopilot/internal/target-altitude</output>
  </filter>

  <!-- reset default baro setting if the AP has now power and is not tied-->
  <filter>
    <name>default-inhg</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <not><property>autopilot/kap140/powered</property></not>
        <not><property alias="../../../../../params/baro-tied"/></not>
      </condition>
    </enable>
    <input>29.92</input>
    <output alias="../../params/baro-inhg"/>
  </filter>

  <!-- start the Pre-Flight-Test if the AP receive enough powered -->
  <filter>
    <name>powered</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <not><property>autopilot/kap140/powered</property></not>
        <greater-than>
          <property alias="../../../../../params/power-supplied"/>
          <expression>
            <product>
              <property alias="../../../../../../../params/power-nominal"/>
              <value>0.7</value>
            </product>
          </expression>
        </greater-than>
      </condition>
    </enable>
    <input>1</input>
    <output>autopilot/kap140/powered</output>
  </filter>

  <!-- control conditions for every PFT stage -->
  <filter>
    <name>bad-condition</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>-1</value>
        </greater-than>
        <less-than>
          <property>autopilot/kap140/panel/state</property>
          <value>3</value>
        </less-than>
        <not><property>autopilot/kap140/bad-condition</property></not>
      </condition>
    </enable>
    <input>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>0</value>
        </equals>
        <not><property>autopilot/kap140/serviceable</property></not>
      </condition>
      <value>1</value>
    </input>
    <input>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>1</value>
        </equals>
        <not><property>autopilot/kap140/programmed</property></not>
      </condition>
      <value>1</value>
    </input>
    <input>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>2</value>
        </equals>
        <or>
          <property>autopilot/kap140/roll-axis-fail</property>
          <property>autopilot/kap140/pitch-axis-fail</property>
        </or>
      </condition>
      <value>1</value>
    </input>
    <output>autopilot/kap140/bad-condition</output>
  </filter>

  <!-- PFT stage 1 -->
  <filter>
    <name>state1-timer</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>0</value>
        </equals>
        <equals>
          <property>autopilot/kap140/powered</property>
          <value>1</value>
        </equals>
        <less-than>
          <property>autopilot/kap140/panel/pft-1</property>
          <value>1</value>
        </less-than>
      </condition>
    </enable>
    <input>
      <condition>
        <property>autopilot/kap140/bad-condition</property>
      </condition>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>0.2</value>
        </sum>
      </expression>
    </input>
    <input>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>4</value>
        </sum>
      </expression>
    </input>
    <output>autopilot/kap140/panel/pft-1</output>
  </filter>

  <filter>
    <name>state1</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>0</value>
        </equals>
        <equals>
          <property>autopilot/kap140/powered</property>
          <value>1</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/pft-1</property>
          <value>1</value>
        </greater-than>
      </condition>
    </enable>
    <input>1</input>
    <output>autopilot/kap140/panel/state</output>
  </filter>

  <!-- PFT stage 2 -->
  <filter>
    <name>state2-timer</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>1</value>
        </equals>
        <equals>
          <property>autopilot/kap140/powered</property>
          <value>1</value>
        </equals>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <property>autopilot/kap140/panel/pft-1</property>
        </greater-than>
        <less-than>
          <property>autopilot/kap140/panel/pft-2</property>
          <value>1</value>
        </less-than>
      </condition>
    </enable>
    <input>
      <condition>
        <property>autopilot/kap140/bad-condition</property>
      </condition>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>0.2</value>
        </sum>
      </expression>
    </input>
    <input>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>4</value>
        </sum>
      </expression>
    </input>
    <output>autopilot/kap140/panel/pft-2</output>
  </filter>

  <filter>
    <name>state2</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>1</value>
        </equals>
        <equals>
          <property>autopilot/kap140/powered</property>
          <value>1</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/pft-2</property>
          <value>1</value>
        </greater-than>
      </condition>
    </enable>
    <input>2</input>
    <output>autopilot/kap140/panel/state</output>
  </filter>

  <!-- PFT stage 3 -->
  <filter>
    <name>state3-timer</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>2</value>
        </equals>
        <equals>
          <property>autopilot/kap140/powered</property>
          <value>1</value>
        </equals>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <property>autopilot/kap140/panel/pft-2</property>
        </greater-than>
        <less-than>
          <property>autopilot/kap140/panel/pft-3</property>
          <value>1</value>
        </less-than>
      </condition>
    </enable>
    <input>
      <condition>
        <property>autopilot/kap140/bad-condition</property>
      </condition>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>0.2</value>
        </sum>
      </expression>
    </input>
    <input>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>2</value>
        </sum>
      </expression>
    </input>
    <output>autopilot/kap140/panel/pft-3</output>
  </filter>

  <filter>
    <name>state3</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>2</value>
        </equals>
        <equals>
          <property>autopilot/kap140/powered</property>
          <value>1</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/pft-3</property>
          <value>1</value>
        </greater-than>
      </condition>
    </enable>
    <input>3</input>
    <output>autopilot/kap140/panel/state</output>
  </filter>

  <!-- PFT finish ; decide if the AP is usable and need baro settings (untied) or not (tied) -->
  <filter>
    <name>state4-5</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>3</value>
        </equals>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <property>autopilot/kap140/panel/pft-3</property>
        </greater-than>
      </condition>
    </enable>
    <input>
      <condition>
        <property>autopilot/kap140/bad-condition</property>
      </condition>
      <value>-1</value>
    </input>
    <input>
      <condition>
        <equals>
          <property alias="../../../../../params/model" />
          <value>3</value>
        </equals>
        <not>
          <property alias="../../../../../params/baro-tied" />
        </not>
      </condition>
      <value>4</value>
    </input>
    <input>5</input>
    <output>autopilot/kap140/panel/state</output>
  </filter>

  <!-- PFT finish ; decide if the AP is usable and need baro settings (untied) or not (tied) -->
  <filter>
    <name>state5</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <and>
          <equals>
            <property>autopilot/kap140/panel/state</property>
            <value>4</value>
          </equals>
          <equals>
            <property>autopilot/kap140/powered</property>
            <value>1</value>
          </equals>
          <greater-than>
            <property>autopilot/kap140/panel/baro-button</property>
            <value>0</value>
          </greater-than>
        </and>
      </condition>
    </enable>
    <input>5</input>
    <output>autopilot/kap140/panel/state</output>
  </filter>

  <!-- set FPM timer while approaching preselected altitude -->
  <filter>
    <name>display FPM while closing to preselected altitude</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>1</value>
        </equals>
        <or>
          <greater-than>
            <property>autopilot/internal/target-climb-rate</property>
            <value>100</value>
          </greater-than>
          <less-than>
            <property>autopilot/internal/target-climb-rate</property>
            <value>-100</value>
          </less-than>
        </or>
        <greater-than>
          <expression>
            <product>
              <abs><property>autopilot/internal/vert-speed-fpm</property></abs>
              <value>0.1</value>
            </product>
          </expression>
          <expression>
            <abs>
              <dif>
                <property>autopilot/internal/target-altitude</property>
                <property>instrumentation/altimeter/indicated-altitude-ft</property>
              </dif>
            </abs>
          </expression>
        </greater-than>
      </condition>
    </enable>
    <input>sim/time/elapsed-sec</input>
    <output>autopilot/kap140/panel/fpm-timer</output>
  </filter>

  <!-- reset FPM timer if we captured the altitude -->
  <filter>
    <name>display FPM while closing to preselected altitude</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>2</value>
        </equals>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/panel/fpm-timer</output>
  </filter>

  <!-- decide what the digit will show up -->
  <filter>
    <name>digit-mode</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>3</value>
        </greater-than>
      </condition>
    </enable>
    <input>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <or>
          <and>
            <equals>
              <property alias="../../../../../../../params/model"/>
              <value>3</value>
            </equals>
            <greater-than>
              <expression>
                <sum>
                  <property>autopilot/kap140/panel/fpm-timer</property>
                  <value>3</value>
                </sum>
              </expression>
              <property>sim/time/elapsed-sec</property>
            </greater-than>
          </and>
          <and>
            <equals>
              <property alias="../../../../../../../params/model"/>
              <value>2</value>
            </equals>
            <equals>
              <property>autopilot/kap140/settings/vertical-mode</property>
              <value>1</value>
            </equals>
          </and>
        </or>
      </condition>
      <value>2</value>
    </input>
    <input>
      <condition>
        <equals>
          <property alias="../../../../../params/model"/>
          <value>3</value>
        </equals>
        <or>
          <equals>
            <property>autopilot/kap140/panel/state</property>
            <value>4</value>
          </equals>
          <and>
            <greater-than>
              <property>autopilot/kap140/panel/state</property>
              <value>4</value>
            </greater-than>
            <greater-than>
              <expression>
                <sum>
                  <property>autopilot/kap140/panel/baro-timer</property>
                  <value>3</value>
                </sum>
              </expression>
              <property>sim/time/elapsed-sec</property>
            </greater-than>
          </and>
        </or>
      </condition>
      <value>3</value>
    </input>
    <input>
      <condition>
        <equals>
          <property alias="../../../../../params/model"/>
          <value>3</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
      </condition>
      <value>1</value>
    </input>
    <input>0</input>
    <output>autopilot/kap140/panel/digit-mode</output>
  </filter>

  <!-- control the digit timer -->
  <filter>
    <name>set digit-timer</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </equals>
        <less-than>
          <property>autopilot/kap140/panel/digit-timer</property>
          <value>1</value>
        </less-than>
      </condition>
    </enable>
    <input>sim/time/elapsed-sec</input>
    <output>autopilot/kap140/panel/digit-timer</output>
  </filter>

  <filter>
    <name>stop digit-timer</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>5</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/digit-timer</property>
          <value>0</value>
        </greater-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/panel/digit-timer</output>
  </filter>

  <!-- control the digit display on Pre-Flight-Test -->
  <filter>
    <name>pft digit</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>0</value>
        </greater-than>
        <less-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </less-than>
      </condition>
    </enable>
    <input>
      <expression>
        <product>
          <property>autopilot/kap140/panel/state</property>
          <value>10000</value>
        </product>
      </expression>
    </input>
    <output>autopilot/kap140/panel/digit</output>
  </filter>

  <!-- what should the digit display show -->
  <filter>
    <name>normal digit</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>3</value>
        </greater-than>
      </condition>
    </enable>
    <input>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/digit-mode</property>
          <value>1</value>
        </equals>
      </condition>
      <expression>
        <abs><property>autopilot/internal/target-altitude</property></abs>
      </expression>
    </input>
    <input>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/digit-mode</property>
          <value>2</value>
        </equals>
      </condition>
      <expression>
        <abs><property>autopilot/internal/target-climb-rate</property></abs>
      </expression>
    </input>
    <input>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/digit-mode</property>
          <value>3</value>
        </equals>
        <equals>
          <property>autopilot/kap140/panel/baro-mode</property>
          <value>0</value>
        </equals>
      </condition>
      <expression>
        <sum>
          <product>
            <property alias="../../../../../../params/baro-inhg"/>
            <value>1000</value>
          </product>
          <value>5</value>
        </sum>
      </expression>
    </input>
    <input>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/digit-mode</property>
          <value>3</value>
        </equals>
        <equals>
          <property>autopilot/kap140/panel/baro-mode</property>
          <value>1</value>
        </equals>
      </condition>
      <property alias="../../../params/baro-hpa"/>
    </input>
    <output>autopilot/kap140/panel/digit</output>
  </filter>

  <!-- switch AP between ON/STBY -->
  <filter>
    <name>AP on</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>5</value>
        </equals>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <property>autopilot/kap140/panel/state-old</property>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/button-ap</property>
          <value>0</value>
        </greater-than>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <expression>
            <sum>
              <property>autopilot/kap140/panel/button-ap</property>
              <value>0.25</value>
            </sum>
          </expression>
        </greater-than>
      </condition>
    </enable>
    <input>6</input>
    <output>autopilot/kap140/panel/state</output>
    <output>autopilot/kap140/panel/fpm-timer</output>
  </filter>

  <filter>
    <name>AP on</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/fpm-timer</property>
          <value>6</value>
        </equals>
      </condition>
    </enable>
    <input>sim/time/elapsed-sec</input>
    <output>autopilot/kap140/panel/fpm-timer</output>
  </filter>

  <filter>
    <name>AP standby</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <or>
          <property>autopilot/kap140/pitch-axis-fail</property>
          <property>autopilot/kap140/roll-axis-fail</property>
        </or>
      </condition>
    </enable>
    <input>5</input>
    <output>autopilot/kap140/panel/state</output>
    <output>autopilot/kap140/panel/ap-timer</output>
  </filter>

  <filter>
    <name>AP standby</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <property>autopilot/kap140/panel/state-old</property>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/button-ap</property>
          <value>0</value>
        </greater-than>
      </condition>
    </enable>
    <input>5</input>
    <output>autopilot/kap140/panel/state</output>
    <output>autopilot/kap140/panel/ap-timer</output>
  </filter>

  <filter>
    <name>set disengage</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/ap-timer</property>
          <value>5</value>
        </equals>
      </condition>
    </enable>
    <input>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>5</value>
        </sum>
      </expression>
    </input>
    <output>autopilot/kap140/panel/ap-timer</output>
  </filter>

  <filter>
    <name>clear disengage</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/ap-timer</property>
          <value>5</value>
        </greater-than>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <property>autopilot/kap140/panel/ap-timer</property>
        </greater-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/panel/ap-timer</output>
  </filter>

  <!-- set default lateral mode at AP activation -->
  <filter>
    <name>lateral mode</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/lateral-mode</property>
          <value>0</value>
        </equals>
      </condition>
    </enable>
    <input>1</input>
    <output>autopilot/kap140/settings/lateral-mode</output>
  </filter>

  <!-- take over FPM at AP activation -->
  <filter>
    <name>set FPM</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>0</value>
        </equals>
      </condition>
    </enable>
    <input>autopilot/internal/vert-speed-fpm</input>
    <output>autopilot/internal/target-climb-rate</output>
  </filter>

  <!-- set default vertical mode at AP activation -->
  <filter>
    <name>vertical mode</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>0</value>
        </equals>
        <greater-than>
          <property alias="../../../../../params/model"/>
          <value>1</value>
        </greater-than>
      </condition>
    </enable>
    <input>1</input>
    <output>autopilot/kap140/settings/vertical-mode</output>
  </filter>

  <!-- reset modes if AP is STBY -->
  <filter>
    <name>init</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <less-than>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </less-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/settings/lateral-mode</output>
    <output>autopilot/kap140/settings/lateral-arm</output>
    <output>autopilot/kap140/settings/vertical-mode</output>
    <output>autopilot/kap140/settings/vertical-arm</output>
    <output>autopilot/internal/target-climb-rate</output>
    <output>autopilot/internal/target-intercept-angle</output>
    <output>autopilot/internal/target-roll-deg</output>
    <output>autopilot/internal/target-pressure</output>
  </filter>

  <!-- reset targets in ROLL mode -->
  <filter>
    <name>init</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <less-than>
          <property>autopilot/kap140//settings/lateral-mode</property>
          <value>1</value>
        </less-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/internal/target-intercept-angle</output>
    <output>autopilot/internal/target-roll-deg</output>
  </filter>

  <!-- set the FPM timer -->
  <filter>
    <name>FPM display</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <or>
          <greater-than>
            <property>autopilot/kap140/panel/button-up</property>
            <value>0</value>
          </greater-than>
          <greater-than>
            <property>autopilot/kap140/panel/button-down</property>
            <value>0</value>
          </greater-than>
        </or>
      </condition>
    </enable>
    <input>sim/time/elapsed-sec</input>
    <output>autopilot/kap140/panel/fpm-timer</output>
  </filter>

  <!--- clear the FPM timer -->
  <filter>
    <name>stop fpm-timer</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
        <greater-than>
          <property>autopilot/kap140/panel/fpm-timer</property>
          <value>1</value>
        </greater-than>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <expression>
            <sum>
              <property>autopilot/kap140/panel/fpm-timer</property>
              <value>3</value>
            </sum>
          </expression>
        </greater-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/panel/fpm-timer</output>
  </filter>

  <!-- FPM setting -->
  <filter>
    <name>FPM up</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>1</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/button-up</property>
          <value>0</value>
        </greater-than>
      </condition>
    </enable>
    <input>
      <expression>
        <sum>
          <product>
            <floor>
              <product>
                <dif>
                  <property>sim/time/elapsed-sec</property>
                  <property>autopilot/kap140/panel/button-up</property>
                </dif>
                <value>3</value>
              </product>
            </floor>
            <value>100</value>
          </product>
          <property>autopilot/kap140/panel/fpm-old</property>
        </sum>
      </expression>
    </input>
    <output>autopilot/internal/target-climb-rate</output>
    <min>-2000</min>
    <max>2000</max>
  </filter>

  <filter>
    <name>FPM down</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/button-down</property>
          <value>0</value>
        </greater-than>
      </condition>
    </enable>
    <input>
      <expression>
        <sum>
          <product>
            <floor>
              <product>
                <dif>
                  <property>sim/time/elapsed-sec</property>
                  <property>autopilot/kap140/panel/button-down</property>
                </dif>
                <value>3</value>
              </product>
            </floor>
            <value>-100</value>
          </product>
          <property>autopilot/kap140/panel/fpm-old</property>
        </sum>
      </expression>
    </input>
    <output>autopilot/internal/target-climb-rate</output>
    <min>-2000</min>
    <max>2000</max>
  </filter>

  <!-- reverence altitude -->
  <filter>
    <name>reverence altitude up</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>2</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/button-up</property>
          <value>0</value>
        </greater-than>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <expression>
            <sum>
              <property>autopilot/kap140/panel/button-up</property>
              <value>1</value>
            </sum>
          </expression>
        </greater-than>
      </condition>
    </enable>
    <input>500</input>
    <output>autopilot/internal/target-climb-rate</output>
  </filter>

  <filter>
    <name>reverence altitude down</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>2</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/button-down</property>
          <value>0</value>
        </greater-than>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <expression>
            <sum>
              <property>autopilot/kap140/panel/button-down</property>
              <value>1</value>
            </sum>
          </expression>
        </greater-than>
      </condition>
    </enable>
    <input>-500</input>
    <output>autopilot/internal/target-climb-rate</output>
  </filter>

  <!-- take over actual climb rare if we are in VS HOLD and CWS is active -->
  <filter>
    <name>set-vs</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>1</value>
        </equals>
        <property>autopilot/kap140/settings/cws</property>
      </condition>
    </enable>
    <input>autopilot/internal/vert-speed-fpm</input>
    <output>autopilot/internal/target-climb-rate</output>
  </filter>

  <!-- set FPM rounded to next 100 ft -->
  <filter>
    <name>init-vs</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>1</value>
        </equals>
        <not><property>autopilot/kap140/settings/cws</property></not>
        <not-equals>
          <expression>
            <mod>
              <property>autopilot/internal/target-climb-rate</property>
              <value>100</value>
            </mod>
          </expression>
          <value>0</value>
        </not-equals>
      </condition>
    </enable>
    <input>
      <expression>
        <product>
          <floor>
            <div>
              <sum>
                <property>autopilot/internal/target-climb-rate</property>
                <value>50</value>
              </sum>
              <value>100</value>
            </div>
          </floor>
          <value>100</value>
        </product>
      </expression>
    </input>
    <min>-2000</min>
    <max>2000</max>
    <output>autopilot/internal/target-climb-rate</output>
  </filter>

  <!-- take over actual pressure if we are in ALT HOLD and CWS is active -->
  <filter>
    <name>set-alt-hold</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>2</value>
        </equals>
        <property>autopilot/kap140/settings/cws</property>
      </condition>
    </enable>
    <input>environment/pressure-inhg</input>
    <output>autopilot/internal/target-pressure</output>
  </filter>

  <!-- control the BARO timer -->
  <filter>
    <name>set baro-timer</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <or>
          <equals>
            <property>autopilot/kap140/panel/state</property>
            <value>4</value>
          </equals>
          <and>
            <greater-than>
              <property>autopilot/kap140/panel/state</property>
              <value>4</value>
            </greater-than>
            <greater-than>
              <property>autopilot/kap140/panel/baro-button</property>
              <value>0</value>
            </greater-than>
          </and>
        </or>
      </condition>
    </enable>
    <input>sim/time/elapsed-sec</input>
    <output>autopilot/kap140/panel/baro-timer</output>
  </filter>

  <!-- switch BARO between InHg/hPa -->
  <filter>
    <name>BARO mode</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>3</value>
        </greater-than>
        <equals>
          <property>autopilot/kap140/panel/baro-mode</property>
          <property>autopilot/kap140/panel/baro-mode-old</property>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/baro-button</property>
          <value>0</value>
        </greater-than>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <expression>
            <sum>
              <property>autopilot/kap140/panel/baro-button</property>
              <value>2.0</value>
            </sum>
          </expression>
        </greater-than>
      </condition>
    </enable>
    <input>
      <condition>
        <property>autopilot/kap140/panel/baro-mode</property>
      </condition>
      <value>0</value>
    </input>
    <input>1</input>
    <output>autopilot/kap140/panel/baro-mode</output>
  </filter>

  <!-- if NAV/APR/REV is armed, take over HDG for itercept angle in the next 5sec -->
  <filter>
    <name>set intercept angle from HDG mode</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <not><property alias="../../../../../params/hsi-installed"/></not>
        <equals>
          <property>autopilot/kap140/settings/lateral-mode</property>
          <value>2</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/hdg-timer</property>
          <value>0</value>
        </greater-than>
      </condition>
    </enable>
    <input>
      <condition>
        <less-than>
          <property>instrumentation/nav-source/heading-needle-deflection</property>
          <value>0</value>
        </less-than>
      </condition>
      <value>-45</value>
    </input>
    <input>45</input>
    <output>autopilot/internal/target-intercept-angle</output>
  </filter>

  <filter>
    <name>reset hdg-timer</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/panel/state</property>
          <value>6</value>
        </equals>
        <greater-than>
          <property>autopilot/kap140/panel/hdg-timer</property>
          <value>0</value>
        </greater-than>
        <greater-than>
          <property>sim/time/elapsed-sec</property>
          <expression>
            <sum>
              <property>autopilot/kap140/panel/hdg-timer</property>
              <value>5</value>
            </sum>
          </expression>
        </greater-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/panel/hdg-timer</output>
  </filter>

  <!-- trigger NAV/APR/REV -->
  <filter>
    <name>capture nav-beam</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/settings/lateral-arm</property>
          <value>0</value>
        </greater-than>
        <property>instrumentation/nav-source/in-range</property>
        <less-than>
          <expression>
            <abs><property>instrumentation/nav-source/heading-needle-deflection</property></abs>
          </expression>
          <value>6</value>
        </less-than>
      </condition>
    </enable>
    <input>
      <expression>
        <product>
          <property>autopilot/kap140/settings/lateral-arm</property>
          <value>-1</value>
        </product>
      </expression>
    </input>
    <output>autopilot/kap140/settings/lateral-arm</output>
  </filter>

  <!-- arm GS -->
  <filter>
    <name>set GS arm if we go to APR mode</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/lateral-arm</property>
          <value>-2</value>
        </equals>
        <greater-than>
          <property alias="../../../../../params/model"/>
          <value>1</value>
        </greater-than>
      </condition>
    </enable>
    <input>2</input>
    <output>autopilot/kap140/settings/vertical-arm</output>
  </filter>

  <!-- set NAV/APR/REV -->
  <filter>
    <name>set lateral mode</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <less-than>
          <property>autopilot/kap140/settings/lateral-arm</property>
          <value>0</value>
        </less-than>
      </condition>
    </enable>
    <input>
      <expression>
        <sum>
          <product>
            <property>autopilot/kap140/settings/lateral-arm</property>
            <value>-1</value>
          </product>
          <value>2</value>
        </sum>
      </expression>
    </input>
    <output>autopilot/kap140/settings/lateral-mode</output>
  </filter>

  <!-- clear lateral arm -->
  <filter>
    <name>clear lateral arm</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <less-than>
          <property>autopilot/kap140/settings/lateral-arm</property>
          <value>0</value>
        </less-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/settings/lateral-arm</output>
    <output>autopilot/internal/target-intercept-angle</output>
    <output>autopilot/internal/target-roll-deg</output>
  </filter>

  <!-- trigger GS -->
  <filter>
    <name>capture gs-beam</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>2</value>
        </equals>
        <less-than>
          <property>instrumentation/nav-source/gs-needle-deflection</property>
          <value>0</value>
        </less-than>
        <greater-than>
          <property>instrumentation/nav-source/gs-needle-deflection</property>
          <value>-1</value>
        </greater-than>
      </condition>
    </enable>
    <input>
      <expression>
        <product>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>-1</value>
        </product>
      </expression>
    </input>
    <output>autopilot/kap140/settings/vertical-arm</output>
  </filter>

  <!-- set target-pressure -->
  <filter>
    <name>set target-pressure</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>1</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>1</value>
        </equals>
        <less-than>
          <expression>
            <abs>
              <dif>
                <property>autopilot/internal/target-altitude</property>
                <property>instrumentation/altimeter/indicated-altitude-ft</property>
              </dif>
            </abs>
          </expression>
          <value>1</value>
        </less-than>
      </condition>
    </enable>
    <input>environment/pressure-inhg</input>
    <output>autopilot/internal/target-pressure</output>
  </filter>

  <!-- capture altitude -->
  <filter>
    <name>capture ALT</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>1</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>1</value>
        </equals>
        <greater-than>
          <property>autopilot/internal/target-pressure</property>
          <value>0</value>
        </greater-than>
      </condition>
    </enable>
    <input>-1</input>
    <output>autopilot/kap140/settings/vertical-arm</output>
  </filter>

  <!-- set vertical mode -->
  <filter>
    <name>set vertical mode to ALT</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>-1</value>
        </equals>
      </condition>
    </enable>
    <input>2</input>
    <output>autopilot/kap140/settings/vertical-mode</output>
  </filter>

  <filter>
    <name>set vertical mode GS</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>-2</value>
        </equals>
        <property>instrumentation/nav-source/gs-in-range</property>
      </condition>
    </enable>
    <input>3</input>
    <output>autopilot/kap140/settings/vertical-mode</output>
  </filter>

  <!-- clear vertical arm -->
  <filter>
    <name>clear vertical arm ALT</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>-1</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>2</value>
        </equals>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/settings/vertical-arm</output>
  </filter>

  <filter>
    <name>clear vertical arm GS</name>
    <type>gain</type>
    <debug>false</debug>
    <enable>
      <condition>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>-2</value>
        </equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>3</value>
        </equals>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/settings/vertical-arm</output>
  </filter>

  <!-- cancel/disable GS if we are not in APR mode -->
  <filter>
    <name>cancel GS</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <not-equals>
          <property>autopilot/kap140/settings/lateral-mode</property>
          <value>4</value>
        </not-equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-arm</property>
          <value>2</value>
        </equals>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/settings/vertical-arm</output>
  </filter>

  <filter>
    <name>disable GS</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <not-equals>
          <property>autopilot/kap140/settings/lateral-mode</property>
          <value>4</value>
        </not-equals>
        <equals>
          <property>autopilot/kap140/settings/vertical-mode</property>
          <value>3</value>
        </equals>
      </condition>
    </enable>
    <input>1</input>
    <output>autopilot/kap140/settings/vertical-mode</output>
  </filter>

  <!-- altitude alerter -->
  <filter>
    <name>approaching 1000ft from preselected altitude</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
        <equals>
          <property>autopilot/kap140/panel/alt-alert</property>
          <value>0</value>
        </equals>
        <less-than>
          <expression>
            <abs>
              <dif>
                <property>autopilot/internal/target-altitude</property>
                <property>instrumentation/altimeter/indicated-altitude-ft</property>
              </dif>
            </abs>
          </expression>
          <value>1000</value>
        </less-than>
        <greater-than>
          <expression>
            <abs>
              <dif>
                <property>autopilot/internal/target-altitude</property>
                <property>instrumentation/altimeter/indicated-altitude-ft</property>
              </dif>
            </abs>
          </expression>
          <value>200</value>
        </greater-than>
      </condition>
    </enable>
    <input>sim/time/elapsed-sec</input>
    <output>autopilot/kap140/panel/alt-alert</output>
    <output>autopilot/kap140/panel/alt-alert-sound</output>
  </filter>

  <filter>
    <name>altitude reaching save band</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
        <not-equals>
          <property>autopilot/kap140/panel/alt-alert</property>
          <value>0</value>
        </not-equals>
        <less-than>
          <expression>
            <abs>
              <dif>
                <property>autopilot/internal/target-altitude</property>
                <property>instrumentation/altimeter/indicated-altitude-ft</property>
              </dif>
            </abs>
          </expression>
          <value>200</value>
        </less-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/panel/alt-alert</output>
  </filter>

  <filter>
    <name>altitude reached</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
        <equals>
          <property>autopilot/kap140/panel/alt-alert</property>
          <value>0</value>
        </equals>
        <equals>
          <property>autopilot/kap140/panel/alt-alert-arm</property>
          <value>0</value>
        </equals>
        <less-than>
          <expression>
            <abs>
              <dif>
                <property>autopilot/internal/target-altitude</property>
                <property>instrumentation/altimeter/indicated-altitude-ft</property>
              </dif>
            </abs>
          </expression>
          <value>5</value>
        </less-than>
      </condition>
    </enable>
    <input>sim/time/elapsed-sec</input>
    <output>autopilot/kap140/panel/alt-alert-arm</output>
  </filter>

  <filter>
    <name>altitude leaving save band</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
        <property>autopilot/kap140/panel/alt-alert-arm</property>
        <equals>
          <property>autopilot/kap140/panel/alt-alert</property>
          <value>0</value>
        </equals>
        <greater-than>
          <expression>
            <abs>
              <dif>
                <property>autopilot/internal/target-altitude</property>
                <property>instrumentation/altimeter/indicated-altitude-ft</property>
              </dif>
            </abs>
          </expression>
          <value>200</value>
        </greater-than>
      </condition>
    </enable>
    <input>sim/time/elapsed-sec</input>
    <output>autopilot/kap140/panel/alt-alert</output>
    <output>autopilot/kap140/panel/alt-alert-sound</output>
  </filter>

  <filter>
    <name>altitude more than 1000ft away</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
        <not-equals>
          <property>autopilot/kap140/panel/alt-alert</property>
          <value>0</value>
        </not-equals>
        <greater-than>
          <expression>
            <abs>
              <dif>
                <property>autopilot/internal/target-altitude</property>
                <property>instrumentation/altimeter/indicated-altitude-ft</property>
              </dif>
            </abs>
          </expression>
          <value>1000</value>
        </greater-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/panel/alt-alert</output>
    <output>autopilot/kap140/panel/alt-alert-arm</output>
  </filter>

  <filter>
    <name>stop sound</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <not-equals>
          <property>autopilot/kap140/panel/alt-alert-sound</property>
          <value>0</value>
        </not-equals>
        <greater-than>
          <property>autopilot/kap140/panel/alt-alert</property>
          <value>0</value>
        </greater-than>
        <greater-than>
          <expression>
            <dif>
              <property>sim/time/elapsed-sec</property>
              <property>autopilot/kap140/panel/alt-alert</property>
            </dif>
          </expression>
          <value>2</value>
        </greater-than>
      </condition>
    </enable>
    <input>0</input>
    <output>autopilot/kap140/panel/alt-alert-sound</output>
  </filter>

  <!-- Pitch Trim (PT) -->
  <filter>
    <name>set pitch up</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
        <less-than>
          <property>controls/flight/elevator</property>
          <value>-0.05</value>
        </less-than>
        <equals>
          <property>autopilot/kap140/sensors/pitch-up</property>
          <value>0</value>
        </equals>
      </condition>
    </enable>
    <input>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>2.0</value>
        </sum>
      </expression>
    </input>
    <output>autopilot/kap140/sensors/pitch-up</output>
  </filter>

  <filter>
    <name>clear pitch up</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>controls/flight/elevator</property>
          <value>-0.05</value>
        </greater-than>
        <greater-than>
          <property>autopilot/kap140/sensors/pitch-up</property>
          <value>0</value>
        </greater-than>
      </condition>
    </enable>
    <input>0.0</input>
    <output>autopilot/kap140/sensors/pitch-up</output>
  </filter>

  <filter>
    <name>set pitch down</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
        <greater-than>
          <property>controls/flight/elevator</property>
          <value>0.05</value>
        </greater-than>
        <equals>
          <property>autopilot/kap140/sensors/pitch-down</property>
          <value>0.0</value>
        </equals>
      </condition>
    </enable>
    <input>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>2.0</value>
        </sum>
      </expression>
    </input>
    <output>autopilot/kap140/sensors/pitch-down</output>
  </filter>

  <filter>
    <name>clear pitch down</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <less-than>
          <property>controls/flight/elevator</property>
          <value>0.05</value>
        </less-than>
        <greater-than>
          <property>autopilot/kap140/sensors/pitch-down</property>
          <value>0.0</value>
        </greater-than>
      </condition>
    </enable>
    <input>0.0</input>
    <output>autopilot/kap140/sensors/pitch-down</output>
  </filter>

  <!-- pitch trim run-away -->
  <filter>
    <name>check pitch trim run-away</name>
    <debug>false</debug>
    <type>gain</type>
    <enable>
      <condition>
        <greater-than>
          <property>autopilot/kap140/panel/state</property>
          <value>4</value>
        </greater-than>
      </condition>
    </enable>
    <input>
      <condition>
        <less-than>
          <property>autopilot/kap140/sensors/pitch-trim</property>
          <value>1.0</value>
        </less-than>
        <not-equals>
          <property>controls/flight/elevator-trim</property>
          <property>autopilot/kap140/sensors/elevator-trim</property>
        </not-equals>
      </condition>
      <expression>
        <sum>
          <property>sim/time/elapsed-sec</property>
          <value>3.0</value>
        </sum>
      </expression>
    </input>
    <input>
      <condition>
        <greater-than>
          <property>autopilot/kap140/sensors/pitch-trim</property>
          <value>1.0</value>
        </greater-than>
        <equals>
          <property>controls/flight/elevator-trim</property>
          <property>autopilot/kap140/sensors/elevator-trim</property>
        </equals>
      </condition>
      <value>0.0</value>
    </input>
    <input>autopilot/kap140/sensors/pitch-trim</input>
    <output>autopilot/kap140/sensors/pitch-trim</output>
  </filter>

  <filter>
    <name>store pitch trim</name>
    <debug>false</debug>
    <type>noise-spike</type>
    <max-rate-of-change>0.03</max-rate-of-change>
    <input>controls/flight/elevator-trim</input>
    <output>autopilot/kap140/sensors/elevator-trim</output>
  </filter>

</PropertyList>
