<?xml version="1.0"?>

<system name="Ground Handling System for Gliders">
	
	<channel name="Wing Holder">
		
		<switch>
			<default value="0"/>
			<test value="1" logic="AND">
				/controls/groundhandling/wingholder eq 1
				gear/unit[1]/WOW eq 1
				/velocities/groundspeed-kt le 15
			</test>
			<output>systems/groundhandling/wingholder</output>
		</switch>
	
	</channel>
	  
	  
	<channel name="Ground Handling">
		
		<switch>
			<default value="0"/>
			<test value="1" logic="AND">
				/controls/groundhandling/groundhandling eq 1
				gear/unit[1]/WOW eq 1
				/velocities/groundspeed-kt le 15
			</test>
			<output>systems/groundhandling/groundhandling</output>
		</switch>
		
		<switch>
			<default value="0"/>
			<test value="/controls/engines/engine/throttle">
				systems/groundhandling/groundhandling eq 1
			</test>
			<output>systems/groundhandling/throttle-in</output>
		</switch>
		
		<pure_gain>
			<input>systems/groundhandling/throttle-in</input>
			<gain>-1.0</gain>
			<output>systems/groundhandling/throttle-rev</output>
		</pure_gain>
		
		<switch>
			<default value="systems/groundhandling/throttle-in"/>
			<test value="systems/groundhandling/throttle-rev">
				/controls/engines/engine[0]/reverser eq 1
			</test>
			<output>systems/groundhandling/throttle</output>
		</switch>
		
		<switch>
			<default value="0"/>
			<test value="fcs/rudder-cmd-norm">
				systems/groundhandling/groundhandling eq 1
			</test>
			<output>systems/groundhandling/rudder</output>
		</switch>
		
	</channel>
	
	<channel name="Ground Handling Aircraft Integration">
		
		<fcs_function name="external_reactions/turn/magnitude">
			<function>
				<product>
					<property>systems/groundhandling/rudder</property>
					<value>-200</value>
				</product>
			</function>
		</fcs_function>
		
		<fcs_function name="external_reactions/pull/magnitude">
			<function>
				<product>
					<property>systems/groundhandling/throttle</property>
					<value>200</value>
				</product>
			</function>
		</fcs_function>
		
		<switch name="ground_handling/wingholder">
			<default value="gear/z-wingflex-in"/>
			<test value="-29.528"><!---0.75m in inches-->
				systems/groundhandling/wingholder eq 1
			</test>
			<output>contact/unit[3]/z-position</output>
			<output>contact/unit[4]/z-position</output>
		</switch>		
	
	</channel>
</system>
