2019-10-14 16:48:35 +00:00
# A3XX Electronic Centralised Aircraft Monitoring System
# Copyright (c) 2019 Jonathan Redpath (legoboyvdlp)
2020-02-07 16:10:54 +00:00
var lines = [props.globals.getNode("ECAM/msg/line1", 1), props.globals.getNode("ECAM/msg/line2", 1), props.globals.getNode("ECAM/msg/line3", 1), props.globals.getNode("ECAM/msg/line4", 1), props.globals.getNode("ECAM/msg/line5", 1), props.globals.getNode("ECAM/msg/line6", 1), props.globals.getNode("ECAM/msg/line7", 1), props.globals.getNode("ECAM/msg/line8", 1)];
var linesCol = [props.globals.getNode("ECAM/msg/linec1", 1), props.globals.getNode("ECAM/msg/linec2", 1), props.globals.getNode("ECAM/msg/linec3", 1), props.globals.getNode("ECAM/msg/linec4", 1), props.globals.getNode("ECAM/msg/linec5", 1), props.globals.getNode("ECAM/msg/linec6", 1), props.globals.getNode("ECAM/msg/linec7", 1), props.globals.getNode("ECAM/msg/linec8", 1)];
var rightLines = [props.globals.getNode("ECAM/rightmsg/line1", 1), props.globals.getNode("ECAM/rightmsg/line2", 1), props.globals.getNode("ECAM/rightmsg/line3", 1), props.globals.getNode("ECAM/rightmsg/line4", 1), props.globals.getNode("ECAM/rightmsg/line5", 1), props.globals.getNode("ECAM/rightmsg/line6", 1), props.globals.getNode("ECAM/rightmsg/line7", 1), props.globals.getNode("ECAM/rightmsg/line8", 1)];
var rightLinesCol = [props.globals.getNode("ECAM/rightmsg/linec1", 1), props.globals.getNode("ECAM/rightmsg/linec2", 1), props.globals.getNode("ECAM/rightmsg/linec3", 1), props.globals.getNode("ECAM/rightmsg/linec4", 1), props.globals.getNode("ECAM/rightmsg/linec5", 1), props.globals.getNode("ECAM/rightmsg/linec6", 1), props.globals.getNode("ECAM/rightmsg/linec7", 1), props.globals.getNode("ECAM/rightmsg/linec8", 1)];
var statusLines = [props.globals.getNode("ECAM/status/line1", 1), props.globals.getNode("ECAM/status/line2", 1), props.globals.getNode("ECAM/status/line3", 1), props.globals.getNode("ECAM/status/line4", 1), props.globals.getNode("ECAM/status/line5", 1), props.globals.getNode("ECAM/status/line6", 1), props.globals.getNode("ECAM/status/line7", 1), props.globals.getNode("ECAM/status/line8", 1)];
var statusLinesCol = [props.globals.getNode("ECAM/status/linec1", 1), props.globals.getNode("ECAM/status/linec2", 1), props.globals.getNode("ECAM/status/linec3", 1), props.globals.getNode("ECAM/status/linec4", 1), props.globals.getNode("ECAM/status/linec5", 1), props.globals.getNode("ECAM/status/linec6", 1), props.globals.getNode("ECAM/status/linec7", 1), props.globals.getNode("ECAM/status/linec8", 1)];
2019-10-14 16:48:35 +00:00
var leftOverflow = props.globals.initNode("/ECAM/warnings/overflow-left", 0, "BOOL");
var rightOverflow = props.globals.initNode("/ECAM/warnings/overflow-right", 0, "BOOL");
var overflow = props.globals.initNode("/ECAM/warnings/overflow", 0, "BOOL");
var lights = [props.globals.initNode("/ECAM/warnings/master-warning-light", 0, "BOOL"), props.globals.initNode("/ECAM/warnings/master-caution-light", 0, "BOOL")];
2020-10-31 23:59:18 +00:00
var aural = [props.globals.initNode("/sim/sound/warnings/crc", 0, "BOOL"), props.globals.initNode("/sim/sound/warnings/chime", 0, "BOOL"), props.globals.initNode("/sim/sound/warnings/cricket", 0, "BOOL"), props.globals.initNode("/sim/sound/warnings/retard", 0, "BOOL"), props.globals.initNode("/sim/sound/warnings/cchord", 0, "BOOL")];
2019-10-14 16:48:35 +00:00
var warningFlash = props.globals.initNode("/ECAM/warnings/master-warning-flash", 0, "BOOL");
var lineIndex = 0;
var rightLineIndex = 0;
var statusIndex = 0;
var flash = 0;
var hasCleared = 0;
var statusFlag = 0;
2020-01-02 21:13:18 +00:00
var counter = 0;
2020-11-16 21:59:47 +00:00
var counterClear = 0;
2020-01-02 21:13:18 +00:00
var noMainMsg = 0;
var storeFirstWarning = nil;
2019-10-14 16:48:35 +00:00
2020-05-06 16:05:53 +00:00
var warningNodes = {
2020-05-06 20:34:08 +00:00
Logic: {
2020-10-31 23:59:18 +00:00
altitudeAlert: props.globals.initNode("/ECAM/warnings/altitude-alert/c-chord"),
altitudeAlertSteady: props.globals.initNode("/ECAM/warnings/altitude-alert/altitude-alert-steady"),
altitudeAlertFlash: props.globals.initNode("/ECAM/warnings/altitude-alert/altitude-alert-flash"),
2020-05-06 20:34:08 +00:00
crossbleedFault: props.globals.initNode("/ECAM/warnings/logic/crossbleed-fault"),
crossbleedWai: props.globals.initNode("/ECAM/warnings/logic/crossbleed-wai"),
2020-05-10 22:58:26 +00:00
bleed1LoTempUnsuc: props.globals.initNode("/ECAM/warnings/logic/bleed-1-lo-temp-unsucc"),
bleed1LoTempXbleed: props.globals.initNode("/ECAM/warnings/logic/bleed-1-lo-temp-xbleed"),
bleed1LoTempBleed: props.globals.initNode("/ECAM/warnings/logic/bleed-1-lo-temp-bleed"),
bleed1LoTempPack: props.globals.initNode("/ECAM/warnings/logic/bleed-1-lo-temp-pack"),
bleed1WaiAvail: props.globals.initNode("/ECAM/warnings/logic/bleed-1-wai-avail"),
bleed2LoTempUnsuc: props.globals.initNode("/ECAM/warnings/logic/bleed-2-lo-temp-unsucc"),
bleed2LoTempXbleed: props.globals.initNode("/ECAM/warnings/logic/bleed-2-lo-temp-xbleed"),
bleed2LoTempBleed: props.globals.initNode("/ECAM/warnings/logic/bleed-2-lo-temp-bleed"),
bleed2LoTempPack: props.globals.initNode("/ECAM/warnings/logic/bleed-2-lo-temp-pack"),
bleed2WaiAvail: props.globals.initNode("/ECAM/warnings/logic/bleed-2-wai-avail"),
2020-05-12 15:57:45 +00:00
waiSysfault: props.globals.initNode("/ECAM/warnings/logic/wing-anti-ice-sys-fault"),
waiLclosed: props.globals.initNode("/ECAM/warnings/flipflop/wing-anti-ice-left-closed"),
waiRclosed: props.globals.initNode("/ECAM/warnings/flipflop/wing-anti-ice-right-closed"),
procWaiShutdown: props.globals.initNode("/ECAM/warnings/logic/proc-wai-shutdown-output"),
waiGndFlight: props.globals.initNode("/ECAM/warnings/logic/wing-anti-ice-gnd-fault"),
2020-05-29 19:20:46 +00:00
pack12Fault: props.globals.initNode("/ECAM/warnings/logic/pack-1-2-fault"),
pack1ResetPb: props.globals.initNode("/ECAM/warnings/logic/reset-pack-1-switch-cmd"),
pack2ResetPb: props.globals.initNode("/ECAM/warnings/logic/reset-pack-2-switch-cmd"),
2020-06-20 19:52:04 +00:00
cabinFans: props.globals.initNode("/ECAM/warnings/logic/cabin-fans-fault"),
2020-07-16 16:00:10 +00:00
rtlu1Fault: props.globals.initNode("/ECAM/warnings/logic/rud-trav-lim-sys-1-fault"),
rtlu2Fault: props.globals.initNode("/ECAM/warnings/logic/rud-trav-lim-sys-2-fault"),
rtlu12Fault: props.globals.initNode("/ECAM/warnings/logic/rud-trav-lim-sys-fault"),
2020-07-17 15:57:10 +00:00
fac12Fault: props.globals.initNode("/ECAM/warnings/logic/fac-12-fault"),
fac1Fault: props.globals.initNode("/ECAM/warnings/logic/fac-1-fault"),
fac2Fault: props.globals.initNode("/ECAM/warnings/logic/fac-2-fault"),
2020-10-17 11:55:09 +00:00
stallWarn: props.globals.initNode("/ECAM/warnings/logic/stall/stall-warn-on"),
2020-07-17 15:57:10 +00:00
yawDamper12Fault: props.globals.initNode("/ECAM/warnings/logic/yaw-damper-12-fault"),
2020-10-17 18:57:21 +00:00
gearNotDown1: props.globals.initNode("/ECAM/warnings/fctl/gear-not-down-not-cancellable"),
gearNotDown2: props.globals.initNode("/ECAM/warnings/fctl/gear-not-down-cancellable"),
gearNotDownLocked: props.globals.initNode("/ECAM/warnings/fctl/gear-not-down-locked"),
gearNotDownLockedFlipflop: props.globals.initNode("/ECAM/warnings/fctl/gear-not-downlocked-output"),
2020-10-18 16:37:23 +00:00
blueGreen: props.globals.initNode("/ECAM/warnings/hyd/blue-green-failure"),
blueGreenFuel: props.globals.initNode("/ECAM/warnings/hyd/blue-green-fuel-consumpt"),
blueYellow: props.globals.initNode("/ECAM/warnings/hyd/blue-yellow-failure"),
blueYellowFuel: props.globals.initNode("/ECAM/warnings/hyd/blue-yellow-fuel-consumpt"),
greenYellow: props.globals.initNode("/ECAM/warnings/hyd/green-yellow-failure"),
greenYellowFuel: props.globals.initNode("/ECAM/warnings/hyd/green-yellow-fuel-consumpt"),
2020-11-26 18:43:22 +00:00
leftElevFail: props.globals.initNode("/ECAM/warnings/fctl/leftElevFault"),
rightElevFail: props.globals.initNode("/ECAM/warnings/fctl/rightElevFault"),
2021-01-30 16:12:34 +00:00
flapNotZero: props.globals.initNode("/ECAM/warnings/fctl/flaps-not-zero"),
2021-01-30 18:31:06 +00:00
slatsConfig: props.globals.initNode("/ECAM/warnings/fctl/slats-config-output"),
flapsConfig: props.globals.initNode("/ECAM/warnings/fctl/flaps-config-output"),
spdBrkConfig: props.globals.initNode("/ECAM/warnings/fctl/spd-brk-config-output"),
pitchTrimConfig: props.globals.initNode("/ECAM/warnings/fctl/pitch-trim-config-output"),
rudTrimConfig: props.globals.initNode("/ECAM/warnings/fctl/rudder-trim-config-output"),
parkBrkConfig: props.globals.initNode("/ECAM/warnings/fctl/park-brk-config-output"),
slatsConfig2: props.globals.initNode("/ECAM/warnings/fctl/slats-config-range"),
flapsConfig2: props.globals.initNode("/ECAM/warnings/fctl/flaps-config-range"),
spdBrkConfig2: props.globals.initNode("/ECAM/warnings/fctl/spd-brk-config-range"),
pitchTrimConfig2: props.globals.initNode("/ECAM/warnings/fctl/pitch-trim-config-range"),
rudTrimConfig2: props.globals.initNode("/ECAM/warnings/fctl/rudder-trim-config-range"),
2021-01-31 17:24:49 +00:00
dc2FuelConsumptionIncreased: props.globals.initNode("/ECAM/warnings/logic/dc-2-fuel-consumption-increased"),
dc2FMSPredictions: props.globals.initNode("/ECAM/warnings/logic/dc-2-fms-predictions-unreliable"),
2021-02-01 18:39:25 +00:00
thrLeversNotSet: props.globals.initNode("/ECAM/warnings/logic/eng/thr-lever-not-set"),
revSet: props.globals.initNode("/ECAM/warnings/logic/eng/reverse-set"),
eng1Fail: props.globals.initNode("/ECAM/warnings/logic/eng/eng-1-fail"),
eng2Fail: props.globals.initNode("/ECAM/warnings/logic/eng/eng-2-fail"),
phase5Trans: props.globals.initNode("/ECAM/warnings/logic/eng/phase-5-output"),
2020-05-06 20:34:08 +00:00
},
2020-05-06 16:05:53 +00:00
Timers: {
2020-05-06 20:34:08 +00:00
apuFaultOutput: props.globals.initNode("/ECAM/warnings/timer/apu-fault-output"),
2020-05-06 16:05:53 +00:00
bleed1Fault: props.globals.initNode("/ECAM/warnings/timer/bleed-1-fault"),
bleed1FaultOutput: props.globals.initNode("/ECAM/warnings/timer/bleed-1-fault-output"),
bleed2Fault: props.globals.initNode("/ECAM/warnings/timer/bleed-2-fault"),
bleed2FaultOutput: props.globals.initNode("/ECAM/warnings/timer/bleed-2-fault-output"),
2020-05-10 22:58:26 +00:00
bleed1NotShutOutput: props.globals.initNode("/ECAM/warnings/timer/prv-1-not-shut-output"),
bleed2NotShutOutput: props.globals.initNode("/ECAM/warnings/timer/prv-2-not-shut-output"),
bleed1And2LoTemp: props.globals.initNode("/ECAM/warnings/timer/bleed-1-and-2-low-temp"),
bleed1And2LoTempOutput: props.globals.initNode("/ECAM/warnings/timer/bleed-1-and-2-low-temp-output"),
2020-05-11 12:45:00 +00:00
bleed1Off60Output: props.globals.initNode("/ECAM/warnings/logic/bleed-1-off-60-output"),
bleed1Off5Output: props.globals.initNode("/ECAM/warnings/logic/bleed-1-off-5-output"),
bleed2Off60Output: props.globals.initNode("/ECAM/warnings/logic/bleed-2-off-60-output"),
bleed2Off5Output: props.globals.initNode("/ECAM/warnings/logic/bleed-2-off-5-output"),
2020-05-12 12:47:49 +00:00
eng1AiceNotClsd: props.globals.initNode("/ECAM/warnings/timer/eng-aice-1-open-output"),
eng2AiceNotClsd: props.globals.initNode("/ECAM/warnings/timer/eng-aice-2-open-output"),
eng1AiceNotOpen: props.globals.initNode("/ECAM/warnings/timer/eng-aice-1-closed-output"),
eng2AiceNotOpen: props.globals.initNode("/ECAM/warnings/timer/eng-aice-2-closed-output"),
2020-10-17 18:57:21 +00:00
LRElevFault: props.globals.initNode("/ECAM/warnings/fctl/lrElevFault-output"),
2020-11-26 18:43:22 +00:00
altnLaw: props.globals.initNode("/ECAM/warnings/fctl/altn-law-output"),
directLaw: props.globals.initNode("/ECAM/warnings/fctl/direct-law-output"),
2020-05-12 15:57:45 +00:00
waiLhiPr: props.globals.initNode("/ECAM/warnings/timer/wing-hi-pr-left"),
waiRhiPr: props.globals.initNode("/ECAM/warnings/timer/wing-hi-pr-right"),
2020-05-29 19:20:46 +00:00
pack1Fault: props.globals.initNode("/ECAM/warnings/timer/pack-1-fault-2"),
pack2Fault: props.globals.initNode("/ECAM/warnings/timer/pack-2-fault-2"),
2020-05-29 19:50:05 +00:00
pack1Off: props.globals.initNode("/ECAM/warnings/timer/pack-1-off"),
pack2Off: props.globals.initNode("/ECAM/warnings/timer/pack-2-off"),
2020-06-20 19:52:04 +00:00
trimAirFault: props.globals.initNode("/ECAM/warnings/timer/trim-air-fault"),
2020-07-17 15:57:10 +00:00
yawDamper1Fault: props.globals.initNode("/ECAM/warnings/timer/yaw-damper-1-fault"),
yawDamper2Fault: props.globals.initNode("/ECAM/warnings/timer/yaw-damper-2-fault"),
2020-08-13 10:32:28 +00:00
navTerrFault: props.globals.initNode("/ECAM/warnings/timer/nav-gpws-terr-fault"),
2020-11-26 18:43:22 +00:00
leftElevFail: props.globals.initNode("/ECAM/warnings/fctl/leftElevFault-output"),
rightElevFail: props.globals.initNode("/ECAM/warnings/fctl/rightElevFault-output"),
2021-01-31 17:24:49 +00:00
staticInverter: props.globals.initNode("/systems/electrical/some-electric-thingie/static-inverter-timer"),
2020-05-10 22:58:26 +00:00
},
Flipflops: {
2020-10-14 17:08:18 +00:00
apuGenFault: props.globals.initNode("/ECAM/warnings/flipflop/apu-gen-fault"),
apuGenFaultOnOff: props.globals.initNode("/ECAM/warnings/flipflop/apu-gen-fault-on-off"),
2020-05-10 22:58:26 +00:00
bleed1LowTemp: props.globals.initNode("/ECAM/warnings/logic/bleed-1-low-temp-flipflop-output"),
bleed2LowTemp: props.globals.initNode("/ECAM/warnings/logic/bleed-2-low-temp-flipflop-output"),
2020-10-14 17:08:18 +00:00
gen1Fault: props.globals.initNode("/ECAM/warnings/flipflop/gen-1-fault"),
gen2Fault: props.globals.initNode("/ECAM/warnings/flipflop/gen-2-fault"),
gen1FaultOnOff: props.globals.initNode("/ECAM/warnings/flipflop/gen-1-fault-on-off"),
gen2FaultOnOff: props.globals.initNode("/ECAM/warnings/flipflop/gen-2-fault-on-off"),
2020-05-28 15:21:54 +00:00
pack1Ovht: props.globals.initNode("/ECAM/warnings/flipflop/pack-1-ovht"),
pack2Ovht: props.globals.initNode("/ECAM/warnings/flipflop/pack-2-ovht"),
2020-10-17 11:55:09 +00:00
parkBrk: props.globals.initNode("/ECAM/warnings/config/park-brk/park-brk-output"),
2020-10-16 21:42:09 +00:00
eng1ThrLvrAbvIdle: props.globals.initNode("/ECAM/warnings/logic/eng/eng-1-thr-lvr-abv-idle"),
eng2ThrLvrAbvIdle: props.globals.initNode("/ECAM/warnings/logic/eng/eng-2-thr-lvr-abv-idle"),
2020-05-06 16:05:53 +00:00
},
};
2019-10-14 16:48:35 +00:00
var warning = {
2020-01-02 11:57:46 +00:00
new: func(msg,colour = "g",aural = 9,light = 9,isMainMsg = 0,lastSubmsg = 0, sdPage = "nil", isMemo = 0) {
2019-10-14 16:48:35 +00:00
var t = {parents:[warning]};
t.msg = msg;
t.colour = colour;
t.aural = aural;
t.light = light;
2020-01-02 11:57:46 +00:00
t.isMainMsg = isMainMsg;
2019-10-14 16:48:35 +00:00
t.lastSubmsg = lastSubmsg;
t.active = 0;
t.noRepeat = 0;
t.noRepeat2 = 0;
t.clearFlag = 0;
t.sdPage = sdPage;
2019-10-29 15:19:43 +00:00
t.isMemo = isMemo;
2019-10-14 16:48:35 +00:00
t.hasCalled = 0;
2019-11-02 14:52:06 +00:00
t.wasActive = 0;
2019-10-14 16:48:35 +00:00
return t
},
write: func() {
if (me.active == 0) { return; }
2019-11-02 15:27:01 +00:00
me.wasActive = 1;
2019-10-14 16:48:35 +00:00
lineIndex = 0;
2020-01-01 21:30:13 +00:00
while (lineIndex <= 7 and lines[lineIndex].getValue() != "") {
2019-10-14 16:48:35 +00:00
lineIndex = lineIndex + 1; # go to next line until empty line
}
2020-01-01 21:30:13 +00:00
if (lineIndex == 8) {
2019-10-14 16:48:35 +00:00
leftOverflow.setBoolValue(1);
} elsif (leftOverflow.getBoolValue()) {
leftOverflow.setBoolValue(0);
}
2020-01-01 21:30:13 +00:00
if (lineIndex <= 7) {
if (lines[lineIndex].getValue() == "" and me.msg != "") { # at empty line. Also checks if message is not blank to allow for some warnings with no displayed msg, eg stall
lines[lineIndex].setValue(me.msg);
linesCol[lineIndex].setValue(me.colour);
}
2019-10-14 16:48:35 +00:00
}
},
warnlight: func() {
2019-11-02 16:20:08 +00:00
if (me.light > 1) { return; }
if (me.active == 0 and me.wasActive == 1) {
2019-11-02 14:52:06 +00:00
lights[me.light].setBoolValue(0);
me.wasActive = 0;
}
2019-11-02 16:20:08 +00:00
if (me.noRepeat == 1 or me.active == 0) { return; }
lights[me.light].setBoolValue(1);
me.noRepeat = 1;
2019-10-14 16:48:35 +00:00
},
sound: func() {
2020-10-16 21:42:09 +00:00
if (me.aural > 3) { return; }
2019-11-02 16:20:08 +00:00
if (me.active == 0 and me.wasActive == 1) {
2019-10-14 16:48:35 +00:00
aural[me.aural].setBoolValue(0);
2019-11-02 14:52:06 +00:00
me.wasActive = 0;
2019-10-14 16:48:35 +00:00
}
2019-11-02 16:20:08 +00:00
if (me.noRepeat2 == 1 or me.active == 0) { return; }
if (me.aural != 0) {
aural[me.aural].setBoolValue(0);
2020-01-02 21:13:18 +00:00
settimer(func() {
aural[me.aural].setBoolValue(1);
}, 0.15);
} else {
2020-10-16 21:42:09 +00:00
aural[me.aural].setBoolValue(1);
2019-11-02 16:20:08 +00:00
}
me.noRepeat2 = 1;
2019-10-14 16:48:35 +00:00
},
callPage: func() {
if (me.sdPage == "nil" or me.hasCalled == 1) { return; }
2020-05-16 20:04:03 +00:00
ecam.SystemDisplay.failCall(me.sdPage);
2019-10-14 16:48:35 +00:00
me.hasCalled = 1;
}
};
var memo = {
new: func(msg,colour = "g") {
var t = {parents:[memo]};
t.msg = msg;
t.colour = colour;
t.active = 0;
return t
},
write: func() {
if (me.active == 1) {
rightLineIndex = 0;
while (rightLines[rightLineIndex].getValue() != "" and rightLineIndex <= 7) {
rightLineIndex = rightLineIndex + 1; # go to next line until empty line
}
if (rightLineIndex > 7) {
rightOverflow.setBoolValue(1);
} elsif (rightOverflow.getBoolValue()) {
rightOverflow.setBoolValue(0);
}
if (rightLines[rightLineIndex].getValue() == "" and rightLineIndex <= 7) { # at empty line
rightLines[rightLineIndex].setValue(me.msg);
rightLinesCol[rightLineIndex].setValue(me.colour);
}
}
},
};
var status = {
new: func(msg,colour) {
var t = {parents:[status]};
t.msg = msg;
t.colour = colour;
t.active = 0;
return t
},
write: func() {
if (me.active == 1) {
statusIndex = 0;
while (statusLines[statusIndex].getValue() != "" and statusIndex <= 7) {
statusIndex = statusIndex + 1; # go to next line until empty line
}
if (statusLines[statusIndex].getValue() == "" and statusIndex <= 7) { # at empty line
statusLines[rightLineIndex].setValue(me.msg);
statusLinesCol[rightLineIndex].setValue(me.colour);
}
}
},
};
var ECAM_controller = {
2019-10-31 18:57:19 +00:00
_recallCounter: 0,
2019-11-06 19:09:42 +00:00
_noneActive: 0,
2020-11-16 21:59:47 +00:00
_ready: 0,
2019-10-14 16:48:35 +00:00
init: func() {
me.reset();
2020-11-16 21:59:47 +00:00
me._ready = 1;
2019-10-14 16:48:35 +00:00
},
2020-11-16 21:59:47 +00:00
loop: func(notification) {
if (!me._ready) {
return;
}
2020-09-15 17:41:40 +00:00
if ((systems.ELEC.Bus.acEss.getValue() >= 110 or systems.ELEC.Bus.ac2.getValue() >= 110) and !pts.Acconfig.running.getBoolValue()) {
2019-10-29 15:19:43 +00:00
# check active messages
2019-10-14 16:48:35 +00:00
messages_priority_3();
messages_priority_2();
messages_priority_1();
messages_priority_0();
2019-10-29 15:19:43 +00:00
messages_config_memo();
2019-10-14 16:48:35 +00:00
messages_memo();
messages_right_memo();
} else {
foreach (var w; warnings.vector) {
w.active = 0;
}
shutUpYou();
}
# clear display momentarily
for(var n = 0; n <= 7; n += 1) {
lines[n].setValue("");
}
for(var n = 0; n <= 7; n += 1) {
rightLines[n].setValue("");
}
# write to ECAM
2020-11-16 21:59:47 +00:00
counter = 0;
2019-10-14 16:48:35 +00:00
2020-09-15 17:41:40 +00:00
if (!pts.Acconfig.running.getBoolValue()) {
2019-11-01 10:59:18 +00:00
foreach (var w; warnings.vector) {
if (w.active == 1) {
2020-01-02 21:13:18 +00:00
if (counter < 9) {
w.write();
counter += 1;
}
2019-11-01 10:59:18 +00:00
w.warnlight();
w.sound();
2019-11-02 16:20:08 +00:00
} elsif (w.wasActive == 1) {
w.warnlight();
w.sound();
2019-11-01 10:59:18 +00:00
}
2019-10-14 16:48:35 +00:00
}
}
2019-10-29 15:19:43 +00:00
if (lines[0].getValue() == "" and flash == 0) { # disable left memos if a warning exists. Warnings are processed first, so this stops leftmemos if line1 is not empty
foreach (var c; configmemos.vector) {
c.write();
}
}
2019-10-14 16:48:35 +00:00
if (lines[0].getValue() == "" and flash == 0) { # disable left memos if a warning exists. Warnings are processed first, so this stops leftmemos if line1 is not empty
foreach (var l; leftmemos.vector) {
l.write();
}
}
foreach (var sL; specialLines.vector) {
sL.write();
}
foreach (var sF; secondaryFailures.vector) {
sF.write();
}
foreach (var m; memos.vector) {
m.write();
}
if (leftOverflow.getBoolValue() == 1 or leftOverflow.getBoolValue() == 1) {
overflow.setBoolValue(1);
} elsif (leftOverflow.getBoolValue() == 0 and leftOverflow.getBoolValue() == 0) {
overflow.setBoolValue(0);
}
},
reset: func() {
2020-11-16 21:59:47 +00:00
me._ready = 0;
2019-10-14 16:48:35 +00:00
foreach (var w; warnings.vector) {
if (w.active == 1) {
w.active = 0;
}
}
2019-10-29 15:19:43 +00:00
foreach (var l; configmemos.vector) {
if (l.active == 1) {
l.active = 0;
}
}
2019-10-14 16:48:35 +00:00
foreach (var l; leftmemos.vector) {
if (l.active == 1) {
l.active = 0;
}
}
foreach (var sL; specialLines.vector) {
if (sL.active == 1) {
sL.active = 0;
}
}
foreach (var sF; secondaryFailures.vector) {
if (sF.active == 1) {
sF.active = 0;
}
}
foreach (var m; memos.vector) {
if (m.active == 1) {
m.active = 0;
}
}
2021-01-30 16:12:34 +00:00
me._ready = 1;
2019-10-14 16:48:35 +00:00
},
clear: func() {
hasCleared = 0;
2020-11-16 21:59:47 +00:00
counterClear = 0;
2020-01-02 21:13:18 +00:00
noMainMsg = 0;
storeFirstWarning = nil;
2019-10-14 16:48:35 +00:00
2020-01-02 21:13:18 +00:00
# first go through the first eight, see how many mainMsg there are
foreach (var w; warnings.vector) {
2020-11-16 21:59:47 +00:00
if (counterClear >= 8) { break; }
2020-01-02 21:13:18 +00:00
if (w.active == 1 and w.clearFlag != 1 and w.isMemo != 1) {
2020-11-16 21:59:47 +00:00
counterClear += 1;
2020-01-02 21:13:18 +00:00
if (w.isMainMsg == 1) {
if (noMainMsg == 0) {
storeFirstWarning = w;
}
noMainMsg += 1;
}
}
}
# then, if there is an overflow and noMainMsg == 1, we clear the first shown ones
if (leftOverflow.getBoolValue() and noMainMsg == 1) {
2020-11-16 21:59:47 +00:00
counterClear = 0;
2019-10-14 16:48:35 +00:00
foreach (var w; warnings.vector) {
2020-11-16 21:59:47 +00:00
if (counterClear >= 8) { break; }
2019-10-29 15:19:43 +00:00
if (w.active == 1 and w.clearFlag != 1 and w.isMemo != 1) {
2020-11-16 21:59:47 +00:00
counterClear += 1;
2020-01-02 11:57:46 +00:00
if (w.isMainMsg == 1) { continue; }
2019-10-14 16:48:35 +00:00
w.clearFlag = 1;
hasCleared = 1;
statusFlag = 1;
}
}
2020-01-02 21:13:18 +00:00
}
# else, we clear the first mainMsg stored
else {
if (storeFirstWarning != nil) {
if (storeFirstWarning.active == 1 and storeFirstWarning.clearFlag != 1 and storeFirstWarning.isMainMsg == 1 and storeFirstWarning.isMemo != 1) {
storeFirstWarning.clearFlag = 1;
2019-10-14 16:48:35 +00:00
hasCleared = 1;
statusFlag = 1;
}
}
}
2020-01-01 21:30:13 +00:00
if (statusFlag == 1 and lines[0].getValue() == "") {
2020-05-16 20:04:03 +00:00
ecam.SystemDisplay.manCall("sts");
2019-10-14 16:48:35 +00:00
statusFlag = 0;
}
},
recall: func() {
2019-11-06 19:09:42 +00:00
me._noneActive = 1;
2019-10-31 18:57:19 +00:00
me._recallCounter = 0;
2019-10-14 16:48:35 +00:00
foreach (var w; warnings.vector) {
if (w.clearFlag == 1) {
w.noRepeat = 0;
w.clearFlag = 0;
2019-10-31 18:57:19 +00:00
me._recallCounter += 1;
2019-10-14 16:48:35 +00:00
}
2019-11-06 19:09:42 +00:00
if (w.active == 1) {
me._noneActive = 0;
}
2019-10-14 16:48:35 +00:00
}
2019-10-31 18:57:19 +00:00
2019-11-06 19:09:42 +00:00
if (me._recallCounter == 0 and me._noneActive) {
2019-10-31 18:57:19 +00:00
FWC.Btn.recallStsNormal.setValue(1);
settimer(func() {
if (FWC.Btn.recallStsNormal.getValue() == 1) { # catch unexpected error, trying something new here
FWC.Btn.recallStsNormal.setValue(0);
} else {
die("Exception in ECAM-controller.nas, line 316");
}
}, 0.1);
}
2019-10-14 16:48:35 +00:00
},
warningReset: func(warning) {
2019-12-28 15:53:17 +00:00
if (warning.aural != 9 and warning.active == 1) {
aural[warning.aural].setBoolValue(0);
}
2019-10-14 16:48:35 +00:00
warning.active = 0;
warning.noRepeat = 0;
warning.noRepeat2 = 0;
2020-01-01 21:49:44 +00:00
# don't set .wasActive to 0, warnlight / sound funcs do that
2019-10-14 16:48:35 +00:00
},
};
setlistener("/systems/electrical/bus/dc-ess", func {
2021-01-30 16:12:34 +00:00
if (systems.ELEC.Bus.dcEss.getValue() < 25) {
2019-10-14 16:48:35 +00:00
ECAM_controller.reset();
}
}, 0, 0);
# Flash Master Warning Light
var shutUpYou = func() {
lights[0].setBoolValue(0);
}
var warnTimer = maketimer(0.25, func {
if (!lights[0].getBoolValue()) {
warnTimer.stop();
warningFlash.setBoolValue(0);
} else if (!warningFlash.getBoolValue()) {
warningFlash.setBoolValue(1);
} else {
warningFlash.setBoolValue(0);
}
});
setlistener("/ECAM/warnings/master-warning-light", func {
if (lights[0].getBoolValue()) {
warningFlash.setBoolValue(0);
warnTimer.start();
} else {
warnTimer.stop();
warningFlash.setBoolValue(0);
}
}, 0, 0);