From 879deba025a54d3a9e3fe0b1a7b4875ee6315aa1 Mon Sep 17 00:00:00 2001 From: vezza Date: Mon, 30 Nov 2020 00:08:21 +0100 Subject: [PATCH] Hydraulic and brake system improvements - loss of braking if no hydraulic pressure; - code restyling; --- Models/FlightDeck/a320.flightdeck.xml | 2 +- Nasal/Systems/hydraulics.nas | 42 +++++++++++++++------------ Systems/a320-fcs.xml | 12 ++++---- Systems/a320-hydraulic.xml | 32 ++++++++++++++++++-- 4 files changed, 62 insertions(+), 26 deletions(-) diff --git a/Models/FlightDeck/a320.flightdeck.xml b/Models/FlightDeck/a320.flightdeck.xml index 2d6e31c2..8e1cd12a 100644 --- a/Models/FlightDeck/a320.flightdeck.xml +++ b/Models/FlightDeck/a320.flightdeck.xml @@ -428,7 +428,7 @@ rotate brakes_accum_psi - systems/hydraulic/brakes/accumulator-pressure-psi + systems/hydraulic/yellow-accumulator-psi 00 700-20 diff --git a/Nasal/Systems/hydraulics.nas b/Nasal/Systems/hydraulics.nas index 5d40f9fc..cd9e5779 100644 --- a/Nasal/Systems/hydraulics.nas +++ b/Nasal/Systems/hydraulics.nas @@ -7,7 +7,7 @@ var rcont = 0; var HYD = { Brakes: { - accumPressPsi: props.globals.initNode("/systems/hydraulic/brakes/accumulator-pressure-psi", 0, "INT"), + accumPressPsi: props.globals.initNode("/systems/hydraulic/yellow-accumulator-psi-cmd", 0, "INT"), leftPressPsi: props.globals.initNode("/systems/hydraulic/brakes/pressure-left-psi", 0, "INT"), rightPressPsi: props.globals.initNode("/systems/hydraulic/brakes/pressure-right-psi", 0, "INT"), askidSw: props.globals.initNode("/systems/hydraulic/brakes/askidnwssw", 1, "BOOL"), @@ -91,9 +91,6 @@ var HYD = { } else { me.Brakes.askidSw.setBoolValue(0); #false } - if (me.Psi.yellow.getValue() > 0 and me.Brakes.accumPressPsi.getValue() < 3000 and me.Psi.yellow.getValue() > me.Brakes.accumPressPsi.getValue()) { - me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() + 50); - } # Decrease accumPressPsi when green and yellow hydraulic's aren't pressurized if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { @@ -106,13 +103,11 @@ var HYD = { } else { rcont = 0; } - if ((me.Psi.green.getValue() == 0) and (me.Psi.yellow.getValue() == 0) and (me.Brakes.accumPressPsi.getValue()) > 0) { + if (me.Psi.yellow.getValue() < me.Brakes.accumPressPsi.getValue() and me.Brakes.accumPressPsi.getValue() > 0) { if (lcont == 1) { - #me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - (35 * me.Brakes.leftbrake.getValue())); me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - 200); } if (rcont == 1) { - #me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - (35 * me.Brakes.leftbrake.getValue())); me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - 200); } if (me.Brakes.accumPressPsi.getValue() < 0) { @@ -124,52 +119,63 @@ var HYD = { if (me.Brakes.mode.getValue() == 1 or (me.Brakes.mode.getValue() == 2 and me.Psi.green.getValue() >= 2500)) { # Normal braking - Green OK if (me.Brakes.leftbrake.getValue() > 0) { - me.Brakes.leftPressPsi.setValue(props.globals.getValue("/systems/hydraulic/green-psi-ptu")); + me.Brakes.leftPressPsi.setValue(me.Psi.green.getValue() * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); } else { me.Brakes.leftPressPsi.setValue(0); } if (me.Brakes.rightbrake.getValue() > 0) { - me.Brakes.rightPressPsi.setValue(props.globals.getValue("/systems/hydraulic/green-psi-ptu")); + me.Brakes.rightPressPsi.setValue(me.Psi.green.getValue() * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); } else { me.Brakes.rightPressPsi.setValue(0); } } else { if ((me.Brakes.mode.getValue() == 2 and me.Psi.green.getValue() < 2500) or me.Brakes.mode.getValue() == 0) { # Alternate Braking (Yellow OK + Antiskid ON + electric OK) - missing condition: BSCU OK-KO - if (me.Psi.yellow.getValue() >= 2500 and me.Brakes.askidSw.getValue() and props.globals.getValue("/systems/electrical/serviceable")) { + if (me.Psi.yellow.getValue() >= 2500 and me.Brakes.askidSw.getValue() and (systems.ELEC.Bus.dc1.getValue() >= 24 or systems.ELEC.Bus.dc2.getValue() >= 24 or systems.ELEC.Bus.dcess.getValue() >= 24)) { if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.leftPressPsi.setValue(props.globals.getValue("/systems/hydraulic/yellow-psi-ptu")); + me.Brakes.leftPressPsi.setValue(me.Psi.yellow.getValue() * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); } else { me.Brakes.leftPressPsi.setValue(0); } if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.rightPressPsi.setValue(props.globals.getValue("/systems/hydraulic/yellow-psi-ptu")); + me.Brakes.rightPressPsi.setValue(me.Psi.yellow.getValue() * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); } else { me.Brakes.rightPressPsi.setValue(0); } } else { # Alternate Braking (Yellow OK + Antiskid OFF + electric OK) - missing condition: BSCU OK-KO - if (me.Psi.yellow.getValue() >= 2500 and !me.Brakes.askidSw.getValue() and props.globals.getValue("/systems/electrical/serviceable")) { + if (me.Psi.yellow.getValue() >= 2500 and !me.Brakes.askidSw.getValue() and (systems.ELEC.Bus.dc1.getValue() >= 24 or systems.ELEC.Bus.dc2.getValue() >= 24 or systems.ELEC.Bus.dcess.getValue() >= 24)) { if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.leftPressPsi.setValue(1000); + me.Brakes.leftPressPsi.setValue(1000 * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); } else { me.Brakes.leftPressPsi.setValue(0); } if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.rightPressPsi.setValue(1000); + me.Brakes.rightPressPsi.setValue(1000 * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); } else { me.Brakes.rightPressPsi.setValue(0); } } else { # Alternate Braking (Yellow KO or Antiskid KO or electric KO) - missing condition: BSCU OK-KO - if (me.Psi.yellow.getValue() < 2500 or !me.Brakes.askidSw.getValue() or !props.globals.getValue("/systems/electrical/serviceable")) { + if (me.Brakes.accumPressPsi.getValue() < 1000 and (me.Psi.yellow.getValue() < 2500 or !me.Brakes.askidSw.getValue() or (systems.ELEC.Bus.dc1.getValue() < 24 and systems.ELEC.Bus.dc2.getValue() < 24 and systems.ELEC.Bus.dcess.getValue() < 24))) { if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.leftPressPsi.setValue(me.Brakes.accumPressPsi.getValue()); + me.Brakes.leftPressPsi.setValue(me.Brakes.accumPressPsi.getValue() * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); } else { me.Brakes.leftPressPsi.setValue(0); } if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.rightPressPsi.setValue(me.Brakes.accumPressPsi.getValue()); + me.Brakes.rightPressPsi.setValue(me.Brakes.accumPressPsi.getValue() * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); + } else { + me.Brakes.rightPressPsi.setValue(0); + } + } else { + if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { + me.Brakes.leftPressPsi.setValue(1000 * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); + } else { + me.Brakes.leftPressPsi.setValue(0); + } + if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { + me.Brakes.rightPressPsi.setValue(1000 * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); } else { me.Brakes.rightPressPsi.setValue(0); } diff --git a/Systems/a320-fcs.xml b/Systems/a320-fcs.xml index 76bd273b..aedce979 100644 --- a/Systems/a320-fcs.xml +++ b/Systems/a320-fcs.xml @@ -1172,11 +1172,13 @@ - - + + + /systems/hydraulic/green-psi ge 2500 + /systems/hydraulic/yellow-psi ge 1000 + /systems/hydraulic/yellow-accumulator-psi gt 0 + + fcs/brake-avail diff --git a/Systems/a320-hydraulic.xml b/Systems/a320-hydraulic.xml index 89113580..097c3c47 100644 --- a/Systems/a320-hydraulic.xml +++ b/Systems/a320-hydraulic.xml @@ -386,7 +386,7 @@ - + /systems/hydraulic/yellow-psi-cmd /systems/hydraulic/sys-incr-rate @@ -397,6 +397,34 @@ /systems/hydraulic/yellow-psi 0.9 + + + + + + + /systems/hydraulic/yellow-psi + 0 + + + /systems/hydraulic/yellow-psi + /systems/hydraulic/yellow-accumulator-psi-cmd + + + + /systems/hydraulic/yellow-psi + /systems/hydraulic/yellow-accumulator-psi-cmd + + /systems/hydraulic/yellow-accumulator-psi-cmd + + + + + + /systems/hydraulic/yellow-accumulator-psi-cmd + /systems/hydraulic/sys-incr-rate + /systems/hydraulic/sys-decr-rate + @@ -510,7 +538,7 @@ /controls/gear/brake-parking ne 1 - /systems/hydraulic/brakes/accumulator-pressure-psi ge 0 + /systems/hydraulic/yellow-accumulator-psi-cmd ge 0