From 5e7a5976f41343a4ef4cee4f7dae53e7fe9bb1e3 Mon Sep 17 00:00:00 2001
From: Jonathan Redpath <legoboyvdlp@gmail.com>
Date: Fri, 19 Oct 2018 16:20:06 +0100
Subject: [PATCH 1/5] FCS: slats and flaps extend slowly if hydraulic or
 electrical failures occur

---
 Systems/a320-fcs.xml | 246 ++++++++++++++++++++++++++-----------------
 1 file changed, 149 insertions(+), 97 deletions(-)

diff --git a/Systems/a320-fcs.xml b/Systems/a320-fcs.xml
index 26cceec3..dace3be3 100644
--- a/Systems/a320-fcs.xml
+++ b/Systems/a320-fcs.xml
@@ -82,7 +82,7 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/roll/gain-switch</independentVar>
 					<tableData>
-						     0     1  
+							 0	   1  
 						0.2 -26.2  0.0
 						0.9 -15.5  0.0
 					</tableData>
@@ -96,7 +96,7 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/roll/gain-switch</independentVar>
 					<tableData>
-						     0     1
+							 0	   1
 						0.2 -45.5  0.0
 						0.9 -36.0  0.0
 					</tableData>
@@ -110,7 +110,7 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/roll/gain-switch</independentVar>
 					<tableData>
-						     0    1
+							 0	  1
 						0.2 -2.1  0.0
 						0.9 -1.1  0.0
 					</tableData>
@@ -124,9 +124,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/pitch/gain-switch</independentVar>
 					<tableData>
-						     0   1  
-						0.2  28  0
-						0.9  23  0
+							 0	 1	
+						0.2	 28	 0
+						0.9	 23	 0
 					</tableData>
 				</table>
 			</function>
@@ -138,9 +138,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/pitch/gain-switch</independentVar>
 					<tableData>
-						     0   1
-						0.2  61  0
-						0.9  45  0
+							 0	 1
+						0.2	 61	 0
+						0.9	 45	 0
 					</tableData>
 				</table>
 			</function>
@@ -152,9 +152,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/pitch/gain-switch</independentVar>
 					<tableData>
-						     0    1
-						0.2  2.9  0.0
-						0.9  1.3  0.0
+							 0	  1
+						0.2	 2.9  0.0
+						0.9	 1.3  0.0
 					</tableData>
 				</table>
 			</function>
@@ -166,7 +166,7 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/yaw/gain-switch</independentVar>
 					<tableData>
-						     0    1
+							 0	  1
 						0.2 -7.5  0.0
 						0.9 -1.5  0.0
 					</tableData>
@@ -180,9 +180,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/yaw/gain-switch</independentVar>
 					<tableData>
-						     0     1
-						0.2  5.01  0.00
-						0.9  1.05  0.00
+							 0	   1
+						0.2	 5.01  0.00
+						0.9	 1.05  0.00
 					</tableData>
 				</table>
 			</function>
@@ -194,9 +194,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/yaw/gain-switch</independentVar>
 					<tableData>
-						     0     1
-						0.2  1.03  0.00
-						0.9  0.79  0.00
+							 0	   1
+						0.2	 1.03  0.00
+						0.9	 0.79  0.00
 					</tableData>
 				</table>
 			</function>
@@ -279,11 +279,11 @@
 						<independentVar lookup="row">attitude/roll-rad</independentVar>
 						<independentVar lookup="column">fbw/roll/a-i</independentVar>
 						<tableData>
-							          -1         0         1
-							-0.575959  0.261799  0.000000  0.000000
-							-0.575958  0.000000  0.000000  0.000000
-							 0.575958  0.000000  0.000000  0.000000
-							 0.575959  0.000000  0.000000 -0.261799
+									  -1		 0		   1
+							-0.575959  0.261799	 0.000000  0.000000
+							-0.575958  0.000000	 0.000000  0.000000
+							 0.575958  0.000000	 0.000000  0.000000
+							 0.575959  0.000000	 0.000000 -0.261799
 						</tableData>
 					</table>
 					<table>
@@ -310,11 +310,11 @@
 						<independentVar lookup="row">attitude/roll-rad</independentVar>
 						<independentVar lookup="column">fbw/roll/a-i</independentVar>
 						<tableData>
-							          -1         0         1
-							-1.169370  0.261799  0.000000  0.000000
-							-1.169369  0.000000  0.000000  0.000000
-							 1.169369  0.000000  0.000000  0.000000
-							 1.169370  0.000000  0.000000 -0.261799
+									  -1		 0		   1
+							-1.169370  0.261799	 0.000000  0.000000
+							-1.169369  0.000000	 0.000000  0.000000
+							 1.169369  0.000000	 0.000000  0.000000
+							 1.169370  0.000000	 0.000000 -0.261799
 						</tableData>
 					</table>
 					<table>
@@ -369,11 +369,11 @@
 						<independentVar lookup="row">attitude/roll-rad</independentVar>
 						<independentVar lookup="column">fbw/roll/a-i</independentVar>
 						<tableData>
-							          -1         0         1
-							-0.698132  0.261799  0.000000  0.000000
-							-0.698131  0.000000  0.000000  0.000000
-							 0.698131  0.000000  0.000000  0.000000
-							 0.698132  0.000000  0.000000 -0.261799
+									  -1		 0		   1
+							-0.698132  0.261799	 0.000000  0.000000
+							-0.698131  0.000000	 0.000000  0.000000
+							 0.698131  0.000000	 0.000000  0.000000
+							 0.698132  0.000000	 0.000000 -0.261799
 						</tableData>
 					</table>
 				</sum>
@@ -523,9 +523,9 @@
 						<independentVar lookup="row">velocities/mach</independentVar>
 						<independentVar lookup="column">position/wow</independentVar>
 						<tableData>
-							     0    1
-							0.2  0.5  1.0
-							0.9  0.1  1.0
+								 0	  1
+							0.2	 0.5  1.0
+							0.9	 0.1  1.0
 						</tableData>
 					</table>
 				</product>
@@ -615,8 +615,8 @@
 					<table>
 						<independentVar lookup="row">/position/gear-agl-ft</independentVar>
 						<tableData>
-							 5  0.2
-							30  0.1
+							 5	0.2
+							30	0.1
 						</tableData>
 					</table>
 				</sum>
@@ -779,11 +779,11 @@
 						<independentVar lookup="row">attitude/pitch-rad</independentVar>
 						<independentVar lookup="column">fbw/pitch/g-pi-switched</independentVar>
 						<tableData>
-							          -1         0         1
-							-0.261799  0.000000  0.000000  0.087266
-							-0.261798  0.000000  0.000000  0.000000
-							 0.523598  0.000000  0.000000  0.000000
-							 0.523599 -0.087266  0.000000  0.000000
+									  -1		 0		   1
+							-0.261799  0.000000	 0.000000  0.087266
+							-0.261798  0.000000	 0.000000  0.000000
+							 0.523598  0.000000	 0.000000  0.000000
+							 0.523599 -0.087266	 0.000000  0.000000
 						</tableData>
 					</table>
 					<table>
@@ -818,9 +818,9 @@
 						<independentVar lookup="row">attitude/pitch-rad</independentVar>
 						<independentVar lookup="column">fbw/pitch/g-pi-switched</independentVar>
 						<tableData>
-							          -1         0       
-							 0.523598 -0.026180  0.000000
-							 0.523599 -0.087266  0.000000
+									  -1		 0		 
+							 0.523598 -0.026180	 0.000000
+							 0.523599 -0.087266	 0.000000
 						</tableData>
 					</table>
 					<table>
