<?xml version="1.0"?>

<!-- IT-AUTOFLIGHT -->

<PropertyList>

 <!-- =============================================================== -->
 <!-- Lateral  Modes                                                  -->
 <!-- =============================================================== -->
 
	<pi-simple-controller>
		<name>ROLL CONTROLLER: HDG/LNAV</name>
		<debug>false</debug>
		<enable>
			<condition>
				<and>
					<or>
						<equals>
							<property>/it-autoflight/output/lat</property>
							<value>0</value>
						</equals>
						<equals>
							<property>/it-autoflight/output/lat</property>
							<value>1</value>
						</equals>
					</or>
					<or>
						<equals>
							<property>/it-autoflight/output/ap1</property>
							<value>1</value>
						</equals>
						<equals>
							<property>/it-autoflight/output/ap2</property>
							<value>1</value>
						</equals>
						<equals>
							<property>/it-autoflight/output/fd1</property>
							<value>1</value>
						</equals>
						<equals>
							<property>/it-autoflight/output/fd2</property>
							<value>1</value>
						</equals>
					</or>
				</and>
			</condition>
		</enable>
		<input>
			<property>/it-autoflight/internal/heading-error-deg</property>
			<scale>
				<property>/it-autoflight/config/cmd/roll-scale</property>
			</scale>
		</input>
		<reference>
			<value>0</value>
		</reference>
		<output>
			<property>/it-autoflight/internal/target-roll-deg</property>
		</output>
		<config>
			<Kp>
				<property>/it-autoflight/config/cmd/roll-kp</property>
			</Kp>
			<Ki>0.0</Ki>
			<min>
				<condition>
					<not-equals>
						<property>/it-autoflight/output/lat</property>
						<value>1</value>
					</not-equals>
				</condition>
				<property>/it-autoflight/input/bank-limit</property>
				<scale>-1</scale>
			</min>
			<min>
				<condition>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>1</value>
					</equals>
				</condition>
				<value>-25</value>
			</min>
			<max>
				<condition>
					<not-equals>
						<property>/it-autoflight/output/lat</property>
						<value>1</value>
					</not-equals>
				</condition>
				<property>/it-autoflight/input/bank-limit</property>
			</max>
			<max>
				<condition>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>1</value>
					</equals>
				</condition>
				<value>25</value>
			</max>
		</config>
	</pi-simple-controller>
	
	<pid-controller>
		<name>VORLOC TRK</name>
		<debug>false</debug>
		<enable>
			<condition>
				<and>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>2</value>
					</equals>
					<or>
						<equals>
							<property>/it-autoflight/output/ap1</property>
							<value>1</value>
						</equals>
						<equals>
							<property>/it-autoflight/output/ap2</property>
							<value>1</value>
						</equals>
						<equals>
							<property>/it-autoflight/output/fd1</property>
							<value>1</value>
						</equals>
						<equals>
							<property>/it-autoflight/output/fd2</property>
							<value>1</value>
						</equals>
					</or>
				</and>
			</condition>
		</enable>
		<input>
			<condition>
				<equals>
					<property>/it-autoflight/settings/use-backcourse</property>
					<value>0</value>
				</equals>
			</condition>
			<property>/it-autoflight/internal/nav-heading-error-deg</property>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-autoflight/settings/use-backcourse</property>
					<value>1</value>
				</equals>
			</condition>
			<property>/it-autoflight/internal/nav-bc-heading-error-deg</property>
		</input>
		<reference>
			<value>0.0</value>
		</reference>
		<output>
			<property>/it-autoflight/internal/target-roll-deg</property>
		</output>
		<config>
			<Kp>
				<property>/it-autoflight/config/cmd/vorloc</property>
			</Kp>
			<beta>1.0</beta>	
			<alpha>0.1</alpha>	
			<gamma>0.0</gamma>		
			<Ti>10.0</Ti>      
			<Td>0.00001</Td>   	
			<u_min>-25</u_min>
			<u_max>25</u_max>
		</config>
	</pid-controller>

	<filter>
		<name>ROLL DEG SYNC</name>
		<debug>false</debug>
		<type>gain</type>
		<gain>1</gain>
		<enable>
			<condition>
				<and>
					<not-equals>
						<property>/it-autoflight/output/ap1</property>
						<value>1</value>
					</not-equals>
					<not-equals>
						<property>/it-autoflight/output/ap2</property>
						<value>1</value>
					</not-equals>
					<not-equals>
						<property>/it-autoflight/output/fd1</property>
						<value>1</value>
					</not-equals>
					<not-equals>
						<property>/it-autoflight/output/fd2</property>
						<value>1</value>
					</not-equals>
				</and>
			</condition>
		</enable>
		<input>/orientation/roll-deg</input>
		<output>/it-autoflight/internal/target-roll-deg</output>
		<min>-25</min>
		<max>25</max>
	</filter>
	
	<filter>
		<name>IT-CONTROLLER: TARGET ROLL CMD</name>
		<debug>false</debug>
		<feedback-if-disabled>true</feedback-if-disabled>
		<initialize-to>output</initialize-to>
		<input>
			<property>/it-autoflight/internal/target-roll-deg</property>
		</input>
		<output>/it-autoflight/internal/target-roll</output>
		<type>noise-spike</type>
		<max-rate-of-change>6</max-rate-of-change>
	</filter>
	
	<pid-controller>
		<name>IT-CONTROLLER: ROLL</name>
		<debug>false</debug>
		<enable>
			<condition>
				<or>
					<equals>
						<property>/it-autoflight/output/ap1</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/ap2</property>
						<value>1</value>
					</equals>
				</or>
			</condition>
		</enable>
		<input>
			<property>/orientation/roll-deg</property>
		</input>
		<reference>
			<condition>
				<and>
					<not-equals>
						<property>/it-autoflight/output/lat</property>
						<value>4</value>
					</not-equals>
					<not-equals>
						<property>/it-autoflight/output/lat</property>
						<value>5</value>
					</not-equals>
				</and>
			</condition>
			<property>/it-autoflight/internal/target-roll</property>
		</reference>
		<reference>
			<condition>
				<or>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>4</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>5</value>
					</equals>
				</or>
			</condition>
			<value>0</value>
		</reference>
		<output>
			<property>/it-autoflight/internal/aileron-cmd</property>
		</output>
		<config>
			<Kp>
				<condition>
					<not-equals>
						<property>/it-autoflight/output/lat</property>
						<value>2</value>
					</not-equals>
				</condition>
				<property>/it-autoflight/config/roll/kp</property>
			</Kp>
			<Kp>
				<condition>
					<equals>
						<property>/it-autoflight/output/lat</property>
						<value>2</value>
					</equals>
				</condition>
				<property>/it-autoflight/config/roll/kp-vloc</property>
			</Kp>
			<beta>1.0</beta>	
			<alpha>0.1</alpha>	
			<gamma>0.0</gamma>	
			<Ti>
				<property>/it-autoflight/config/roll/ti</property>
			</Ti>    
			<Td>
				<property>/it-autoflight/config/roll/td</property>
			</Td>    	
			<u_min>
				<property>/it-autoflight/config/roll/umin</property>
			</u_min>
			<u_max>
				<property>/it-autoflight/config/roll/umax</property>
			</u_max>
		</config>
	</pid-controller>
	
	<filter>
		<name>IT-CONTROLLER: ROLL CMD</name>
		<debug>false</debug>
		<feedback-if-disabled>true</feedback-if-disabled>
		<initialize-to>output</initialize-to>
		<enable>
			<condition>
				<or>
					<equals>
						<property>/it-autoflight/output/ap1</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/ap2</property>
						<value>1</value>
					</equals>
				</or>
			</condition>
		</enable>
		<input>
			<property>/it-autoflight/internal/aileron-cmd</property>
		</input>
		<output>/controls/flight/aileron</output>
		<type>noise-spike</type>
		<max-rate-of-change>0.5</max-rate-of-change>
	</filter>
	
 <!-- =============================================================== -->
 <!-- Yaw Control                                                     -->
 <!-- =============================================================== -->
	
	<pi-simple-controller>
		<name>RUDDER VORLOC TRK</name>
		<debug>false</debug>
		<enable>
			<condition>
				<equals>
					<property>/it-autoflight/output/lat</property>
					<value>4</value>
				</equals>
			</condition>
		</enable>
		<input>
			<property>/it-autoflight/internal/nav-heading-error-deg</property>
		</input>
		<reference>
			<value>0</value>
		</reference>
		<output>/it-autoflight/internal/rudder-cmd</output>
		<config>
			<Kp>
				<property>/it-autoflight/config/autoland/kp-rudder</property>
			</Kp>
			<Ki>0</Ki>
		</config>
		<min>-0.25</min>
		<max>0.25</max>
	</pi-simple-controller>
	
	<filter>
		<name>IT-CONTROLLER: RUDDER CMD</name>
		<debug>false</debug>
		<feedback-if-disabled>true</feedback-if-disabled>
		<initialize-to>output</initialize-to>
		<enable>
			<condition>
				<or>
					<equals>
						<property>/it-autoflight/output/ap1</property>
						<value>1</value>
					</equals>
					<equals>
						<property>/it-autoflight/output/ap2</property>
						<value>1</value>
					</equals>
				</or>
			</condition>
		</enable>
		<input>
			<condition>
				<not-equals>
					<property>/it-autoflight/output/lat</property>
					<value>4</value>
				</not-equals>
			</condition>
			<value>0</value>
		</input>
		<input>
			<condition>
				<equals>
					<property>/it-autoflight/output/lat</property>
					<value>4</value>
				</equals>
			</condition>
			<property>/it-autoflight/internal/rudder-cmd</property>
		</input>
		<output>/controls/flight/rudder</output>
		<type>noise-spike</type>
		<max-rate-of-change>0.20</max-rate-of-change>
	</filter>

</PropertyList>