2018-04-09 15:07:31 +00:00
# A3XX Electronic Centralised Aircraft Monitoring System
# Jonathan Redpath (legoboyvdlp)
##############################################
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
2018-06-05 20:12:28 +00:00
var num_lines = 6;
var msg = nil;
var spacer = nil;
var line = nil;
2018-07-30 18:49:35 +00:00
var right_line = nil;
2018-08-03 14:48:34 +00:00
var wow = getprop("/gear/gear[1]/wow");
2018-11-16 18:31:29 +00:00
setprop("/ECAM/show-left-msg", 1);
2018-11-16 18:27:37 +00:00
setprop("/ECAM/show-right-msg", 1);
2018-08-02 19:42:14 +00:00
setprop("/ECAM/warnings/master-warning-light", 0);
setprop("/ECAM/warnings/master-caution-light", 0);
2018-06-05 20:12:28 +00:00
2018-07-30 18:49:35 +00:00
var warning = {
msg: "",
active: 0,
2018-07-31 14:11:12 +00:00
colour: "",
aural: "",
light: "",
2018-08-02 19:42:14 +00:00
noRepeat: 0,
new: func(msg,active,colour,aural,light,noRepeat) {
2018-07-30 18:49:35 +00:00
var t = {parents:[warning]};
t.msg = msg;
t.active = active;
2018-07-31 14:11:12 +00:00
t.colour = colour;
2018-08-02 19:42:14 +00:00
t.aural = aural;
t.light = light;
t.noRepeat = noRepeat;
2018-07-30 18:49:35 +00:00
return t
},
write: func() {
var line = 1;
while (getprop("/ECAM/msg/line" ~ line) != "") {
line = line + 1; # go to next line until empty line
2018-07-31 14:11:12 +00:00
}
2018-08-07 09:30:07 +00:00
if (getprop("/ECAM/msg/line" ~ line) == "" and me.active == 1 and me.msg != "") { # at empty line. Also checks if message is not blank to allow for some warnings with no displayed msg, eg stall
2018-07-31 14:11:12 +00:00
setprop("/ECAM/msg/line" ~ line, me.msg);
setprop("/ECAM/msg/linec" ~ line, me.colour);
2018-07-30 18:49:35 +00:00
}
},
2018-08-02 19:42:14 +00:00
warnlight: func() {
2018-09-28 11:26:20 +00:00
if ((me.light != "none" or me.light != "") and me.noRepeat == 0 and me.active == 1) { # only toggle light once per message, allows canceling
2018-08-02 19:42:14 +00:00
setprop("/ECAM/warnings/master-"~me.light~"-light", 1);
me.noRepeat = 1;
}
},
2018-08-03 09:36:02 +00:00
sound: func() {
2018-09-28 11:26:20 +00:00
if (me.active and (me.aural != "none" or me.aural != "") and getprop("/sim/sound/warnings/"~me.aural) != 1) {
2018-08-03 09:36:02 +00:00
setprop("/sim/sound/warnings/"~me.aural, 1);
} else if (!me.active or me.aural == "none") {
if (getprop("/sim/sound/warnings/"~me.aural) == 1) {
setprop("/sim/sound/warnings/"~me.aural, 0);
}
}
},
2018-07-30 18:49:35 +00:00
};
var memo = {
msg: "",
active: 0,
2018-07-31 14:11:12 +00:00
colour: "",
2018-08-02 19:42:14 +00:00
new: func(msg,active,colour) {
2018-07-30 18:49:35 +00:00
var t = {parents:[memo]};
t.msg = msg;
t.active = active;
2018-07-31 14:11:12 +00:00
t.colour = colour;
2018-07-30 18:49:35 +00:00
return t
},
write: func() {
var right_line = 1;
while (getprop("/ECAM/rightmsg/line" ~ right_line) != "") {
right_line = right_line + 1; # go to next line until empty line
}
2018-07-31 14:11:12 +00:00
2018-07-30 18:49:35 +00:00
if (getprop("/ECAM/rightmsg/line" ~ right_line) == "" and me.active == 1) { # at empty line
2018-07-31 14:11:12 +00:00
setprop("/ECAM/rightmsg/line" ~ right_line, me.msg);
setprop("/ECAM/rightmsg/linec" ~ right_line, me.colour);
2018-07-30 18:49:35 +00:00
}
},
};
2018-11-15 04:02:59 +00:00
2018-06-05 20:12:28 +00:00
# messages logic and added to arrays
2018-07-31 14:11:12 +00:00
var warnings = std.Vector.new([
2018-11-15 04:02:59 +00:00
var lg_not_dn = warning.new(msg: "L/G GEAR NOT DOWN", active: 0, colour: "r", aural: "crc", light: "warning", noRepeat: 0),
var pack1_fault = warning.new(msg: "AIR PACK 1 FAULT ", active: 0, colour: "a", aural: "chime", light: "caution", noRepeat: 0),
var pack1_fault_subwarn_1 = warning.new(msg: "-PACK 1.............OFF ", active: 0, colour: "b", aural: "none", light: "none", noRepeat: 0),
var pack2_fault = warning.new(msg: "AIR PACK 2 FAULT ", active: 0, colour: "a", aural: "chime", light: "caution", noRepeat: 0),
var pack2_fault_subwarn_1 = warning.new(msg: "-PACK 2.............OFF ", active: 0, colour: "b", aural: "none", light: "none", noRepeat: 0),
var park_brk_on = warning.new(msg: "PARK BRK ON", active: 0, colour: "a", aural: "chime", light: "caution", noRepeat: 0)
2018-10-02 13:37:50 +00:00
]);
2018-09-28 12:43:07 +00:00
2018-11-16 18:02:13 +00:00
var activeWarnings = std.Vector.new();
2018-10-02 13:37:50 +00:00
var leftmemos = std.Vector.new([
2018-11-15 04:02:59 +00:00
var company_alert = warning.new(msg: "COMPANY ALERT", active: 0, colour: "g", aural: "buzzer", light: "none", noRepeat: 0), # Not yet implemented, buzzer sound
var refuelg = warning.new(msg: "REFUELG", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0),
var irs_in_align = warning.new(msg: "IRS IN ALIGN", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0), # Not yet implemented
var gnd_splrs = warning.new(msg: "GND SPLRS ARMED", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0),
var seatbelts = warning.new(msg: "SEAT BELTS", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0),
var nosmoke = warning.new(msg: "NO SMOKING", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0),
var strobe_lt_off = warning.new(msg: "STROBE LT OFF", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0),
var outr_tk_fuel_xfrd = warning.new(msg: "OUTR TK FUEL XFRD", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0), # Not yet implemented
var fob_3T = warning.new(msg: "FOB BELOW 3T", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0),
var gpws_flap_mode_off = warning.new(msg: "GPWS FLAP MODE OFF", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0),
var atc_datalink_stby = warning.new(msg: "ATC DATALINK STBY", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0), # Not yet implemented
var company_datalink_stby = warning.new(msg: "COMPANY DATALINK STBY", active: 0, colour: "g", aural: "none", light: "none", noRepeat: 0) # Not yet implemented
2018-07-31 14:11:12 +00:00
]);
2018-07-30 18:49:35 +00:00
var memos = std.Vector.new([
2018-11-15 04:02:59 +00:00
var to_inhibit = memo.new(msg: "T.O. INHIBIT", active: 0, colour: "m"),
var ldg_inhibit = memo.new(msg: "LDG INHIBIT", active: 0, colour: "m"),
2018-11-16 18:27:37 +00:00
var land_asap_r = memo.new(msg: "LAND ASAP", active: 0, colour: "r"),
var land_asap_a = memo.new(msg: "LAND ASAP", active: 0, colour: "a"),
var ap_off = memo.new(msg: "AP OFF", active: 0, colour: "r"),
var athr_off = memo.new(msg: "A/THR OFF", active: 0, colour: "a"),
2018-11-15 04:02:59 +00:00
var spd_brk = memo.new(msg: "SPEED BRK", active: 0, colour: "g"),
var park_brk = memo.new(msg: "PARK BRK", active: 0, colour: "g"),
var ptu = memo.new(msg: "HYD PTU", active: 0, colour: "g"),
var rat = memo.new(msg: "RAT OUT", active: 0, colour: "g"),
var emer_gen = memo.new(msg: "EMER GEN", active: 0, colour: "g"),
var ram_air = memo.new(msg: "RAM AIR ON", active: 0, colour: "g"),
var nw_strg_disc = memo.new(msg: "NW STRG DISC", active: 0, colour: "g"), # Not yet implemented
var ignition = memo.new(msg: "IGNITION", active: 0, colour: "g"),
var cabin_ready = memo.new(msg: "CABIN READY", active: 0, colour: "g"), # Not yet implemented
var pred_ws_off = memo.new(msg: "PRED W/S OFF", active: 0, colour: "g"), # Not yet implemented
var terr_stby = memo.new(msg: "TERR STBY", active: 0, colour: "g"), # Not yet implemented
var tcas_stby = memo.new(msg: "TCAS STBY", active: 0, colour: "g"), # Not yet implemented
var acars_call = memo.new(msg: "ACARS CALL", active: 0, colour: "g"), # Not yet implemented
var company_call = memo.new(msg: "COMPANY CALL", active: 0, colour: "g"), # Not yet implemented
var satcom_alert = memo.new(msg: "SATCOM ALERT", active: 0, colour: "g"), # Not yet implemented
var acars_msg = memo.new(msg: "ACARS MSG", active: 0, colour: "g"), # Not yet implemented
var company_msg = memo.new(msg: "COMPANY MSG", active: 0, colour: "g"), # Not yet implemented
var eng_aice = memo.new(msg: "ENG A.ICE", active: 0, colour: "g"),
var wing_aice = memo.new(msg: "WING A.ICE", active: 0, colour: "g"),
var ice_not_det = memo.new(msg: "ICE NOT DET", active: 0, colour: "g"), # Not yet implemented
var hi_alt = memo.new(msg: "HI ALT", active: 0, colour: "g"), # Not yet implemented
var apu_avail = memo.new(msg: "APU AVAIL", active: 0, colour: "g"),
var apu_bleed = memo.new(msg: "APU BLEED", active: 0, colour: "g"), # Not yet implemented
var ldg_lt = memo.new(msg: "LDG LT", active: 0, colour: "g"),
var brk_fan = memo.new(msg: "BRK FAN", active: 0, colour: "g"), # Not yet implemented
var audio3_xfrd = memo.new(msg: "AUDIO 3 XFRD", active: 0, colour: "g"), # Not yet implemented
var switchg_pnl = memo.new(msg: "SWITCHG PNL", active: 0, colour: "g"), # Not yet implemented
var gpws_flap3 = memo.new(msg: "GPWS FLAP 3", active: 0, colour: "g"), # Not yet implemented
var hf_data_ovrd = memo.new(msg: "HF DATA OVRD", active: 0, colour: "g"), # Not yet implemented
var hf_voice = memo.new(msg: "HF VOICE", active: 0, colour: "g"), # Not yet implemented
var acars_stby = memo.new(msg: "ACARS STBY", active: 0, colour: "g"), # Not yet implemented
var vhf3_voice = memo.new(msg: "VHF3 VOICE", active: 0, colour: "g"),
var auto_brk_lo = memo.new(msg: "AUTO BRK LO", active: 0, colour: "g"),
var auto_brk_med = memo.new(msg: "AUTO BRK MED", active: 0, colour: "g"),
var auto_brk_max = memo.new(msg: "AUTO BRK MAX", active: 0, colour: "g"),
var auto_brk_off = memo.new(msg: "AUTO BRK OFF", active: 0, colour: "g"), # Not yet implemented
var man_ldg_elev = memo.new(msg: "MAN LDG ELEV", active: 0, colour: "g"), # Not yet implemented
var ctr_tk_feedg = memo.new(msg: "CTR TK FEEDG", active: 0, colour: "g"), # Not yet implemented
var fuelx = memo.new(msg: "FUEL X FEED", active: 0, colour: "g")
2018-07-30 18:49:35 +00:00
]);
2018-09-28 11:26:20 +00:00
var clearWarnings = std.Vector.new();
2018-07-30 18:49:35 +00:00
2018-06-05 20:12:28 +00:00
var ECAM_controller = {
loop: func() {
# check active messages
# config_warnings();
2018-11-16 18:02:13 +00:00
# messages_priority_3();
# messages_priority_2();
# messages_priority_1();
# messages_priority_0();
2018-11-16 18:27:37 +00:00
messages_memo();
messages_right_memo();
2018-06-05 20:12:28 +00:00
2018-07-31 14:11:12 +00:00
# clear display momentarily
2018-07-30 11:53:33 +00:00
2018-11-16 18:02:13 +00:00
for(var n = 1; n < 8; n += 1) {
setprop("/ECAM/msg/line" ~ n, "");
2018-06-06 20:46:41 +00:00
}
2018-07-30 11:53:33 +00:00
2018-11-16 18:02:13 +00:00
for(var n = 1; n < 8; n += 1) {
setprop("/ECAM/rightmsg/line" ~ n, "");
2018-07-30 11:53:33 +00:00
}
2018-07-31 14:11:12 +00:00
# write to ECAM
2018-11-16 18:02:13 +00:00
# foreach (var w; warnings.vector) {
# w.write();
# w.warnlight();
# w.sound();
# }
2018-07-31 14:11:12 +00:00
2018-10-02 13:37:50 +00:00
if (warnings.size() == 0) {
2018-11-16 18:02:13 +00:00
foreach (var l; leftmemos.vector) {
l.write();
2018-10-02 13:37:50 +00:00
}
}
2018-07-31 14:11:12 +00:00
foreach (var m; memos.vector) {
m.write();
}
2018-04-09 15:07:31 +00:00
},
2018-09-28 19:34:54 +00:00
};