<?xml version="1.0"?>

<!--
	Canopy control. For the MiG-15bis, but can be used in every JSB craft.
	Author: Slavutinsky Victor
-->

<system>

	<fileheader>
		<author> Slavutinsky Victor </author>
		<filecreationdate> 2010-10-03 </filecreationdate>
		<version>$Revision: 1.00 $</version>
		<description> Canopy </description>
	</fileheader>

<!--	That must be aded to set file

	<fdm>
		<jsbsim>
			<systems>
				<canopy>
					<serviceable type="bool">1</serviceable>
					<command type="float">1</command>
					<pos type="float">1</pos>
					<lock-pos type="float">0</lock-pos>
					<tored type="float">0</tored>
				</canopy>
				<sounds>
					<canopy-lock-click>
						<on type="float">0</on>
					</canopy-lock-click>
				</sounds>
			</systems>
		</jsbsim>
	</fdm>

-->

	<channel name="Canopy">

		<!-- Serviceabled -->

		<switch name="calculations/canopy/command-serviceabled">
			<default value="systems/canopy/pos"/>
			<test logic="AND" value="systems/canopy/command">
				systems/canopy/serviceable eq 1.0
			</test>
			<output>systems/canopy/command-serviceabled</output>
		</switch>

		<!-- Matched -->

		<switch name="calculations/canopy/command-matched">
			<default value="systems/canopy/command-serviceabled"/>
			<test logic="AND" value="1.0">
				velocities/mach gt 0.2
				systems/canopy/pos gt 0.01
			</test>
			<output>systems/canopy/command-matched</output>
		</switch>

		<switch name="calculations/canopy/match-feedback">
			<default value="systems/canopy/command"/>
			<test logic="AND" value="1.0">
				velocities/mach gt 0.2
				systems/canopy/pos gt 0.01
				systems/canopy/serviceable eq 1.0
			</test>
			<output>systems/canopy/command</output>
		</switch>

		<!-- Fix Up/Down-->

		<fcs_function name="calculations/canopy/lock-command">
			<function>
				<table>
					<independentVar lookup="column">systems/canopy/command-matched</independentVar>
					<independentVar lookup="row">systems/canopy/pos</independentVar>
				<tableData>
						0.0	1.0
					0.0	0.0	1.0
					0.1	1.0	1.0
					0.2	1.0	1.0
					0.21	0.0	1.0
					0.99	0.0	1.0
					1.0	0.0	0.0
				</tableData>
				</table>
			</function>
			<output>systems/canopy/lock-command</output>
		</fcs_function>

		<kinematic name="calculations/canopy/lock-pos">
			<input>systems/canopy/lock-command</input>
			<traverse>
			<setting>
				<position>0</position>
				<time>0</time>
			</setting>
			<setting>
				<position>1</position>
				<time>0.1</time>
			</setting>
			</traverse>
			<output>systems/canopy/lock-pos</output>
		</kinematic>

		<!-- Up/Down -->

		<kinematic name="calculations/canopy/pos">
			<input>systems/canopy/command-matched</input>
			<traverse>
			<setting>
				<position>0</position>
				<time>0</time>
			</setting>
			<setting>
				<position>1</position>
				<time>0.5</time>
			</setting>
			</traverse>
			<output>systems/canopy/pos</output>
		</kinematic>

		<!-- Lock sound-->

		<fcs_function name="calculations/canopy/lock-click">
			<function>
				<table>
					<independentVar lookup="column">systems/canopy/command-matched</independentVar>
					<independentVar lookup="row">systems/canopy/pos</independentVar>
				<tableData>
						0.0	1.0
					0.0	0.0	0.0
					0.15	1.0	0.0
					0.3	0.0	0.0
					1.0	0.0	0.0
				</tableData>
				</table>
			</function>
			<output>systems/sounds/canopy-lock-click/on</output>
		</fcs_function>

	</channel>

</system>