@@ -1066,7 +1066,7 @@
 					<independentVar lookup="row">/controls/flight/rudder</independentVar>
 					<independentVar lookup="column">fbw/fmgc/enabled</independentVar>
 					<tableData>
-						       0  1
+							   0  1
 						-1.00 -1  0
 						-0.04  0  0
 						 0.04  0  0
@@ -1192,8 +1192,8 @@
 				<table>
 					<independentVar lookup="row">/velocities/airspeed-kt</independentVar>
 					<tableData>
-						 62  1.0
-						116  0.0
+						 62	 1.0
+						116	 0.0
 					</tableData>
 				</table>
 			</function>
@@ -1204,8 +1204,8 @@
 				<table>
 					<independentVar lookup="row">/velocities/airspeed-kt</independentVar>
 					<tableData>
-						 72  1.0
-						121  0.0
+						 72	 1.0
+						121	 0.0
 					</tableData>
 				</table>
 			</function>
@@ -1222,8 +1222,8 @@
 				<table>
 					<independentVar lookup="row">spoilers/anti-droop-cmd</independentVar>
 					<tableData>
-						0.5  0.0
-						1.0  1.0
+						0.5	 0.0
+						1.0	 1.0
 					</tableData>
 				</table>
 			</function>
@@ -1521,9 +1521,9 @@
 				<independentVar lookup="row">velocities/mach</independentVar>
 				<independentVar lookup="column">atmosphere/density-altitude</independentVar>
 				<tableData>
-					     0     43000
-					0.0  1.00  0.850
-					0.9  0.02  0.750
+						 0	   43000
+					0.0	 1.00  0.850
+					0.9	 0.02  0.750
 				</tableData>
 			</table>
 		</scheduled_gain>
@@ -1534,9 +1534,9 @@
 				<independentVar lookup="row">velocities/mach</independentVar>
 				<independentVar lookup="column">atmosphere/density-altitude</independentVar>
 				<tableData>
-					     0     43000
-					0.0  1.00  0.850
-					0.9  0.02  0.750
+						 0	   43000
+					0.0	 1.00  0.850
+					0.9	 0.02  0.750
 				</tableData>
 			</table>
 		</scheduled_gain>
@@ -1547,9 +1547,9 @@
 				<independentVar lookup="row">velocities/mach</independentVar>
 				<independentVar lookup="column">atmosphere/density-altitude</independentVar>
 				<tableData>
-					     0     43000
-					0.0  1.00  0.850
-					0.9  0.02  0.750
+						 0	   43000
+					0.0	 1.00  0.850
+					0.9	 0.02  0.750
 				</tableData>
 			</table>
 		</scheduled_gain>
@@ -1563,34 +1563,34 @@
 				<table>
 					<independentVar lookup="row">/velocities/airspeed-kt</independentVar>
 					<tableData>
-						160.00  25.000
-						162.15  23.649
-						165.02  22.226
-						168.64  21.015
-						172.25  19.734
-						176.59  18.595
-						181.67  17.525
-						186.75  16.385
-						191.83  15.316
-						197.65  14.318
-						205.65  13.247
-						212.93  12.318
-						219.48  11.462
-						227.48  10.533
-						236.96  9.7450
-						246.43  8.8863
-						255.18  8.0990
-						266.12  7.4525
-						277.06  6.7704
-						288.00  6.0884
-						299.67  5.5124
-						311.35  5.0075
-						323.03  4.5736
-						335.44  4.2104
-						347.13  3.9186
-						358.81  3.6979
-						370.50  3.5482
-						380.00  3.4000
+						160.00	25.000
+						162.15	23.649
+						165.02	22.226
+						168.64	21.015
+						172.25	19.734
+						176.59	18.595
+						181.67	17.525
+						186.75	16.385
+						191.83	15.316
+						197.65	14.318
+						205.65	13.247
+						212.93	12.318
+						219.48	11.462
+						227.48	10.533
+						236.96	9.7450
+						246.43	8.8863
+						255.18	8.0990
+						266.12	7.4525
+						277.06	6.7704
+						288.00	6.0884
+						299.67	5.5124
+						311.35	5.0075
+						323.03	4.5736
+						335.44	4.2104
+						347.13	3.9186
+						358.81	3.6979
+						370.50	3.5482
+						380.00	3.4000
 					</tableData>
 				</table>
 			</function>
@@ -1738,6 +1738,19 @@
 	</channel>
 	
 	<channel name="Flaps">
+		<switch name="fcs/sfcc/unit1-avail">
+			<default value="0"/>
+			<test logic="OR" value="1">
+				/systems/electrical/bus/dc-ess ge 25
+			</test>
+		</switch>
+		
+		<switch name="fcs/sfcc/unit2-avail">
+			<default value="0"/>
+			<test logic="OR" value="1">
+				/systems/electrical/bus/dc2 ge 25
+			</test>
+		</switch>
 		
 		<pure_gain name="fcs/flap-pos-gain">
 			<input>/controls/flight/flaps</input>
@@ -1746,9 +1759,29 @@
 		
 		<switch name="fcs/flap-pos-rate">
 			<default value="0.0"/>
-			<test logic="OR" value="1.16666666">
+			<test logic="AND" value="1.16666666">
 				/systems/hydraulic/green-psi ge 1500
 				/systems/hydraulic/yellow-psi ge 1500
+				fcs/sfcc/unit1-avail eq 1
+				fcs/sfcc/unit2-avail eq 1
+			</test>
+			<test logic="AND" value="0.58333333">
+				/systems/hydraulic/green-psi ge 1500
+				fcs/sfcc/unit1-avail eq 1
+				fcs/sfcc/unit2-avail eq 0
+			</test>
+			<test logic="AND" value="0.58333333">
+				/systems/hydraulic/yellow-psi ge 1500
+				fcs/sfcc/unit1-avail eq 0
+				fcs/sfcc/unit2-avail eq 1
+			</test>
+			<test logic="AND" value="0.58333333">
+				/systems/hydraulic/green-psi ge 1500
+				/systems/hydraulic/yellow-psi lt 1500
+			</test>
+			<test logic="AND" value="0.58333333">
+				/systems/hydraulic/green-psi lt 1500
+				/systems/hydraulic/yellow-psi ge 1500
 			</test>
 		</switch>
 		
@@ -1782,10 +1815,29 @@
 		
 		<switch name="fcs/slat-pos-rate">
 			<default value="0.0"/>
-			<test logic="OR" value="1.35">
+			<test logic="AND" value="1.35">
 				/systems/hydraulic/blue-psi ge 1500
 				/systems/hydraulic/green-psi ge 1500
-				/systems/hydraulic/yellow-psi ge 1500
+				fcs/sfcc/unit1-avail eq 1
+				fcs/sfcc/unit2-avail eq 1
+			</test>
+			<test logic="AND" value="0.675">
+				/systems/hydraulic/blue-psi ge 1500
+				fcs/sfcc/unit1-avail eq 1
+				fcs/sfcc/unit2-avail eq 0
+			</test>
+			<test logic="AND" value="0.675">
+				/systems/hydraulic/green-psi ge 1500
+				fcs/sfcc/unit1-avail eq 0
+				fcs/sfcc/unit2-avail eq 1
+			</test>
+			<test logic="AND" value="0.675">
+				/systems/hydraulic/blue-psi ge 1500
+				/systems/hydraulic/green-psi lt 1500
+			</test>
+			<test logic="AND" value="0.675">
+				/systems/hydraulic/blue-psi lt 1500
+				/systems/hydraulic/green-psi ge 1500
 			</test>
 		</switch>
 		
@@ -1848,9 +1900,9 @@
 					<independentVar lookup="row">/velocities/groundspeed-kt</independentVar>
 					<independentVar lookup="column">hydraulics/tiller/switch</independentVar>
 					<tableData>
