From 8e63cdd6ab73cbe9fec295050d6e61d05f4fed8c Mon Sep 17 00:00:00 2001 From: Joshua Davidson Date: Thu, 5 Oct 2017 23:35:36 -0400 Subject: [PATCH] A3XX: Update charging logic --- A320-main.xml | 1 + Nasal/electrical.nas | 40 +++++++++++++++++++--------------------- Nasal/libraries.nas | 2 +- revision.txt | 2 +- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/A320-main.xml b/A320-main.xml index ee6b6ed0..0523a092 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -583,6 +583,7 @@ + 0 1 0 diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas index fde2729b..8e0bcacc 100644 --- a/Nasal/electrical.nas +++ b/Nasal/electrical.nas @@ -409,37 +409,35 @@ var master_elec = func { setprop("/systems/electrical/bus/dcbat", 0); } - if (battery1_volts > 27.9 or (dcbat == 0)) { - charge1.stop(); - } else if (batt1_fail) { - charge1.stop(); - } - - if (battery2_volts > 27.9 or (dcbat == 0)) { - charge2.stop(); - } else if (batt2_fail) { - charge2.stop(); - } - dc1 = getprop("/systems/electrical/bus/dc1"); dc2 = getprop("/systems/electrical/bus/dc2"); - if ((dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) { + if (battery1_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) { decharge1.stop(); charge1.start(); + } else if (battery1_volts == 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) { + charge1.stop(); + decharge1.stop(); + } else if (battery1_sw and !batt1_fail) { + charge1.stop(); + decharge1.start(); + } else { + decharge1.stop(); + charge1.stop(); } - if ((dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) { + if (battery2_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) { decharge2.stop(); charge2.start(); - } - - if ((dcbat == 0) and battery1_sw and !batt1_fail) { - decharge1.start(); - } - - if ((dcbat == 0) and battery2_sw and !batt2_fail) { + } else if (battery2_volts == 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) { + charge2.stop(); + decharge2.stop(); + } else if (battery2_sw and !batt2_fail) { + charge2.stop(); decharge2.start(); + } else { + decharge2.stop(); + charge2.stop(); } if (getprop("/systems/electrical/bus/ac-ess") < 110) { diff --git a/Nasal/libraries.nas b/Nasal/libraries.nas index 779872a4..bafc6e5c 100644 --- a/Nasal/libraries.nas +++ b/Nasal/libraries.nas @@ -225,7 +225,7 @@ setlistener("/sim/signals/fdm-initialized", func { }); var librariesLoop = maketimer(0.1, func { - if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/switches/cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or getprop("controls/gear/brake-parking") == 0)) { + if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/switches/cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or getprop("/controls/gear/brake-parking") == 0)) { setprop("/controls/switches/cart", 0); setprop("/controls/pneumatic/switches/groundair", 0); } diff --git a/revision.txt b/revision.txt index de4f119c..f55a6f7c 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -2106 \ No newline at end of file +2107 \ No newline at end of file