From 56ac2228576d3478cc1dccdbe2110fb44a9bc11c Mon Sep 17 00:00:00 2001 From: Joshua Davidson <joshuadavidson2000@gmail.com> Date: Wed, 16 May 2018 20:20:46 -0400 Subject: [PATCH 1/5] System: something --- Nasal/electrical.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas index a1970f7d..f67facf9 100644 --- a/Nasal/electrical.nas +++ b/Nasal/electrical.nas @@ -410,7 +410,7 @@ var ELEC = { setprop("/systems/electrical/bus/dc1", 0); setprop("/systems/electrical/bus/dc-ess", dc_volt_std); setprop("/systems/electrical/extra/tr1-volts", 0); - setprop("/systems/electrical/bus/dc1-amps", 0); + setprop("/systems/electrical/bus/dc1-amps", 0); setprop("/systems/electrical/extra/tr1-amps", 0); } else { setprop("/systems/electrical/bus/dc1", 0); From ecb240de3d9270c0f484b6cc31d21ad6aa512cd1 Mon Sep 17 00:00:00 2001 From: Joshua Davidson <joshuadavidson2000@gmail.com> Date: Wed, 16 May 2018 20:22:33 -0400 Subject: [PATCH 2/5] System: something --- Nasal/electrical.nas | 2 -- 1 file changed, 2 deletions(-) diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas index f67facf9..9b72fe23 100644 --- a/Nasal/electrical.nas +++ b/Nasal/electrical.nas @@ -428,13 +428,11 @@ var ELEC = { setprop("/systems/electrical/extra/tr2-amps", tr_amps_std); } else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) { setprop("/systems/electrical/bus/dc2", dc_volt_std); - setprop("/systems/electrical/extra/tr2-volts", dc_volt_std); setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); setprop("/systems/electrical/extra/tr2-amps", tr_amps_std); } else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) { setprop("/systems/electrical/bus/dc2", dc_volt_std); - setprop("/systems/electrical/extra/tr2-volts", dc_volt_std); setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); setprop("/systems/electrical/extra/tr2-amps", tr_amps_std); From 7862ae1b89c7ddc23d692dd1284ee92f2da473d5 Mon Sep 17 00:00:00 2001 From: Joshua Davidson <joshuadavidson2000@gmail.com> Date: Wed, 16 May 2018 20:24:36 -0400 Subject: [PATCH 3/5] System: something --- Nasal/electrical.nas | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas index 9b72fe23..7e23db08 100644 --- a/Nasal/electrical.nas +++ b/Nasal/electrical.nas @@ -380,31 +380,31 @@ var ELEC = { setprop("/systems/electrical/bus/dc1", dc_volt_std); setprop("/systems/electrical/bus/dc-ess", dc_volt_std); setprop("/systems/electrical/extra/tr1-volts", dc_volt_std); - setprop("/systems/electrical/bus/dc1-amps", dc_amps_std); + setprop("/systems/electrical/bus/dc1-amps", dc_amps_std); setprop("/systems/electrical/extra/tr1-amps", tr_amps_std); } else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) { setprop("/systems/electrical/bus/dc1", dc_volt_std); setprop("/systems/electrical/bus/dc-ess", dc_volt_std); setprop("/systems/electrical/extra/tr1-volts", dc_volt_std); - setprop("/systems/electrical/bus/dc1-amps", dc_amps_std); + setprop("/systems/electrical/bus/dc1-amps", dc_amps_std); setprop("/systems/electrical/extra/tr1-amps", tr_amps_std); } else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) { setprop("/systems/electrical/bus/dc1", dc_volt_std); setprop("/systems/electrical/bus/dc-ess", dc_volt_std); setprop("/systems/electrical/extra/tr1-volts", dc_volt_std); - setprop("/systems/electrical/bus/dc1-amps", dc_amps_std); + setprop("/systems/electrical/bus/dc1-amps", dc_amps_std); setprop("/systems/electrical/extra/tr1-amps", tr_amps_std); } else if (apu_ext_crosstie_sw == 1 and xtieL) { setprop("/systems/electrical/bus/dc1", dc_volt_std); setprop("/systems/electrical/bus/dc-ess", dc_volt_std); setprop("/systems/electrical/extra/tr1-volts", dc_volt_std); - setprop("/systems/electrical/bus/dc1-amps", dc_amps_std); + setprop("/systems/electrical/bus/dc1-amps", dc_amps_std); setprop("/systems/electrical/extra/tr1-amps", tr_amps_std); } else if (emergen) { setprop("/systems/electrical/bus/dc1", 0); setprop("/systems/electrical/bus/dc-ess", dc_volt_std); setprop("/systems/electrical/extra/tr1-volts", 0); - setprop("/systems/electrical/bus/dc1-amps", 0); + setprop("/systems/electrical/bus/dc1-amps", 0); setprop("/systems/electrical/extra/tr1-amps", 0); } else if (dcbat and ias >= 50) { setprop("/systems/electrical/bus/dc1", 0); @@ -415,8 +415,8 @@ var ELEC = { } else { setprop("/systems/electrical/bus/dc1", 0); setprop("/systems/electrical/extra/tr1-volts", 0); - setprop("/systems/electrical/bus/dc1-amps", 0); - setprop("/systems/electrical/extra/tr1-amps", 0); + setprop("/systems/electrical/bus/dc1-amps", 0); + setprop("/systems/electrical/extra/tr1-amps", 0); setprop("/systems/electrical/bus/dc-ess", 0); } @@ -424,37 +424,37 @@ var ELEC = { if (stateR == 3 and gen2_sw and !gen2_fail) { setprop("/systems/electrical/bus/dc2", dc_volt_std); setprop("/systems/electrical/extra/tr2-volts", dc_volt_std); - setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); + setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); setprop("/systems/electrical/extra/tr2-amps", tr_amps_std); } else if (extpwr_on and gen_ext_sw and apu_ext_crosstie_sw) { setprop("/systems/electrical/bus/dc2", dc_volt_std); setprop("/systems/electrical/extra/tr2-volts", dc_volt_std); - setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); + setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); setprop("/systems/electrical/extra/tr2-amps", tr_amps_std); } else if (gen_apu and !genapu_fail and apu_ext_crosstie_sw) { setprop("/systems/electrical/bus/dc2", dc_volt_std); setprop("/systems/electrical/extra/tr2-volts", dc_volt_std); - setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); + setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); setprop("/systems/electrical/extra/tr2-amps", tr_amps_std); } else if (apu_ext_crosstie_sw == 1 and xtieR) { setprop("/systems/electrical/bus/dc2", dc_volt_std); setprop("/systems/electrical/extra/tr2-volts", dc_volt_std); - setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); + setprop("/systems/electrical/bus/dc2-amps", dc_amps_std); setprop("/systems/electrical/extra/tr2-amps", tr_amps_std); } else if (emergen) { setprop("/systems/electrical/bus/dc2", 0); setprop("/systems/electrical/extra/tr2-volts", 0); - setprop("/systems/electrical/bus/dc2-amps", 0); + setprop("/systems/electrical/bus/dc2-amps", 0); setprop("/systems/electrical/extra/tr2-amps", 0); } else if (dcbat and ias >= 50) { setprop("/systems/electrical/bus/dc2", 0); setprop("/systems/electrical/extra/tr2-volts", 0); - setprop("/systems/electrical/bus/dc2-amps", 0); + setprop("/systems/electrical/bus/dc2-amps", 0); setprop("/systems/electrical/extra/tr2-amps", 0); } else { setprop("/systems/electrical/bus/dc2", 0); setprop("/systems/electrical/extra/tr2-volts", 0); - setprop("/systems/electrical/bus/dc2-amps", 0); + setprop("/systems/electrical/bus/dc2-amps", 0); setprop("/systems/electrical/extra/tr2-amps", 0); } @@ -576,9 +576,9 @@ var ELEC = { } if (!gen_apu and !gen_ext_sw and (!gen1_sw or !gen2_sw)) { - setprop("/systems/electrical/extra/galleyshed", 1); + setprop("/systems/electrical/extra/galleyshed", 1); } else { - setprop("/systems/electrical/extra/galleyshed", 0); + setprop("/systems/electrical/extra/galleyshed", 0); } if (((ac1 == 0 and ac2 == 0 and ias >= 100) or manrat) and replay == 0) { @@ -602,12 +602,12 @@ var ELEC = { if (battery1_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) { if (getprop("/systems/electrical/battery1-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery1-volts", battery1_volts + 0.02877666); # Roughly 15mins to 25.9 + setprop("/systems/electrical/battery1-volts", battery1_volts + 0.02877666);# Roughly 15mins to 25.9 setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec")); } } else if (battery1_sw and !batt1_fail) { if (getprop("/systems/electrical/battery1-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery1-volts", battery1_volts - 0.01438833); # Roughly 30mins from 25.9 + setprop("/systems/electrical/battery1-volts", battery1_volts - 0.01438833);# Roughly 30mins from 25.9 setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec")); } } else { @@ -616,12 +616,12 @@ var ELEC = { if (battery2_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) { if (getprop("/systems/electrical/battery2-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery2-volts", battery2_volts + 0.02877666); # Roughly 15mins to 25.9 + setprop("/systems/electrical/battery2-volts", battery2_volts + 0.02877666);# Roughly 15mins to 25.9 setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec")); } } else if (battery2_sw and !batt2_fail) { if (getprop("/systems/electrical/battery2-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery2-volts", battery2_volts - 0.01438833); # Roughly 30mins from 25.9 + setprop("/systems/electrical/battery2-volts", battery2_volts - 0.01438833);# Roughly 30mins from 25.9 setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec")); } } else { @@ -762,7 +762,7 @@ var ELEC = { setprop("/controls/ventilation/blowFail", 0); } - foreach(var screena; screens) { + foreach(var screena;screens) { power_consumption = screena.power_consumption(); if (getprop(screena.elec_prop) != 0) { setprop("/systems/electrical/DU/" ~ screena.name ~ "/watts", power_consumption); @@ -771,7 +771,7 @@ var ELEC = { } } - foreach(var lighta; lights) { + foreach(var lighta;lights) { power_consumption = lighta.power_consumption(); if (getprop(lighta.elec_prop) != 0 and getprop(lighta.control_prop) != 0) { setprop("/systems/electrical/light/" ~ lighta.name ~ "/watts", power_consumption); From 62af7daa67d8d1fb89fc158ed41b7d449b399c13 Mon Sep 17 00:00:00 2001 From: Joshua Davidson <joshuadavidson2000@gmail.com> Date: Wed, 16 May 2018 23:18:19 -0400 Subject: [PATCH 4/5] Systems: Some electrical fixes --- Nasal/electrical.nas | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas index 7e23db08..63f85e0b 100644 --- a/Nasal/electrical.nas +++ b/Nasal/electrical.nas @@ -36,6 +36,8 @@ setlistener("/sim/signals/fdm-initialized", func { var battery2_sw = getprop("/controls/electrical/switches/battery2"); var battery1_volts = getprop("/systems/electrical/battery1-volts"); var battery2_volts = getprop("/systems/electrical/battery2-volts"); + var battery1_amps = getprop("/systems/electrical/battery1-amps"); + var battery2_amps = getprop("/systems/electrical/battery2-amps"); var rpmapu = getprop("/systems/apu/rpm"); var extpwr_on = getprop("/controls/switches/cart"); var stateL = getprop("/engines/engine[0]/state"); @@ -304,19 +306,22 @@ var ELEC = { replay = getprop("/sim/replay/replay-state"); wow = getprop("/gear/gear[1]/wow"); - if (battery1_sw and !batt1_fail) { + if (battery1_volts >= 20 and battery1_sw and !batt1_fail) { setprop("/systems/electrical/battery1-amps", dc_amps_std); } else { setprop("/systems/electrical/battery1-amps", 0); } - if (battery2_sw and !batt2_fail) { + if (battery2_volts >= 20 and battery2_sw and !batt2_fail) { setprop("/systems/electrical/battery2-amps", dc_amps_std); } else { setprop("/systems/electrical/battery2-amps", 0); } - if (getprop("/systems/electrical/battery1-amps") > 120 or getprop("/systems/electrical/battery2-amps") > 120) { + battery1_amps = getprop("/systems/electrical/battery1-amps"); + battery2_amps = getprop("/systems/electrical/battery2-amps"); + + if (battery1_amps > 120 or battery2_amps > 120) { setprop("/systems/electrical/bus/dcbat", dc_volt_std); } else { setprop("/systems/electrical/bus/dcbat", 0); @@ -602,12 +607,12 @@ var ELEC = { if (battery1_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) { if (getprop("/systems/electrical/battery1-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery1-volts", battery1_volts + 0.02877666);# Roughly 15mins to 25.9 + setprop("/systems/electrical/battery1-volts", battery1_volts + 0.02877666); # Roughly 15mins to 25.9 setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec")); } } else if (battery1_sw and !batt1_fail) { if (getprop("/systems/electrical/battery1-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery1-volts", battery1_volts - 0.01438833);# Roughly 30mins from 25.9 + setprop("/systems/electrical/battery1-volts", battery1_volts - 0.01438833); # Roughly 30mins from 25.9 setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec")); } } else { @@ -616,12 +621,12 @@ var ELEC = { if (battery2_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) { if (getprop("/systems/electrical/battery2-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery2-volts", battery2_volts + 0.02877666);# Roughly 15mins to 25.9 + setprop("/systems/electrical/battery2-volts", battery2_volts + 0.02877666); # Roughly 15mins to 25.9 setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec")); } } else if (battery2_sw and !batt2_fail) { if (getprop("/systems/electrical/battery2-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery2-volts", battery2_volts - 0.01438833);# Roughly 30mins from 25.9 + setprop("/systems/electrical/battery2-volts", battery2_volts - 0.01438833); # Roughly 30mins from 25.9 setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec")); } } else { From 0c3aa121fa730f2939250afea9528c79d8cafbf4 Mon Sep 17 00:00:00 2001 From: Joshua Davidson <joshuadavidson2000@gmail.com> Date: Thu, 17 May 2018 00:17:20 -0400 Subject: [PATCH 5/5] Systems: Overhaul Battery Charging logic (again) --- Nasal/electrical.nas | 64 +++++++++++++++++++++++++++++++++++--------- revision.txt | 2 +- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/Nasal/electrical.nas b/Nasal/electrical.nas index 63f85e0b..8660a1f1 100644 --- a/Nasal/electrical.nas +++ b/Nasal/electrical.nas @@ -1,6 +1,5 @@ # A3XX Electrical System # Joshua Davidson (it0uchpods) and Jonathan Redpath (legoboyvdlp) -# Some parts are in JSBsim system! ############################################## # Copyright (c) Joshua Davidson (it0uchpods) # @@ -38,6 +37,10 @@ setlistener("/sim/signals/fdm-initialized", func { var battery2_volts = getprop("/systems/electrical/battery2-volts"); var battery1_amps = getprop("/systems/electrical/battery1-amps"); var battery2_amps = getprop("/systems/electrical/battery2-amps"); + var battery1_percent = getprop("/systems/electrical/battery1-percent"); + var battery2_percent = getprop("/systems/electrical/battery2-percent"); + var battery1_percent_calc = 0; + var battery2_percent_calc = 0; var rpmapu = getprop("/systems/apu/rpm"); var extpwr_on = getprop("/controls/switches/cart"); var stateL = getprop("/engines/engine[0]/state"); @@ -158,6 +161,8 @@ var ELEC = { setprop("/systems/electrical/battery2-volts", 26.5); setprop("/systems/electrical/battery1-amps", 0); setprop("/systems/electrical/battery2-amps", 0); + setprop("/systems/electrical/battery1-percent", 68); + setprop("/systems/electrical/battery2-percent", 68); setprop("/systems/electrical/bus/dc1", 0); setprop("/systems/electrical/bus/dc2", 0); setprop("/systems/electrical/bus/dcbat", 0); @@ -276,6 +281,8 @@ var ELEC = { battery2_sw = getprop("/controls/electrical/switches/battery2"); battery1_volts = getprop("/systems/electrical/battery1-volts"); battery2_volts = getprop("/systems/electrical/battery2-volts"); + battery1_percent = getprop("/systems/electrical/battery1-percent"); + battery2_percent = getprop("/systems/electrical/battery2-percent"); rpmapu = getprop("/systems/apu/rpm"); extpwr_on = getprop("/controls/switches/cart"); stateL = getprop("/engines/engine[0]/state"); @@ -605,34 +612,65 @@ var ELEC = { dc1 = getprop("/systems/electrical/bus/dc1"); dc2 = getprop("/systems/electrical/bus/dc2"); - if (battery1_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) { - if (getprop("/systems/electrical/battery1-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery1-volts", battery1_volts + 0.02877666); # Roughly 15mins to 25.9 + if (battery1_percent < 100 and (dc1 > 25 or dc2 > 25) and battery1_sw and !batt1_fail) { + if (getprop("/systems/electrical/battery1-time") + 30 < getprop("/sim/time/elapsed-sec")) { + battery1_percent_calc = battery1_percent + 4.5; # Roughly 90 percent every 10 mins + if (battery1_percent_calc > 100) { + battery1_percent_calc = 100; + } + setprop("/systems/electrical/battery1-percent", battery1_percent_calc); setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec")); } - } else if (battery1_sw and !batt1_fail) { - if (getprop("/systems/electrical/battery1-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery1-volts", battery1_volts - 0.01438833); # Roughly 30mins from 25.9 + } else if (battery1_amps >= 120 and battery1_sw and !batt1_fail) { + if (getprop("/systems/electrical/battery1-time") + 30 < getprop("/sim/time/elapsed-sec")) { + battery1_percent_calc = battery1_percent - 1.5; # Roughly 90 percent every 30 mins + if (battery1_percent_calc < 0) { + battery1_percent_calc = 0; + } + setprop("/systems/electrical/battery1-percent", battery1_percent_calc); setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec")); } } else { setprop("/systems/electrical/battery1-time", getprop("/sim/time/elapsed-sec")); } - if (battery2_volts < 27.9 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) { - if (getprop("/systems/electrical/battery2-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery2-volts", battery2_volts + 0.02877666); # Roughly 15mins to 25.9 + if (battery1_percent < 100 and (dc1 > 25 or dc2 > 25) and battery2_sw and !batt2_fail) { + if (getprop("/systems/electrical/battery2-time") + 30 < getprop("/sim/time/elapsed-sec")) { + battery2_percent_calc = battery2_percent + 4.5; # Roughly 90 percent every 10 mins + if (battery2_percent_calc > 100) { + battery2_percent_calc = 100; + } + setprop("/systems/electrical/battery2-percent", battery2_percent_calc); setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec")); } - } else if (battery2_sw and !batt2_fail) { - if (getprop("/systems/electrical/battery2-time") + 60 < getprop("/sim/time/elapsed-sec")) { - setprop("/systems/electrical/battery2-volts", battery2_volts - 0.01438833); # Roughly 30mins from 25.9 + } else if (battery2_amps >= 120 and battery2_sw and !batt2_fail) { + if (getprop("/systems/electrical/battery2-time") + 30 < getprop("/sim/time/elapsed-sec")) { + battery2_percent_calc = battery2_percent - 1.5; # Roughly 90 percent every 30 mins + if (battery2_percent_calc < 0) { + battery2_percent_calc = 0; + } + setprop("/systems/electrical/battery2-percent", battery2_percent_calc); setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec")); } } else { setprop("/systems/electrical/battery2-time", getprop("/sim/time/elapsed-sec")); } + battery1_percent = getprop("/systems/electrical/battery1-percent"); + battery2_percent = getprop("/systems/electrical/battery2-percent"); + + if (battery1_percent >= 10) { + setprop("/systems/electrical/battery1-volts", math.clamp(24 + (battery1_percent - 10) * (27.9 - 24) / (100 - 10), 24, 27.9)); + } else { + setprop("/systems/electrical/battery1-volts", math.clamp(battery1_percent * (24) / (10), 0, 24)); + } + + if (battery2_percent >= 10) { + setprop("/systems/electrical/battery2-volts", math.clamp(24 + (battery2_percent - 10) * (27.9 - 24) / (100 - 10), 24, 30)); + } else { + setprop("/systems/electrical/battery2-volts", math.clamp(battery2_percent * (24) / (10), 0, 24)); + } + if (getprop("/systems/electrical/bus/ac-ess") < 110) { if (getprop("/it-autoflight/output/ap1") == 1) { setprop("/it-autoflight/input/ap1", 0); diff --git a/revision.txt b/revision.txt index e102aea8..fd09341e 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -4410 \ No newline at end of file +4411 \ No newline at end of file