<?xml version="1.0"?>
<flight_control name="FCS">
	<channel name="Pitch">
		<summer name="Pitch Trim Sum">
			<input>fcs/elevator-cmd-norm</input>
			<input>fcs/pitch-trim-cmd-norm</input>
			<clipto>
				<min> -1 </min>
				<max>  1 </max>
			</clipto>
		</summer>
		
		<aerosurface_scale name="Elevator Control">
			<input>fcs/pitch-trim-sum</input>
			<range>
				<min> -0.35 </min>
				<max>  0.35 </max>
			</range>
			<output>fcs/elevator-pos-rad</output>
		</aerosurface_scale>
		
		<aerosurface_scale name="Elevator Normalization">
			<input>fcs/elevator-pos-rad</input>
			<domain>
				<min> -0.35 </min>
				<max>  0.35 </max>
			</domain>
			<range>
				<min> -1 </min>
				<max>  1 </max>
			</range>
			<output>fcs/elevator-pos-norm</output>
		</aerosurface_scale>
	</channel>
	
	<channel name="Roll">
		<summer name="Roll Trim Sum">
			<input>fcs/aileron-cmd-norm</input>
			<input>fcs/roll-trim-cmd-norm</input>
			<clipto>
				<min> -1 </min>
				<max>  1 </max>
			</clipto>
		</summer>
		
		<aerosurface_scale name="Left Aileron Control">
			<input>fcs/roll-trim-sum</input>
			<range>
				<min> -0.35 </min>
				<max>  0.35 </max>
			</range>
			<output>fcs/left-aileron-pos-rad</output>
		</aerosurface_scale>
		
		<aerosurface_scale name="Right Aileron Control">
			<input>-fcs/roll-trim-sum</input>
			<range>
				<min> -0.35 </min>
				<max>  0.35 </max>
			</range>
			<output>fcs/right-aileron-pos-rad</output>
		</aerosurface_scale>
		
		<aerosurface_scale name="Left Aileron Normalization">
			<input>fcs/left-aileron-pos-rad</input>
			<domain>
				<min> -0.35 </min>
				<max>  0.35 </max>
			</domain>
			<range>
				<min> -1 </min>
				<max>  1 </max>
			</range>
			<output>fcs/left-aileron-int-norm</output>
		</aerosurface_scale>
		
		<aerosurface_scale name="Right Aileron Normalization">
			<input>fcs/right-aileron-pos-rad</input>
			<domain>
				<min> -0.35 </min>
				<max>  0.35 </max>
			</domain>
			<range>
				<min> -1 </min>
				<max>  1 </max>
			</range>
			<output>fcs/right-aileron-int-norm</output>
		</aerosurface_scale>
	</channel>
	
	<channel name="Yaw">
		<summer name="Rudder Command Sum">
			<input>fcs/rudder-cmd-norm</input>
			<input>fcs/yaw-trim-cmd-norm</input>
			<clipto>
				<min> -1 </min>
				<max>  1 </max>
			</clipto>
		</summer>
		
		<aerosurface_scale name="Rudder Control">
			<input>fcs/rudder-command-sum</input>
			<range>
				<min> -0.35 </min>
				<max>  0.35 </max>
			</range>
			<output>fcs/rudder-pos-rad</output>
		</aerosurface_scale>
		
		<aerosurface_scale name="Rudder Normalization">
			<input>fcs/rudder-pos-rad</input>
			<domain>
				<min> -0.35 </min>
				<max>  0.35 </max>
			</domain>
			<range>
				<min> -1 </min>
				<max>  1 </max>
			</range>
			<output>fcs/rudder-pos-norm</output>
		</aerosurface_scale>
	</channel>
	<channel name="Landing Gear">
		<switch name="fcs/gear-no-wow">
			<default value="1"/>
			<test logic="AND" value="0">
				gear/unit[1]/WOW eq 1
				gear/unit[2]/WOW eq 1
			</test>
		</switch>
		
		<kinematic name="Landing Gear Control">
			<input>gear/gear-cmd-norm</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>    10 </time>
				</setting>
			</traverse>
			<output>gear/gear-pos-norm</output>
		</kinematic>
		
		<fcs_function name="fcs/wheelbrake-cmd">
			<function>
				<table>
					<independentVar lookup="row">fcs/speedbrake-cmd</independentVar>
					<tableData>
						0	0
						0.9	0
						1	0.6
					</tableData>
				</table>
			</function>
		</fcs_function>
		
		<kinematic>
			<input>fcs/wheelbrake-cmd</input>
			<traverse>
				<setting>
					<position>0</position>
					<time>0</time>
				</setting>
				<setting>
					<position>1</position>
					<time>0</time>
				</setting>
			</traverse>
			<output>fcs/left-brake-cmd-norm</output>
		</kinematic>
	</channel>
	
	<channel name="Speed Brake">
		
		<fcs_function name="fcs/speedbrake-cmd-throttle">
			<function>
				<table>
					<independentVar lookup="row">/controls/engines/engine/throttle</independentVar>
					<tableData>
						0	1
						1	0
					</tableData>
				</table>
			</function>
		</fcs_function>
		<switch>
			<default value="fcs/speedbrake-cmd-throttle"/>
			<test value="/controls/flight/spoilers">
				/sim/model/variant eq 1
			</test>
			<output>fcs/speedbrake-cmd</output>
		</switch>
		
		<fcs_function name="fcs/speedbrake-int-norm">
			<function>
				<table>
					<independentVar lookup="row">fcs/speedbrake-cmd</independentVar>
					<tableData>
						0	0
						0.9	1
						1	1
					</tableData>
				</table>
			</function>
		</fcs_function>
		<kinematic name="Speedbrake Control">
			<input>fcs/speedbrake-int-norm</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>     0 </time>
				</setting>
			</traverse>
			<output>fcs/speedbrake-pos-norm</output>
		</kinematic>
		
	</channel>
	<channel name="Flaps">
		<fcs_function>
			<function>
				<product>
					<table>
						<independentVar lookup="row">/controls/flight/flaps</independentVar>
						<tableData>
							0	-7
							0.2	-5
							0.3	-2
							0.4	0
							0.5	5
							0.6	10
							0.7	25
							1	25
						</tableData>
					</table>
					<value>0.04</value>
				</product>
			</function>
			<output>fcs/flap-cmd-norm</output>
		</fcs_function>
		<kinematic>
			<input>fcs/flap-cmd-norm</input>
			<traverse>
				<setting>
					<position>  -1 </position>
					<time>      0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>    3 </time>
				</setting>
			</traverse>
			<output>fcs/flap-pos-norm</output>
		</kinematic>
		
		<aerosurface_scale>
			<input>fcs/flap-pos-norm</input>
			<range>
				<min>-25</min>
				<max>25</max>
			</range>
			<output>fcs/flap-pos-deg</output>
		</aerosurface_scale>
		
		<!--	We use aileron output properties as they are already transmitted via MP and would be unused else	-->
		<summer>
			<input>fcs/flap-pos-norm</input>
			<input>fcs/left-aileron-int-norm</input>
			<output>fcs/left-aileron-pos-norm</output>
		</summer>
		<summer>
			<input>fcs/flap-pos-norm</input>
			<input>fcs/right-aileron-int-norm</input>
			<output>fcs/right-aileron-pos-norm</output>
		</summer>
		
		
	</channel>
	<channel name="General">
		
		<fcs_function name="/arcus/canopy-input">
			<function>
				<min>
					<property>/arcus/canopy-cmd</property>
					<table>
						<independentVar lookup="row">velocities/vc-kts</independentVar>
						<tableData>
							0  1.00
							40  0.05
						</tableData>
					</table>
				</min>
			</function>
		</fcs_function>
		
		<lag_filter name="/arcus/canopy-norm">
			<input>/arcus/canopy-input</input>
			<c1>4.0</c1>
		</lag_filter>
		
		<fcs_function>
			<function>
				<sum>
					<value>19.0</value>
					<product>
						<property>/sim/systems/wingflexer/z-m</property>
						<value>0.867</value> <!-- compensate for wing contact points not being at the wingtip -->
						<value>39.3700787</value> <!-- meter to inch -->
					</product>
				</sum>
			</function>
			<clipto>
				<min>-39</min>
				<max>158</max>
			</clipto>
			<output>gear/z-wingflex-in</output>
		</fcs_function>
	</channel>
	
	<channel name="Water Ballast: Unit conversion for Wingflexer">
		
		<pure_gain>
			<input>inertia/pointmass-weight-lbs[2]</input>
			<gain>0.45359237</gain>	<!-- lbs to kg -->
			<output>systems/wingflexer/fuel-kg[0]</output>
		</pure_gain>
		<pure_gain>
			<input>inertia/pointmass-weight-lbs[3]</input>
			<gain>0.45359237</gain>	<!-- lbs to kg -->
			<output>systems/wingflexer/fuel-kg[1]</output>
		</pure_gain>
		
	</channel>
</flight_control>
