1
0
Fork 0

Add proper implementation of altitude alert, works according to spec, pls test

This commit is contained in:
legoboyvdlp R 2020-03-17 19:56:01 +00:00
parent bc096f1ac2
commit 67ae1e461a
7 changed files with 4257 additions and 4074 deletions

View file

@ -190,13 +190,13 @@ setlistener("/sim/signals/fdm-initialized", func {
writeSettings(); writeSettings();
if (getprop("options/system/save-state") == 1) if (getprop("options/system/save-state") == 1)
{ {
save.restore(save.default, getprop("/sim/fg-home") ~ "/Export/" ~ getprop("/sim/aircraft") ~ "-save.xml"); save.restore(save.default, getprop("sim/fg-home") ~ "/Export/" ~ getprop("sim/aircraft") ~ "-save.xml");
} }
spinning.stop(); spinning.stop();
}); });
setlistener("/sim/signals/exit", func { setlistener("/sim/signals/exit", func {
save.save(save.default, getprop("/sim/fg-home") ~ "/Export/" ~ getprop("/sim/aircraft") ~ "-save.xml"); save.save(save.default, getprop("sim/fg-home") ~ "/Export/" ~ getprop("sim/aircraft") ~ "-save.xml");
}); });
var renderingSettings = { var renderingSettings = {

View file

@ -5307,6 +5307,10 @@
</condition> </condition>
<command>nasal</command> <command>nasal</command>
<script> <script>
if (getprop("sim/sound/warnings/cchord")) {
setprop("sim/sound/warnings/cchord-inhibit", 1);
}
if (getprop("it-autoflight/output/ap-warning") == 1) { if (getprop("it-autoflight/output/ap-warning") == 1) {
setprop("it-autoflight/output/ap-warning", 0); setprop("it-autoflight/output/ap-warning", 0);
} }

View file

@ -169,6 +169,8 @@ var ilsFlash2 = props.globals.initNode("/instrumentation/pfd/flash-indicators/il
var qnhFlash = props.globals.initNode("/instrumentation/pfd/flash-indicators/qnh-flash", 0, "BOOL"); var qnhFlash = props.globals.initNode("/instrumentation/pfd/flash-indicators/qnh-flash", 0, "BOOL");
var altFlash1 = props.globals.initNode("/instrumentation/pfd/flash-indicators/alt-flash-1", 0, "BOOL"); var altFlash1 = props.globals.initNode("/instrumentation/pfd/flash-indicators/alt-flash-1", 0, "BOOL");
var altFlash2 = props.globals.initNode("/instrumentation/pfd/flash-indicators/alt-flash-2", 0, "BOOL"); var altFlash2 = props.globals.initNode("/instrumentation/pfd/flash-indicators/alt-flash-2", 0, "BOOL");
var amberFlash1 = props.globals.initNode("/instrumentation/pfd/flash-indicators/amber-flash-1", 0, "BOOL");
var amberFlash2 = props.globals.initNode("/instrumentation/pfd/flash-indicators/amber-flash-2", 0, "BOOL");
var canvas_PFD_base = { var canvas_PFD_base = {
init: func(canvas_group, file) { init: func(canvas_group, file) {
@ -217,8 +219,8 @@ var canvas_PFD_base = {
return ["FMA_man","FMA_manmode","FMA_flxtemp","FMA_thrust","FMA_lvrclb","FMA_pitch","FMA_pitcharm","FMA_pitcharm2","FMA_roll","FMA_rollarm","FMA_combined","FMA_ctr_msg","FMA_catmode","FMA_cattype","FMA_nodh","FMA_dh","FMA_dhn","FMA_ap","FMA_fd","FMA_athr", return ["FMA_man","FMA_manmode","FMA_flxtemp","FMA_thrust","FMA_lvrclb","FMA_pitch","FMA_pitcharm","FMA_pitcharm2","FMA_roll","FMA_rollarm","FMA_combined","FMA_ctr_msg","FMA_catmode","FMA_cattype","FMA_nodh","FMA_dh","FMA_dhn","FMA_ap","FMA_fd","FMA_athr",
"FMA_man_box","FMA_flx_box","FMA_thrust_box","FMA_pitch_box","FMA_pitcharm_box","FMA_roll_box","FMA_rollarm_box","FMA_combined_box","FMA_catmode_box","FMA_cattype_box","FMA_cat_box","FMA_dh_box","FMA_ap_box","FMA_fd_box","FMA_athr_box","FMA_Middle1", "FMA_man_box","FMA_flx_box","FMA_thrust_box","FMA_pitch_box","FMA_pitcharm_box","FMA_roll_box","FMA_rollarm_box","FMA_combined_box","FMA_catmode_box","FMA_cattype_box","FMA_cat_box","FMA_dh_box","FMA_ap_box","FMA_fd_box","FMA_athr_box","FMA_Middle1",
"FMA_Middle2","ASI_max","ASI_scale","ASI_target","ASI_mach","ASI_mach_decimal","ASI_trend_up","ASI_trend_down","ASI_digit_UP","ASI_digit_DN","ASI_decimal_UP","ASI_decimal_DN","ASI_index","ASI_error","ASI_group","ASI_frame","AI_center","AI_bank", "FMA_Middle2","ASI_max","ASI_scale","ASI_target","ASI_mach","ASI_mach_decimal","ASI_trend_up","ASI_trend_down","ASI_digit_UP","ASI_digit_DN","ASI_decimal_UP","ASI_decimal_DN","ASI_index","ASI_error","ASI_group","ASI_frame","AI_center","AI_bank",
"AI_bank_lim","AI_bank_lim_X","AI_pitch_lim","AI_pitch_lim_X","AI_slipskid","AI_horizon","AI_horizon_ground","AI_horizon_sky","AI_stick","AI_stick_pos","AI_heading","AI_agl_g","AI_agl","AI_error","AI_group","FD_roll","FD_pitch","ALT_box_flash", "ALT_scale","ALT_target", "AI_bank_lim","AI_bank_lim_X","AI_pitch_lim","AI_pitch_lim_X","AI_slipskid","AI_horizon","AI_horizon_ground","AI_horizon_sky","AI_stick","AI_stick_pos","AI_heading","AI_agl_g","AI_agl","AI_error","AI_group","FD_roll","FD_pitch","ALT_box_flash","ALT_box_amber","ALT_box_amber_flash",
"ALT_target_digit","ALT_one","ALT_two","ALT_three","ALT_four","ALT_five","ALT_digits","ALT_tens","ALT_digit_UP","ALT_digit_DN","ALT_error","ALT_group","ALT_group2","ALT_frame","VS_pointer","VS_box","VS_digit","VS_error","VS_group","QNH","QNH_setting", "ALT_scale","ALT_target","ALT_target_digit","ALT_one","ALT_two","ALT_three","ALT_four","ALT_five","ALT_digits","ALT_tens","ALT_digit_UP","ALT_digit_DN","ALT_error","ALT_group","ALT_group2","ALT_frame","VS_pointer","VS_box","VS_digit","VS_error","VS_group","QNH","QNH_setting",
"QNH_std","QNH_box","LOC_pointer","LOC_scale","GS_scale","GS_pointer","CRS_pointer","HDG_target","HDG_scale","HDG_one","HDG_two","HDG_three","HDG_four","HDG_five","HDG_six","HDG_seven","HDG_digit_L","HDG_digit_R","HDG_error","HDG_group","HDG_frame", "QNH_std","QNH_box","LOC_pointer","LOC_scale","GS_scale","GS_pointer","CRS_pointer","HDG_target","HDG_scale","HDG_one","HDG_two","HDG_three","HDG_four","HDG_five","HDG_six","HDG_seven","HDG_digit_L","HDG_digit_R","HDG_error","HDG_group","HDG_frame",
"TRK_pointer","machError","ilsError","ils_code","ils_freq","dme_dist","dme_dist_legend","ILS_HDG_R","ILS_HDG_L","ILS_right","ILS_left","outerMarker","middleMarker","innerMarker","v1_group","v1_text","vr_speed","F_target","S_target","flap_max","clean_speed"]; "TRK_pointer","machError","ilsError","ils_code","ils_freq","dme_dist","dme_dist_legend","ILS_HDG_R","ILS_HDG_L","ILS_right","ILS_left","outerMarker","middleMarker","innerMarker","v1_group","v1_text","vr_speed","F_target","S_target","flap_max","clean_speed"];
}, },
@ -1500,23 +1502,49 @@ var canvas_PFD_1 = {
me["ALT_target"].hide(); me["ALT_target"].hide();
} }
alt_target_diff = target_altitude.getValue() - altitude.getValue(); if (!getprop("ECAM/alt-alert-flash") and !getprop("ECAM/alt-alert-steady")) {
if ((FMGCphase.getValue() == '2' and alt_target_diff < 750 and alt_target_diff > 200) or (FMGCphase.getValue() == '4' and alt_target_diff > -750 and alt_target_diff < -200)) { alt_going1 = 0;
if (alt_going1 == 0) { amber_going1 = 0;
alt_going1 = 1; me["ALT_box_flash"].hide();
} me["ALT_box_amber"].hide();
if (alt_going1 == 1) { me["ALT_box_amber_flash"].hide();
altTimer1.start(); } else {
if (getprop("ECAM/alt-alert-flash")) {
if (alt_going1 == 1) {
me["ALT_box_flash"].hide();
altTimer1.stop();
}
if (amber_going1 == 0) {
amber_going1 = 1;
}
if (amber_going1 == 1) {
me["ALT_box_amber"].show();
amberTimer1.start();
}
if (amberFlash1.getValue() == 1) {
me["ALT_box_amber_flash"].show();
} else {
me["ALT_box_amber_flash"].hide();
}
} elsif (getprop("ECAM/alt-alert-steady")) {
if (amber_going1 == 1) {
me["ALT_box_amber"].hide();
me["ALT_box_amber_flash"].hide();
amberTimer1.stop();
}
if (alt_going1 == 0) {
alt_going1 = 1;
}
if (alt_going1 == 1) {
me["ALT_box_flash"].show();
altTimer1.start();
}
if (altFlash1.getValue() == 1) { if (altFlash1.getValue() == 1) {
me["ALT_box_flash"].show(); me["ALT_box_flash"].show();
} else { } else {
me["ALT_box_flash"].hide(); me["ALT_box_flash"].hide();
} }
} }
} else {
altTimer1.stop();
alt_going1 = 0;
me["ALT_box_flash"].hide();
} }
} else { } else {
me["ALT_error"].show(); me["ALT_error"].show();
@ -1525,6 +1553,8 @@ var canvas_PFD_1 = {
me["ALT_group2"].hide(); me["ALT_group2"].hide();
me["ALT_scale"].hide(); me["ALT_scale"].hide();
me["ALT_box_flash"].hide(); me["ALT_box_flash"].hide();
me["ALT_box_amber"].hide();
me["ALT_box_amber_flash"].hide();
} }
me.updateCommonFast(); me.updateCommonFast();
@ -2116,25 +2146,50 @@ var canvas_PFD_2 = {
me["ALT_target"].hide(); me["ALT_target"].hide();
} }
alt_target_diff = target_altitude.getValue() - altitude.getValue(); if (!getprop("ECAM/alt-alert-flash") and !getprop("ECAM/alt-alert-steady")) {
if ((FMGCphase.getValue() == '2' and alt_target_diff < 750 and alt_target_diff > 200) or (FMGCphase.getValue() == '4' and alt_target_diff > -750 and alt_target_diff < -200)) { alt_going2 = 0;
if (alt_going2 == 0) { amber_going2 = 0;
alt_going2 = 1; me["ALT_box_flash"].hide();
} me["ALT_box_amber"].hide();
if (alt_going2 == 1) { me["ALT_box_amber_flash"].hide();
altTimer2.start(); } else {
if (getprop("ECAM/alt-alert-flash")) {
if (alt_going2 == 1) {
me["ALT_box_flash"].hide();
altTimer2.stop();
}
if (amber_going2 == 0) {
amber_going2 = 1;
}
if (amber_going2 == 1) {
me["ALT_box_amber"].show();
amberTimer2.start();
}
if (amberFlash2.getValue() == 1) {
me["ALT_box_amber_flash"].show();
} else {
me["ALT_box_amber_flash"].hide();
}
} elsif (getprop("ECAM/alt-alert-steady")) {
if (amber_going2 == 1) {
me["ALT_box_amber"].hide();
me["ALT_box_amber_flash"].hide();
amberTimer2.stop();
}
if (alt_going2 == 0) {
alt_going2 = 1;
}
if (alt_going2 == 1) {
me["ALT_box_flash"].show();
altTimer2.start();
}
if (altFlash2.getValue() == 1) { if (altFlash2.getValue() == 1) {
me["ALT_box_flash"].show(); me["ALT_box_flash"].show();
} else { } else {
me["ALT_box_flash"].hide(); me["ALT_box_flash"].hide();
} }
} }
} else {
altTimer2.stop();
alt_going2 = 0;
me["ALT_box_flash"].hide();
} }
} else { } else {
me["ALT_error"].show(); me["ALT_error"].show();
me["ALT_frame"].setColor(1,0,0); me["ALT_frame"].setColor(1,0,0);
@ -2142,6 +2197,8 @@ var canvas_PFD_2 = {
me["ALT_group2"].hide(); me["ALT_group2"].hide();
me["ALT_scale"].hide(); me["ALT_scale"].hide();
me["ALT_box_flash"].hide(); me["ALT_box_flash"].hide();
me["ALT_box_amber"].hide();
me["ALT_box_amber_flash"].hide();
} }
me.updateCommonFast(); me.updateCommonFast();
@ -2425,3 +2482,21 @@ var altTimer2 = maketimer(0.50, func {
} }
}); });
var amber_going1 = 0;
var amberTimer1 = maketimer(0.50, func {
if (!amberFlash1.getBoolValue()) {
amberFlash1.setBoolValue(1);
} else {
amberFlash1.setBoolValue(0);
}
});
var amber_going2 = 0;
var amberTimer2 = maketimer(0.50, func {
if (!amberFlash2.getBoolValue()) {
amberFlash2.setBoolValue(1);
} else {
amberFlash2.setBoolValue(0);
}
});

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 291 KiB