-						       -1     0  1
-						30.000 -70.0  0  70.0
-						30.001 -10.0  0  10.0
+							   -1	  0	 1
+						30.000 -70.0  0	 70.0
+						30.001 -10.0  0	 10.0
 					</tableData>
 				</table>
 			</function>

From eed45e2a16c6363c8dd81cfc61d81d6cdee8dd66 Mon Sep 17 00:00:00 2001
From: Jonathan Redpath <legoboyvdlp@gmail.com>
Date: Fri, 19 Oct 2018 16:21:21 +0100
Subject: [PATCH 2/5] Revision

---
 revision.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/revision.txt b/revision.txt
index cdc309eb..8eb54da3 100644
--- a/revision.txt
+++ b/revision.txt
@@ -1 +1 @@
-4678
\ No newline at end of file
+4679
\ No newline at end of file

From c828cab5cc2e4c3ff84d13a261472578cb237d6d Mon Sep 17 00:00:00 2001
From: Joshua Davidson <joshuadavidson2000@gmail.com>
Date: Fri, 19 Oct 2018 12:24:54 -0400
Subject: [PATCH 3/5] GUI: Reformat FCS XML...

---
 Systems/a320-fcs.xml | 195 ++++++++++++++++++++++---------------------
 1 file changed, 100 insertions(+), 95 deletions(-)

diff --git a/Systems/a320-fcs.xml b/Systems/a320-fcs.xml
index dace3be3..2d628ccf 100644
--- a/Systems/a320-fcs.xml
+++ b/Systems/a320-fcs.xml
@@ -82,7 +82,7 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/roll/gain-switch</independentVar>
 					<tableData>
-							 0	   1  
+						     0     1  
 						0.2 -26.2  0.0
 						0.9 -15.5  0.0
 					</tableData>
@@ -96,7 +96,7 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/roll/gain-switch</independentVar>
 					<tableData>
-							 0	   1
+						     0     1
 						0.2 -45.5  0.0
 						0.9 -36.0  0.0
 					</tableData>
@@ -110,7 +110,7 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/roll/gain-switch</independentVar>
 					<tableData>
-							 0	  1
+						     0    1
 						0.2 -2.1  0.0
 						0.9 -1.1  0.0
 					</tableData>
@@ -124,9 +124,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/pitch/gain-switch</independentVar>
 					<tableData>
-							 0	 1	
-						0.2	 28	 0
-						0.9	 23	 0
+						     0   1  
+						0.2  28  0
+						0.9  23  0
 					</tableData>
 				</table>
 			</function>
@@ -138,9 +138,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/pitch/gain-switch</independentVar>
 					<tableData>
-							 0	 1
-						0.2	 61	 0
-						0.9	 45	 0
+						     0   1
+						0.2  61  0
+						0.9  45  0
 					</tableData>
 				</table>
 			</function>
@@ -152,9 +152,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/pitch/gain-switch</independentVar>
 					<tableData>
-							 0	  1
-						0.2	 2.9  0.0
-						0.9	 1.3  0.0
+						     0    1
+						0.2  2.9  0.0
+						0.9  1.3  0.0
 					</tableData>
 				</table>
 			</function>
@@ -166,7 +166,7 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/yaw/gain-switch</independentVar>
 					<tableData>
-							 0	  1
+						     0    1
 						0.2 -7.5  0.0
 						0.9 -1.5  0.0
 					</tableData>
@@ -180,9 +180,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/yaw/gain-switch</independentVar>
 					<tableData>
-							 0	   1
-						0.2	 5.01  0.00
-						0.9	 1.05  0.00
+						     0     1
+						0.2  5.01  0.00
+						0.9  1.05  0.00
 					</tableData>
 				</table>
 			</function>
@@ -194,9 +194,9 @@
 					<independentVar lookup="row">velocities/mach</independentVar>
 					<independentVar lookup="column">fbw/yaw/gain-switch</independentVar>
 					<tableData>
-							 0	   1
-						0.2	 1.03  0.00
-						0.9	 0.79  0.00
+						     0     1
+						0.2  1.03  0.00
+						0.9  0.79  0.00
 					</tableData>
 				</table>
 			</function>
@@ -279,11 +279,11 @@
 						<independentVar lookup="row">attitude/roll-rad</independentVar>
 						<independentVar lookup="column">fbw/roll/a-i</independentVar>
 						<tableData>
-									  -1		 0		   1
-							-0.575959  0.261799	 0.000000  0.000000
-							-0.575958  0.000000	 0.000000  0.000000
-							 0.575958  0.000000	 0.000000  0.000000
-							 0.575959  0.000000	 0.000000 -0.261799
+							          -1         0         1
+							-0.575959  0.261799  0.000000  0.000000
+							-0.575958  0.000000  0.000000  0.000000
+							 0.575958  0.000000  0.000000  0.000000
+							 0.575959  0.000000  0.000000 -0.261799
 						</tableData>
 					</table>
 					<table>
@@ -310,11 +310,11 @@
 						<independentVar lookup="row">attitude/roll-rad</independentVar>
 						<independentVar lookup="column">fbw/roll/a-i</independentVar>
 						<tableData>
-									  -1		 0		   1
-							-1.169370  0.261799	 0.000000  0.000000
-							-1.169369  0.000000	 0.000000  0.000000
-							 1.169369  0.000000	 0.000000  0.000000
-							 1.169370  0.000000	 0.000000 -0.261799
+							          -1         0         1
+							-1.169370  0.261799  0.000000  0.000000
+							-1.169369  0.000000  0.000000  0.000000
+							 1.169369  0.000000  0.000000  0.000000
+							 1.169370  0.000000  0.000000 -0.261799
 						</tableData>
 					</table>
 					<table>
@@ -369,11 +369,11 @@
 						<independentVar lookup="row">attitude/roll-rad</independentVar>
 						<independentVar lookup="column">fbw/roll/a-i</independentVar>
 						<tableData>
-									  -1		 0		   1
-							-0.698132  0.261799	 0.000000  0.000000
-							-0.698131  0.000000	 0.000000  0.000000
-							 0.698131  0.000000	 0.000000  0.000000
-							 0.698132  0.000000	 0.000000 -0.261799
+							          -1         0         1
+							-0.698132  0.261799  0.000000  0.000000
+							-0.698131  0.000000  0.000000  0.000000
+							 0.698131  0.000000  0.000000  0.000000
+							 0.698132  0.000000  0.000000 -0.261799
 						</tableData>
 					</table>
 				</sum>
@@ -523,9 +523,9 @@
 						<independentVar lookup="row">velocities/mach</independentVar>
 						<independentVar lookup="column">position/wow</independentVar>
 						<tableData>
-								 0	  1
-							0.2	 0.5  1.0
-							0.9	 0.1  1.0
+							     0    1
+							0.2  0.5  1.0
+							0.9  0.1  1.0
 						</tableData>
 					</table>
 				</product>
@@ -615,8 +615,8 @@
 					<table>
 						<independentVar lookup="row">/position/gear-agl-ft</independentVar>
 						<tableData>
-							 5	0.2
-							30	0.1
+							 5  0.2
+							30  0.1
 						</tableData>
 					</table>
 				</sum>
@@ -779,11 +779,11 @@
 						<independentVar lookup="row">attitude/pitch-rad</independentVar>
 						<independentVar lookup="column">fbw/pitch/g-pi-switched</independentVar>
 						<tableData>
