2019-10-29 15:19:43 +00:00
# A3XX FWC Phases
# Copyright (c) 2019 Jonathan Redpath (legoboyvdlp)
2021-06-22 14:26:56 +00:00
var currentPhase = nil;
2019-10-29 15:19:43 +00:00
var FWC = {
2019-10-31 18:57:19 +00:00
Btn: {
2020-06-25 23:27:26 +00:00
clr: props.globals.initNode("/ECAM/buttons/clear-btn", 0, "BOOL"),
recall: props.globals.initNode("/ECAM/buttons/recall-btn", 0, "BOOL"),
recallStsNormal: props.globals.initNode("/ECAM/buttons/recall-status-normal", 0, "BOOL"),
recallStsNormalOutput: props.globals.initNode("/ECAM/buttons/recall-status-normal-output", 0, "BOOL"),
2019-10-31 18:57:19 +00:00
},
2019-10-29 15:19:43 +00:00
Monostable: {
2020-06-25 23:27:26 +00:00
phase1: props.globals.initNode("/ECAM/phases/monostable/phase-1-300", 0, "BOOL"),
phase5: props.globals.initNode("/ECAM/phases/monostable/phase-5", 0, "BOOL"),
2021-06-22 14:26:56 +00:00
phase5Temp: 0,
2020-06-25 23:27:26 +00:00
phase7: props.globals.initNode("/ECAM/phases/monostable/phase-7", 0, "BOOL"),
2021-06-22 14:26:56 +00:00
phase7Temp: 0,
2020-06-25 23:27:26 +00:00
phase9: props.globals.initNode("/ECAM/phases/monostable/phase-9", 0, "BOOL"),
2020-10-20 21:24:29 +00:00
phase1Output: props.globals.initNode("/ECAM/phases/monostable/phase-1-300-output"),
2021-06-22 14:26:56 +00:00
phase1OutputTemp: 0,
2020-06-25 23:27:26 +00:00
phase5Output: props.globals.initNode("/ECAM/phases/monostable/phase-5-output"),
2021-06-22 14:26:56 +00:00
phase5OutputTemp: 0,
2020-06-25 23:27:26 +00:00
phase7Output: props.globals.initNode("/ECAM/phases/monostable/phase-7-output"),
2021-06-22 14:26:56 +00:00
phase7OutputTemp: 0,
2020-06-25 23:27:26 +00:00
phase9Output: props.globals.initNode("/ECAM/phases/monostable/phase-9-output"),
toPowerOutput: props.globals.getNode("/ECAM/phases/monostable/to-power-set-output"),
m80kt: props.globals.getNode("/ECAM/phases/monostable-80kt"),
altAlert1: props.globals.initNode("/ECAM/altitude-alert-monostable-set", 0, "BOOL"),
altAlert1Output: props.globals.initNode("/ECAM/altitude-alert-monostable-output"),
altAlert2: props.globals.initNode("/ECAM/flipflop/altitude-alert-rs-set", 0, "BOOL"),
2019-10-29 15:19:43 +00:00
},
Flipflop: {
2020-06-25 23:27:26 +00:00
phase2Set: props.globals.initNode("/ECAM/phases/flipflop/phase-2-set", 0, "BOOL"),
phase2Reset: props.globals.initNode("/ECAM/phases/flipflop/phase-2-reset", 0, "BOOL"),
phase2Output: props.globals.initNode("/ECAM/phases/flipflop/phase-2-output", 0, "BOOL"),
2021-06-22 14:26:56 +00:00
phase2OutputTemp: 0,
2020-06-25 23:27:26 +00:00
phase10Set: props.globals.initNode("/ECAM/phases/flipflop/phase-10-set", 0, "BOOL"),
phase10Reset: props.globals.initNode("/ECAM/phases/flipflop/phase-10-reset", 0, "BOOL"),
phase10Output: props.globals.initNode("/ECAM/phases/flipflop/phase-10-output", 0, "BOOL"),
recallSet: props.globals.initNode("/ECAM/flipflop/recall-set", 0, "BOOL"),
recallReset: props.globals.initNode("/ECAM/flipflop/recall-reset", 0, "BOOL"),
recallOutput: props.globals.initNode("/ECAM/flipflop/recall-output", 0, "BOOL"),
2021-06-22 14:26:56 +00:00
recallOutputTemp: 0,
2020-06-25 23:27:26 +00:00
},
Logic: {
2020-11-18 16:58:09 +00:00
gnd: props.globals.getNode("/ECAM/logic/ground-calc-immediate"),
2020-07-17 15:57:10 +00:00
IRSinAlign: props.globals.initNode("/ECAM/irs-in-align", 0, "BOOL"),
2020-11-02 17:51:31 +00:00
feet1500: props.globals.getNode("/ECAM/phases/phase-calculation/altitude-ge-1500"),
feet800: props.globals.getNode("/ECAM/phases/phase-calculation/altitude-ge-800"),
2019-10-29 15:19:43 +00:00
},
Timer: {
2020-11-02 17:51:31 +00:00
eng1idle: props.globals.getNode("/ECAM/phases/timer/eng1idle"),
eng2idle: props.globals.getNode("/ECAM/phases/timer/eng2idle"),
eng1or2: props.globals.getNode("/ECAM/phases/phase-calculation/one-engine-running"),
2020-06-25 23:27:26 +00:00
toInhibit: props.globals.initNode("/ECAM/phases/timer/to-inhibit", 0, "INT"),
ldgInhibit: props.globals.initNode("/ECAM/phases/timer/ldg-inhibit", 0, "INT"),
eng1idleOutput: props.globals.getNode("/ECAM/phases/timer/eng1idle-output"),
eng2idleOutput: props.globals.getNode("/ECAM/phases/timer/eng2idle-output"),
2020-11-02 17:51:31 +00:00
eng1and2Off: props.globals.getNode("/ECAM/phases/phase-calculation/engines-1-2-not-running"),
2021-06-22 14:26:56 +00:00
eng1and2OffTemp: 0,
2020-11-02 17:51:31 +00:00
eng1or2Output: props.globals.getNode("/ECAM/phases/phase-calculation/engine-1-or-2-running"),
2021-06-22 14:26:56 +00:00
eng1or2OutputTemp: 0,
2020-06-25 23:27:26 +00:00
toInhibitOutput: props.globals.getNode("/ECAM/phases/timer/to-inhibit-output"),
ldgInhibitOutput: props.globals.getNode("/ECAM/phases/timer/ldg-inhibit-output"),
2020-10-31 23:59:18 +00:00
gnd: props.globals.getNode("/ECAM/timer/ground-calc"), # ZGND
2020-06-25 23:27:26 +00:00
gnd2Sec: props.globals.getNode("/ECAM/phases/monostable/gnd-output"),
2020-11-02 17:51:31 +00:00
gnd2SecHalf: props.globals.getNode("/ECAM/phases/monostable/gnd-output-2"), # hack to prevent getting confused between phase 5 / 6
2019-10-29 15:19:43 +00:00
},
2020-06-25 23:27:26 +00:00
speed80: props.globals.initNode("/ECAM/phases/speed-gt-80", 0, "BOOL"),
2021-06-22 14:26:56 +00:00
speed80Temp: 0,
2020-11-02 17:51:31 +00:00
toPower: props.globals.getNode("/ECAM/phases/phase-calculation/takeoff-power"),
2021-06-22 14:26:56 +00:00
toPowerTemp: 0,
2020-10-31 23:59:18 +00:00
altChg: props.globals.getNode("/it-autoflight/input/alt-is-changing", 1),
2019-10-29 15:19:43 +00:00
};
2020-11-26 19:24:42 +00:00
var gnd = nil;
var gndTimer = nil;
2019-10-29 15:19:43 +00:00
var phaseLoop = func() {
2020-11-18 16:58:09 +00:00
if ((systems.ELEC.Bus.acEss.getValue() < 110 and systems.ELEC.Bus.ac2.getValue() < 110) or pts.Acconfig.running.getBoolValue()) { return; }
2019-10-31 18:57:19 +00:00
if (pts.Sim.Replay.replayActive.getBoolValue()) { return; }
2021-06-22 14:26:56 +00:00
currentPhase = pts.ECAM.fwcWarningPhase.getValue();
2020-11-26 19:24:42 +00:00
gnd = FWC.Logic.gnd.getBoolValue();
gndTimer = FWC.Timer.gnd.getValue();
2019-10-29 15:19:43 +00:00
2021-06-22 14:26:56 +00:00
if (FWC.Flipflop.recallReset.getValue() != 0) {
FWC.Flipflop.recallReset.setValue(0);
2019-10-29 15:19:43 +00:00
}
2021-06-22 14:26:56 +00:00
FWC.toPowerTemp = FWC.toPower.getBoolValue();
FWC.Timer.eng1and2OffTemp = FWC.Timer.eng1and2Off.getValue();
FWC.Timer.eng1or2OutputTemp = FWC.Timer.eng1or2Output.getBoolValue();
FWC.speed80Temp = FWC.speed80.getBoolValue();
FWC.Monostable.phase1OutputTemp = FWC.Monostable.phase1Output.getBoolValue();
FWC.Flipflop.phase2OutputTemp = FWC.Flipflop.phase2Output.getBoolValue();
FWC.Monostable.phase5Temp = FWC.Monostable.phase5.getBoolValue();
FWC.Monostable.phase5OutputTemp = FWC.Monostable.phase5Output.getBoolValue();
FWC.Monostable.phase7Temp = FWC.Monostable.phase7.getBoolValue();
FWC.Monostable.phase7OutputTemp = FWC.Monostable.phase7Output.getBoolValue();
# Set Phases
if ((gnd and FWC.Timer.eng1and2OffTemp and currentPhase != 9) and !FWC.Monostable.phase1OutputTemp) {
2019-10-29 15:19:43 +00:00
setPhase(1);
}
2021-06-22 14:26:56 +00:00
if (FWC.Timer.eng1or2OutputTemp and (gnd and !FWC.toPowerTemp and !FWC.speed80Temp) and !FWC.Flipflop.phase2OutputTemp) {
2019-10-29 15:19:43 +00:00
setPhase(2);
}
2021-06-22 14:26:56 +00:00
if (FWC.Timer.eng1or2OutputTemp and (gndTimer == 1 and FWC.toPowerTemp) and !FWC.speed80Temp) {
2019-10-29 15:19:43 +00:00
setPhase(3);
}
2021-06-22 14:26:56 +00:00
if ((gndTimer == 1 and FWC.toPowerTemp) and FWC.speed80Temp) {
2019-10-29 15:19:43 +00:00
setPhase(4);
}
2021-06-22 14:26:56 +00:00
if (FWC.Monostable.phase5Temp and FWC.Monostable.phase5OutputTemp) {
2019-10-29 15:19:43 +00:00
setPhase(5);
}
2021-06-22 14:26:56 +00:00
if (!gnd and FWC.Timer.gnd2SecHalf.getValue() != 1 and (!FWC.Monostable.phase5Temp or !FWC.Monostable.phase5OutputTemp) and (!FWC.Monostable.phase7Temp or !FWC.Monostable.phase7OutputTemp)) {
2019-10-29 15:19:43 +00:00
setPhase(6);
}
2021-06-22 14:26:56 +00:00
if ((FWC.Monostable.phase7Temp and FWC.Monostable.phase7OutputTemp) and currentPhase != 8) {
2019-10-29 15:19:43 +00:00
setPhase(7);
}
2021-06-22 14:26:56 +00:00
if (!FWC.toPowerTemp and FWC.speed80Temp and (gnd or FWC.Timer.gnd2Sec.getValue() == 1)) {
2019-10-29 15:19:43 +00:00
setPhase(8);
}
2021-06-22 14:26:56 +00:00
if (FWC.Flipflop.phase2OutputTemp and (gnd and !FWC.toPowerTemp and !FWC.speed80Temp) and FWC.Timer.eng1or2.getBoolValue()) {
2019-10-29 15:19:43 +00:00
setPhase(9);
}
2021-06-22 14:26:56 +00:00
if ((gnd and FWC.Timer.eng1and2OffTemp and currentPhase == 9) and FWC.Monostable.phase1OutputTemp) {
2019-10-29 15:19:43 +00:00
setPhase(10);
}
2019-10-31 18:57:19 +00:00
# FWC Inhibiting
2021-06-22 14:26:56 +00:00
currentPhase = pts.ECAM.fwcWarningPhase.getValue();
FWC.Flipflop.recallOutputTemp = FWC.Flipflop.recallOutput.getValue();
if (currentPhase >= 3 and currentPhase <= 5 and !FWC.Flipflop.recallOutputTemp) {
2019-10-31 18:57:19 +00:00
FWC.Timer.toInhibit.setValue(1);
} else {
FWC.Timer.toInhibit.setValue(0);
}
2021-06-22 14:26:56 +00:00
if (currentPhase == 7 or currentPhase == 8 and !FWC.Flipflop.recallOutputTemp) {
2019-10-31 18:57:19 +00:00
FWC.Timer.ldgInhibit.setValue(1);
} else {
FWC.Timer.ldgInhibit.setValue(0);
}
2019-10-29 15:19:43 +00:00
}
var _lastPhase = nil;
var setPhase = func(newPhase) {
if (newPhase >= 1 and newPhase <= 10 and _lastPhase != newPhase) {
pts.ECAM.fwcWarningPhase.setValue(newPhase);
2019-10-31 18:57:19 +00:00
FWC.Flipflop.recallReset.setValue(1);
2019-10-29 15:19:43 +00:00
_lastPhase = newPhase;
}
2019-10-31 18:57:19 +00:00
}
setlistener("/ECAM/buttons/recall-btn", func() {
FWC.Flipflop.recallSet.setValue(FWC.Btn.recall.getBoolValue());
}, 0, 0);