From 4b58edb995db7536ea23cefbb5df76ee6f22a9c4 Mon Sep 17 00:00:00 2001 From: vezza Date: Mon, 23 Nov 2020 02:14:05 +0100 Subject: [PATCH] Hydraulic and brake systems improvements: - fix flightdeck brakes pressure indicator's bug; - disable autobrake if antiskid is disabled or green pressure is low/missing; - set hydraulic brakes snd accumulator's pressure; to be done: set brake power according to brake's pressure --- Models/FlightDeck/a320.flightdeck.xml | 16 ++-- Nasal/Systems/brakesystem.nas | 2 +- Nasal/Systems/hydraulics.nas | 104 +++++++++++++++++++++++++- Systems/libraries.xml | 40 ---------- 4 files changed, 115 insertions(+), 47 deletions(-) diff --git a/Models/FlightDeck/a320.flightdeck.xml b/Models/FlightDeck/a320.flightdeck.xml index 915d3d1e..bbd645a8 100644 --- a/Models/FlightDeck/a320.flightdeck.xml +++ b/Models/FlightDeck/a320.flightdeck.xml @@ -365,7 +365,7 @@ rotate brakes_lb_psi systems/hydraulic/brakes/pressure-left-psi - 0.03 + -0.03 systems/hydraulic/brakes/mode @@ -381,7 +381,7 @@ rotate brakes_rb_psi systems/hydraulic/brakes/pressure-right-psi - -0.03 + 0.03 systems/hydraulic/brakes/mode @@ -399,10 +399,16 @@ systems/hydraulic/brakes/accumulator-pressure-psi 00 - 70066 - 200078 - 300090 + 700-66 + 2000-78 + 3000-90 + + + systems/hydraulic/brakes/mode + 2 + + brakes_accum_psi.axis diff --git a/Nasal/Systems/brakesystem.nas b/Nasal/Systems/brakesystem.nas index 3b98f390..ca021df9 100755 --- a/Nasal/Systems/brakesystem.nas +++ b/Nasal/Systems/brakesystem.nas @@ -406,7 +406,7 @@ var Autobrake = { 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) { + 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 and systems.HYD.Brakes.askidSw.getValue() and systems.HYD.Psi.green.getValue() >= 2500 ) { me.active.setBoolValue(1); } elsif (me._active) { me.active.setBoolValue(0); diff --git a/Nasal/Systems/hydraulics.nas b/Nasal/Systems/hydraulics.nas index 3cd48602..0d6ec5ce 100644 --- a/Nasal/Systems/hydraulics.nas +++ b/Nasal/Systems/hydraulics.nas @@ -2,6 +2,8 @@ # Jonathan Redpath # Copyright (c) 2019 Jonathan Redpath +var lcont = 0; +var rcont = 0; var HYD = { Brakes: { @@ -10,10 +12,11 @@ var HYD = { rightPressPsi: props.globals.initNode("/systems/hydraulic/brakes/pressure-right-psi", 0, "INT"), askidSw: props.globals.initNode("/systems/hydraulic/brakes/askidnwssw", 1, "BOOL"), mode: props.globals.initNode("/systems/hydraulic/brakes/mode", 0, "INT"), + leftbrake: props.globals.getNode("/controls/gear/brake-left"), + rightbrake: props.globals.getNode("/controls/gear/brake-right"), lbrake: props.globals.initNode("/systems/hydraulic/brakes/lbrake", 0, "INT"), rbrake: props.globals.initNode("/systems/hydraulic/brakes/rbrake", 0, "INT"), noserubber: props.globals.initNode("/systems/hydraulic/brakes/nose-rubber", 0, "INT"), - counter: props.globals.initNode("/systems/hydraulic/brakes/counter", 0, "INT"), }, Fail: { blueElec: props.globals.getNode("/systems/failures/hydraulic/blue-elec"), @@ -85,11 +88,110 @@ var HYD = { me.Fail.yellowLeak.setBoolValue(0); }, loop: func() { + if (me.Brakes.leftbrake.getValue() == 1) { + me.Brakes.lbrake.setValue(1); + } else { + me.Brakes.lbrake.setValue(0); + } + if (me.Brakes.rightbrake.getValue() == 1) { + me.Brakes.rbrake.setValue(1); + } else { + me.Brakes.rbrake.setValue(0); + } + if (props.globals.getValue("/controls/gear/nws-switch") == 1) { + me.Brakes.askidSw.setBoolValue(1); #true + } else { + me.Brakes.askidSw.setBoolValue(0); #false + } if (me.Brakes.mode.getValue() == 2) { if (me.Psi.yellow.getValue() > 2500 and me.Brakes.accumPressPsi.getValue() < 700) { 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) { + lcont = lcont + 1; + } else { + lcont = 0; + } + if (me.Brakes.rightbrake.getValue() > 0) { + rcont = rcont + 1; + } else { + rcont = 0; + } + if ((me.Psi.green.getValue() == 0) and (me.Psi.yellow.getValue() == 0) 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() - 35); + } + if (rcont == 1) { + #me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - (35 * me.Brakes.leftbrake.getValue())); + me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - 35); + } + if (me.Brakes.accumPressPsi.getValue() < 0) { + me.Brakes.accumPressPsi.setValue(0); + } + } + + # Braking Pressure + 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.lbrake.getValue() > 0) { + me.Brakes.leftPressPsi.setValue(props.globals.getValue("/systems/hydraulic/green-psi-ptu")); + } else { + me.Brakes.leftPressPsi.setValue(0); + } + if (me.Brakes.rbrake.getValue() > 0) { + me.Brakes.rightPressPsi.setValue(props.globals.getValue("/systems/hydraulic/green-psi-ptu")); + } else { + me.Brakes.rightPressPsi.setValue(0); + } + } else { + if (me.Brakes.mode.getValue() == 2 and me.Psi.green.getValue() < 2500) { + # 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.Brakes.lbrake.getValue() > 0) { + me.Brakes.leftPressPsi.setValue(props.globals.getValue("/systems/hydraulic/yellow-psi-ptu")); + } else { + me.Brakes.leftPressPsi.setValue(0); + } + if (me.Brakes.rbrake.getValue() > 0) { + me.Brakes.rightPressPsi.setValue(props.globals.getValue("/systems/hydraulic/yellow-psi-ptu")); + } 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.Brakes.lbrake.getValue() > 0) { + me.Brakes.leftPressPsi.setValue(1000); + } else { + me.Brakes.leftPressPsi.setValue(0); + } + if (me.Brakes.rbrake.getValue() > 0) { + me.Brakes.rightPressPsi.setValue(1000); + } 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.lbrake.getValue() > 0) { + me.Brakes.leftPressPsi.setValue(me.Brakes.accumPressPsi.getValue()); + } else { + me.Brakes.leftPressPsi.setValue(0); + } + if (me.Brakes.rbrake.getValue() > 0) { + me.Brakes.rightPressPsi.setValue(me.Brakes.accumPressPsi.getValue()); + } else { + me.Brakes.rightPressPsi.setValue(0); + } + } + } + } + } + } }, }; diff --git a/Systems/libraries.xml b/Systems/libraries.xml index cf97f463..52d14c55 100644 --- a/Systems/libraries.xml +++ b/Systems/libraries.xml @@ -740,46 +740,6 @@ /controls/flight/auto-coordination - - - - Left Press - gain - 1.0 - 0.05 - - - - /controls/gear/brake-left - 0.0 0 - 0.31000 - 0.62000 - 1.03000 -
-
- - /systems/hydraulic/brakes/pressure-left-psi -
- - - Right Press - gain - 1.0 - 0.05 - - - - /controls/gear/brake-right - 0.0 0 - 0.31000 - 0.62000 - 1.03000 -
-
- - /systems/hydraulic/brakes/pressure-right-psi -
- Left Door gain