-									  -1		 0		   1
-							-0.261799  0.000000	 0.000000  0.087266
-							-0.261798  0.000000	 0.000000  0.000000
-							 0.523598  0.000000	 0.000000  0.000000
-							 0.523599 -0.087266	 0.000000  0.000000
+							          -1         0         1
+							-0.261799  0.000000  0.000000  0.087266
+							-0.261798  0.000000  0.000000  0.000000
+							 0.523598  0.000000  0.000000  0.000000
+							 0.523599 -0.087266  0.000000  0.000000
 						</tableData>
 					</table>
 					<table>
@@ -818,9 +818,9 @@
 						<independentVar lookup="row">attitude/pitch-rad</independentVar>
 						<independentVar lookup="column">fbw/pitch/g-pi-switched</independentVar>
 						<tableData>
-									  -1		 0		 
-							 0.523598 -0.026180	 0.000000
-							 0.523599 -0.087266	 0.000000
+							          -1         0       
+							 0.523598 -0.026180  0.000000
+							 0.523599 -0.087266  0.000000
 						</tableData>
 					</table>
 					<table>
@@ -1066,7 +1066,7 @@
 					<independentVar lookup="row">/controls/flight/rudder</independentVar>
 					<independentVar lookup="column">fbw/fmgc/enabled</independentVar>
 					<tableData>
-							   0  1
+						       0  1
 						-1.00 -1  0
 						-0.04  0  0
 						 0.04  0  0
@@ -1192,8 +1192,8 @@
 				<table>
 					<independentVar lookup="row">/velocities/airspeed-kt</independentVar>
 					<tableData>
-						 62	 1.0
-						116	 0.0
+						 62  1.0
+						116  0.0
 					</tableData>
 				</table>
 			</function>
@@ -1204,8 +1204,8 @@
 				<table>
 					<independentVar lookup="row">/velocities/airspeed-kt</independentVar>
 					<tableData>
-						 72	 1.0
-						121	 0.0
+						 72  1.0
+						121  0.0
 					</tableData>
 				</table>
 			</function>
@@ -1222,8 +1222,8 @@
 				<table>
 					<independentVar lookup="row">spoilers/anti-droop-cmd</independentVar>
 					<tableData>
-						0.5	 0.0
-						1.0	 1.0
+						0.5  0.0
+						1.0  1.0
 					</tableData>
 				</table>
 			</function>
@@ -1521,9 +1521,9 @@
 				<independentVar lookup="row">velocities/mach</independentVar>
 				<independentVar lookup="column">atmosphere/density-altitude</independentVar>
 				<tableData>
-						 0	   43000
-					0.0	 1.00  0.850
-					0.9	 0.02  0.750
+					     0     43000
+					0.0  1.00  0.850
+					0.9  0.02  0.750
 				</tableData>
 			</table>
 		</scheduled_gain>
@@ -1534,9 +1534,9 @@
 				<independentVar lookup="row">velocities/mach</independentVar>
 				<independentVar lookup="column">atmosphere/density-altitude</independentVar>
 				<tableData>
-						 0	   43000
-					0.0	 1.00  0.850
-					0.9	 0.02  0.750
+					     0     43000
+					0.0  1.00  0.850
+					0.9  0.02  0.750
 				</tableData>
 			</table>
 		</scheduled_gain>
@@ -1547,9 +1547,9 @@
 				<independentVar lookup="row">velocities/mach</independentVar>
 				<independentVar lookup="column">atmosphere/density-altitude</independentVar>
 				<tableData>
-						 0	   43000
-					0.0	 1.00  0.850
-					0.9	 0.02  0.750
+					     0     43000
+					0.0  1.00  0.850
+					0.9  0.02  0.750
 				</tableData>
 			</table>
 		</scheduled_gain>
@@ -1563,34 +1563,34 @@
 				<table>
 					<independentVar lookup="row">/velocities/airspeed-kt</independentVar>
 					<tableData>
-						160.00	25.000
-						162.15	23.649
-						165.02	22.226
-						168.64	21.015
-						172.25	19.734
-						176.59	18.595
-						181.67	17.525
-						186.75	16.385
-						191.83	15.316
-						197.65	14.318
-						205.65	13.247
-						212.93	12.318
-						219.48	11.462
-						227.48	10.533
-						236.96	9.7450
-						246.43	8.8863
-						255.18	8.0990
-						266.12	7.4525
-						277.06	6.7704
-						288.00	6.0884
-						299.67	5.5124
-						311.35	5.0075
-						323.03	4.5736
-						335.44	4.2104
-						347.13	3.9186
-						358.81	3.6979
-						370.50	3.5482
-						380.00	3.4000
+						160.00  25.000
+						162.15  23.649
+						165.02  22.226
+						168.64  21.015
+						172.25  19.734
+						176.59  18.595
+						181.67  17.525
+						186.75  16.385
+						191.83  15.316
+						197.65  14.318
+						205.65  13.247
+						212.93  12.318
+						219.48  11.462
+						227.48  10.533
+						236.96  9.7450
+						246.43  8.8863
+						255.18  8.0990
+						266.12  7.4525
+						277.06  6.7704
+						288.00  6.0884
+						299.67  5.5124
+						311.35  5.0075
+						323.03  4.5736
+						335.44  4.2104
+						347.13  3.9186
+						358.81  3.6979
+						370.50  3.5482
+						380.00  3.4000
 					</tableData>
 				</table>
 			</function>
@@ -1737,7 +1737,8 @@
 	
 	</channel>
 	
-	<channel name="Flaps">
+	<channel name="SFCC">
+		
 		<switch name="fcs/sfcc/unit1-avail">
 			<default value="0"/>
 			<test logic="OR" value="1">
@@ -1751,6 +1752,10 @@
 				/systems/electrical/bus/dc2 ge 25
 			</test>
 		</switch>
+	
+	</channel>
+	
+	<channel name="Flaps">
 		
 		<pure_gain name="fcs/flap-pos-gain">
 			<input>/controls/flight/flaps</input>
@@ -1900,9 +1905,9 @@
 					<independentVar lookup="row">/velocities/groundspeed-kt</independentVar>
 					<independentVar lookup="column">hydraulics/tiller/switch</independentVar>
 					<tableData>
-							   -1	  0	 1
-						30.000 -70.0  0	 70.0
-						30.001 -10.0  0	 10.0
+						       -1     0  1
+						30.000 -70.0  0  70.0
+						30.001 -10.0  0  10.0
 					</tableData>
 				</table>
 			</function>

From 568fa31d8b69b025578cb31f248808f9308a2467 Mon Sep 17 00:00:00 2001
From: Joshua Davidson <joshuadavidson2000@gmail.com>
Date: Fri, 19 Oct 2018 17:45:13 -0400
Subject: [PATCH 4/5] Control: Rework AP, fix lots of stuff

---
 Systems/fmgc-drivers.xml  | 220 ++++++++++++++------------------------
 Systems/fmgc-pitch.xml    |  54 +++-------
 Systems/fmgc-roll-yaw.xml | 151 +++++++++++---------------
 Systems/fmgc-thrust.xml   | 138 ++++++------------------
 revision.txt              |   2 +-
 5 files changed, 190 insertions(+), 375 deletions(-)

diff --git a/Systems/fmgc-drivers.xml b/Systems/fmgc-drivers.xml
index 5df5e0e7..8e360728 100644
--- a/Systems/fmgc-drivers.xml
+++ b/Systems/fmgc-drivers.xml
@@ -9,11 +9,9 @@
 <!-- IT-AUTOFLIGHT -->
 
 <PropertyList>
-
- <!-- =============================================================== -->
- <!-- Predictors                                                      -->
- <!-- =============================================================== -->
- 
+	
+	<!-- Predictors -->
+	
 	<predict-simple>
 		<name>IAS 5 SECOND PREDICTOR</name>
 		<debug>false</debug>
@@ -22,7 +20,7 @@
 		<seconds>5.0</seconds>
 		<filter-gain>0.0</filter-gain>
 	</predict-simple>
