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

<system name="cat-hold">

    <channel name="cat-hold">

<!-- vertical hold -->
        <!--only a guess , to animate the body when tied, and to avoid a huge pitch during catapulting-->
        <scheduled_gain name="systems/cat-hold/gear-compression">
            <input>launchbar/launch-bar-pos-norm</input>
            <table>
                <independentVar>/gear/gear[0]/compression-ft</independentVar>
                <tableData>
                    0       1
                    0.5     0.25
                    0.8     0.1
                    1          0
                </tableData>
            </table>
        </scheduled_gain>

        <!--on calcul une force de maintient pendant le catapultage-->

        <fcs_function name="systems/cat-hold/force-on">
                <function>
                    <product>
                        <property>inertia/weight-lbs</property>
                        <property>systems/cat-hold/gear-compression</property>
                        <value>0.4</value>
                    </product>
                </function>
         </fcs_function>

         <!--on calcul une force de maintient pendant l'attente-->
        <!-- on  anime  l' effet de tension -->

         <switch name="systems/cat-hold/force-engage">
             <default value="0"/>
             <test  logic="AND" value="0.1">
                 launchbar/launch-bar-pos-norm gt 0.9
             </test>
        </switch>

         <fcs_function name="systems/cat-hold/force-off">
             <function>
                 <product>
                     <property>inertia/weight-lbs</property>
                     <property>systems/cat-hold/force-engage</property>
                 </product>
             </function>
         </fcs_function>

        
	<switch name="systems/cat-hold/magnitude">
             <default value="0"/>
             <test logic="OR" value="systems/cat-hold/force-on">
		/surface-positions/holdback  != 0                
             </test>
             <!--<test logic="AND" value="systems/cat-hold/force-off">
                 systems/launchbar/switch == 1
                 systems/cat-hold/force-on == 0
             </test>-->
             <output>external_reactions/cat-hold/magnitude</output>
         </switch>
         




         
    </channel>

</system>