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
|
2020-11-23 01:14:05 +00:00
|
|
|
var lcont = 0;
|
|
|
|
var rcont = 0;
|
2019-10-14 16:48:35 +00:00
|
|
|
|
|
|
|
var HYD = {
|
2019-10-15 18:03:43 +00:00
|
|
|
Brakes: {
|
|
|
|
accumPressPsi: props.globals.initNode("/systems/hydraulic/brakes/accumulator-pressure-psi", 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"),
|
|
|
|
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"),
|
|
|
|
blueLeak: props.globals.getNode("/systems/failures/hydraulic/blue-leak"),
|
|
|
|
greenEng: props.globals.getNode("/systems/failures/hydraulic/green-edp"),
|
|
|
|
greenLeak: props.globals.getNode("/systems/failures/hydraulic/green-leak"),
|
|
|
|
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"),
|
|
|
|
yellowLeak: props.globals.getNode("/systems/failures/hydraulic/yellow-leak"),
|
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"),
|
|
|
|
},
|
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"),
|
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
|
|
|
},
|
2019-10-14 16:48:35 +00:00
|
|
|
init: func() {
|
2019-10-15 15:46:38 +00:00
|
|
|
me.resetFail();
|
|
|
|
me.Qty.blueInput.setValue(math.round((rand() * 4) + 8 , 0.1)); # Random between 8 and 12
|
|
|
|
me.Qty.greenInput.setValue(math.round((rand() * 4) + 8 , 0.1)); # Random between 8 and 12
|
|
|
|
me.Qty.yellowInput.setValue(math.round((rand() * 4) + 8 , 0.1)); # Random between 8 and 12
|
|
|
|
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);
|
|
|
|
},
|
|
|
|
resetFail: func() {
|
|
|
|
me.Fail.blueElec.setBoolValue(0);
|
|
|
|
me.Fail.blueLeak.setBoolValue(0);
|
|
|
|
me.Fail.greenEng.setBoolValue(0);
|
|
|
|
me.Fail.greenLeak.setBoolValue(0);
|
|
|
|
me.Fail.ptuFault.setBoolValue(0);
|
|
|
|
me.Fail.yellowEng.setBoolValue(0);
|
|
|
|
me.Fail.yellowElec.setBoolValue(0);
|
|
|
|
me.Fail.yellowLeak.setBoolValue(0);
|
2019-10-14 16:48:35 +00:00
|
|
|
},
|
|
|
|
loop: func() {
|
2020-11-23 01:14:05 +00:00
|
|
|
if (props.globals.getValue("/controls/gear/nws-switch") == 1) {
|
|
|
|
me.Brakes.askidSw.setBoolValue(1); #true
|
|
|
|
} else {
|
|
|
|
me.Brakes.askidSw.setBoolValue(0); #false
|
|
|
|
}
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Psi.yellow.getValue() > 0 and me.Brakes.accumPressPsi.getValue() < 3000 and me.Psi.yellow.getValue() > me.Brakes.accumPressPsi.getValue()) {
|
2020-09-12 17:13:34 +00:00
|
|
|
me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() + 50);
|
2019-10-15 18:03:43 +00:00
|
|
|
}
|
2020-11-23 01:14:05 +00:00
|
|
|
|
|
|
|
# Decrease accumPressPsi when green and yellow hydraulic's aren't pressurized
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
lcont = lcont + 1;
|
|
|
|
} else {
|
|
|
|
lcont = 0;
|
|
|
|
}
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
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()));
|
2020-11-26 22:49:10 +00:00
|
|
|
me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - 200);
|
2020-11-23 01:14:05 +00:00
|
|
|
}
|
|
|
|
if (rcont == 1) {
|
|
|
|
#me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - (35 * me.Brakes.leftbrake.getValue()));
|
2020-11-26 22:49:10 +00:00
|
|
|
me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - 200);
|
2020-11-23 01:14:05 +00:00
|
|
|
}
|
|
|
|
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
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.leftbrake.getValue() > 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
me.Brakes.leftPressPsi.setValue(props.globals.getValue("/systems/hydraulic/green-psi-ptu"));
|
|
|
|
} else {
|
|
|
|
me.Brakes.leftPressPsi.setValue(0);
|
|
|
|
}
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.rightbrake.getValue() > 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
me.Brakes.rightPressPsi.setValue(props.globals.getValue("/systems/hydraulic/green-psi-ptu"));
|
|
|
|
} else {
|
|
|
|
me.Brakes.rightPressPsi.setValue(0);
|
|
|
|
}
|
|
|
|
} else {
|
2020-11-26 22:49:10 +00:00
|
|
|
if ((me.Brakes.mode.getValue() == 2 and me.Psi.green.getValue() < 2500) or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
# 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")) {
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
me.Brakes.leftPressPsi.setValue(props.globals.getValue("/systems/hydraulic/yellow-psi-ptu"));
|
|
|
|
} else {
|
|
|
|
me.Brakes.leftPressPsi.setValue(0);
|
|
|
|
}
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
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")) {
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
me.Brakes.leftPressPsi.setValue(1000);
|
|
|
|
} else {
|
|
|
|
me.Brakes.leftPressPsi.setValue(0);
|
|
|
|
}
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
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")) {
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
me.Brakes.leftPressPsi.setValue(me.Brakes.accumPressPsi.getValue());
|
|
|
|
} else {
|
|
|
|
me.Brakes.leftPressPsi.setValue(0);
|
|
|
|
}
|
2020-11-26 22:49:10 +00:00
|
|
|
if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) {
|
2020-11-23 01:14:05 +00:00
|
|
|
me.Brakes.rightPressPsi.setValue(me.Brakes.accumPressPsi.getValue());
|
|
|
|
} else {
|
|
|
|
me.Brakes.rightPressPsi.setValue(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-14 16:48:35 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
setlistener("/controls/gear/gear-down", func {
|
2020-09-15 17:41:40 +00:00
|
|
|
if (!pts.Controls.Gear.gearDown.getValue() and (pts.Gear.wow[0].getValue() or pts.Gear.wow[1].getValue() or pts.Gear.wow[2].getValue())) {
|
|
|
|
pts.Controls.Gear.gearDown.setValue(1);
|
2019-10-14 16:48:35 +00:00
|
|
|
}
|
|
|
|
});
|