-
+	
 	<predict-simple>
 		<name>IAS 10 SECOND PREDICTOR</name>
 		<debug>false</debug>
@@ -49,7 +47,7 @@
 		<seconds>5.0</seconds>
 		<filter-gain>0.0</filter-gain>
 	</predict-simple>
-
+	
 	<predict-simple>
 		<name>MACH 10 SECOND PREDICTOR</name>
 		<debug>false</debug>
@@ -67,16 +65,13 @@
 		<seconds>15.0</seconds>
 		<filter-gain>0.0</filter-gain>
 	</predict-simple>
-  
- <!-- =============================================================== -->
- <!-- Autopilot Helpers/Calculators                                   -->
- <!-- =============================================================== -->
-
+	
+	<!-- Autopilot Helpers/Calculators -->
+	
 	<filter>
 		<name>AUTOLAND FD FPM</name>
 		<type>gain</type>
 		<gain>1.0</gain>
-		<update-interval-secs type="double">0.05</update-interval-secs>
 		<input> 
 			<expression>
 				<table>
@@ -89,12 +84,11 @@
 		</input>
 		<output>/it-autoflight/internal/target-fpm-c2</output>
 	</filter>
- 
+	
 	<filter>
 		<name>AUTOLAND FPM</name>
 		<type>gain</type>
 		<gain>1.0</gain>
-		<update-interval-secs type="double">0.05</update-interval-secs>
 		<input> 
 			<expression>
 				<table>
@@ -111,12 +105,11 @@
 		</input>
 		<output>/it-autoflight/internal/target-fpm-c</output>
 	</filter>
- 
+	
 	<filter>
 		<name>FMGC MNG SPD</name>
 		<type>gain</type>
 		<gain>1.0</gain>
-		<update-interval-secs type="double">0.05</update-interval-secs>
 		<input>
 			<expression>
 				<product>
@@ -138,7 +131,6 @@
 		<name>FMGC MNG MACH</name>
 		<type>gain</type>
 		<gain>1.0</gain>
-		<update-interval-secs type="double">0.05</update-interval-secs>
 		<input> 
 			<expression>
 				<product>
@@ -164,7 +156,6 @@
 		<name>FMGC Target IAS PFD</name>
 		<type>gain</type>
 		<gain>1.0</gain>
-		<update-interval-secs type="double">0.1</update-interval-secs>
 		<input>
 			<condition>
 				<equals>
@@ -193,10 +184,11 @@
 		</input>
 		<output>/FMGC/internal/target-ias-pfd</output>
 	</filter>
- 
+	
 	<filter>
 		<name>KTS INPUT FILTER</name>
 		<debug>false</debug>
+		<type>noise-spike</type>
 		<feedback-if-disabled>true</feedback-if-disabled>
 		<initialize-to>output</initialize-to>
 		<input>
@@ -218,32 +210,6 @@
 			<property>/it-autoflight/settings/togaspd</property>
 		</input>
 		<output>/it-autoflight/internal/flch-kts</output>
-		<type>noise-spike</type>
-		<max-rate-of-change>
-			<condition>
-				<or>
-					<and>
-						<not-equals>
-							<property>/it-autoflight/output/vert</property>
-							<value>4</value>
-						</not-equals>
-						<not-equals>
-							<property>/it-autoflight/output/vert</property>
-							<value>7</value>
-						</not-equals>
-					</and>
-					<equals>
-						<property>/gear/gear[1]/wow</property>
-						<value>1</value>
-					</equals>
-					<equals>
-						<property>/gear/gear[2]/wow</property>
-						<value>1</value>
-					</equals>
-				</or>
-			</condition>
-			<value>100</value>
-		</max-rate-of-change>
 		<max-rate-of-change>
 			<condition>
 				<and>
@@ -257,6 +223,10 @@
 							<value>7</value>
 						</equals>
 					</or>
+					<equals>
+						<property>/it-autoflight/input/kts-mach</property>
+						<value>0</value>
+					</equals>
 					<equals>
 						<property>/gear/gear[1]/wow</property>
 						<value>0</value>
@@ -269,43 +239,33 @@
 			</condition>
 			<value>5</value>
 		</max-rate-of-change>
+		<max-rate-of-change>100</max-rate-of-change>
 	</filter>
 	
 	<filter>
 		<name>MACH INPUT FILTER</name>
 		<debug>false</debug>
+		<type>noise-spike</type>
 		<feedback-if-disabled>true</feedback-if-disabled>
 		<initialize-to>output</initialize-to>
-		<input>
-			<property>/it-autoflight/input/spd-mach</property>
-		</input>
+		<input>/it-autoflight/input/spd-mach</input>
 		<output>/it-autoflight/internal/flch-mach</output>
-		<type>noise-spike</type>
-		<max-rate-of-change>
-			<condition>
-				<or>
-					<not-equals>
-						<property>/it-autoflight/output/vert</property>
-						<value>4</value>
-					</not-equals>
-					<equals>
-						<property>/gear/gear[1]/wow</property>
-						<value>1</value>
-					</equals>
-					<equals>
-						<property>/gear/gear[2]/wow</property>
-						<value>1</value>
-					</equals>
-				</or>
-			</condition>
-			<value>1</value>
-		</max-rate-of-change>
 		<max-rate-of-change>
 			<condition>
 				<and>
+					<or>
+						<equals>
+							<property>/it-autoflight/output/vert</property>
+							<value>4</value>
+						</equals>
+						<equals>
+							<property>/it-autoflight/output/vert</property>
+							<value>7</value>
+						</equals>
+					</or>
 					<equals>
-						<property>/it-autoflight/output/vert</property>
-						<value>4</value>
+						<property>/it-autoflight/input/kts-mach</property>
+						<value>1</value>
 					</equals>
 					<equals>
 						<property>/gear/gear[1]/wow</property>
@@ -319,8 +279,9 @@
 			</condition>
 			<value>0.05</value>
 		</max-rate-of-change>
+		<max-rate-of-change>1</max-rate-of-change>
 	</filter>
- 
+	
 	<filter>
 		<name>IAS SYNC</name>
 		<type>gain</type>
@@ -333,7 +294,6 @@
 				</equals>
 			</condition>
 		</enable>
-		<update-interval-secs type="double">0.5</update-interval-secs>
 		<input>/instrumentation/airspeed-indicator/indicated-speed-kt</input>
 		<output>/it-autoflight/input/spd-kts</output>
 	</filter>
@@ -350,7 +310,6 @@
 				</equals>
 			</condition>
 		</enable>
-		<update-interval-secs type="double">0.5</update-interval-secs>
 		<input>/instrumentation/airspeed-indicator/indicated-mach</input>
 		<output>/it-autoflight/input/spd-mach</output>
 	</filter>
@@ -365,9 +324,7 @@
 			</condition>
 			<property>/orientation/heading-deg</property>
 		</input>
-		<input>
-			<property>/orientation/heading-magnetic-deg</property>
-		</input>
+		<input>/orientation/heading-magnetic-deg</input>
 		<reference>0</reference>
 		<output>/it-autoflight/internal/heading-deg</output>
 		<output>/instrumentation/pfd/heading-deg</output>
@@ -522,7 +479,10 @@
 		<input>
 			<expression>
 				<floor>
-					<property>/it-autoflight/internal/vert-speed-fpm</property>
+					<sum>
+						<property>/it-autoflight/internal/vert-speed-fpm</property>
+						<value>0.5</value>
+					</sum>
 				</floor>
 			</expression>
 		</input>
@@ -532,31 +492,18 @@
 	<filter>
 		<name>VERT SPEED FILTER</name>
 		<debug>false</debug>
