<?xml version="1.0"  encoding="UTF-8"?>
<!--
    usable with flightgear or JSBSim stand-alone
    COPYRIGHT gerard robin  23-03-2010
-->

<system name="Instrumentation">

  <channel name="radar-altitude">

    <fcs_function name="instruments/agl-under_wheel">
      <function>
        <difference>
          <property>position/h-agl-ft</property>
          <property>instruments/agl-offset-ref</property>
        </difference>
      </function>
    </fcs_function>
  </channel>
  <property value="-7.3">instruments/pitch-offset-ref</property>
  <channel name="attitude">
    <fcs_function name="instruments/indicated-pitch-deg">
      <function>
        <difference>
          <product>
            <property>attitude/pitch-rad</property>
            <value>57.29578</value>
          </product>
          <property>instruments/pitch-offset-ref</property>
        </difference>
      </function>
    </fcs_function>
  </channel>

  <channel name="UBody speed" execrate="2">
    <fcs_function>
      <function>
        <product>
          <value>0.598424</value>
          <property>/velocities/uBody-fps</property>
        </product>
      </function>
      <output>/velocities/smooth-kt</output>
    </fcs_function>
    <lag_filter name="/velocities/smooth-kt-filtered">
      <input>/velocities/smooth-kt</input>
      <c1>0.5</c1>
    </lag_filter>
  </channel>

  <channel name="vacuum_system" execrate="8">
    <fcs_function>
      <function>
        <ifthen>
          <gt><p>propulsion/engine/engine-rpm</p><v>20.0</v></gt>
          <product>
            <value>10</value>
            <property>propulsion/engine/engine-rpm</property>
          </product>
          <v>0.00</v>
        </ifthen>
      </function>
      <output>/engines/engine/rpm</output>
    </fcs_function>
  </channel>

  <channel name="heading-error">
    <fcs_function name="instruments/heading-indicator/heading-error-deg-raw">
      <function>
        <difference>
          <property>/instrumentation/heading-indicator/heading-bug-deg</property>
          <property>/instrumentation/heading-indicator/indicated-heading-deg</property>
        </difference>
      </function>
    </fcs_function>

    <fcs_function name="instruments/heading-indicator/heading-error-deg-subtracted">
      <function>
        <product>
          <difference>
            <property>instruments/heading-indicator/heading-error-deg-raw</property>
            <value>360.0</value>
          </difference>
          <value>1.0</value>
        </product>
      </function>
    </fcs_function>

    <fcs_function name="instruments/heading-indicator/heading-error-deg-added">
      <function>
        <product>
          <sum>
            <property>instruments/heading-indicator/heading-error-deg-raw</property>
            <value>360.0</value>
          </sum>
          <value>1.0</value>
        </product>
      </function>
    </fcs_function>

    <switch name="instruments/heading-indicator/heading-error-deg">
      <default value="instruments/heading-indicator/heading-error-deg-raw"/>
      <test value="instruments/heading-indicator/heading-error-deg-subtracted">
        instruments/heading-indicator/heading-error-deg-raw GT 180.0
      </test>
      <test value="instruments/heading-indicator/heading-error-deg-added">
        instruments/heading-indicator/heading-error-deg-raw LT -180.0
      </test>
    </switch>
  </channel>

</system>
