props.nas

This commit is contained in:
Jonathan Redpath 2019-02-12 19:18:55 +00:00
parent 2f4e5cf5d9
commit 27e4f11421
4 changed files with 70 additions and 75 deletions

View file

@ -1584,7 +1584,7 @@
</condition> </condition>
</animation> </animation>
<!--<animation> <animation>
<type>pick</type> <type>pick</type>
<object-name>ecam_rcl</object-name> <object-name>ecam_rcl</object-name>
<action> <action>
@ -1598,10 +1598,10 @@
</greater-than-equals> </greater-than-equals>
</condition> </condition>
<command>nasal</command> <command>nasal</command>
<script>ecam.rclBTN();</script> <script>ecam.ECAM_controller.recall();</script>
</binding> </binding>
</action> </action>
</animation>--> </animation>
<animation> <animation>
<type>pick</type> <type>pick</type>

View file

@ -1,28 +1,29 @@
# A3XX Electronic Centralised Aircraft Monitoring System # A3XX Electronic Centralised Aircraft Monitoring System
# Copyright (c) 2019 Jonathan Redpath (legoboyvdlp) # Copyright (c) 2019 Jonathan Redpath (legoboyvdlp)
var num_lines = 6; var leftmsgEnable = props.globals.initNode("/ECAM/show-left-msg", 1, "BOOL");
var msg = nil; var rightmsgEnable = props.globals.initNode("/ECAM/show-right-msg", 1, "BOOL");
var spacer = nil;
var line = nil;
var right_line = nil;
var light = 0;
var flash = 0;
setprop("/ECAM/show-left-msg", 1);
setprop("/ECAM/show-right-msg", 1);
setprop("/ECAM/warnings/master-warning-light", 0);
setprop("/ECAM/warnings/master-warning-flash", 0);
setprop("/ECAM/warnings/master-caution-light", 0);
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 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 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)];
var leftOverflow = props.globals.initNode("/ECAM/warnings/overflow-left", 0, "BOOL"); var leftOverflow = props.globals.initNode("/ECAM/warnings/overflow-left", 0, "BOOL");
var rightOverflow = props.globals.initNode("/ECAM/warnings/overflow-right", 0, "BOOL"); var rightOverflow = props.globals.initNode("/ECAM/warnings/overflow-right", 0, "BOOL");
var overflow = props.globals.initNode("/ECAM/warnings/overflow", 0, "BOOL"); var overflow = props.globals.initNode("/ECAM/warnings/overflow", 0, "BOOL");
var dc_ess = props.globals.getNode("/systems/electrical/bus/dc-ess", 1);
var lights = [props.globals.initNode("/ECAM/warnings/master-warning-light", 0, "BOOL"), props.globals.initNode("/ECAM/warnings/master-caution-light", 0, "BOOL")]; var lights = [props.globals.initNode("/ECAM/warnings/master-warning-light", 0, "BOOL"), props.globals.initNode("/ECAM/warnings/master-caution-light", 0, "BOOL")];
var aural = [props.globals.initNode("/sim/sound/warnings/crc", 0, "BOOL"), props.globals.initNode("/sim/sound/warnings/chime", 0, "BOOL")]; var aural = [props.globals.initNode("/sim/sound/warnings/crc", 0, "BOOL"), props.globals.initNode("/sim/sound/warnings/chime", 0, "BOOL")];
var warningFlash = props.globals.initNode("/ECAM/warnings/master-warning-flash", 0, "BOOL");
var lineIndex = 0;
var rightLineIndex = 0;
var statusIndex = 0;
var warning = { var warning = {
msg: "", msg: "",
@ -65,16 +66,21 @@ var warning = {
}, },
warnlight: func() { warnlight: func() {
if (me.active == 0 or me.light >= 1) {return;} if (me.active == 0 or me.light >= 1) {return;}
if (me.noRepeat == 0) { # only toggle light once per message, allows canceling
if (me.noRepeat == 0 and lights[me.light].getBoolValue() == 0) { # only toggle light once per message, allows canceling
lights[me.light].setBoolValue(1); lights[me.light].setBoolValue(1);
me.noRepeat = 1; me.noRepeat = 1;
} }
}, },
sound: func() { sound: func() {
if (me.active == 0 or me.aural >= 1) {return;} if (me.aural >= 1) {return;}
if (aural[me.aural].getBoolValue() != 1) { if (me.active == 1) {
aural[me.aural].setBoolValue(1); if (aural[me.aural].getValue() != 1) {
aural[me.aural].setBoolValue(1);
}
} else {
if (aural[me.aural].getValue() == 1) {
aural[me.aural].setBoolValue(0);
}
} }
# have to cancel it anyway, I think it does not go out even if failure is removed # have to cancel it anyway, I think it does not go out even if failure is removed
}, },
@ -95,20 +101,20 @@ var memo = {
}, },
write: func() { write: func() {
if (me.active == 1) { if (me.active == 1) {
right_line = 1; rightLineIndex = 0;
while (getprop("/ECAM/rightmsg/line" ~ right_line) != "" and right_line <= 8) { while (rightLines[rightLineIndex].getValue() != "" and rightLineIndex <= 7) {
right_line = right_line + 1; # go to next line until empty line rightLineIndex = rightLineIndex + 1; # go to next line until empty line
} }
if (right_line > 8) { if (rightLineIndex > 7) {
setprop("/ECAM/warnings/overflow-right", 1); rightOverflow.setBoolValue(1);
} elsif (getprop("/ECAM/warnings/overflow-right") == 1) { } elsif (rightOverflow.getBoolValue() == 1) {
setprop("/ECAM/warnings/overflow-right", 0); rightOverflow.setBoolValue(0);
} }
if (getprop("/ECAM/rightmsg/line" ~ right_line) == "" and right_line <= 8) { # at empty line if (rightLines[rightLineIndex].getValue() != "" == "" and rightLineIndex <= 7) { # at empty line
setprop("/ECAM/rightmsg/line" ~ right_line, me.msg); rightLines[rightLineIndex].setValue(me.msg);
setprop("/ECAM/rightmsg/linec" ~ right_line, me.colour); rightLinesCol[rightLineIndex].setValue(me.colour);
} }
} }
}, },
@ -129,14 +135,14 @@ var status = {
}, },
write: func() { write: func() {
if (me.active == 1) { if (me.active == 1) {
status_line = 1; statusIndex = 0;
while (getprop("/ECAM/status/line" ~ status_line) != "" and status_line <= 8) { while (statusLines[statusIndex].getValue() != "" and statusIndex <= 7) {
status_line = status_line + 1; # go to next line until empty line statusIndex = statusIndex + 1; # go to next line until empty line
} }
if (getprop("/ECAM/status/line" ~ status_line) == "" and status_line <= 8) { # at empty line if (statusLines[statusIndex].getValue() == "" and statusIndex <= 7) { # at empty line
setprop("/ECAM/status/line" ~ status_line, me.msg); statusLines[rightLineIndex].setValue(me.msg);
setprop("/ECAM/status/linec" ~ status_line, me.colour); statusLinesCol[rightLineIndex].setValue(me.colour);
} }
} }
}, },
@ -159,12 +165,12 @@ var ECAM_controller = {
# clear display momentarily # clear display momentarily
for(var n = 1; n <= 8; n += 1) { for(var n = 0; n <= 7; n += 1) {
setprop("/ECAM/msg/line" ~ n, ""); lines[n].setValue("");
} }
for(var n = 1; n <= 8; n += 1) { for(var n = 0; n <= 7; n += 1) {
setprop("/ECAM/rightmsg/line" ~ n, ""); rightLines[n].setValue("");
} }
# write to ECAM # write to ECAM
@ -175,7 +181,7 @@ var ECAM_controller = {
w.sound(); w.sound();
} }
if (getprop("/ECAM/msg/line1") == "") { # disable left memos if a warning exists. Warnings are processed first, so this stops leftmemos if line1 is not empty if (lines[0].getValue() == "") { # 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) { foreach (var l; leftmemos.vector) {
l.write(); l.write();
} }
@ -193,10 +199,10 @@ var ECAM_controller = {
m.write(); m.write();
} }
if (getprop("/ECAM/warnings/overflow-left") == 1 or getprop("/ECAM/warnings/overflow-right") == 1) { if (leftOverflow.getBoolValue() == 1 or leftOverflow.getBoolValue() == 1) {
setprop("/ECAM/warnings/overflow", 1); overflow.setBoolValue(1);
} elsif (getprop("/ECAM/warnings/overflow-left") == 0 and getprop("/ECAM/warnings/overflow-right") == 0) { } elsif (leftOverflow.getBoolValue() == 0 and leftOverflow.getBoolValue() == 0) {
setprop("/ECAM/warnings/overflow", 0); overflow.setBoolValue(0);
} }
}, },
reset: func() { reset: func() {
@ -241,7 +247,7 @@ var ECAM_controller = {
recall: func() { recall: func() {
foreach (var w; warnings.vector) { foreach (var w; warnings.vector) {
if (w.clearFlag == 1) { if (w.clearFlag == 1) {
w.noRepeat = 1; w.noRepeat = 0;
w.clearFlag = 0; w.clearFlag = 0;
break; break;
} }
@ -250,7 +256,7 @@ var ECAM_controller = {
}; };
setlistener("/systems/electrical/bus/dc-ess", func { setlistener("/systems/electrical/bus/dc-ess", func {
if (getprop("/systems/electrical/bus/dc-ess") < 25) { if (dc_ess.getValue() < 25) {
ECAM_controller.reset(); ECAM_controller.reset();
} }
}, 0, 0); }, 0, 0);
@ -261,25 +267,22 @@ var ECAMloopTimer = maketimer(0.2, func {
# Flash Master Warning Light # Flash Master Warning Light
var warnTimer = maketimer(0.25, func { var warnTimer = maketimer(0.25, func {
flash = getprop("/ECAM/warnings/master-warning-flash"); if (lights[0].getValue() == 0) {
light = getprop("/ECAM/warnings/master-warning-light");
if (!light) {
warnTimer.stop(); warnTimer.stop();
setprop("/ECAM/warnings/master-warning-flash", 0); warningFlash.setBoolValue(0);
} else if (flash != 1) { } else if (warningFlash.getBoolValue() != 1) {
setprop("/ECAM/warnings/master-warning-flash", 1); warningFlash.setBoolValue(1);
} else { } else {
setprop("/ECAM/warnings/master-warning-flash", 0); warningFlash.setBoolValue(0);
} }
}); });
setlistener("/ECAM/warnings/master-warning-light", func { setlistener("/ECAM/warnings/master-warning-light", func {
light = getprop("/ECAM/warnings/master-warning-light"); if (lights[0].getValue() == 1) {
if (light == 1) { warningFlash.setBoolValue(0);
setprop("/ECAM/warnings/master-warning-flash", 0);
warnTimer.start(); warnTimer.start();
} else { } else {
warnTimer.stop(); warnTimer.stop();
setprop("/ECAM/warnings/master-warning-flash", 0); warningFlash.setBoolValue(0);
} }
}, 0, 0); }, 0, 0);

View file

@ -33,7 +33,7 @@ var messages_priority_3 = func {
flaps_config_1.noRepeat = 0; flaps_config_1.noRepeat = 0;
} }
if (getprop("/controls/flight/speedbrake") != 0 and getprop("/ECAM/warning-phase") >= 3 and getprop("/ECAM/warning-phase") <= 4) { if ((spd_brk_config.clearFlag == 0) and getprop("/controls/flight/speedbrake") != 0 and getprop("/ECAM/warning-phase") >= 3 and getprop("/ECAM/warning-phase") <= 4) {
spd_brk_config.active = 1; spd_brk_config.active = 1;
spd_brk_config_1.active = 1; spd_brk_config_1.active = 1;
} else { } else {
@ -43,7 +43,7 @@ var messages_priority_3 = func {
spd_brk_config_1.noRepeat = 0; spd_brk_config_1.noRepeat = 0;
} }
if ((getprop("/fdm/jsbsim/hydraulics/elevator-trim/final-deg") > 1.75 or getprop("/fdm/jsbsim/hydraulics/elevator-trim/final-deg") < -3.65) and getprop("/ECAM/warning-phase") >= 3 and getprop("/ECAM/warning-phase") <= 4) { if ((pitch_trim_config.clearFlag == 0) and (getprop("/fdm/jsbsim/hydraulics/elevator-trim/final-deg") > 1.75 or getprop("/fdm/jsbsim/hydraulics/elevator-trim/final-deg") < -3.65) and getprop("/ECAM/warning-phase") >= 3 and getprop("/ECAM/warning-phase") <= 4) {
pitch_trim_config.active = 1; pitch_trim_config.active = 1;
pitch_trim_config_1.active = 1; pitch_trim_config_1.active = 1;
} else { } else {
@ -53,7 +53,7 @@ var messages_priority_3 = func {
pitch_trim_config_1.noRepeat = 0; pitch_trim_config_1.noRepeat = 0;
} }
if ((getprop("/fdm/jsbsim/hydraulics/rudder/trim-cmd-deg") < -3.55 or getprop("/fdm/jsbsim/hydraulics/rudder/trim-cmd-deg") > 3.55) and getprop("/ECAM/warning-phase") >= 3 and getprop("/ECAM/warning-phase") <= 4) { if ((rud_trim_config.clearFlag == 0) and (getprop("/fdm/jsbsim/hydraulics/rudder/trim-cmd-deg") < -3.55 or getprop("/fdm/jsbsim/hydraulics/rudder/trim-cmd-deg") > 3.55) and getprop("/ECAM/warning-phase") >= 3 and getprop("/ECAM/warning-phase") <= 4) {
rud_trim_config.active = 1; rud_trim_config.active = 1;
rud_trim_config_1.active = 1; rud_trim_config_1.active = 1;
} else { } else {
@ -63,7 +63,7 @@ var messages_priority_3 = func {
rud_trim_config_1.noRepeat = 0; rud_trim_config_1.noRepeat = 0;
} }
if (getprop("/controls/gear/brake-parking") == 1 and getprop("/ECAM/warning-phase") >= 3 and getprop("/ECAM/warning-phase") <= 4) { if ((park_brk_config.clearFlag == 0) and getprop("/controls/gear/brake-parking") == 1 and getprop("/ECAM/warning-phase") >= 3 and getprop("/ECAM/warning-phase") <= 4) {
park_brk_config.active = 1; park_brk_config.active = 1;
} else { } else {
park_brk_config.active = 0; park_brk_config.active = 0;
@ -71,14 +71,14 @@ var messages_priority_3 = func {
} }
# AUTOFLT # AUTOFLT
if (getprop("/it-autoflight/output/ap-warning") == 2) { if ((ap_offw.clearFlag == 0) and getprop("/it-autoflight/output/ap-warning") == 2) {
ap_offw.active = 1; ap_offw.active = 1;
} else { } else {
ap_offw.active = 0; ap_offw.active = 0;
ap_offw.noRepeat = 0; ap_offw.noRepeat = 0;
} }
if (getprop("/ECAM/warning-phase") >= 5 and getprop("/ECAM/warning-phase") <= 7 and getprop("/systems/thrust/thr-locked") == 1) { if ((athr_lock.clearFlag == 0) and getprop("/ECAM/warning-phase") >= 5 and getprop("/ECAM/warning-phase") <= 7 and getprop("/systems/thrust/thr-locked") == 1) {
athr_lock.active = 1; athr_lock.active = 1;
athr_lock_1.active = 1; athr_lock_1.active = 1;
} else { } else {
@ -88,7 +88,7 @@ var messages_priority_3 = func {
athr_lock_1.noRepeat = 0; athr_lock_1.noRepeat = 0;
} }
if (getprop("/it-autoflight/output/athr-warning") == 2 and getprop("/ECAM/warning-phase") != 4 and getprop("/ECAM/warning-phase") != 8 and getprop("/ECAM/warning-phase") != 10) { if ((athr_offw.clearFlag == 0) and getprop("/it-autoflight/output/athr-warning") == 2 and getprop("/ECAM/warning-phase") != 4 and getprop("/ECAM/warning-phase") != 8 and getprop("/ECAM/warning-phase") != 10) {
athr_offw.active = 1; athr_offw.active = 1;
athr_offw_1.active = 1; athr_offw_1.active = 1;
} else { } else {
@ -98,7 +98,7 @@ var messages_priority_3 = func {
athr_offw_1.noRepeat = 0; athr_offw_1.noRepeat = 0;
} }
if (getprop("/it-autoflight/output/athr") == 1 and ((getprop("/systems/thrust/eng-out") != 1 and (getprop("/systems/thrust/state1") == "MAN" or getprop("/systems/thrust/state2") == "MAN")) or (getprop("/systems/thrust/eng-out") == 1 and (getprop("/systems/thrust/state1") == "MAN" or getprop("/systems/thrust/state2") == "MAN" or (getprop("/systems/thrust/state1") == "MAN THR" and getprop("/controls/engines/engine[0]/throttle-pos") <= 0.83) or (getprop("/systems/thrust/state2") == "MAN THR" and getprop("/controls/engines/engine[0]/throttle-pos") <= 0.83)))) and (getprop("/ECAM/warning-phase") >= 5 and getprop("/ECAM/warning-phase") <= 7)) { if ((athr_lim.clearFlag == 0) and getprop("/it-autoflight/output/athr") == 1 and ((getprop("/systems/thrust/eng-out") != 1 and (getprop("/systems/thrust/state1") == "MAN" or getprop("/systems/thrust/state2") == "MAN")) or (getprop("/systems/thrust/eng-out") == 1 and (getprop("/systems/thrust/state1") == "MAN" or getprop("/systems/thrust/state2") == "MAN" or (getprop("/systems/thrust/state1") == "MAN THR" and getprop("/controls/engines/engine[0]/throttle-pos") <= 0.83) or (getprop("/systems/thrust/state2") == "MAN THR" and getprop("/controls/engines/engine[0]/throttle-pos") <= 0.83)))) and (getprop("/ECAM/warning-phase") >= 5 and getprop("/ECAM/warning-phase") <= 7)) {
athr_lim.active = 1; athr_lim.active = 1;
athr_lim_1.active = 1; athr_lim_1.active = 1;
} else { } else {

View file

@ -8,14 +8,6 @@
# Sounds: 0 = master warn, 1 = chime, 9 = other # Sounds: 0 = master warn, 1 = chime, 9 = other
# Left E/WD # Left E/WD
var warningsOld = std.Vector.new([
var lg_not_dn = warning.new(msg: "L/G GEAR NOT DOWN", active: 0, colour: "r", aural: 0, light: 0, noRepeat: 0, clearFlag: 0),
var pack1_fault = warning.new(msg: "AIR PACK 1 FAULT ", active: 0, colour: "a", aural: 1, light: 1, noRepeat: 0, clearFlag: 0),
var pack1_fault_subwarn_1 = warning.new(msg: "-PACK 1.............OFF ", active: 0, colour: "b", aural: 9, light: 9, noRepeat: 0, clearFlag: 0),
var pack2_fault = warning.new(msg: "AIR PACK 2 FAULT ", active: 0, colour: "a", aural: 1, light: 1, noRepeat: 0, clearFlag: 0),
var pack2_fault_subwarn_1 = warning.new(msg: "-PACK 2.............OFF ", active: 0, colour: "b", aural: 9, light: 9, noRepeat: 0, clearFlag: 0),
var park_brk_on = warning.new(msg: "PARK BRK ON", active: 0, colour: "a", aural: 1, light: 1, noRepeat: 0, clearFlag: 0)
]);
var warnings = std.Vector.new([ var warnings = std.Vector.new([
var flap_not_zero = warning.new(msg: "F/CTL FLAP LVR NOT ZERO", active: 0, colour: "r", aural: 0, light: 0, noRepeat: 0, clearFlag: 0), var flap_not_zero = warning.new(msg: "F/CTL FLAP LVR NOT ZERO", active: 0, colour: "r", aural: 0, light: 0, noRepeat: 0, clearFlag: 0),