+		<type>noise-spike</type>
 		<feedback-if-disabled>true</feedback-if-disabled>
 		<initialize-to>output</initialize-to>
-		<input>
-			<property>/it-autoflight/input/vs</property>
-		</input>
+		<input>/it-autoflight/input/vs</input>
 		<output>/it-autoflight/internal/vs</output>
-		<type>noise-spike</type>
-		<max-rate-of-change>
-			<condition>
-				<or>
-					<equals>
-						<property>/gear/gear[1]/wow</property>
-						<value>1</value>
-					</equals>
-					<equals>
-						<property>/gear/gear[2]/wow</property>
-						<value>1</value>
-					</equals>
-				</or>
-			</condition>
-			<value>2000</value>
-		</max-rate-of-change>
 		<max-rate-of-change>
 			<condition>
 				<and>
+					<equals>
+						<property>/it-autoflight/output/vert</property>
+						<value>1</value>
+					</equals>
 					<equals>
 						<property>/gear/gear[1]/wow</property>
 						<value>0</value>
@@ -569,8 +516,9 @@
 			</condition>
 			<value>300</value>
 		</max-rate-of-change>
+		<max-rate-of-change>2000</max-rate-of-change>
 	</filter>
-
+	
 	<filter>
 		<name>NAV ERROR DEG</name>
 		<debug>false</debug>
@@ -589,7 +537,7 @@
 			<max>180</max>
 		</period>
 	</filter>
-
+	
 	<filter>
 		<name>INTERNAL VERTICAL SPEED COMPUTER</name>
 		<debug>false</debug>
@@ -830,49 +778,13 @@
 		</input>
 		<output>/it-autoflight/internal/fpa</output>
 	</filter>
-
- <!-- =============================================================== -->
- <!-- Flight Director                                                 -->
- <!-- =============================================================== -->
- 
+	
+	<!-- Flight Director -->
+	
 	<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-fd</output>
 		<type>noise-spike</type>
-		<max-rate-of-change>15</max-rate-of-change>
-	</filter>
-	
-	<filter>
-		<name>FD: ROLL</name>
-		<debug>false</debug>
-		<type>gain</type>
-		<gain>1.0</gain>
-		<input>
-			<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>
-			<expression>
-				<dif>
-					<property>/it-autoflight/internal/target-roll-fd</property>
-					<property>/orientation/roll-deg</property>
-				</dif>
-			</expression>
-		</input>
 		<input>
 			<condition>
 				<or>
@@ -886,9 +798,37 @@
 					</equals>
 				</or>
 			</condition>
+			<value>0</value>
+		</input>
+		<input>/it-autoflight/internal/target-roll-deg</input>
+		<output>/it-autoflight/internal/target-roll-fd</output>
+		<max-rate-of-change>
+			<condition>
+				<and>
+					<not-equals>
+						<property>/it-autoflight/output/fd1</property>
+						<value>1</value>
+					</not-equals>
+					<not-equals>
+						<property>/it-autoflight/output/fd1</property>
+						<value>1</value>
+					</not-equals>
+				</and>
+			</condition>
+			<value>50</value>
+		</max-rate-of-change>
+		<max-rate-of-change>15</max-rate-of-change>
+	</filter>
+	
+	<filter>
+		<name>FD: ROLL</name>
+		<debug>false</debug>
+		<type>gain</type>
+		<gain>1.0</gain>
+		<input>
 			<expression>
 				<dif>
-					<value>0</value>
+					<property>/it-autoflight/internal/target-roll-fd</property>
 					<property>/orientation/roll-deg</property>
 				</dif>
 			</expression>
@@ -897,7 +837,7 @@
 		<min>-30</min>
 		<max>30</max>
 	</filter>
-
+	
 	<filter>
 		<name>FD: PITCH</name>
 		<debug>false</debug>
diff --git a/Systems/fmgc-pitch.xml b/Systems/fmgc-pitch.xml
index ed8a1e6e..117cb06c 100644
--- a/Systems/fmgc-pitch.xml
+++ b/Systems/fmgc-pitch.xml
@@ -45,15 +45,9 @@
 				</condition>
 			<property>/it-autoflight/internal/mng-alt</property>
 		</reference>
-		<output>
-			<property>/it-autoflight/internal/target-fpm</property>
-		</output>
-		<min>
-			<property>/it-autoflight/internal/min-vs</property>
-		</min>
-		<max>
-			<property>/it-autoflight/internal/max-vs</property>
-		</max>
+		<output>/it-autoflight/internal/target-fpm</output>
+		<min>/it-autoflight/internal/min-vs</min>
+		<max>/it-autoflight/internal/max-vs</max>
 	</filter>
 
 	<pid-controller>
@@ -87,15 +81,9 @@
 				</and>
 			</condition>
 		</enable>
-		<input>
-			<property>/it-autoflight/internal/fpa</property>
-		</input>
-		<reference>
-			<property>/it-autoflight/input/fpa</property>
-		</reference>
-		<output>
-			<property>/it-autoflight/internal/target-fpm-d</property>
-		</output>
+		<input>/it-autoflight/internal/fpa</input>
+		<reference>/it-autoflight/input/fpa</reference>
+		<output>/it-autoflight/internal/target-fpm-d</output>
 		<config>
 			<Kp>
 				<expression>
@@ -106,9 +94,6 @@
 					</table>
 				</expression>
 			</Kp>
-			<beta>1.0</beta>
-			<alpha>0.1</alpha>
-			<gamma>0.0</gamma>
 			<Ti>2.0</Ti>
 			<Td>0.002</Td>
 			<u_min>
@@ -215,9 +200,7 @@
 			<property>/it-autoflight/internal/flch-mach</property>
 			<scale>1000.0</scale>
 		</reference>
-		<output>
-			<property>/it-autoflight/internal/target-fpm-b</property>
-		</output>
+		<output>/it-autoflight/internal/target-fpm-b</output>
 		<config>
 			<Kp>
 				<condition>
@@ -237,9 +220,6 @@
 				</condition>
 				<value>-60</value>
 			</Kp>
-			<beta>1.0</beta>    
-			<alpha>0.1</alpha>  
-			<gamma>0.0</gamma>  
 			<Ti>2.5</Ti>        
 			<Td>0.001</Td>
 			<u_min>
@@ -505,9 +485,7 @@
 				</and>
 			</condition>
 		</enable>
-		<input>
-			<property>/it-autoflight/internal/vert-speed-fpm</property>
-		</input>
+		<input>/it-autoflight/internal/vert-speed-fpm</input>
 		<reference>
 			<condition>
 				<or>
@@ -590,9 +568,7 @@
 			</condition>
 			<property>/it-autoflight/internal/nav1-rate-of-climb-fpm</property>
 		</reference>
-		<output>
-			<property>/it-autoflight/internal/target-pitch-deg</property>
-		</output>
+		<output>/it-autoflight/internal/target-pitch-deg</output>
 		<config>
 			<Kp>
 				<condition>
@@ -717,15 +693,9 @@
 		<debug>false</debug>
 		<type>gain</type>
 		<gain>0.15</gain>
-		<input>
-			<property>/orientation/pitch-deg</property>
-		</input>
-		<reference>
-			<property>/it-autoflight/internal/target-pitch-deg</property>
-		</reference>
-		<output>
-			<property>/fdm/jsbsim/fbw/fmgc/pitch-cmd</property> <!-- Inputs to the FBW Pitch Rate -->
-		</output>
+		<input>/orientation/pitch-deg</input>
+		<reference>/it-autoflight/internal/target-pitch-deg</reference>
+		<output>/fdm/jsbsim/fbw/fmgc/pitch-cmd</output> <!-- Inputs to the FBW Pitch -->
 		<min>-0.3</min>
 		<max>0.3</max>
 	</filter>
