<?xml version="1.0"?>
<flight_control name="Dornier DO228: Flight Controls">
	<channel name="Autopilot">
		<switch>
			<default value="/controls/flight/aileron"/>
			<test value="/autopilot/servos/roll/command" logic="AND">
				/systems/electrical/outputs/ap-servos ge 14
				/autopilot/servos/roll/serviceable eq 1
				/autopilot/internal/autopilot-active eq 1
			</test>
			<output>fcs/aileron-cmd-norm</output>
		</switch>
		<switch>
			<default value="/controls/flight/elevator"/>
			<test value="/autopilot/servos/pitch/command" logic="AND">
				/systems/electrical/outputs/ap-servos ge 14
				/autopilot/servos/pitch/serviceable eq 1
				/autopilot/internal/autopilot-active eq 1
			</test>
			<output>fcs/elevator-cmd-norm</output>
		</switch>
		<switch>
			<default value="/controls/flight/elevator-trim"/>
			<test value="/autopilot/servos/pitch-trim/command" logic="AND">
				/systems/electrical/outputs/ap-servos ge 14
				/autopilot/servos/pitch-trim/serviceable eq 1
				/autopilot/internal/autopilot-active eq 1
			</test>
			<output>fcs/pitch-trim-cmd-norm</output>
		</switch>
		<switch>
			<default value="/controls/flight/rudder"/>
			<test value="/autopilot/servos/yaw/command" logic="AND">
				/systems/electrical/outputs/ap-servos ge 14
				/autopilot/servos/yaw/serviceable eq 1
				/autopilot/internal/yaw-damper-active eq 1
			</test>
			<output>fcs/rudder-cmd-norm</output>
		</switch>
	</channel>
	<!--	Elevator deflection (ref. [1] p.7-21):
	up	30 deg	0.5236 rad
	down	25 deg	0.4363 rad
	-->
	<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.5236 </min>
				<max>  0.4363 </max>
			</range>
			<output>fcs/elevator-pos-rad</output>
		</aerosurface_scale>
		
		<aerosurface_scale name="Elevator Normalization">
			<input>fcs/elevator-pos-rad</input>
			<domain>
				<min> -0.5236 </min>
				<max>  0.5236 </max>
			</domain>
			<range>
				<min> -1 </min>
				<max>  1 </max>
			</range>
			<output>fcs/elevator-pos-norm</output>
		</aerosurface_scale>
	</channel>
	
	<!--	Aileron deflection (ref. [1] p.7-20):
	up	25 deg
	down	18 deg
	Aileron droop (ref. [1] p.7-24):
	Flap setting			Aileron droop
	UP	(intern:0.0)		0 deg (absolute: 6 deg)
	1	(intern:0.17)		4 deg (absolute: 10 deg)
	2	(intern:0.67)		8 deg (absolute: 14 deg)
	DN	(intern:1.0)		9 deg (absolute: 15 deg)
	-->
	<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>
		
		<fcs_function>
			<function>
				<table>
					<independentVar lookup="row">fcs/flap-pos-norm</independentVar>
					<independentVar lookup="column">fcs/roll-trim-sum</independentVar>
					<tableData>
							-1	0	1
						0.0	-25	0	18
						0.17	-25	4	18
						0.67	-25	8	18
						1.0	-25	9	18
					</tableData>
				</table>
			</function>
			<output>fcs/left-aileron-pos-deg</output>
		</fcs_function>
		
		<fcs_function>
			<function>
				<table>
					<independentVar lookup="row">fcs/flap-pos-norm</independentVar>
					<independentVar lookup="column">fcs/roll-trim-sum</independentVar>
					<tableData>
							-1	0	1
						0.0	18	0	-25
						0.17	18	4	-25
						0.67	18	8	-25
						1.0	18	9	-25
					</tableData>
				</table>
			</function>
			<output>fcs/right-aileron-pos-deg</output>
		</fcs_function>
		
		<aerosurface_scale name="Left Aileron Normalization">
			<input>fcs/left-aileron-pos-deg</input>
			<domain>
				<min> -25 </min>
				<max>  25 </max>
			</domain>
			<range>
				<min> -1 </min>
				<max>  1 </max>
			</range>
			<output>fcs/left-aileron-pos-norm</output>
		</aerosurface_scale>
		
		<aerosurface_scale name="Right Aileron Normalization">
			<input>fcs/right-aileron-pos-deg</input>
			<domain>
				<min> -25 </min>
				<max>  25 </max>
			</domain>
			<range>
				<min> -1 </min>
				<max>  1 </max>
			</range>
			<output>fcs/right-aileron-pos-norm</output>
		</aerosurface_scale>
	</channel>
	
	<!--	Rudder deflections (ref. [1] p.7-23): 24 deg (0.4189 rad) left/right	-->
	<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.4189 </min>
				<max>  0.4189 </max>
			</range>
			<output>fcs/rudder-pos-rad</output>
		</aerosurface_scale>
		
		<aerosurface_scale name="Rudder Normalization">
			<input>fcs/rudder-pos-rad</input>
			<domain>
				<min> -0.4189 </min>
				<max>  0.4189 </max>
			</domain>
			<range>
				<min> -1 </min>
				<max>  1 </max>
			</range>
			<output>fcs/rudder-pos-norm</output>
		</aerosurface_scale>
	</channel>
	
	<!--	
	up	25 deg
	down	18 deg
	Flap deflections (ref. [1] p.7-24):
	Flap setting			Flap deflection
	UP	(intern:0.0)		0 deg
	1	(intern:0.17)		5 deg
	2	(intern:0.67)		20 deg
	DN	(intern:1.0)		30 deg
	-->
	<channel name="Flaps">
		<kinematic name="Flaps Control">
			<input>/controls/flight/flaps-int</input>
			<traverse>
				<setting>
					<position>  0 </position>
					<time>      0 </time>
				</setting>
				<setting>
					<position>  5 </position>
					<time>      4 </time>
				</setting>
				<setting>
					<position> 20 </position>
					<time>      4 </time>
				</setting>
				<setting>
					<position> 30 </position>
					<time>      3 </time>
				</setting>
			</traverse>
			<output>fcs/flap-pos-deg</output>
		</kinematic>
		
		<aerosurface_scale name="Flap Normalization">
			<input>fcs/flap-pos-deg</input>
			<domain>
				<min>  0 </min>
				<max> 30 </max>
			</domain>
			<range>
				<min> 0 </min>
				<max> 1 </max>
			</range>
			<output>fcs/flap-pos-norm</output>
		</aerosurface_scale>
	</channel>
	
	
	<property value="1.0">gear/gear-int-norm</property>
	<property value="0.0">fcs/nws-microswitch-wow</property>
	<channel name="Landing Gear">
		<!--	Nose Wheel Steering	-->
		<switch name="fcs/steering-cmd-norm">
			<default value="0"/>
			<test value="fcs/rudder-cmd-norm">
				systems/hydraulic/pressure-psi > 2500
				gear/gear-pos-norm eq 1.0
				fcs/nws-microswitch-wow eq 1
				/controls/gear/nws-switch eq 1
			</test>
		</switch>
		<switch name="fcs/steering-limit-norm">
			<default value="0.1778"/> <!-- 8 / 45 -->
			<test value="1">
				/controls/gear/nws-45-button eq 1
			</test>
		</switch>
		<pure_gain name="fcs/steering-int-norm">
			<input>fcs/steering-cmd-norm</input>
			<gain>fcs/steering-limit-norm</gain>
		</pure_gain>
		<lag_filter>
			<input>fcs/steering-int-norm</input>
			<c1>7</c1>
			<output>fcs/steering-pos-norm</output>
		</lag_filter>
		
		<!--	used for PFD	-->
		<switch name="fcs/gear-no-wow">
			<default value="1"/>
			<test logic="AND" value="0">
				gear/unit[0]/WOW eq 1
				gear/unit[1]/WOW eq 1
				gear/unit[2]/WOW eq 1
			</test>
		</switch>
		
		<!--	used for gear lever light	-->
		<switch name="fcs/gear-transit">
			<default value="0"/>
			<test logic="AND" value="1">
				gear/gear-pos-norm ne 0
				gear/gear-pos-norm ne 1
			</test>
		</switch>
		
		<!--	ref. [1] p.7-30: duration approx. 7 secs	-->
		<kinematic name="Landing Gear Control">
			<input>gear/gear-int-norm</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>     7 </time>
				</setting>
			</traverse>
			<output>gear/gear-pos-norm</output>
		</kinematic>
		
		<!--	Parking Brake	-->
		<!--	adapted from A320-family	-->
		<kinematic name="Landing Gear Control">
			<input>/controls/gear/brake-parking</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>     1 </time>
				</setting>
			</traverse>
			<output>fcs/brake-parking</output>
		</kinematic>
		
		<summer>
			<input>/controls/gear/brake-left</input>
			<input>fcs/brake-parking</input>
			<clipto>
				<min>0</min>
				<max>1</max>
			</clipto>
			<output>fcs/left-brake-cmd-norm</output>
		</summer>
		
		<summer>
			<input>/controls/gear/brake-right</input>
			<input>fcs/brake-parking</input>
			<clipto>
				<min>0</min>
				<max>1</max>
			</clipto>
			<output>fcs/right-brake-cmd-norm</output>
		</summer>
	</channel>
	<channel name="Thruster">
		<summer name="Thrust Coefficient Left">
			<input>propulsion/engine[0]/thrust-coefficient</input>
			<output>systems/propulsion/thrust-coefficient-left</output>
		</summer>
		<summer name="Thrust Coefficient Right">
			<input>propulsion/engine[1]/thrust-coefficient</input>
			<output>systems/propulsion/thrust-coefficient-right</output>
		</summer>
		<summer name="Thrust Coefficient Left-Right">
			<input>systems/propulsion/thrust-coefficient-left</input>
			<input>-systems/propulsion/thrust-coefficient-right</input>
			<output>systems/propulsion/thrust-coefficient-left-right</output>
		</summer>
		<summer name="Thrust Coefficient">
			<input>systems/propulsion/thrust-coefficient-left</input>
			<input>systems/propulsion/thrust-coefficient-right</input>
			<output>systems/propulsion/thrust-coefficient</output>
		</summer>
	</channel>
	<channel name="Doors">
		<kinematic>
			<input>/doors/pilot-cmd-norm</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 0.1 </position>
					<time>     1 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>     2 </time>
				</setting>
			</traverse>
			<output>/doors/pilot-pos-norm</output>
		</kinematic>
		<kinematic>
			<input>/doors/passenger-cmd-norm</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>     3 </time>
				</setting>
			</traverse>
			<output>/doors/passenger-pos-norm</output>
		</kinematic>
		<kinematic>
			<input>/doors/cargo-cmd-norm</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>     2 </time>
				</setting>
			</traverse>
			<output>/doors/cargo-pos-norm</output>
		</kinematic>
		<kinematic>
			<input>/doors/baggage-front-cmd-norm</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>     2 </time>
				</setting>
			</traverse>
			<output>/doors/baggage-front-pos-norm</output>
		</kinematic>
		<kinematic>
			<input>/doors/baggage-rear-cmd-norm</input>
			<traverse>
				<setting>
					<position> 0 </position>
					<time>     0 </time>
				</setting>
				<setting>
					<position> 1 </position>
					<time>     2 </time>
				</setting>
			</traverse>
			<output>/doors/baggage-rear-pos-norm</output>
		</kinematic>
	</channel>
	
</flight_control>
