<?xml version="1.0"?>

<!-- McDonnell Douglas DC-10 Libraries -->
<!-- Copyright (c) 2026 Josh Davidson (Octal450) -->

<system name="DC-10: Libraries">
	
	<channel name="FDM Rate Libraries">
		
		<switch name="position/wow">
			<default value="0"/>
			<test logic="OR" value="1">
				gear/unit[0]/WOW eq 1
				gear/unit[1]/WOW eq 1
				gear/unit[2]/WOW eq 1
			</test>
			<output>/position/wow</output> <!-- Copy to local tree -->
		</switch>
		
		<switch name="aero/alpha-deg-fixed">
			<default value="0"/>
			<test value="aero/alpha-deg">
				gear/unit[0]/WOW eq 0
			</test>
		</switch>
		
		<fcs_function name="position/gear-agl">
			<function>
				<difference>
					<property>/position/altitude-agl-ft</property>
					<value>17.1</value>
				</difference>
			</function>
		</fcs_function>
		
		<lag_filter name="position/gear-agl-ft">
			<input>position/gear-agl</input>
			<c1>20</c1>
			<output>/position/gear-agl-ft</output> <!-- So flight recorder can override it -->
		</lag_filter>
		
		<pure_gain name="inertia/weight-kg">
			<input>inertia/weight-lbs</input>
			<gain>0.45359237</gain>
		</pure_gain>
		
		<fcs_function name="inertia/cg-percent-mac">
			<function>
				<product>
					<quotient>
						<difference>
							<product>
								<property>inertia/cg-x-in</property>
								<value>0.0254</value> <!-- Inches to meters -->
							</product>
							<value>-0.21384</value> <!-- Offset -->
						</difference>
						<value>8.59</value> <!-- MAC length -->
					</quotient>
					<value>100</value>
				</product>
			</function>
		</fcs_function>
		
		<fcs_function name="inertia/zfwcg-x-in">
			<function>
				<quotient> <!-- Weighted average -->
					<sum>
						<product>
							<property>inertia/empty-weight-lbs</property>
							<property>inertia/empty-weight-x-in</property>
						</product>
						<product>
							<property>inertia/pointmass-weight-lbs[0]</property>
							<property>inertia/pointmass-location-X-inches[0]</property>
						</product>
						<product>
							<property>inertia/pointmass-weight-lbs[1]</property>
							<property>inertia/pointmass-location-X-inches[1]</property>
						</product>
						<product>
							<property>inertia/pointmass-weight-lbs[2]</property>
							<property>inertia/pointmass-location-X-inches[2]</property>
						</product>
						<product>
							<property>inertia/pointmass-weight-lbs[3]</property>
							<property>inertia/pointmass-location-X-inches[3]</property>
						</product>
						<product>
							<property>inertia/pointmass-weight-lbs[4]</property>
							<property>inertia/pointmass-location-X-inches[4]</property>
						</product>
						<product>
							<property>inertia/pointmass-weight-lbs[5]</property>
							<property>inertia/pointmass-location-X-inches[5]</property>
						</product>
					</sum>
					<sum>
						<property>inertia/empty-weight-lbs</property>
						<property>inertia/pointmass-weight-lbs[0]</property>
						<property>inertia/pointmass-weight-lbs[1]</property>
						<property>inertia/pointmass-weight-lbs[2]</property>
						<property>inertia/pointmass-weight-lbs[3]</property>
						<property>inertia/pointmass-weight-lbs[4]</property>
						<property>inertia/pointmass-weight-lbs[5]</property>
					</sum>
				</quotient>
			</function>
		</fcs_function>
		
		<fcs_function name="inertia/zfwcg-percent-mac">
			<function>
				<product>
					<quotient>
						<difference>
							<product>
								<property>inertia/zfwcg-x-in</property>
								<value>0.0254</value> <!-- Inches to meters -->
							</product>
							<value>-0.21384</value> <!-- Offset -->
						</difference>
						<value>8.59</value> <!-- MAC length -->
					</quotient>
					<value>100</value>
				</product>
			</function>
		</fcs_function>
		
		<switch name="contact/any-wow"> <!-- For failure-bridge.nas -->
			<default value="0"/>
			<test logic="OR" value="1">
				contact/unit[6]/WOW eq 1
				contact/unit[7]/WOW eq 1
				contact/unit[8]/WOW eq 1
				contact/unit[9]/WOW eq 1
				contact/unit[10]/WOW eq 1
				contact/unit[11]/WOW eq 1
				contact/unit[12]/WOW eq 1
				contact/unit[13]/WOW eq 1
				contact/unit[14]/WOW eq 1
				contact/unit[15]/WOW eq 1
				contact/unit[16]/WOW eq 1
				contact/unit[17]/WOW eq 1
				contact/unit[18]/WOW eq 1
			</test>
			<output>contact/any-wow-out</output>
		</switch>
	
	</channel>
	
	<channel name="Execrate 8 Libraries" execrate="8">
		
		<switch name="/systems/engines/any-engine-out">
			<default value="0"/>
			<test logic="OR" value="1">
				/engines/engine[0]/state ne 3
				/engines/engine[1]/state ne 3
				/engines/engine[2]/state ne 3
			</test>
		</switch>
		
		<switch name="/systems/engines/multi-engine-out">
			<default value="0"/>
			<test logic="AND" value="1">
				/engines/engine[0]/state ne 3
				/engines/engine[1]/state ne 3
			</test>
			<test logic="AND" value="1">
				/engines/engine[0]/state ne 3
				/engines/engine[2]/state ne 3
			</test>
			<test logic="AND" value="1">
				/engines/engine[1]/state ne 3
				/engines/engine[2]/state ne 3
			</test>
		</switch>
		
		<fcs_function name="/systems/libraries/blink-med">
			<function>
				<floor>
					<mod>
						<product>
							<property>sim-time-sec</property>
							<value>2.5</value>
						</product>
						<value>2</value>
					</mod>
				</floor>
			</function>
		</fcs_function>
	
	</channel>

</system>