diff --git a/Systems/fmgc-roll-yaw.xml b/Systems/fmgc-roll-yaw.xml
index 662a5d59..78719d0b 100644
--- a/Systems/fmgc-roll-yaw.xml
+++ b/Systems/fmgc-roll-yaw.xml
@@ -51,15 +51,9 @@
 				</and>
 			</condition>
 		</enable>
-		<input>
-			<property>/it-autoflight/internal/heading-error-deg</property>
-		</input>
-		<reference>
-			<value>0</value>
-		</reference>
-		<output>
-			<property>/it-autoflight/internal/target-roll-deg</property>
-		</output>
+		<input>/it-autoflight/internal/heading-error-deg</input>
+		<reference>0</reference>
+		<output>/it-autoflight/internal/target-roll-deg</output>
 		<config>
 			<Kp>-1.8</Kp>
 			<Ki>-0.000001</Ki>
@@ -67,9 +61,7 @@
 				<property>/it-autoflight/internal/bank-limit</property>
 				<scale>-1</scale>
 			</min>
-			<max>
-				<property>/it-autoflight/internal/bank-limit</property>
-			</max>
+			<max>/it-autoflight/internal/bank-limit</max>
 		</config>
 	</pi-simple-controller>
 	
@@ -104,30 +96,9 @@
 				</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>
+		<input>/it-autoflight/internal/nav-heading-error-deg</input>
+		<reference>0</reference>
+		<output>/it-autoflight/internal/target-roll-deg</output>
 		<config>
 			<Kp>-2.8</Kp>
 			<Ki>-0.0001</Ki>
@@ -135,9 +106,7 @@
 				<property>/it-autoflight/internal/bank-limit</property>
 				<scale>-1</scale>
 			</min>
-			<max>
-				<property>/it-autoflight/internal/bank-limit</property>
-			</max>
+			<max>/it-autoflight/internal/bank-limit</max>
 		</config>
 	</pi-simple-controller>
 
@@ -174,48 +143,14 @@
 			<property>/it-autoflight/internal/bank-limit</property>
 			<scale>-1</scale>
 		</min>
-		<max>
-			<property>/it-autoflight/internal/bank-limit</property>
-		</max>
+		<max>/it-autoflight/internal/bank-limit</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>
-	
-	<filter>
-		<name>System Command: Roll Rate</name>
-		<debug>false</debug>
-		<type>gain</type>
-		<gain>-0.1</gain>
 		<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>
@@ -229,10 +164,58 @@
 				</or>
 			</condition>
 			<value>0</value>
-		</reference>
-		<output>
-			<property>/fdm/jsbsim/fbw/fmgc/roll-cmd</property> <!-- Inputs to the FBW Roll Rate -->
-		</output>   	
+		</input>
+		<input>/it-autoflight/internal/target-roll-deg</input>
+		<output>/it-autoflight/internal/target-roll</output>
+		<max-rate-of-change>
+			<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>
+			<value>50</value>
+		</max-rate-of-change>
+		<max-rate-of-change>
+			<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>
+				</and>
+			</condition>
+			<value>15</value>
+		</max-rate-of-change>
+		<max-rate-of-change>8</max-rate-of-change>
+	</filter>
+	
+	<filter>
+		<name>System Command: Roll Rate</name>
+		<debug>false</debug>
+		<type>gain</type>
+		<gain>-0.1</gain>
+		<input>/orientation/roll-deg</input>
+		<reference>/it-autoflight/internal/target-roll</reference>
+		<output>/fdm/jsbsim/fbw/fmgc/roll-cmd</output> <!-- Inputs to the FBW Roll -->
 		<min>-0.32</min>
 		<max>0.32</max>
 	</filter>
@@ -252,12 +235,8 @@
 				</equals>
 			</condition>
 		</enable>
-		<input>
-			<property>/it-autoflight/internal/nav-heading-error-deg</property>
-		</input>
-		<reference>
-			<value>0</value>
-		</reference>
+		<input>/it-autoflight/internal/nav-heading-error-deg</input>
+		<reference>0</reference>
 		<output>/it-autoflight/internal/rudder-cmd</output>
 		<config>
 			<Kp>
@@ -299,6 +278,7 @@
 	<filter>
 		<name>IT-CONTROLLER: RUDDER CMD</name>
 		<debug>false</debug>
+		<type>noise-spike</type>
 		<feedback-if-disabled>true</feedback-if-disabled>
 		<initialize-to>output</initialize-to>
 		<input>
@@ -319,8 +299,7 @@
 			</condition>
 			<property>/it-autoflight/internal/rudder-cmd</property>
 		</input>
-		<output>/fdm/jsbsim/fbw/fmgc/yaw-cmd</output>
-		<type>noise-spike</type>
+		<output>/fdm/jsbsim/fbw/fmgc/yaw-cmd</output> <!-- Inputs to the FBW Yaw -->
 		<max-rate-of-change>0.6</max-rate-of-change>
 	</filter>
 
diff --git a/Systems/fmgc-thrust.xml b/Systems/fmgc-thrust.xml
index 4bb11f75..0c13a4c2 100644
--- a/Systems/fmgc-thrust.xml
+++ b/Systems/fmgc-thrust.xml
@@ -7,44 +7,17 @@
 -->
 
 <PropertyList>
-
- <!-- =============================================================== -->
- <!-- Thrust Modes                                                    -->
- <!-- =============================================================== -->
- 
+	
+	<!-- Thrust Axis -->
+	
 	<filter>
 		<name>KTS INPUT FILTER</name>
 		<debug>false</debug>
+		<type>noise-spike</type>
 		<feedback-if-disabled>true</feedback-if-disabled>
 		<initialize-to>output</initialize-to>
-		<input>
-			<property>/it-autoflight/input/spd-kts</property>
-		</input>
+		<input>/it-autoflight/input/spd-kts</input>
 		<output>/it-autoflight/internal/kts</output>
-		<type>noise-spike</type>
-		<max-rate-of-change>
-			<condition>
-				<or>
-					<not-equals>
-						<property>/it-autoflight/output/thr-mode</property>
-						<value>0</value>
-					</not-equals>
-					<equals>
-						<property>/it-autoflight/output/athr</property>
-						<value>0</value>
-					</equals>
-					<equals>
-						<property>/gear/gear[1]/wow</property>
-						<value>1</value>
-					</equals>
-					<equals>
-						<property>/gear/gear[2]/wow</property>
-						<value>1</value>
-					</equals>
-				</or>
-			</condition>
-			<value>200</value>
-		</max-rate-of-change>
 		<max-rate-of-change>
 			<condition>
 				<and>
@@ -56,6 +29,10 @@
 						<property>/it-autoflight/output/athr</property>
 						<value>1</value>
 					</equals>
+					<equals>
+						<property>/it-autoflight/input/kts-mach</property>
+						<value>0</value>
+					</equals>
 					<equals>
 						<property>/gear/gear[1]/wow</property>
 						<value>0</value>
@@ -68,41 +45,17 @@
 			</condition>
 			<value>10</value>
 		</max-rate-of-change>
+		<max-rate-of-change>200</max-rate-of-change>
 	</filter>
 	
 	<filter>
 		<name>MACH INPUT FILTER</name>
 		<debug>false</debug>
+		<type>noise-spike</type>
 		<feedback-if-disabled>true</feedback-if-disabled>
 		<initialize-to>output</initialize-to>
-		<input>
-			<property>/it-autoflight/input/spd-mach</property>
-		</input>
+		<input>/it-autoflight/input/spd-mach</input>
 		<output>/it-autoflight/internal/mach</output>