After

Width:  |  Height:  |  Size: 294 KiB

View file

@ -35,6 +35,7 @@ var timer10secIRS = nil;
var altAlertInhibit = nil; var altAlertInhibit = nil;
var alt250 = nil; var alt250 = nil;
var alt750 = nil; var alt750 = nil;
var bigThree = nil;
var messages_priority_3 = func { var messages_priority_3 = func {
phaseVar = phaseNode.getValue(); phaseVar = phaseNode.getValue();
@ -748,13 +749,13 @@ var messages_priority_3 = func {
} }
# C-Chord # C-Chord
if ((pts.Modes.Altimeter.std.getValue() and abs(fcu.altSet.getValue() - getprop("/systems/navigation/adr/output/baro-alt-1-capt")) < 250) or !pts.Modes.Altimeter.std.getValue() and abs(fcu.altSet.getValue() - getprop("/systems/navigation/adr/output/baro-alt-corrected-1-capt")) < 250) { if ((pts.Modes.Altimeter.std.getValue() and abs(fcu.altSet.getValue() - getprop("systems/navigation/adr/output/baro-alt-1-capt")) < 250) or !pts.Modes.Altimeter.std.getValue() and abs(fcu.altSet.getValue() - getprop("systems/navigation/adr/output/baro-alt-corrected-1-capt")) < 250) {
alt250 = 1; alt250 = 1;
} else { } else {
alt250 = 0; alt250 = 0;
} }
if ((pts.Modes.Altimeter.std.getValue() and abs(fcu.altSet.getValue() - getprop("/systems/navigation/adr/output/baro-alt-1-capt")) < 750) or !pts.Modes.Altimeter.std.getValue() and abs(fcu.altSet.getValue() - getprop("/systems/navigation/adr/output/baro-alt-corrected-1-capt")) < 750) { if ((pts.Modes.Altimeter.std.getValue() and abs(fcu.altSet.getValue() - getprop("systems/navigation/adr/output/baro-alt-1-capt")) < 750) or !pts.Modes.Altimeter.std.getValue() and abs(fcu.altSet.getValue() - getprop("systems/navigation/adr/output/baro-alt-corrected-1-capt")) < 750) {
alt750 = 1; alt750 = 1;
} else { } else {
alt750 = 0; alt750 = 0;
@ -766,7 +767,13 @@ var messages_priority_3 = func {
altAlertInhibit = 0; altAlertInhibit = 0;
} }
if ((fcu.ap1.getBoolValue() or fcu.ap2.getBoolValue()) and (alt750 and !alt250 and !altAlertInhibit)) { if (alt750 and !alt250 and !altAlertInhibit) {
FWC.Monostable.altAlert2.setValue(1);
} else {
FWC.Monostable.altAlert2.setValue(0);
}
if ((fcu.ap1.getBoolValue() or fcu.ap2.getBoolValue()) and FWC.Monostable.altAlert2.getValue()) {
FWC.Monostable.altAlert1.setValue(1); FWC.Monostable.altAlert1.setValue(1);
} else { } else {
FWC.Monostable.altAlert1.setValue(0); FWC.Monostable.altAlert1.setValue(0);
@ -790,12 +797,33 @@ var messages_priority_3 = func {
setprop("ECAM/flipflop/alt-alert-3-rs-set", 0); setprop("ECAM/flipflop/alt-alert-3-rs-set", 0);
} }
if (!gnd and (FWC.Monostable.altAlert1Output.getValue() or ((!alt750 and !alt250 and !altAlertInhibit and getprop("ECAM/flipflop/alt-alert-rs-output")) or (!alt750 and !alt250 and !altAlertInhibit and getprop("ECAM/flipflop/alt-alert-3-rs-output")) or getprop("ECAM/flipflop/alt-alert-3-rs-set") == 1))) { if ((!alt750 and !alt250 and !altAlertInhibit and getprop("ECAM/flipflop/alt-alert-rs-output")) or (!alt750 and !alt250 and !altAlertInhibit and getprop("ECAM/flipflop/alt-alert-3-rs-output")) or getprop("ECAM/flipflop/alt-alert-3-rs-set")) {
print(alt750); bigThree = 1;
print(alt250);
setprop("/sim/sound/warnings/cchord", 1);
} else { } else {
setprop("/sim/sound/warnings/cchord", 0); bigThree = 0;
}
if (!gnd and (FWC.Monostable.altAlert1Output.getValue() or bigThree)) {
if (!getprop("sim/sound/warnings/cchord-inhibit")) {
setprop("sim/sound/warnings/cchord", 1);
} else {
setprop("sim/sound/warnings/cchord", 0);
}
} else {
setprop("sim/sound/warnings/cchord", 0);
setprop("sim/sound/warnings/cchord-inhibit", 0);
}
if (!gnd and getprop("ECAM/flipflop/alt-alert-3-rs-set") != 1 and alt750 and !alt250 and !altAlertInhibit) {
setprop("ECAM/alt-alert-steady", 1);
} else {
setprop("ECAM/alt-alert-steady", 0);
}
if (!gnd and bigThree) {
setprop("ECAM/alt-alert-flash", 1);
} else {
setprop("ECAM/alt-alert-flash", 0);
} }
if (!systems.cargoTestBtn.getBoolValue()) { if (!systems.cargoTestBtn.getBoolValue()) {

View file

@ -40,6 +40,7 @@ var FWC = {
m80kt: props.globals.getNode("ECAM/phases/monostable-80kt"), m80kt: props.globals.getNode("ECAM/phases/monostable-80kt"),
altAlert1: props.globals.initNode("ECAM/altitude-alert-monostable-set", 0, "BOOL"), altAlert1: props.globals.initNode("ECAM/altitude-alert-monostable-set", 0, "BOOL"),
altAlert1Output: props.globals.initNode("ECAM/altitude-alert-monostable-output"), altAlert1Output: props.globals.initNode("ECAM/altitude-alert-monostable-output"),
altAlert2: props.globals.initNode("ECAM/flipflop/altitude-alert-rs-set", 0, "BOOL"),
}, },
Flipflop: { Flipflop: {
gearSet: props.globals.initNode("ECAM/phases/flipflop/gear-set", 0, "BOOL"), gearSet: props.globals.initNode("ECAM/phases/flipflop/gear-set", 0, "BOOL"),

View file

@ -228,17 +228,44 @@
<output>ECAM/buttons/recall-status-normal-output</output> <output>ECAM/buttons/recall-status-normal-output</output>
</flipflop> </flipflop>
<flipflop>
<type>SR</type>
<S>
<property>ECAM/altitude-alert-monostable-set</property>
</S>
<R>
<property>ECAM/altitude-alert-monostable-intermediate-output</property>
</R>
<output>ECAM/altitude-alert-monostable-flipflop-intermediate</output>
</flipflop>
<flipflop> <flipflop>
<type>monostable</type> <type>monostable</type>
<inverted type="bool">true</inverted>
<time> <time>
<value>1.5</value> <value>1.5</value>
</time> </time>
<S> <S>
<property>ECAM/altitude-alert-monostable-set</property> <not><property>ECAM/altitude-alert-monostable-flipflop-intermediate</property></not>
</S> </S>
<output>ECAM/altitude-alert-monostable-output</output> <output>ECAM/altitude-alert-monostable-intermediate-output</output>
</flipflop> </flipflop>
<filter>
<type>gain</type>
<gain>1.0</gain>
<input>
<condition>
<and>
<property>ECAM/altitude-alert-monostable-flipflop-intermediate</property>
<not><property>ECAM/altitude-alert-monostable-intermediate-output</property></not>
</and>
</condition>
<value>1</value>
</input>
<output>ECAM/altitude-alert-monostable-output</output>
</filter>
<filter> <filter>
<type>derivative</type> <type>derivative</type>
<input>it-autoflight/input/alt</input> <input>it-autoflight/input/alt</input>
@ -292,11 +319,13 @@
<filter> <filter>
<type>gain</type>
<gain>1.0</gain>
<input> <input>
<condition> <condition>
<or> <or>
<property>ECAM/gear-downlocked-set</property> <equals><property>ECAM/gear-downlocked-output</property><value>1</value></equals>
<property>ECAM/alt-is-changing</property> <equals><property>ECAM/alt-is-changing</property><value>1</value></equals>
</or> </or>
</condition> </condition>
<value>1</value> <value>1</value>
@ -304,8 +333,8 @@
<input> <input>
<condition> <condition>
<and> <and>
<not><property>ECAM/gear-downlocked-set</property></not> <equals><property>ECAM/gear-downlocked-output</property><value>0</value></equals>
<not><property>ECAM/alt-is-changing</property></not> <equals><property>ECAM/alt-is-changing</property><value>0</value></equals>
</and> </and>
</condition> </condition>
<value>0</value> <value>0</value>
@ -316,7 +345,7 @@
<flipflop> <flipflop>
<type>RS</type> <type>RS</type>
<S> <S>
<property>ECAM/altitude-alert-monostable-set</property> <property>ECAM/flipflop/altitude-alert-rs-set</property>
</S> </S>
<R> <R>
<property>ECAM/flipflop/alt-alert-rs-reset</property> <property>ECAM/flipflop/alt-alert-rs-reset</property>