<?xml version="1.0"?>
<system name="Dornier DO228: Engines">
	
	<channel name="Engine Controls">
		<!--	See Ref. [1] p.7-55 ff.	-->
		<!--	The Dornier DO228 has two main engine levers: Engine Speed and Power	-->
		<!--	Engine Speed:
				* sets fuel supply (USFG: Underspeed Fuel Governor and High Pressure Fuel Shutoff Valve) and propeller governor:
		
					Position				Fuel Supply				Propeller Governor
								USFG			High Pressure Shutoff Valve
								( Power Lever < FI )					( Power Lever > FI )
		
					FEATHER			-			CUTOFF				FEATHER
					SHUTOFF RANGE		-			CUTOFF				??
					LOW			70% RPM			ON				94% RPM
					CRUISE RANGE					ON				96-100% RPM
					HIGH			97% RPM			ON				100% RPM
		-->
		<!--	Power:
				* controls engine mode (beta)
				* when in beta: controls propeller pitch
				* when not in beta: controls fuel flow (=> torque)
					
					Position		Propeller Pitch		Fuel Flow
					REVERSE			REVERSE			set by USFG
					Ground Idle (GI)	??			Minimum			(= beta range end, set in Engines/Honeywell_TPE331-10GP-511D.xml)
					Flight Idle (FI)	Minimum			Minimum
					MAX						Maximum
				* there is a mechanical stop at FI, this is simulated by cutting power lever range into two ranges:
					Normal: from FI to Max
					Reverse: from FI to Reverse
					The Reverse key (Del) is used to select between the two ranges
		-->
		<!--	JSBSim provides the following engine controls:
					Property				Description			Used as
				/controls/engines/engine[ ]/cutoff		Fuel Supply OFF/ON		High Pressure Shutoff Valve
				/controls/engines/engine[ ]/propeller-pitch	Propeller *GOVERNING*		Propeller Governor
				/controls/engines/engine[ ]/propeller-feather	Propeller Feather OFF/ON	Propeller Feather
				fcs/throttle-cmd-norm[ ]			Power Lever			Power Lever (beta mode operation is done internally by JSBSim)
				/controls/engines/engine[ ]/reverse		Reverse				Beta
		-->
		<!--	High Pressure Fuel Shutoff Valve: set by nasal	-->
		<!--	Propeller Governor	-->
		<fcs_function>
			<function>
				<table>
					<independentVar lookup="row">/controls/engines/engine[0]/engine-speed</independentVar>
					<tableData>
						0.25	0.0
						1.0	1.0
					</tableData>
				</table>
			</function>
			<output>fcs/advance-cmd-norm[0]</output>
		</fcs_function>
		<fcs_function>
			<function>
				<table>
					<independentVar lookup="row">/controls/engines/engine[1]/engine-speed</independentVar>
					<tableData>
						0.25	0.0
						1.0	1.0
					</tableData>
				</table>
			</function>
			<output>fcs/advance-cmd-norm[1]</output>
		</fcs_function>
		<!--	Propeller Feather	-->
		<switch>
			<default value="0"/>
			<test value="1">
				/controls/engines/engine[0]/engine-speed le 0.05
			</test>
			<output>/controls/engines/engine[0]/propeller-feather</output>
		</switch>
		<switch>
			<default value="0"/>
			<test value="1">
				/controls/engines/engine[1]/engine-speed le 0.05
			</test>
			<output>/controls/engines/engine[1]/propeller-feather</output>
		</switch>
	</channel>
	
	<channel name="Engine Control Animation">
		<pure_gain>
			<input>/controls/engines/engine[0]/throttle</input>
			<gain>-0.352</gain>
			<output>/controls/engines/engine[0]/power-lever-reverse-pos</output>
		</pure_gain>
		<switch>
			<default value="/controls/engines/engine[0]/throttle"/>
			<test value="/controls/engines/engine[0]/power-lever-reverse-pos">
				/controls/engines/engine[0]/reverser eq 1
			</test>
			<output>/controls/engines/engine[0]/power-lever-pos</output>
		</switch>
		<pure_gain>
			<input>/controls/engines/engine[1]/throttle</input>
			<gain>-0.352</gain>
			<output>/controls/engines/engine[1]/power-lever-reverse-pos</output>
		</pure_gain>
		<switch>
			<default value="/controls/engines/engine[1]/throttle"/>
			<test value="/controls/engines/engine[1]/power-lever-reverse-pos">
				/controls/engines/engine[1]/reverser eq 1
			</test>
			<output>/controls/engines/engine[1]/power-lever-pos</output>
		</switch>
	</channel>
	
	<channel name="Oil Pressure">
		<pure_gain>
			<input>/engines/engine[0]/oil-pressure-psi</input>
			<gain>2.0</gain>
			<output>/engines/engine[0]/oil-pressure-psi-corrected</output>
		</pure_gain>
		<pure_gain>
			<input>/engines/engine[1]/oil-pressure-psi</input>
			<gain>2.0</gain>
			<output>/engines/engine[1]/oil-pressure-psi-corrected</output>
		</pure_gain>
	</channel>
	
</system>
