<?xml version="1.0"?>
<!--	Dornier DO228(-212 NG) RSD (Reference Speed Deviation) and Stall Warning System	-->
<!--	Bea Wolf (D-ECHO)	-->

<!--
	Reference: ref.[1] p.7-127ff.
		Description
			* Vs is calculated based on:
				Lift Computer output
				Flap position
				Lift Tranducer (heated along with Pitot LH)
			* Stall warning is activated about 5-12 knots above Vs
			* Push-to-test: When Stall warning light is pushed:
				* RSD needle moves into SLOW range
				* Stall warning is activated
		
		
-->

<system name="Dornier DO228: RSD and Stall Warning System">
	
	<channel name="Electrical Power">
		<switch name="instrumentation/rsd/powered">
			<default value="0"/>
			<test value="1">
				/systems/electrical/outputs/stall-warn gt 15
			</test>
		</switch>
	</channel>
	
	<channel name="Lift Computer">
		<!--	see src/RSD_Stall_Speed_Calculations.ods	-->
		<pure_gain>
			<input>inertia/weight-lbs</input>
			<gain>0.45359237</gain>	<!-- lbs to kg	-->
			<output>instrumentation/rsd/input/weight-kg</output>
		</pure_gain>
		<fcs_function name="instrumentation/rsd/stall-speed/step-1">
			<function>
				<table>
					<independentVar lookup="row">instrumentation/rsd/input/weight-kg</independentVar>
					<independentVar lookup="column">fcs/flap-pos-deg</independentVar>
					<tableData>
							0	5	20	30
						4000	63.4	59.4	52	48.7
						4500	69.6	64.5	58.3	54.9
						5000	72.8	68.7	61.7	59
						5500	76.6	72.3	65	62.8
						6000	80	75	68	65.7
						6500	83.6	78.5	71	69
					</tableData>
				</table>
			</function>
		</fcs_function>
		<fcs_function name="instrumentation/rsd/stall-speed/calculated-stall-speed-kcas">
			<function>
				<table>
					<independentVar lookup="row">/accelerations/pilot-g</independentVar>
					<independentVar lookup="column">instrumentation/rsd/stall-speed/step-1</independentVar>
					<tableData>
							50	85
						1.0	50	85
						1.1	52.2	89
						1.2	54.7	93
						1.3	57	97
						1.4	59	101
						1.5	61	104.2
						1.6	63	108
						1.7	65.3	111
						1.8	67	114.2
						1.9	69	117.3
						2.0	71	120.1
					</tableData>
				</table>
			</function>
		</fcs_function>
		<pure_gain>
			<input>instrumentation/rsd/stall-speed/calculated-stall-speed-kcas</input>
			<gain>1.3</gain>
			<output>instrumentation/rsd/stall-speed/calculated-stall-speed-kcas-1_3</output>
		</pure_gain>
		<fcs_function name="instrumentation/rsd/rsd-deviation-kts">
			<function>
				<difference>
					<property>velocities/vc-kts</property>
					<property>instrumentation/rsd/stall-speed/calculated-stall-speed-kcas-1_3</property>
				</difference>
			</function>
		</fcs_function>
	</channel>
	
	<property value="0.0">instrumentation/rsd/needle-raw</property>
	
	<!--	Needle Deflections:
			maximum: 42 deg
			range beginning: 20.5 deg
			neutral: 0 deg
	-->
	<channel name="Indication">
		<fcs_function>
			<function>
				<table>
					<independentVar>instrumentation/rsd/rsd-deviation-kts</independentVar>
					<tableData>
						-23	-1.0
						23	1.0
					</tableData>
				</table>
			</function>
			<output>instrumentation/rsd/needle-calculated-norm</output>
		</fcs_function>
		<actuator>
			<input>instrumentation/rsd/powered</input>
			<rate_limit>4.0</rate_limit>
			<output>/instrumentation/rsd/off-flag</output>
		</actuator>
		<switch>
			<default value="0.0"/>
			<test value="instrumentation/rsd/needle-calculated-norm" logic="AND">
				/instrumentation/rsd/stall-warning/pushed ne 1
				fcs/gear-no-wow eq 1
			</test>
			<test value="-1.0">
				/instrumentation/rsd/stall-warning/pushed eq 1
			</test>
			<output>instrumentation/rsd/needle-raw</output>
		</switch>
		<actuator>
			<input>instrumentation/rsd/needle-raw</input>
			<rate_limit>1.0</rate_limit>
			<output>/instrumentation/rsd/rsd-needle</output>
		</actuator>
		<switch>
			<default value="0"/>
			<test value="instrumentation/rsd/powered">
				/instrumentation/rsd/rsd-needle lt -0.488
			</test>
			<output>/instrumentation/rsd/stall-warning/active</output>
		</switch>
	</channel>
</system>
