2019-10-14 16:48:35 +00:00
# A3XX Hydraulic System
2019-10-15 15:46:38 +00:00
# Jonathan Redpath
2019-10-14 16:48:35 +00:00
2019-10-15 15:46:38 +00:00
# Copyright (c) 2019 Jonathan Redpath
2019-10-14 16:48:35 +00:00
var HYD = {
2021-06-07 14:38:50 +00:00
lcont: 0,
rcont: 0,
2019-10-15 18:03:43 +00:00
Brakes: {
2021-08-03 11:00:39 +00:00
accumPressPsi: props.globals.initNode("/systems/hydraulic/yellow-accumulator-psi-cmd", 3000, "INT"),
2019-10-15 18:03:43 +00:00
leftPressPsi: props.globals.initNode("/systems/hydraulic/brakes/pressure-left-psi", 0, "INT"),
rightPressPsi: props.globals.initNode("/systems/hydraulic/brakes/pressure-right-psi", 0, "INT"),
mode: props.globals.initNode("/systems/hydraulic/brakes/mode", 0, "INT"),
2020-11-23 01:14:05 +00:00
leftbrake: props.globals.getNode("/controls/gear/brake-left"),
rightbrake: props.globals.getNode("/controls/gear/brake-right"),
2019-10-15 18:03:43 +00:00
noserubber: props.globals.initNode("/systems/hydraulic/brakes/nose-rubber", 0, "INT"),
},
2019-10-15 15:46:38 +00:00
Fail: {
2020-06-26 13:00:28 +00:00
blueElec: props.globals.getNode("/systems/failures/hydraulic/blue-elec"),
2022-01-03 20:46:42 +00:00
blueElecOvht: props.globals.getNode("/systems/failures/hydraulic/blue-elec-ovht"),
2020-06-26 13:00:28 +00:00
blueLeak: props.globals.getNode("/systems/failures/hydraulic/blue-leak"),
2022-01-03 20:46:42 +00:00
blueReservoirAirPressLow: props.globals.getNode("/systems/failures/hydraulic/blue-reservoir-air-press-lo"),
blueReservoirOvht: props.globals.getNode("/systems/failures/hydraulic/blue-reservoir-ovht"),
2020-06-26 13:00:28 +00:00
greenEng: props.globals.getNode("/systems/failures/hydraulic/green-edp"),
greenLeak: props.globals.getNode("/systems/failures/hydraulic/green-leak"),
2022-01-03 20:46:42 +00:00
greenReservoirAirPressLow: props.globals.getNode("/systems/failures/hydraulic/green-reservoir-air-press-lo"),
greenReservoirOvht: props.globals.getNode("/systems/failures/hydraulic/green-reservoir-ovht"),
2020-06-26 13:00:28 +00:00
ptuFault: props.globals.getNode("/systems/failures/hydraulic/ptu"),
yellowEng: props.globals.getNode("/systems/failures/hydraulic/yellow-edp"),
yellowElec: props.globals.getNode("/systems/failures/hydraulic/yellow-elec"),
2022-01-03 20:46:42 +00:00
yellowElecOvht: props.globals.getNode("/systems/failures/hydraulic/yellow-elec-ovht"),
2020-06-26 13:00:28 +00:00
yellowLeak: props.globals.getNode("/systems/failures/hydraulic/yellow-leak"),
2022-01-03 20:46:42 +00:00
yellowReservoirAirPressLow: props.globals.getNode("/systems/failures/hydraulic/yellow-reservoir-air-press-lo"),
yellowReservoirOvht: props.globals.getNode("/systems/failures/hydraulic/yellow-reservoir-ovht"),
2019-10-15 15:46:38 +00:00
},
Psi: {
2020-06-26 13:00:28 +00:00
blue: props.globals.getNode("/systems/hydraulic/blue-psi"),
green: props.globals.getNode("/systems/hydraulic/green-psi"),
yellow: props.globals.getNode("/systems/hydraulic/yellow-psi"),
2019-10-15 18:03:43 +00:00
},
Ptu: {
2020-06-26 13:00:28 +00:00
active: props.globals.getNode("/systems/hydraulic/sources/ptu/ptu-hydraulic-condition"),
diff: props.globals.getNode("/systems/hydraulic/yellow-psi-diff"),
2019-10-15 15:46:38 +00:00
},
2020-10-18 16:37:23 +00:00
Pump: {
yellowElec: props.globals.getNode("/systems/hydraulic/sources/yellow-elec/pump-operate"),
2022-01-06 17:47:03 +00:00
yellowElecFail: props.globals.getNode("/ECAM/warnings/hyd/yellow-elec-pump-fail"),
2020-10-18 16:37:23 +00:00
},
2019-10-15 15:46:38 +00:00
Qty: {
blueInput: props.globals.initNode("/systems/hydraulic/blue-qty-input", 0, "INT"),
2020-10-18 16:37:23 +00:00
blue: props.globals.getNode("/systems/hydraulic/blue-qty"),
2019-10-15 15:46:38 +00:00
greenInput: props.globals.initNode("/systems/hydraulic/green-qty-input", 0, "INT"),
2020-10-18 16:37:23 +00:00
green: props.globals.getNode("/systems/hydraulic/green-qty"),
2019-10-15 15:46:38 +00:00
yellowInput: props.globals.initNode("/systems/hydraulic/yellow-qty-input", 0, "INT"),
2020-10-18 16:37:23 +00:00
yellow: props.globals.getNode("/systems/hydraulic/yellow-qty"),
2019-10-15 15:46:38 +00:00
},
2019-10-15 18:03:43 +00:00
Rat: {
2020-06-26 13:00:28 +00:00
position: props.globals.getNode("/systems/hydraulic/sources/rat/position"),
2019-10-15 18:03:43 +00:00
},
2019-10-15 15:46:38 +00:00
Switch: {
2020-06-26 13:00:28 +00:00
blueElec: props.globals.getNode("/controls/hydraulic/switches/blue-elec"),
blueElecOvrd: props.globals.getNode("/controls/hydraulic/switches/blue-elec-ovrd"),
greenEDP: props.globals.getNode("/controls/hydraulic/switches/green-edp"),
ptu: props.globals.getNode("/controls/hydraulic/switches/ptu"),
rat: props.globals.getNode("/controls/hydraulic/switches/rat-man"),
yellowEDP: props.globals.getNode("/controls/hydraulic/switches/yellow-edp"),
yellowElec: props.globals.getNode("/controls/hydraulic/switches/yellow-elec"),
2021-02-08 15:45:57 +00:00
nwsSwitch: props.globals.getNode("/controls/gear/nws-switch"),
2019-10-15 15:46:38 +00:00
},
2019-10-15 18:03:43 +00:00
Valve: {
2020-06-26 13:00:28 +00:00
yellowFire: props.globals.getNode("/systems/hydraulic/sources/yellow-edp/fire-valve"),
greenFire: props.globals.getNode("/systems/hydraulic/sources/green-edp/fire-valve"),
2019-10-15 18:03:43 +00:00
},
2021-08-05 15:47:56 +00:00
Warnings: {
blueAbnormLoPr: props.globals.getNode("/ECAM/warnings/hyd/blue-abnorm-lo-pr"),
greenAbnormLoPr: props.globals.getNode("/ECAM/warnings/hyd/green-abnorm-lo-pr"),
yellowAbnormLoPr: props.globals.getNode("/ECAM/warnings/hyd/yellow-abnorm-lo-pr"),
2022-01-06 17:47:03 +00:00
blueLoLvl: props.globals.getNode("/systems/hydraulic/relays/blue-reservoir-low-qty-switch"),
greenLoLvl: props.globals.getNode("/systems/hydraulic/relays/green-reservoir-low-qty-switch"),
yellowLoLvl: props.globals.getNode("/systems/hydraulic/relays/yellow-reservoir-low-qty-switch"),
blueReservoirOvht: props.globals.getNode("/systems/hydraulic/relays/blue-reservoir-overheat"),
greenReservoirOvht: props.globals.getNode("/systems/hydraulic/relays/green-reservoir-overheat"),
yellowReservoirOvht: props.globals.getNode("/systems/hydraulic/relays/yellow-reservoir-overheat"),
2021-08-05 15:47:56 +00:00
},
2019-10-14 16:48:35 +00:00
init: func() {
2021-11-02 21:32:24 +00:00
me.resetFailures();
2021-08-31 11:23:22 +00:00
me.Qty.blueInput.setValue(8);
me.Qty.greenInput.setValue(16);
me.Qty.yellowInput.setValue(15);
2019-10-15 15:46:38 +00:00
me.Switch.blueElec.setValue(1);
me.Switch.blueElecOvrd.setValue(0);
me.Switch.greenEDP.setValue(1);
me.Switch.ptu.setValue(1);
me.Switch.rat.setValue(0);
me.Switch.yellowEDP.setValue(1);
me.Switch.yellowElec.setValue(0);
2021-08-03 11:00:39 +00:00
me.Brakes.accumPressPsi.setValue(3000);
2019-10-15 15:46:38 +00:00
},
2021-11-02 21:32:24 +00:00
resetFailures: func() {
2019-10-15 15:46:38 +00:00
me.Fail.blueElec.setBoolValue(0);
2022-01-03 20:46:42 +00:00
me.Fail.blueElecOvht.setBoolValue(0);
2019-10-15 15:46:38 +00:00
me.Fail.blueLeak.setBoolValue(0);
2022-01-03 20:46:42 +00:00
me.Fail.blueReservoirAirPressLow.setBoolValue(0);
me.Fail.blueReservoirOvht.setBoolValue(0);
2019-10-15 15:46:38 +00:00
me.Fail.greenEng.setBoolValue(0);
me.Fail.greenLeak.setBoolValue(0);
2022-01-03 20:46:42 +00:00
me.Fail.greenReservoirAirPressLow.setBoolValue(0);
me.Fail.greenReservoirOvht.setBoolValue(0);
2019-10-15 15:46:38 +00:00
me.Fail.ptuFault.setBoolValue(0);
me.Fail.yellowEng.setBoolValue(0);
me.Fail.yellowElec.setBoolValue(0);
2022-01-03 20:46:42 +00:00
me.Fail.yellowElecOvht.setBoolValue(0);
2019-10-15 15:46:38 +00:00
me.Fail.yellowLeak.setBoolValue(0);
2022-01-03 20:46:42 +00:00
me.Fail.yellowReservoirAirPressLow.setBoolValue(0);
me.Fail.yellowReservoirOvht.setBoolValue(0);
2019-10-14 16:48:35 +00:00
},
2021-02-08 15:45:57 +00:00
loop: func(notification) {
2021-06-07 14:38:50 +00:00
# Decrease accumPressPsi when green and yellow hydraulics aren't pressurized
2021-02-08 15:45:57 +00:00
if (me.Brakes.leftbrake.getValue() > 0 or notification.brakesMode == 0) {
2021-06-07 14:38:50 +00:00
me.lcont = me.lcont + 1;
2020-11-23 01:14:05 +00:00
} else {
2021-06-07 14:38:50 +00:00
me.lcont = 0;
2020-11-23 01:14:05 +00:00
}
2021-02-08 15:45:57 +00:00
if (me.Brakes.rightbrake.getValue() > 0 or notification.brakesMode == 0) {
2021-06-07 14:38:50 +00:00
me.rcont = me.rcont + 1;
2020-11-23 01:14:05 +00:00
} else {
2021-06-07 14:38:50 +00:00
me.rcont = 0;
2020-11-23 01:14:05 +00:00
}
2021-06-07 14:38:50 +00:00
2021-02-08 15:45:57 +00:00
if (notification.yellow < notification.accumPressPsi and notification.accumPressPsi > 0) {
2021-06-07 14:38:50 +00:00
if (me.lcont == 1) {
me.Brakes.accumPressPsi.setValue(notification.accumPressPsi - 200);
2020-11-23 01:14:05 +00:00
}
2021-06-07 14:38:50 +00:00
if (me.rcont == 1) {
me.Brakes.accumPressPsi.setValue(notification.accumPressPsi - 200);
2020-11-23 01:14:05 +00:00
}
2021-02-08 15:45:57 +00:00
if (notification.accumPressPsi < 0) {
2020-11-23 01:14:05 +00:00
me.Brakes.accumPressPsi.setValue(0);
}
}
2021-08-03 11:00:39 +00:00
2020-11-23 01:14:05 +00:00
# Braking Pressure
2021-02-08 15:45:57 +00:00
if (notification.brakesMode == 1 or (notification.brakesMode == 2 and notification.green >= 2500)) {
2020-11-23 01:14:05 +00:00
# Normal braking - Green OK
2021-02-08 15:45:57 +00:00
if (notification.leftBrake > 0) {
me.Brakes.leftPressPsi.setValue(notification.green * notification.leftBrakeFCS);
2020-11-23 01:14:05 +00:00
} else {
me.Brakes.leftPressPsi.setValue(0);
}
2021-02-08 15:45:57 +00:00
if (notification.rightBrake > 0) {
me.Brakes.rightPressPsi.setValue(notification.green * notification.rightBrakeFCS);
2020-11-23 01:14:05 +00:00
} else {
me.Brakes.rightPressPsi.setValue(0);
}
} else {
2021-02-08 15:45:57 +00:00
if ((notification.brakesMode == 2 and notification.green < 2500) or notification.brakesMode == 0) {
2020-11-23 01:14:05 +00:00
# Alternate Braking (Yellow OK + Antiskid ON + electric OK) - missing condition: BSCU OK-KO
2021-02-08 15:45:57 +00:00
if (notification.yellow >= 2500 and notification.NWSSwitch and (notification.dc1 >= 24 or notification.dc2 >= 24 or notification.dcEss >= 24)) {
if (notification.leftBrake > 0 or notification.brakesMode == 0) {
me.Brakes.leftPressPsi.setValue(notification.yellow * notification.leftBrakeFCS);
2020-11-23 01:14:05 +00:00
} else {
me.Brakes.leftPressPsi.setValue(0);
}
2021-02-08 15:45:57 +00:00
if (notification.rightBrake > 0 or notification.brakesMode == 0) {
me.Brakes.rightPressPsi.setValue(notification.yellow * notification.rightBrakeFCS);
2020-11-23 01:14:05 +00:00
} else {
me.Brakes.rightPressPsi.setValue(0);
}
} else {
# Alternate Braking (Yellow OK + Antiskid OFF + electric OK) - missing condition: BSCU OK-KO
2021-02-08 15:45:57 +00:00
if (notification.yellow >= 2500 and !notification.NWSSwitch and (notification.dc1 >= 24 or notification.dc2 >= 24 or notification.dcEss >= 24)) {
if (notification.leftBrake > 0 or notification.brakesMode == 0) {
me.Brakes.leftPressPsi.setValue(1000 * notification.leftBrakeFCS);
2020-11-23 01:14:05 +00:00
} else {
me.Brakes.leftPressPsi.setValue(0);
}
2021-02-08 15:45:57 +00:00
if (notification.rightBrake > 0 or notification.brakesMode == 0) {
me.Brakes.rightPressPsi.setValue(1000 * notification.rightBrakeFCS);
2020-11-23 01:14:05 +00:00
} else {
me.Brakes.rightPressPsi.setValue(0);
}
} else {
# Alternate Braking (Yellow KO or Antiskid KO or electric KO) - missing condition: BSCU OK-KO
2021-02-08 15:45:57 +00:00
if (notification.accumPressPsi < 1000 and (notification.yellow < 2500 or !notification.NWSSwitch or (notification.dc1 < 24 and notification.dc2 < 24 and notification.dcEss < 24))) {
if (notification.leftBrake > 0 or notification.brakesMode == 0) {
me.Brakes.leftPressPsi.setValue(notification.accumPressPsi * notification.leftBrakeFCS);
2020-11-29 23:08:21 +00:00
} else {
me.Brakes.leftPressPsi.setValue(0);
}
2021-02-08 15:45:57 +00:00
if (notification.rightBrake > 0 or notification.brakesMode == 0) {
me.Brakes.rightPressPsi.setValue(notification.accumPressPsi * notification.rightBrakeFCS);
2020-11-29 23:08:21 +00:00
} else {
me.Brakes.rightPressPsi.setValue(0);
}
} else {
2021-02-08 15:45:57 +00:00
if (notification.leftBrake > 0 or notification.brakesMode == 0) {
me.Brakes.leftPressPsi.setValue(1000 * notification.leftBrakeFCS);
2020-11-23 01:14:05 +00:00
} else {
me.Brakes.leftPressPsi.setValue(0);
}
2021-02-08 15:45:57 +00:00
if (notification.rightBrake > 0 or notification.brakesMode == 0) {
me.Brakes.rightPressPsi.setValue(1000 * notification.rightBrakeFCS);
2020-11-23 01:14:05 +00:00
} else {
me.Brakes.rightPressPsi.setValue(0);
}
}
}
}
}
}
2019-10-14 16:48:35 +00:00
},
};
2021-02-08 15:45:57 +00:00
# Emesary
var A320Hydraulic = notifications.SystemRecipient.new("A320 Hydraulic",HYD.loop,HYD);
emesary.GlobalTransmitter.Register(A320Hydraulic);
var input = {
"blue": "/systems/hydraulic/blue-psi",
"green": "/systems/hydraulic/green-psi",
"yellow": "/systems/hydraulic/yellow-psi",
"brakesMode": "/systems/hydraulic/brakes/mode",
"accumPressPsi": "/systems/hydraulic/yellow-accumulator-psi-cmd",
"leftBrake": "/controls/gear/brake-left",
"rightBrake": "/controls/gear/brake-right",
"leftBrakeFCS": "/fdm/jsbsim/fcs/left-brake-cmd-norm",
"rightBrakeFCS": "/fdm/jsbsim/fcs/right-brake-cmd-norm",
"NWSSwitch": "/controls/gear/nws-switch",
};
foreach (var name; keys(input)) {
emesary.GlobalTransmitter.NotifyAll(notifications.FrameNotificationAddProperty.new("A320 Hydraulic", name, input[name]));
}