2019-10-29 15:19:43 +00:00
# A3XX FWC Phases
2021-06-22 14:39:48 +00:00
# Copyright (c) 2021 Jonathan Redpath (legoboyvdlp)
2019-10-29 15:19:43 +00:00
2021-06-22 14:26:56 +00:00
var currentPhase = nil;
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
}
2022-01-03 20:46:42 +00:00
setlistener("/ECAM/buttons/recall-btn", func(val) {
FWC.Flipflop.recallSet.setValue(val.getBoolValue());
2019-10-31 18:57:19 +00:00
}, 0, 0);