<?xml version="1.0"?>
<!--
    Usable with FlightGear
    Copyright Gerard Robin  31-03-2009
    Under License:  GPLv2
-->

<system name="Propulsion">


    <property value="0">/sim/rendering/contrail-shader</property>
    <channel name="Propulsion">


        <switch name="Cutoff">
            <default value="fcs/cutoff-switch"/>
            <test  logic="AND" value="1">
               propulsion/engine[0]/n2 gt 0.15
                /controls/engines/engine[0]/starter == 1
                propulsion/engine[0]/set-running == 0
                /environment/wildfire/fire-on-crash == 0
            </test>
            <output>fcs/cutoff-switch</output>
        </switch>


        <pure_gain name="Throttle0">
            <input>fcs/throttle-cmd-norm</input>
            <gain>1.2</gain>
            <output>fcs/throttle-pos-norm</output>
        </pure_gain>

        <kinematic name="Cutoff Switch Delay">
            <input>fcs/cutoff-switch</input>
            <traverse>
                <setting>
                    <position>0.0000</position>
                    <time>0.0000</time>
                </setting>
                <setting>
                    <position>1.0000</position>
                    <time>1.0000</time>
                </setting>
            </traverse>
        </kinematic>



        <pure_gain name="Throttle0 Cmd">
            <input>fcs/throttle-cmd-norm[0]</input>
            <gain>fcs/cutoff-switch-delay</gain>
        </pure_gain>

        <switch name="Fuel Pump0 Cmd">
            <default value="0"/>
            <test  logic="AND" value="1">
                fcs/cutoff-switch == 1
            </test>
            <output>/controls/engines/engine[0]/fuel-pump</output>
        </switch>



        <switch name="Cutoff0 Cmd">
            <default value="1"/>
            <test  logic="AND" value="0">
                fcs/cutoff-switch-delay == 1
                fcs/fuel-pump0-cmd == 1
                /systems/electrical/outputs/fuel-pump gt 27
            </test>
            <output>propulsion/cutoff_cmd</output>
        </switch>

       <!-- Only for animation-->

        <scheduled_gain name="systems/animations/heatscale">
            <input>/engines/engine[0]/augmentation</input>
            <table>
                <independentVar>velocities/u-fps</independentVar>
                <tableData>
                    0       0.5
                    20     0.5
                    60    0.6
                    120     0.8
                    200     1
                    350     1
                </tableData>
            </table>
        </scheduled_gain>

        <scheduled_gain name="systems/animations/heatcolor">
            <input>/engines/engine[0]/augmentation</input>
            <table>
                <independentVar>velocities/u-fps</independentVar>
                <tableData>
                    0       0.45
                    20     0.4
                    60    0.35
                    120     0.3
                    200     0.25
                    350     0.22
                </tableData>
            </table>
        </scheduled_gain>

        <scheduled_gain name="systems/animations/heatsmoke">
            <input>/engines/engine[0]/running</input>
            <table>
                <independentVar>velocities/u-fps</independentVar>
                <tableData>
                    0       1
                    20     0.4
                    60    0.3
                    120     0.1
                    200     0.05
                    350     0.02
                </tableData>
            </table>
        </scheduled_gain>

        <scheduled_gain name="systems/animations/startsmoke">
            <input>fcs/fuel-pump0-cmd</input>
            <table>
                <independentVar>/engines/engine[0]/n2</independentVar>
                <tableData>
                    0       0
                    1       0.2
                    60     0.03
                </tableData>
            </table>
        </scheduled_gain>

        <switch name="systems/animations/contrail">
            <default value="0"/>
            <test  logic="AND" value="1">
                /sim/rendering/contrail-shader  == 1
                position/h-sl-ft gt 30000
                /engines/engine[0]/n2 gt 63
            </test>
            <output>/ai/submodels/f8e-contrail</output>
        </switch>


    </channel>

</system>
