<?xml version="1.0"?>

<!-- Copyright (c) 2021 Josh Davidson (Octal450) -->

<PropertyList>
	
	<!-- Thrust Axis -->
	<filter>
		<name>A/THR Knots Input Gain</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>/it-autoflight/input/kts</input>
		<output>/it-autoflight/internal/athr-kts-cmd</output>
		<min>
			<expression>
				<difference>
					<property>/instrumentation/airspeed-indicator/indicated-speed-kt</property>
					<value>25</value>
				</difference>
			</expression>
		</min>
		<max>
			<expression>
				<sum>
					<property>/instrumentation/airspeed-indicator/indicated-speed-kt</property>
					<value>25</value>
				</sum>
			</expression>
		</max>
	</filter>
	
	<filter>
		<name>A/THR Knots Input Filter</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<initialize-to>output</initialize-to>
		<input>/it-autoflight/internal/athr-kts-cmd</input>
		<output>/it-autoflight/internal/athr-kts</output>
		<max-rate-of-change>
			<condition>
				<and>
					<equals>
						<property>/fdm/jsbsim/fadec/athr/active</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/thr-mode</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/it-autoflight/input/kts-mach</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/gear/gear[1]/wow</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/gear/gear[2]/wow</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
			<value>10</value>
		</max-rate-of-change>
		<max-rate-of-change>200</max-rate-of-change>
	</filter>
	
	<filter>
		<name>A/THR Mach Input Gain</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<input>/it-autoflight/input/mach</input>
		<output>/it-autoflight/internal/athr-mach-cmd</output>
		<min>
			<expression>
				<difference>
					<property>/instrumentation/airspeed-indicator/indicated-mach</property>
					<value>0.045</value>
				</difference>
			</expression>
		</min>
		<max>
			<expression>
				<sum>
					<property>/instrumentation/airspeed-indicator/indicated-mach</property>
					<value>0.045</value>
				</sum>
			</expression>
		</max>
	</filter>
	
	<filter>
		<name>A/THR Mach Input Filter</name>
		<debug>false</debug>
		<type>noise-spike</type>
		<feedback-if-disabled>true</feedback-if-disabled>
		<initialize-to>output</initialize-to>
		<input>/it-autoflight/internal/athr-mach-cmd</input>
		<output>/it-autoflight/internal/athr-mach</output>
		<max-rate-of-change>
			<condition>
				<and>
					<equals>
						<property>/fdm/jsbsim/fadec/athr/active</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/thr-mode</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/it-autoflight/input/kts-mach</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/gear/gear[1]/wow</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/gear/gear[2]/wow</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
			<value>0.08</value>
		</max-rate-of-change>
		<max-rate-of-change>2</max-rate-of-change>
	</filter>
	
	<pid-controller>
		<name>IT-CONTROLLER: Knots</name>
		<debug>false</debug>
		<enable>
			<condition>
				<and>
					<equals>
						<property>/fdm/jsbsim/fadec/athr/active</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/input/kts-mach</property>
						<value>0</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/thr-mode</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>/it-autoflight/internal/current-speed-input</input>
		<reference>/it-autoflight/internal/athr-kts</reference>
		<output>/fdm/jsbsim/fadec/athr/cmd</output>
		<config>
			<Kp>0.055</Kp>
			<Ti>9.0</Ti>
			<Td>0.00001</Td>
			<u_min>/fdm/jsbsim/fadec/limit/idle-norm</u_min>
			<u_max>/fdm/jsbsim/fadec/athr/max</u_max>
		</config>
	</pid-controller>
	
	<pid-controller>
		<name>IT-CONTROLLER: Mach</name>
		<debug>false</debug>
		<enable>
			<condition>
				<and>
					<equals>
						<property>/fdm/jsbsim/fadec/athr/active</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/input/kts-mach</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/thr-mode</property>
						<value>0</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>
			<property>/it-autoflight/internal/current-mach-input</property>
			<scale>1000</scale>
		</input>
		<reference>
			<property>/it-autoflight/internal/athr-mach</property>
			<scale>1000</scale>
		</reference>
		<output>/fdm/jsbsim/fadec/athr/cmd</output>
		<config>
			<Kp>0.055</Kp>
			<Ti>9.0</Ti>
			<Td>0.00001</Td>
			<u_min>/fdm/jsbsim/fadec/limit/idle-norm</u_min>
			<u_max>/fdm/jsbsim/fadec/athr/max</u_max>
		</config>
	</pid-controller>
	
	<filter>
		<name>IT-CONTROLLER: Idle Limit</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<and>
					<equals>
						<property>/fdm/jsbsim/fadec/athr/active</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/thr-mode</property>
						<value>1</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>0</input>
		<output>/fdm/jsbsim/fadec/athr/cmd</output>
	</filter>
	
	<filter>
		<name>IT-CONTROLLER: Thrust Limit</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<and>
					<equals>
						<property>/fdm/jsbsim/fadec/athr/active</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/thr-mode</property>
						<value>2</value>
					</equals>
				</and>
			</condition>
		</enable>
		<input>1</input>
		<output>/fdm/jsbsim/fadec/athr/cmd</output>
	</filter>
	
	<filter>
		<name>System Command: Throttle Inactive Sync</name>
		<type>gain</type>
		<gain>1.0</gain>
		<enable>
			<condition>
				<not-equals>
					<property>/fdm/jsbsim/fadec/athr/active</property>
					<value>1</value>
				</not-equals>
			</condition>
		</enable>
		<input>/fdm/jsbsim/fadec/athr/max</input> <!-- Highest throttle -->
		<output>/fdm/jsbsim/fadec/athr/cmd</output>
	</filter>

</PropertyList>