From f5f709bba76a9fac4a7c6dab3ec18255a7139328 Mon Sep 17 00:00:00 2001
From: Jonathan Redpath <legoboyvdlp@gmail.com>
Date: Sat, 10 Jun 2017 20:51:50 +0100
Subject: [PATCH] major updates

---
 AircraftConfig/acconfig.nas            |  1 -
 Models/Instruments/OHpanel/OHpanel.xml |  6 +++---
 Nasal/hydraulics.nas                   | 22 ++++++++++++++++++++++
 Nasal/pneumatics.nas                   | 12 +-----------
 Systems/libraries.xml                  |  6 ++++++
 5 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/AircraftConfig/acconfig.nas b/AircraftConfig/acconfig.nas
index 83d0e6ea..7b7d7027 100644
--- a/AircraftConfig/acconfig.nas
+++ b/AircraftConfig/acconfig.nas
@@ -98,7 +98,6 @@ var systemsReset = func {
 	systems.ADIRSreset();
 	systems.pneu_init();
 	systems.hyd_init();
-	systems.press_init();
 	systems.fuel_init();
 	fmgc.FMGCinit();
 	mcdu1.MCDU_reset();
diff --git a/Models/Instruments/OHpanel/OHpanel.xml b/Models/Instruments/OHpanel/OHpanel.xml
index 579778d2..522e07b0 100644
--- a/Models/Instruments/OHpanel/OHpanel.xml
+++ b/Models/Instruments/OHpanel/OHpanel.xml
@@ -3185,7 +3185,7 @@
 					</or>
 				</condition>
 				<command>property-toggle</command>
-				<property>/controls/pressurization/auto</property>
+				<property>/systems/pressurization/auto</property>
 			</binding>
 			<binding>
 				<command>nasal</command>
@@ -3217,7 +3217,7 @@
 		<condition>
 			<or>
 				<equals>
-					<property>/controls/pressurization/auto</property>
+					<property>/systems/pressurization/auto</property>
 					<value>0</value>
 				</equals>
 				<equals>
@@ -3230,7 +3230,7 @@
 	
 	<animation>
 		<type>pick</type>
-		<object-name>DitchBtn</object-name>
+		<object-name>DitchBtn1</object-name>
 		<object-name>DitchBtn2O</object-name>
 		<action>
 			<button>0</button>
diff --git a/Nasal/hydraulics.nas b/Nasal/hydraulics.nas
index 5968e386..8abd5b5c 100644
--- a/Nasal/hydraulics.nas
+++ b/Nasal/hydraulics.nas
@@ -18,6 +18,8 @@ var hyd_init = func {
 	setprop("/systems/hydraulic/blue-psi", 0);
 	setprop("/systems/hydraulic/green-psi", 0);
 	setprop("/systems/hydraulic/yellow-psi", 0);
+	setprop("/systems/hydraulic/spoiler3and4-inhibit", 0);
+	setprop("/systems/hydraulic/spoiler-inhibit", 0);
 	setprop("/controls/gear/brake-parking", 0);
 	hyd_timer.start();
 }
@@ -133,6 +135,26 @@ var master_hyd = func {
 			setprop("/systems/hydraulic/yellow-psi", 0);
 		}
 	}
+	
+	var lelev = getprop("/systems/failures/elevator-left");
+	var relev = getprop("/systems/failures/elevator-right");
+	var flap = getprop("/controls/flight/flap-txt");
+	var state1 = getprop("/systems/thrust/state1");
+	var state2 = getprop("/systems/thrust/state2");
+	var alpha = getprop("/systems/thrust/alpha-floor");
+	var sec1 = getprop("/systems/failures/sec1");
+	var sec3 = getprop("/systems/failures/sec3");
+	#var aoa_prot = getprop("aoaprotection);
+	if (lelev or relev) {
+		setprop("/systems/hydraulic/spoiler3and4-inhibit", 1);
+	} else {
+			setprop("/systems/hydraulic/spoiler3and4-inhibit", 0);
+	}
+	if ((flap == "FULL") or alpha or (sec1 and sec3) or (((state1 == "MCT") or (state1 == "TOGA")) and ((state2 == "MCT") or (state2 == "TOGA")))) {
+		setprop("/systems/hydraulic/spoiler-inhibit", 1);
+	} else {
+			setprop("/systems/hydraulic/spoiler-inhibit", 0);
+	}
 }
 
 #######################
diff --git a/Nasal/pneumatics.nas b/Nasal/pneumatics.nas
index cd4e96a9..ac5295d4 100644
--- a/Nasal/pneumatics.nas
+++ b/Nasal/pneumatics.nas
@@ -44,7 +44,7 @@ var pneu_init = func {
 	setprop("/systems/pressurization/targetalt", altitude); 
 	setprop("/systems/pressurization/diff-to-target", "0");
 	setprop("/systems/pressurization/ditchingpb", 0);
-	setprop("/systems/pressurization/targetvs", 0);
+	setprop("/systems/pressurization/targetvs", "0");
 	pneu_timer.start();
 }
 
@@ -188,16 +188,6 @@ var master_pneu = func {
 	
 	if (ditch and auto) {
 		setprop("/systems/pressurization/outflowpos", "1");
-	} 
-	
-	if ((targetvs => 0) and (targetvs < 1000) and !ditch) {
-		setprop("/systems/pressurization/outflowpos", "0.75");
-	} else if ((targetvs => 1000) and (targetvs < 1999) and !ditch) {
-		setprop("/systems/pressurization/outflowpos", "0.55");
-	} else if ((targetvs => 2000) and !ditch) {
-		setprop("/systems/pressurization/outflowpos", "0.25");
-	} else if ((targetvs < 0) and !ditch) {
-		setprop("/systems/pressurization/outflowpos", "1");
 	}
 }
 
diff --git a/Systems/libraries.xml b/Systems/libraries.xml
index bd21f060..d85879ca 100644
--- a/Systems/libraries.xml
+++ b/Systems/libraries.xml
@@ -231,10 +231,16 @@
         <update-interval-secs type="double">0.1</update-interval-secs>
         <input> 
 			<condition>
+				<or>
 				<equals>
 					<property>/gear/gear[1]/wow</property>
 					<value>1</value>
 				</equals>
+				<less-than>
+					<property>/systems/pressurization/targetalt-cmd</property>
+					<property>/systems/pressurization/cabinalt-norm</property>
+				</less-than>
+				</or>
 			</condition>
 			<property>/systems/pressurization/cabinalt-norm</property>
         </input>