<?xml version="1.0"?>

<system name="fuel">
	<channel name="Fuel"> 	
		<!--Simulate fuel temperature as lagging behind environment temperature (TODO reference?!)-->
		<lag_filter name="/consumables/fuel/tank[0]/temperature-degc">
			<input>/environment/temperature-degc</input>
			<c1>0.01</c1>
		</lag_filter>
		
		<!--The indicated fuel level drops to zero when the radio is transmitting-->
		<switch>
			<default value="0"/>
			<test value="1" logic="AND">
				/controls/radios/comm-ptt eq 1
				/systems/electrical/outputs/comm ge 9
			</test>
			<output>/consumables/fuel/tank[0]/radio-interfering</output>
		</switch>
		<fcs_function name="/consumables/fuel/tank[0]/indicated-level-norm">
			<function>
				<product>
					<property>/consumables/fuel/tank[0]/level-norm</property>
					<table>
						<independentVar>/consumables/fuel/tank[0]/radio-interfering</independentVar>
						<tableData>
							0	1
							1	0
						</tableData>
					</table> 
				</product>
			</function>  
		</fcs_function> 
		
		<!--Has Fuel Logic-->
		<!--Engine has fuel when either the engine-driven pump or the electrical fuel pump supply it-->
		<switch name="propulsion/edp-status">
			<default value="0"/>
			<test value="1" logic="AND">
				propulsion/engine/set-running eq 1
				/controls/fuel/feed-pump/serviceable eq 1
			</test>
		</switch>
		<switch name="propulsion/elp-status">
			<default value="0"/>
			<test value="1" logic="AND">
				/systems/electrical/outputs/fuel-pump ge 9
				/controls/fuel/electric-pump/serviceable eq 1
			</test>
		</switch>
		<switch>
			<default value="0"/>
			<test value="1" logic="AND">
				/controls/fuel/selected-tank eq 0
				<test logic="OR">
					propulsion/elp-status eq 1
					propulsion/edp-status eq 1
				</test>
			</test>
			<output>propulsion/tank/priority</output>
		</switch>
		
		<!--Annunciator Panel-->
		<!--FUEL LOW LEVEL light-->
		<switch>
			<default value="0"/>
			<test value="1">
				/consumables/fuel/tank[0]/indicated-level-norm le 0.1
			</test>
			<output>/consumables/fuel/fuel-low</output>
		</switch>
		<switch>
			<default value="0"/>
			<test value="1">
				propulsion/tank/contents-lbs le 0.05
			</test>
			<output>/consumables/fuel/fuel-low2</output>
		</switch>
	</channel>
</system>

