diff --git a/A320-main.xml b/A320-main.xml
index 79c9e982..3427949b 100644
--- a/A320-main.xml
+++ b/A320-main.xml
@@ -4209,7 +4209,6 @@
Aircraft/A320-family/Nasal/Systems/ADIRS/ADR.nas
Aircraft/A320-family/Nasal/Panels/SwitchingPanel.nas
Aircraft/A320-family/Nasal/Systems/Comm/HF.nas
- Aircraft/A320-family/Nasal/Systems/brakes.nas
Aircraft/A320-family/Nasal/Systems/brakesystem.nas
Aircraft/A320-family/Nasal/Systems/fire.nas
Aircraft/A320-family/Nasal/Systems/ground_services.nas
diff --git a/AircraftConfig/acconfig.nas b/AircraftConfig/acconfig.nas
index 1699b07e..b52e10f4 100644
--- a/AircraftConfig/acconfig.nas
+++ b/AircraftConfig/acconfig.nas
@@ -519,7 +519,7 @@ var takeoff = func {
setprop("/controls/atc/mode-knob", 4);
atc.transponderPanel.modeSwitch(5);
setprop("/controls/flight/elevator-trim", -0.07);
- systems.arm_autobrake(3);
+ systems.Autobrake.arm_autobrake(3);
setprop("/ECAM/to-config-test", 1);
settimer(func {
setprop("/ECAM/to-config-test", 0);
diff --git a/Models/FlightDeck/a320.flightdeck.xml b/Models/FlightDeck/a320.flightdeck.xml
index 59d09c5a..afc59808 100644
--- a/Models/FlightDeck/a320.flightdeck.xml
+++ b/Models/FlightDeck/a320.flightdeck.xml
@@ -1630,10 +1630,10 @@
nasal
@@ -1657,10 +1657,10 @@
nasal
@@ -1684,10 +1684,10 @@
nasal
@@ -6243,7 +6243,7 @@
rotate
LRudderPedalL
LRudderPedalR
- controls/gear/brake-left
+ /fdm/jsbsim/fcs/brake-left
15
0
@@ -6261,7 +6261,7 @@
rotate
RRudderPedalL
RRudderPedalR
- controls/gear/brake-right
+ /fdm/jsbsim/fcs/brake-right
15
0
diff --git a/Nasal/Libraries/libraries.nas b/Nasal/Libraries/libraries.nas
index 6295262c..8537af9b 100644
--- a/Nasal/Libraries/libraries.nas
+++ b/Nasal/Libraries/libraries.nas
@@ -188,7 +188,7 @@ var systemsInit = func {
systems.ADIRS.init();
systems.eng_init();
systems.APUController.init();
- systems.autobrake_init();
+ systems.Autobrake.init();
systems.fire_init();
fmgc.flightPlanController.reset();
fmgc.windController.reset();
diff --git a/Nasal/Libraries/property-tree-setup.nas b/Nasal/Libraries/property-tree-setup.nas
index 7101d0ff..b451be5d 100644
--- a/Nasal/Libraries/property-tree-setup.nas
+++ b/Nasal/Libraries/property-tree-setup.nas
@@ -4,6 +4,10 @@
# Anything that says Temp is set by another file to avoid multiple getValue calls
# Usage Example: pts.Class.SubClass.node.getValue()
+var Acconfig = {
+ running: props.globals.getNode("/systems/acconfig/autoconfig-running"),
+};
+
var APU = {
masterSw: props.globals.getNode("/controls/apu/master"),
rpm: props.globals.getNode("/engines/engine[2]/n1"),
@@ -37,6 +41,7 @@ var Controls = {
rudderTrim: props.globals.getNode("/controls/flight/rudder-trim"),
},
Gear: {
+ brake: [props.globals.getNode("/controls/gear/brake-left"),props.globals.getNode("/controls/gear/brake-right")],
gearDown: props.globals.getNode("/controls/gear/gear-down"),
parkingBrake: props.globals.getNode("/controls/gear/brake-parking"),
},
diff --git a/Nasal/Systems/brakes.nas b/Nasal/Systems/brakes.nas
deleted file mode 100644
index 0e9f767d..00000000
--- a/Nasal/Systems/brakes.nas
+++ /dev/null
@@ -1,80 +0,0 @@
-# A3XX Autobrake
-# Joshua Davidson (Octal450)
-
-# Copyright (c) 2020 Josh Davidson (Octal450)
-
-var thr1 = 0;
-var thr2 = 0;
-var wow0 = 0;
-var gnd_speed = 0;
-setprop("controls/autobrake/active", 0);
-setprop("controls/autobrake/mode", 0);
-setprop("controls/autobrake/decel-rate", 0);
-
-var autobrake_init = func {
- setprop("controls/autobrake/active", 0);
- setprop("controls/autobrake/mode", 0);
-}
-
-# Override FG's generic brake
-controls.applyBrakes = func(v, which = 0) {
- if (getprop("systems/acconfig/autoconfig-running") != 1) {
- if (which <= 0) {
- interpolate("/controls/gear/brake-left", v, 0.5);
- }
- if (which >= 0) {
- interpolate("/controls/gear/brake-right", v, 0.5);
- }
- }
-}
-
-# Set autobrake mode
-var arm_autobrake = func(mode) {
- wow0 = getprop("gear/gear[0]/wow");
- gnd_speed = getprop("velocities/groundspeed-kt");
- if (mode == 0) { # OFF
- absChk.stop();
- if (getprop("controls/autobrake/active") == 1) {
- setprop("controls/autobrake/active", 0);
- setprop("controls/gear/brake-left", 0);
- setprop("controls/gear/brake-right", 0);
- }
- setprop("controls/autobrake/decel-rate", 0);
- setprop("controls/autobrake/mode", 0);
- } else if (mode == 1 and wow0 != 1) { # LO
- setprop("controls/autobrake/decel-rate", 1.7);
- setprop("controls/autobrake/mode", 1);
- absChk.start();
- } else if (mode == 2 and wow0 != 1) { # MED
- setprop("controls/autobrake/decel-rate", 3);
- setprop("controls/autobrake/mode", 2);
- absChk.start();
- } else if (mode == 3 and wow0 == 1 and gnd_speed < 40) { # MAX
- setprop("controls/autobrake/decel-rate", 6);
- setprop("controls/autobrake/mode", 3);
- absChk.start();
- }
-}
-
-# Autobrake loop
-var absChk = maketimer(0.2, func {
- thr1 = getprop("controls/engines/engine[0]/throttle");
- thr2 = getprop("controls/engines/engine[1]/throttle");
- wow0 = getprop("gear/gear[0]/wow");
- gnd_speed = getprop("velocities/groundspeed-kt");
- if (gnd_speed > 72) {
- if (getprop("controls/autobrake/mode") != 0 and thr1 < 0.15 and thr2 < 0.15 and wow0 == 1) {
- setprop("controls/autobrake/active", 1);
- } else {
- setprop("controls/autobrake/active", 0);
- setprop("controls/gear/brake-left", 0);
- setprop("controls/gear/brake-right", 0);
- }
- }
- if (getprop("controls/autobrake/mode") == 3 and getprop("controls/gear/gear-down") == 0) {
- arm_autobrake(0);
- }
- if (getprop("controls/autobrake/mode") != 0 and wow0 == 1 and getprop("controls/autobrake/active") == 1 and (getprop("controls/gear/brake-left") > 0.05 or getprop("controls/gear/brake-right") > 0.05)) {
- arm_autobrake(0);
- }
-});
diff --git a/Nasal/Systems/brakesystem.nas b/Nasal/Systems/brakesystem.nas
index 0e70979b..344436ca 100755
--- a/Nasal/Systems/brakesystem.nas
+++ b/Nasal/Systems/brakesystem.nas
@@ -1,3 +1,9 @@
+# A3XX Autobrake and Braking
+# Joshua Davidson (Octal450)
+
+# Copyright (c) 2020 Josh Davidson (Octal450)
+
+
##########################################################################
# Simple Brake Simulation System
# 2010, Thorsten Brehm
@@ -63,7 +69,7 @@ var BrakeSystem =
setprop("gear/gear[1]/Lbrake-thermal-energy",0.0);
setprop("gear/gear[2]/Rbrake-thermal-energy",0.0);
- setprop("controls/gear/brake-fans",0);
+ setprop("/controls/gear/brake-fans",0);
setprop("gear/gear[1]/Lbrake-smoke",0);
setprop("gear/gear[2]/Rbrake-smoke",0);
setprop("gear/gear[1]/L-Thrust",0);
@@ -80,21 +86,21 @@ var BrakeSystem =
var tatdegc = getprop("/systems/navigation/probes/tat-1/compute-tat") or 0;
var atemp = getprop("environment/temperature-degc") or 0;
var vmach = getprop("velocities/mach") or 0;
- var tatdegc = getprop("systems/navigation/probes/tat-1/compute-tat");
+ var tatdegc = getprop("/systems/navigation/probes/tat-1/compute-tat");
setprop("gear/gear[1]/L1brake-temp-degc",tatdegc+getprop("gear/gear[1]/L1error-temp-degc"));
setprop("gear/gear[1]/L2brake-temp-degc",tatdegc+getprop("gear/gear[1]/L2error-temp-degc"));
setprop("gear/gear[2]/R3brake-temp-degc",tatdegc+getprop("gear/gear[2]/R3error-temp-degc"));
setprop("gear/gear[2]/R4brake-temp-degc",tatdegc+getprop("gear/gear[2]/R4error-temp-degc"));
- setprop("sim/animation/fire-services",0);
+ setprop("/sim/animation/fire-services",0);
me.LastSimTime = 0.0;
},
# update brake energy
update : func()
{
- var CurrentTime = getprop("sim/time/elapsed-sec");
+ var CurrentTime = getprop("/sim/time/elapsed-sec");
var dt = CurrentTime - me.LastSimTime;
var LThermalEnergy = getprop("gear/gear[1]/Lbrake-thermal-energy");
var RThermalEnergy = getprop("gear/gear[2]/Rbrake-thermal-energy");
@@ -107,12 +113,12 @@ var BrakeSystem =
var L_thrust_lb = getprop("engines/engine[0]/thrust_lb");
var R_thrust_lb = getprop("engines/engine[1]/thrust_lb");
- if (getprop("sim/freeze/replay-state")==0 and dt<1.0) {
+ if (getprop("/sim/freeze/replay-state")==0 and dt<1.0) {
var OnGround = getprop("gear/gear[1]/wow");
#cooling effect: adjust cooling factor by a value proportional to the environment temp (m.CoolingFactor + environment temp-degc * 0.00001)
var LCoolingRatio = me.CoolingFactor+(tatdegc*0.000001);
var RCoolingRatio = me.CoolingFactor+(tatdegc*0.000001);
- if (getprop("controls/gear/brake-fans")) {
+ if (getprop("/controls/gear/brake-fans")) {
#increase CoolingRatio if Brake Fans are active
LCoolingRatio = LCoolingRatio * 3;
RCoolingRatio = RCoolingRatio * 3;
@@ -169,8 +175,8 @@ var BrakeSystem =
var V2_R = V1 - me.BrakeDecel * dt * RBrakeLevel;
LThermalEnergy += (Mass * getprop("gear/gear[1]/compression-norm") * (math.pow(V1, 2) - math.pow(V2_L, 2)) / 2);
- if (getprop("services/chocks/enable")) {
- if (!getprop("controls/gear/brake-parking")) {
+ if (getprop("/services/chocks/enable")) {
+ if (!getprop("/controls/gear/brake-parking")) {
# cooling effect: reduce thermal energy by (LnCoolFactor) * dt
LThermalEnergy = LThermalEnergy * math.exp(LnCoolFactor * dt);
} else {
@@ -179,7 +185,7 @@ var BrakeSystem =
LThermalEnergy = (LThermalEnergy * math.exp(LnCoolFactor * dt)) + (L_Thrust * dt);
};
} else {
- if (!getprop("controls/gear/brake-parking")) {
+ if (!getprop("/controls/gear/brake-parking")) {
if (LBrakeLevel>0) {
if (V2_L>0) {
#LThermalEnergy += (Mass * (math.pow(V1, 2) - math.pow(V2_L, 2)) / 2) + L_thrust;
@@ -202,8 +208,8 @@ var BrakeSystem =
};
RThermalEnergy += (Mass * getprop("gear/gear[2]/compression-norm") * (math.pow(V1, 2) - math.pow(V2_R, 2)) / 2);
- if (getprop("services/chocks/enable")) {
- if (!getprop("controls/gear/brake-parking")) {
+ if (getprop("/services/chocks/enable")) {
+ if (!getprop("/controls/gear/brake-parking")) {
# cooling effect: reduce thermal energy by (RnCoolFactor) * dt
RThermalEnergy = RThermalEnergy * math.exp(RnCoolFactor * dt);
} else {
@@ -212,7 +218,7 @@ var BrakeSystem =
RThermalEnergy = (RThermalEnergy * math.exp(RnCoolFactor * dt)) + (R_Thrust * dt);
};
} else {
- if (!getprop("controls/gear/brake-parking")) {
+ if (!getprop("/controls/gear/brake-parking")) {
if (RBrakeLevel>0) {
if (V2_R>0) {
#RThermalEnergy += (Mass * (math.pow(V1, 2) - math.pow(V2_R, 2)) / 2) + R_thrust;
@@ -304,13 +310,13 @@ var BrakeSystem =
} else {
# stop smoke processing
setprop("gear/gear[1]/Lbrake-smoke",0);
- setprop("sim/animation/fire-services",0);
+ setprop("/sim/animation/fire-services",0);
me.LSmokeActive = 0;
};
if (getprop("gear/gear[1]/Lbrake-thermal-energy") > 1.5) {
- setprop("sim/animation/fire-services",1);
+ setprop("/sim/animation/fire-services",1);
} else {
- setprop("sim/animation/fire-services",0);
+ setprop("/sim/animation/fire-services",0);
};
},
@@ -344,21 +350,102 @@ var BrakeSystem =
me.RSmokeActive = 0;
};
if (getprop("gear/gear[2]/Rbrake-thermal-energy") > 1.5) {
- setprop("sim/animation/fire-services",1);
+ setprop("/sim/animation/fire-services",1);
} else {
- setprop("sim/animation/fire-services",0);
+ setprop("/sim/animation/fire-services",0);
};
},
};
var BrakeSys = BrakeSystem.new();
-setlistener("sim/signals/fdm-initialized",
+#############
+# Autobrake #
+#############
+
+var Autobrake = {
+ active: props.globals.initNode("/controls/autobrake/active", 0, "BOOL"),
+ mode: props.globals.initNode("/controls/autobrake/mode", 0, "INT"),
+ decel: props.globals.initNode("/controls/autobrake/decel-rate", 0, "DOUBLE"),
+ _wow0: 0,
+ _gnd_speed: 0,
+ _mode: 0,
+ _active: 0,
+ init: func() {
+ me.active.setBoolValue(0);
+ me.mode.setValue(0);
+ me.decel.setValue(0);
+ },
+ arm_autobrake: func(mode) {
+ me._wow0 = pts.Gear.wow[0].getBoolValue();
+ me._gnd_speed = pts.Velocities.groundspeed.getValue();
+ if (mode == 0) { # OFF
+ absChk.stop();
+ if (me.active.getBoolValue()) {
+ me.active.setBoolValue(0);
+ pts.Controls.Gear.brake[0].setValue(0);
+ pts.Controls.Gear.brake[1].setValue(0);
+ }
+ me.decel.setValue(0);
+ me.mode.setValue(0);
+ } else if (mode == 1 and !me._wow0) { # LO
+ me.decel.setValue(2.0);
+ me.mode.setValue(1);
+ absChk.start();
+ } else if (mode == 2 and !me._wow0) { # MED
+ me.decel.setValue(3);
+ me.mode.setValue(2);
+ absChk.start();
+ } else if (mode == 3 and me._wow0 and me._gnd_speed < 40) { # MAX
+ me.decel.setValue(6);
+ me.mode.setValue(3);
+ absChk.start();
+ }
+ },
+ loop: func() {
+ me._wow0 = pts.Gear.wow[0].getBoolValue();
+ me._gnd_speed = pts.Velocities.groundspeed.getValue();
+ me._mode = me.mode.getValue();
+ me._active = me.active.getBoolValue();
+ if (me._gnd_speed > 72) {
+ if (me._mode != 0 and pts.Controls.Engines.Engine.throttle[0].getValue() < 0.15 and pts.Controls.Engines.Engine.throttle[1].getValue() < 0.15 and me._wow0) {
+ me.active.setBoolValue(1);
+ } elsif (me._active) {
+ me.active.setBoolValue(0);
+ pts.Controls.Gear.brake[0].setValue(0);
+ pts.Controls.Gear.brake[1].setValue(0);
+ }
+ }
+
+ if (me._mode == 3 and !pts.Controls.Gear.gearDown.getBoolValue()) {
+ me.arm_autobrake(0);
+ }
+ if (me._mode != 0 and me._wow0 and me._active and (pts.Controls.Gear.brake[0].getValue() > 0.05 or pts.Controls.Gear.brake[1].getValue() > 0.05)) {
+ me.arm_autobrake(0);
+ }
+ },
+};
+
+# Override FG's generic brake
+controls.applyBrakes = func(v, which = 0) {
+ if (!pts.Acconfig.running.getBoolValue()) {
+ if (which <= 0) {
+ pts.Controls.Gear.brake[0].setValue(v);
+ }
+ if (which >= 0) {
+ pts.Controls.Gear.brake[1].setValue(v);
+ }
+ }
+}
+setlistener("/sim/signals/fdm-initialized",
# executed on _every_ FDM reset (but not installing new listeners)
func(idle) { BrakeSys.reset(); },
0,0);
-settimer(func()
- {
- BrakeSys.update();
- }, 5);
+settimer(func() { BrakeSys.update(); }, 5);
+
+
+# Autobrake loop
+var absChk = maketimer(0.2, func {
+ Autobrake.loop();
+});
diff --git a/Systems/a320-fcs.xml b/Systems/a320-fcs.xml
index 8b01954c..7352d6aa 100644
--- a/Systems/a320-fcs.xml
+++ b/Systems/a320-fcs.xml
@@ -1087,38 +1087,88 @@
20
-
+
/controls/gear/brake-left
- /controls/gear/brake-parking
- /services/chocks/enable
+ 2
+
+
+
+ /controls/gear/brake-right
+ 2
+
+
+
+
+
+
+
+
+
+
+ fcs/brake-avail
+
+ /services/chocks/enable
+ fcs/brake-left
+
+ /controls/autobrake/brake-left
+ /controls/autobrake/active
+
+ /controls/gear/brake-parking
+
+
+
0
1
-
+
+
+
+ fcs/left-brake-input
+ 10
+
-
-
- /controls/autobrake/active eq 1
+
+
+ /systems/acconfig/autoconfig-running eq 1
-
- /controls/gear/brake-right
- /controls/gear/brake-parking
- /services/chocks/enable
+
+
+
+ fcs/brake-avail
+
+ /services/chocks/enable
+ fcs/brake-right
+
+ /controls/autobrake/brake-right
+ /controls/autobrake/active
+
+ /controls/gear/brake-parking
+
+
+
0
1
-
+
+
+
+ fcs/right-brake-input
+ 10
+
-
-
- /controls/autobrake/active eq 1
+
+
+ /systems/acconfig/autoconfig-running eq 1