-		<type>noise-spike</type>
-		<max-rate-of-change>
-			<condition>
-				<or>
-					<not-equals>
-						<property>/it-autoflight/output/thr-mode</property>
-						<value>0</value>
-					</not-equals>
-					<equals>
-						<property>/it-autoflight/output/athr</property>
-						<value>0</value>
-					</equals>
-					<equals>
-						<property>/gear/gear[1]/wow</property>
-						<value>1</value>
-					</equals>
-					<equals>
-						<property>/gear/gear[2]/wow</property>
-						<value>1</value>
-					</equals>
-				</or>
-			</condition>
-			<value>2</value>
-		</max-rate-of-change>
 		<max-rate-of-change>
 			<condition>
 				<and>
@@ -114,6 +67,10 @@
 						<property>/it-autoflight/output/athr</property>
 						<value>1</value>
 					</equals>
+					<equals>
+						<property>/it-autoflight/input/kts-mach</property>
+						<value>1</value>
+					</equals>
 					<equals>
 						<property>/gear/gear[1]/wow</property>
 						<value>0</value>
@@ -126,6 +83,7 @@
 			</condition>
 			<value>0.1</value>
 		</max-rate-of-change>
+		<max-rate-of-change>2</max-rate-of-change>
 	</filter>
 	
 	<filter>
@@ -250,28 +208,15 @@
 				</and>
 			</condition>
 		</enable>
-		<input>
-			<property>/instrumentation/airspeed-indicator/indicated-speed-kt</property>
-		</input>
-		<reference>
-			<property>/it-autoflight/internal/kts</property>
-		</reference>
-		<output>
-			<property>/controls/engines/throttle-cmd-pid</property>
-		</output>
+		<input>/instrumentation/airspeed-indicator/indicated-speed-kt</input>
+		<reference>/it-autoflight/internal/kts</reference>
+		<output>/controls/engines/throttle-cmd-pid</output>
 		<config>
 			<Kp>0.055</Kp>
-			<beta>1.0</beta>
-			<alpha>0.1</alpha>
-			<gamma>0.0</gamma>
 			<Ti>9.0</Ti>
 			<Td>0.00001</Td>
-			<u_min>
-				<property>/controls/engines/idle-limit</property>
-			</u_min>
-			<u_max>
-				<property>/controls/engines/throttle-pid-max</property>
-			</u_max>
+			<u_min>/controls/engines/idle-limit</u_min>
+			<u_max>/controls/engines/throttle-pid-max</u_max>
 		</config>
 	</pid-controller>
 	
@@ -390,22 +335,13 @@
 			<property>/it-autoflight/internal/mach</property>
 			<scale>1000.0</scale>
 		</reference>
-		<output>
-			<property>/controls/engines/throttle-cmd-pid</property>
-		</output>
+		<output>/controls/engines/throttle-cmd-pid</output>
 		<config>
 			<Kp>0.055</Kp>
-			<beta>1.0</beta>
-			<alpha>0.1</alpha>
-			<gamma>0.0</gamma>
 			<Ti>9.0</Ti>
 			<Td>0.00001</Td>
-			<u_min>
-				<property>/controls/engines/idle-limit</property>
-			</u_min>
-			<u_max>
-				<property>/controls/engines/throttle-pid-max</property>
-			</u_max>
+			<u_min>/controls/engines/idle-limit</u_min>
+			<u_max>/controls/engines/throttle-pid-max</u_max>
 		</config>
 	</pid-controller>
 	
@@ -512,12 +448,8 @@
 				</and>
 			</condition>
 		</enable>
-		<input>
-			<value>0.0</value>
-		</input>
-		<output>
-			<property>/controls/engines/throttle-cmd-pid</property>
-		</output>
+		<input>0.0</input>
+		<output>/controls/engines/throttle-cmd-pid</output>
 	</filter>
 	
 	<filter>
@@ -623,12 +555,8 @@
 				</and>
 			</condition>
 		</enable>
-		<input>
-			<value>1.0</value>
-		</input>
-		<output>
-			<property>/controls/engines/throttle-cmd-pid</property>
-		</output>
+		<input>1.0</input>
+		<output>/controls/engines/throttle-cmd-pid</output>
 	</filter>
 	
 	<filter>
@@ -725,12 +653,10 @@
 					</not-equals>
 				</and>
 			</condition>
-			<value>1</value>
+			<value>1.0</value>
 		</input>
-		<input>0</input>
-		<output>
-			<property>/controls/engines/throttle-cmd-pid</property>
-		</output>
+		<input>0.0</input>
+		<output>/controls/engines/throttle-cmd-pid</output>
 	</filter>
 
 </PropertyList>
diff --git a/revision.txt b/revision.txt
index cdc309eb..8eb54da3 100644
--- a/revision.txt
+++ b/revision.txt
@@ -1 +1 @@
-4678
\ No newline at end of file
+4679
\ No newline at end of file

From c56f351d907cb666db1e6be093acdaae91b0b986 Mon Sep 17 00:00:00 2001
From: Joshua Davidson <joshuadavidson2000@gmail.com>
Date: Fri, 19 Oct 2018 17:47:09 -0400
Subject: [PATCH 5/5] Control: Rework AP, fix lots of stuff

---
 Systems/fmgc-pitch.xml    | 10 ++++------
 Systems/fmgc-roll-yaw.xml | 14 +++++---------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/Systems/fmgc-pitch.xml b/Systems/fmgc-pitch.xml
index 117cb06c..e00c794e 100644
--- a/Systems/fmgc-pitch.xml
+++ b/Systems/fmgc-pitch.xml
@@ -9,10 +9,8 @@
 <!-- IT-AUTOFLIGHT -->
 
 <PropertyList>
-
- <!-- =============================================================== -->
- <!-- Vertical Modes                                                  -->
- <!-- =============================================================== -->
+	
+	<!-- Pitch Axis -->
 	
 	<filter>
 		<name>ALTITUDE CAPTURE/HOLD</name>
@@ -49,7 +47,7 @@
 		<min>/it-autoflight/internal/min-vs</min>
 		<max>/it-autoflight/internal/max-vs</max>
 	</filter>
-
+	
 	<pid-controller>
 		<name>FPA HOLD</name>
 		<debug>false</debug>
@@ -687,7 +685,7 @@
 		<min>-15</min>
 		<max>30</max>
 	</filter>
-
+	
 	<filter>
 		<name>System Command: Pitch Rate</name>
 		<debug>false</debug>
diff --git a/Systems/fmgc-roll-yaw.xml b/Systems/fmgc-roll-yaw.xml
index 78719d0b..4164e50e 100644
--- a/Systems/fmgc-roll-yaw.xml
+++ b/Systems/fmgc-roll-yaw.xml
@@ -9,11 +9,9 @@
 <!-- IT-AUTOFLIGHT -->
 
 <PropertyList>
-
- <!-- =============================================================== -->
- <!-- Lateral  Modes                                                  -->
- <!-- =============================================================== -->
-
+	
+	<!-- Roll Axis -->
+	
 	<pi-simple-controller>
 		<name>ROLL CONTROLLER: HDG/LNAV</name>
 		<debug>false</debug>
@@ -109,7 +107,7 @@
 			<max>/it-autoflight/internal/bank-limit</max>
 		</config>
 	</pi-simple-controller>
-
+	
 	<filter>
 		<name>ROLL DEG SYNC</name>
 		<debug>false</debug>
@@ -220,9 +218,7 @@
 		<max>0.32</max>
 	</filter>
 	
- <!-- =============================================================== -->
- <!-- Yaw Control                                                     -->
- <!-- =============================================================== -->
+	<!-- Yaw Axis -->
 	
 	<pi-simple-controller>
 		<name>RUDDER VORLOC TRK</name>