<?xml version="1.0"?>

<!-- McDonnell Douglas DC-10 Spoilers -->
<!-- Copyright (c) 2026 Josh Davidson (Octal450) -->

<system name="DC-10: Spoilers">
	
	<channel name="Spoiler Lever and Logic">.
		
		<switch name="/systems/fcs/spoilers/speedbrake-inhibit"> <!-- Prevents extension but does not retract -->
			<default value="0"/>
			<test logic="AND" value="0">
				position/wow eq 1
				/controls/flight/speedbrake-arm eq 1
			</test>
			<test logic="AND" value="1">
				fcs/flap-pos-deg ge 4.5
				gear/unit[0]/WOW eq 0
			</test>
		</switch>
		
		<fcs_function name="/controls/flight/speedbrake-fixed"> <!-- Rounds to 4 figures to fix a potential problem -->
			<function>
				<quotient>
					<floor>
						<sum>
							<product>
								<property>/controls/flight/speedbrake</property>
								<value>10000</value>
							</product>
							<value>0.5</value> <!-- Make it round correctly -->
						</sum>
					</floor>
					<value>10000</value>
				</quotient>
			</function>
		</fcs_function>
		
		<switch name="/systems/fcs/spoilers/auto-speedbrake-arm"> <!-- Important for spoiler axis -->
			<default value="/controls/flight/speedbrake-arm"/>
			<test value="0">
				/controls/flight/speedbrake-fixed ge 0.2
			</test>
			<output>/controls/flight/speedbrake-arm</output>
		</switch>
		
		<switch name="/systems/fcs/spoilers/max-lever">
			<default value="3"/>
			<test value="4">
				gear/unit[0]/WOW eq 1
			</test>
		</switch>
		
		<switch name="/systems/fcs/spoilers/auto-speedbrake-max">
			<default value="2"/>
			<test value="4">
				gear/unit[0]/WOW eq 1
			</test>
		</switch>
		
		<switch name="/systems/fcs/spoilers/lever-input">
			<default value="0"/>
			<test logic="AND" value="1">
				/controls/flight/speedbrake-fixed ge 0.2
				/controls/flight/speedbrake-fixed lt 0.4
			</test>
			<test logic="AND" value="2">
				/controls/flight/speedbrake-fixed ge 0.4
				/controls/flight/speedbrake-fixed lt 0.6
			</test>
			<test logic="AND" value="3">
				/controls/flight/speedbrake-fixed ge 0.6
				/controls/flight/speedbrake-fixed lt 0.8
			</test>
			<test value="4">
				/controls/flight/speedbrake-fixed ge 0.8
			</test>
			<clipto>
				<min>0</min>
				<max>/systems/fcs/spoilers/max-lever</max>
			</clipto>
		</switch>
		
		<switch name="/systems/fcs/spoilers/main-gear-or">
			<default value="0"/>
			<test logic="OR" value="1">
				gear/unit[1]/WOW eq 1
				gear/unit[2]/WOW eq 1
			</test>
		</switch>
		
		<switch name="/systems/fcs/spoilers/arm-input-wow"> <!-- Latching Switch -->
			<default value="position/wow"/>
			<test logic="AND" value="/systems/fcs/spoilers/arm-input-wow">
				/controls/flight/speedbrake-arm eq 1
				position/wow eq 1
			</test>
		</switch>
		
		<switch name="/systems/fcs/spoilers/rto-input-kts"> <!-- Latching Switch -->
			<default value="/instrumentation/airspeed-indicator/indicated-speed-kt"/>
			<test logic="AND" value="/systems/fcs/spoilers/rto-input-kts">
				/controls/flight/speedbrake-arm eq 1
				/systems/fcs/spoilers/auto-speedbrake-feedback gt 0
			</test>
		</switch>
		
		<switch name="/systems/fcs/spoilers/auto-speedbrake-arm-cmd">
			<default value="0"/>
			<test logic="AND" value="1"> <!-- Landing -->
				/controls/flight/speedbrake-arm eq 1
				/systems/fcs/spoilers/arm-input-wow ne 1
			</test>
			<test logic="AND" value="2"> <!-- RTO 1 -->
				/controls/flight/speedbrake-arm eq 1
				/systems/fcs/spoilers/arm-input-wow eq 1
			</test>
		</switch>
		
		<switch name="/systems/fcs/spoilers/multi-reverse">
			<default value="0"/>
			<test logic="AND" value="1">
				/systems/engines/reverse-1/position-cmd-out eq 1
				/systems/engines/reverse-2/position-cmd-out eq 1
			</test>
			<test logic="AND" value="1">
				/systems/engines/reverse-1/position-cmd-out eq 1
				/systems/engines/reverse-3/position-cmd-out eq 1
			</test>
			<test logic="AND" value="1">
				/systems/engines/reverse-2/position-cmd-out eq 1
				/systems/engines/reverse-3/position-cmd-out eq 1
			</test>
		</switch>
		
		<switch name="/systems/fcs/spoilers/auto-speedbrake">
			<description>Flip flop for autospeedbrake</description>
			<default value="/systems/fcs/spoilers/auto-speedbrake"/>
			<test value="/systems/fcs/spoilers/auto-speedbrake"> <!-- No power, don't do anything -->
				/systems/electrical/bus/ac-1 lt 112
			</test>
			<test logic="OR" value="0"> <!-- Reset -->
				/systems/engines/throttle-lever-feedback[1] ge 0.05
				/systems/fcs/spoilers/auto-speedbrake-arm-cmd eq 0
			</test>
			<test logic="AND" value="4"> <!-- Set --> <!-- Landing -->
				/systems/engines/throttle-lever-feedback[1] lt 0.05
				/systems/fcs/spoilers/auto-speedbrake-arm-cmd eq 1
				/systems/fcs/spoilers/main-gear-or eq 1
				/instrumentation/airspeed-indicator/indicated-speed-kt ge 60
				fcs/flap-pos-deg ge 30
			</test>
			<test logic="AND" value="4"> <!-- Set --> <!-- RTO -->
				/systems/fcs/spoilers/multi-reverse eq 1
				/systems/fcs/spoilers/auto-speedbrake-arm-cmd eq 2
				/systems/fcs/spoilers/main-gear-or eq 1
				/instrumentation/airspeed-indicator/indicated-speed-kt ge 60
			</test>
			<output>/systems/fcs/spoilers/auto-speedbrake-feedback</output>
			<clipto>
				<min>0</min>
				<max>/systems/fcs/spoilers/auto-speedbrake-max</max>
			</clipto>
		</switch>
		
		<switch name="/systems/fcs/spoilers/lever-cmd">
			<default value="/systems/fcs/spoilers/lever-input"/>
			<test value="/systems/fcs/spoilers/auto-speedbrake">
				/controls/flight/speedbrake-arm eq 1
			</test>
		</switch>
		
		<fcs_function name="/systems/fcs/spoilers/aileron-input">
			<function>
				<table>
					<independentVar lookup="row">/systems/fcs/ailerons/output-surfaces</independentVar>
					<tableData>
						-1.00 -1
						-0.01  0
						 0.01  0
						 1.00  1
					</tableData>
				</table>
			</function>
		</fcs_function>
		
		<fcs_function name="/systems/fcs/spoilers/aileron">
			<function>
				<product>
					<pow>
						<abs><property>/systems/fcs/spoilers/aileron-input</property></abs>
						<value>1.75</value>
					</pow>
					<ifthen>
						<lt>
							<property>/systems/fcs/spoilers/aileron-input</property>
							<value>0</value>
						</lt>
						<value>-1</value>
						<value>1</value>
					</ifthen>
				</product>
			</function>
		</fcs_function>
		
		<pure_gain name="/systems/fcs/spoilers/aileron-left">
			<input>/systems/fcs/spoilers/aileron</input>
			<gain>1.0</gain>
			<clipto>
				<min>-1.0</min>
				<max>0.0</max>
			</clipto>
		</pure_gain>
		
		<pure_gain name="/systems/fcs/spoilers/aileron-right">
			<input>/systems/fcs/spoilers/aileron</input>
			<gain>1.0</gain>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</pure_gain>
		
		<fcs_function name="/systems/fcs/spoilers/trim-aileron">
			<function>
				<table>
					<independentVar lookup="row">/systems/fcs/ailerons/trim-left</independentVar> <!-- Left cause polarity is same -->
					<tableData> <!-- After 5 (0.25) degrees of aileron, spoilers deflect up to 6 deg -->
						-0.35 -0.1
						-0.25  0.0
						 0.25  0.0
						 0.35  0.1
					</tableData>
				</table>
			</function>
		</fcs_function>
		
		<switch name="/systems/fcs/spoilers/main-cmd-deg">
			<default value="0"/>
			<test value="10">
				/systems/fcs/spoilers/lever-cmd eq 1
			</test>
			<test value="20">
				/systems/fcs/spoilers/lever-cmd eq 2
			</test>
			<test value="30">
				/systems/fcs/spoilers/lever-cmd eq 3
			</test>
			<test value="60">
				/systems/fcs/spoilers/lever-cmd eq 4
			</test>
			<output>/gear/abs/spoilers-cmd-deg</output>
		</switch>
		
		<aerosurface_scale name="/systems/fcs/spoilers/main-cmd">
			<input>/systems/fcs/spoilers/main-cmd-deg</input>
			<domain>
				<min>0</min>
				<max>60</max>
			</domain>
			<range>
				<min>0.0</min>
				<max>1.0</max>
			</range>
		</aerosurface_scale>
		
		<fcs_function name="/systems/fcs/spoilers/main-left-cmd"> <!-- So it retracts but only when needed -->
			<function>
				<min>
					<property>/systems/fcs/spoilers/main-cmd</property>
					<difference>
						<value>1</value>
						<property>/systems/fcs/spoilers/aileron-right</property>
					</difference>
				</min>
			</function>
		</fcs_function>
		
		<fcs_function name="/systems/fcs/spoilers/main-right-cmd"> <!-- So it retracts but only when needed -->
			<function>
				<min>
					<property>/systems/fcs/spoilers/main-cmd</property>
					<sum>
						<value>1</value>
						<property>/systems/fcs/spoilers/aileron-left</property>
					</sum>
				</min>
			</function>
		</fcs_function>
		
		<fcs_function name="/systems/fcs/spoiler-droop-rate">
			<function>
				<table>
					<independentVar lookup="row">aero/qbar-psf</independentVar>
					<tableData>
						 9  1
						33  6
					</tableData>
				</table>
			</function>
		</fcs_function>
	
	</channel>
	
	<channel name="Spoiler L1">
		
		<summer name="/systems/fcs/spoiler-l1/sum">
			<input>-/systems/fcs/spoilers/aileron-left</input>
			<input>-/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-left-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-l1/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-l1/sum">
				/systems/hydraulics/sys-2-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-l1/cmd-deg">
			<input>/systems/fcs/spoiler-l1/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-l1/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-2-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-l1/final-actuator">
			<input>/systems/fcs/spoiler-l1/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-l1/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-l1/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler L2">
		
		<summer name="/systems/fcs/spoiler-l2/sum">
			<input>-/systems/fcs/spoilers/aileron-left</input>
			<input>-/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-left-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-l2/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-l2/sum">
				/systems/hydraulics/sys-1-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-l2/cmd-deg">
			<input>/systems/fcs/spoiler-l2/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-l2/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-1-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-l2/final-actuator">
			<input>/systems/fcs/spoiler-l2/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-l2/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-l2/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler L3">
		
		<summer name="/systems/fcs/spoiler-l3/sum">
			<input>-/systems/fcs/spoilers/aileron-left</input>
			<input>-/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-left-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-l3/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-l3/sum">
				/systems/hydraulics/sys-3-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-l3/cmd-deg">
			<input>/systems/fcs/spoiler-l3/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-l3/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-3-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-l3/final-actuator">
			<input>/systems/fcs/spoiler-l3/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-l3/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-l3/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler L4">
		
		<summer name="/systems/fcs/spoiler-l4/sum">
			<input>-/systems/fcs/spoilers/aileron-left</input>
			<input>-/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-left-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-l4/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-l4/sum">
				/systems/hydraulics/sys-1-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-l4/cmd-deg">
			<input>/systems/fcs/spoiler-l4/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-l4/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-1-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-l4/final-actuator">
			<input>/systems/fcs/spoiler-l4/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-l4/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-l4/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler L5">
		
		<summer name="/systems/fcs/spoiler-l5/sum">
			<input>-/systems/fcs/spoilers/aileron-left</input>
			<input>-/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-left-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-l5/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-l5/sum">
				/systems/hydraulics/sys-2-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-l5/cmd-deg">
			<input>/systems/fcs/spoiler-l5/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-l5/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-2-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-l5/final-actuator">
			<input>/systems/fcs/spoiler-l5/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-l5/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-l5/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler R1">
		
		<summer name="/systems/fcs/spoiler-r1/sum">
			<input>/systems/fcs/spoilers/aileron-right</input>
			<input>/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-right-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-r1/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-r1/sum">
				/systems/hydraulics/sys-2-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-r1/cmd-deg">
			<input>/systems/fcs/spoiler-r1/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-r1/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-2-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-r1/final-actuator">
			<input>/systems/fcs/spoiler-r1/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-r1/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-r1/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler R2">
		
		<summer name="/systems/fcs/spoiler-r2/sum">
			<input>/systems/fcs/spoilers/aileron-right</input>
			<input>/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-right-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-r2/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-r2/sum">
				/systems/hydraulics/sys-1-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-r2/cmd-deg">
			<input>/systems/fcs/spoiler-r2/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-r2/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-1-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-r2/final-actuator">
			<input>/systems/fcs/spoiler-r2/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-r2/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-r2/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler R3">
		
		<summer name="/systems/fcs/spoiler-r3/sum">
			<input>/systems/fcs/spoilers/aileron-right</input>
			<input>/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-right-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-r3/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-r3/sum">
				/systems/hydraulics/sys-3-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-r3/cmd-deg">
			<input>/systems/fcs/spoiler-r3/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-r3/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-3-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-r3/final-actuator">
			<input>/systems/fcs/spoiler-r3/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-r3/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-r3/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler R4">
		
		<summer name="/systems/fcs/spoiler-r4/sum">
			<input>/systems/fcs/spoilers/aileron-right</input>
			<input>/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-right-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-r4/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-r4/sum">
				/systems/hydraulics/sys-1-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-r4/cmd-deg">
			<input>/systems/fcs/spoiler-r4/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-r4/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-1-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-r4/final-actuator">
			<input>/systems/fcs/spoiler-r4/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-r4/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-r4/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Spoiler R5">
		
		<summer name="/systems/fcs/spoiler-r5/sum">
			<input>/systems/fcs/spoilers/aileron-right</input>
			<input>/systems/fcs/spoilers/trim-aileron</input>
			<input>/systems/fcs/spoilers/main-right-cmd</input>
			<clipto>
				<min>0.0</min>
				<max>1.0</max>
			</clipto>
		</summer>
		
		<switch name="/systems/fcs/spoiler-r5/switch">
			<default value="0"/>
			<test value="/systems/fcs/spoiler-r5/sum">
				/systems/hydraulics/sys-2-psi ge 2200
			</test>
		</switch>
		
		<pure_gain name="/systems/fcs/spoiler-r5/cmd-deg">
			<input>/systems/fcs/spoiler-r5/switch</input>
			<gain>60</gain>
		</pure_gain>
		
		<switch name="/systems/fcs/spoiler-r5/rate">
			<default value="/systems/fcs/spoiler-droop-rate"/>
			<test value="100">
				/systems/acconfig/autoconfig-running eq 1
			</test>
			<test value="40">
				/systems/hydraulics/sys-2-psi ge 2200
			</test>
		</switch>
		
		<actuator name="/systems/fcs/spoiler-r5/final-actuator">
			<input>/systems/fcs/spoiler-r5/cmd-deg</input>
			<rate_limit>/systems/fcs/spoiler-r5/rate</rate_limit>
			<lag>26.5</lag>
			<output>/systems/fcs/spoiler-r5/final-deg</output>
		</actuator>
	
	</channel>
	
	<channel name="Output">
		
		<summer name="/systems/fcs/spoiler-left-sum">
			<input>/systems/fcs/spoiler-l1/final-actuator</input>
			<input>/systems/fcs/spoiler-l2/final-actuator</input>
			<input>/systems/fcs/spoiler-l3/final-actuator</input>
			<input>/systems/fcs/spoiler-l4/final-actuator</input>
			<input>/systems/fcs/spoiler-l5/final-actuator</input>
		</summer>
		
		<fcs_function name="/systems/fcs/spoiler-left-deg">
			<function>
				<quotient>
					<property>/systems/fcs/spoiler-left-sum</property>
					<value>5</value>
				</quotient>
			</function>
		</fcs_function>
		
		<summer name="/systems/fcs/spoiler-right-sum">
			<input>/systems/fcs/spoiler-r1/final-actuator</input>
			<input>/systems/fcs/spoiler-r2/final-actuator</input>
			<input>/systems/fcs/spoiler-r3/final-actuator</input>
			<input>/systems/fcs/spoiler-r4/final-actuator</input>
			<input>/systems/fcs/spoiler-r5/final-actuator</input>
		</summer>
		
		<fcs_function name="/systems/fcs/spoiler-right-deg">
			<function>
				<quotient>
					<property>/systems/fcs/spoiler-right-sum</property>
					<value>5</value>
				</quotient>
			</function>
		</fcs_function>
		
		<fcs_function name="/systems/fcs/spoiler-symmetrical-deg">
			<function>
				<quotient>
					<min>
						<property>/systems/fcs/spoiler-left-sum</property>
						<property>/systems/fcs/spoiler-right-sum</property>
					</min>
					<value>5</value>
				</quotient>
			</function>
		</fcs_function>
	
	</channel>

</system>
