1
0
Fork 0

Style improvements and restore work that was reverted

This commit is contained in:
legoboyvdlp R 2021-06-13 19:29:25 +01:00
parent cebc7584e9
commit 851c06ec3e
2 changed files with 93 additions and 134 deletions

View file

@ -69,8 +69,8 @@ setprop("position/gear-agl-ft", 0);
setprop("/it-autoflight/settings/accel-agl-ft", 1500); #eventually set to 1500 above runway setprop("/it-autoflight/settings/accel-agl-ft", 1500); #eventually set to 1500 above runway
setprop("/it-autoflight/internal/vert-speed-fpm", 0); setprop("/it-autoflight/internal/vert-speed-fpm", 0);
setprop("/it-autoflight/output/fma-pwr", 0); setprop("/it-autoflight/output/fma-pwr", 0);
setprop("instrumentation/nav[0]/nav-id", "XXX"); setprop("/instrumentation/nav[0]/nav-id", "XXX");
setprop("instrumentation/nav[1]/nav-id", "XXX"); setprop("/instrumentation/nav[1]/nav-id", "XXX");
setprop("/FMGC/internal/ils1-mcdu", "XXX/999.99"); setprop("/FMGC/internal/ils1-mcdu", "XXX/999.99");
setprop("/FMGC/internal/ils2-mcdu", "XXX/999.99"); setprop("/FMGC/internal/ils2-mcdu", "XXX/999.99");
setprop("/FMGC/internal/vor1-mcdu", "XXX/999.99"); setprop("/FMGC/internal/vor1-mcdu", "XXX/999.99");
@ -97,9 +97,9 @@ var FMGCinit = func {
setprop("/FMGC/internal/loc-source", "NAV0"); setprop("/FMGC/internal/loc-source", "NAV0");
setprop("/FMGC/internal/optalt", 0); setprop("/FMGC/internal/optalt", 0);
setprop("/FMGC/internal/landing-time", -99); setprop("/FMGC/internal/landing-time", -99);
setprop("/FMGC/internal/align1-time", -99); FMGCAlignTime[0].setValue(-99);
setprop("/FMGC/internal/align2-time", -99); FMGCAlignTime[1].setValue(-99);
setprop("/FMGC/internal/align3-time", -99); FMGCAlignTime[2].setValue(-99);
setprop("/FMGC/internal/block-fuel-time", -99); setprop("/FMGC/internal/block-fuel-time", -99);
setprop("/FMGC/internal/fuel-pred-time", -99); setprop("/FMGC/internal/fuel-pred-time", -99);
masterFMGC.start(); masterFMGC.start();
@ -336,7 +336,7 @@ var updateFuel = func {
final_time = final_fuel / (2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903)); # x2 for 2 engines final_time = final_fuel / (2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903)); # x2 for 2 engines
if (final_time < 0) { if (final_time < 0) {
final_time = 0; final_time = 0;
} else if (final_time > 480) { } elsif (final_time > 480) {
final_time = 480; final_time = 480;
} }
if (num(final_time) >= 60) { if (num(final_time) >= 60) {
@ -358,7 +358,7 @@ var updateFuel = func {
final_fuel = final_time * 2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903); # x2 for 2 engines final_fuel = final_time * 2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903); # x2 for 2 engines
if (final_fuel < 0) { if (final_fuel < 0) {
final_fuel = 0; final_fuel = 0;
} else if (final_fuel > 80000) { } elsif (final_fuel > 80000) {
final_fuel = 80000; final_fuel = 80000;
} }
FMGCInternal.finalFuel = final_fuel / 1000; FMGCInternal.finalFuel = final_fuel / 1000;
@ -367,14 +367,14 @@ var updateFuel = func {
# Calculate alternate fuel # Calculate alternate fuel
if (!FMGCInternal.altFuelSet and FMGCInternal.altAirportSet) { if (!FMGCInternal.altFuelSet and FMGCInternal.altAirportSet) {
#calc #calc
} else if (FMGCInternal.altFuelSet and FMGCInternal.altAirportSet) { } elsif (FMGCInternal.altFuelSet and FMGCInternal.altAirportSet) {
#dummy calc for now #dummy calc for now
alt_fuel = 1000 * num(FMGCInternal.altFuel); alt_fuel = 1000 * num(FMGCInternal.altFuel);
zfw = 1000 * FMGCInternal.zfw; zfw = 1000 * FMGCInternal.zfw;
alt_time = alt_fuel / (2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903)); # x2 for 2 engines alt_time = alt_fuel / (2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903)); # x2 for 2 engines
if (alt_time < 0) { if (alt_time < 0) {
alt_time = 0; alt_time = 0;
} else if (alt_time > 480) { } elsif (alt_time > 480) {
alt_time = 480; alt_time = 480;
} }
if (num(alt_time) >= 60) { if (num(alt_time) >= 60) {
@ -384,7 +384,7 @@ var updateFuel = func {
} else { } else {
FMGCInternal.altTime = sprintf("%04d", alt_time); FMGCInternal.altTime = sprintf("%04d", alt_time);
} }
} else if (!FMGCInternal.altFuelSet) { } elsif (!FMGCInternal.altFuelSet) {
FMGCInternal.altFuel = 0.0; FMGCInternal.altFuel = 0.0;
FMGCInternal.altTime = "0000"; FMGCInternal.altTime = "0000";
} }
@ -415,7 +415,7 @@ var updateFuel = func {
trip_fuel = 4.018e+02 + (dist*3.575e+01) + (dist*dist*-4.260e-02) + (dist*dist*dist*-1.446e-05) + (dist*dist*dist*dist*4.101e-09) + (dist*dist*dist*dist*dist*-6.753e-13) + (dist*dist*dist*dist*dist*dist*5.074e-17) + (crz*-2.573e+01) + (dist*crz*-1.583e-01) + (dist*dist*crz*8.147e-04) + (dist*dist*dist*crz*4.485e-08) + (dist*dist*dist*dist*crz*-7.656e-12) + (dist*dist*dist*dist*dist*crz*4.503e-16) + (crz*crz*4.427e-01) + (dist*crz*crz*-1.137e-03) + (dist*dist*crz*crz*-4.409e-06) + (dist*dist*dist*crz*crz*-3.345e-11) + (dist*dist*dist*dist*crz*crz*4.985e-15) + (crz*crz*crz*-2.471e-03) + (dist*crz*crz*crz*1.223e-05) + (dist*dist*crz*crz*crz*9.660e-09) + (dist*dist*dist*crz*crz*crz*-2.127e-14) + (crz*crz*crz*crz*5.714e-06) + (dist*crz*crz*crz*crz*-3.546e-08) + (dist*dist*crz*crz*crz*crz*-7.536e-12) + (crz*crz*crz*crz*crz*-4.061e-09) + (dist*crz*crz*crz*crz*crz*3.355e-11) + (crz*crz*crz*crz*crz*crz*-1.451e-12); trip_fuel = 4.018e+02 + (dist*3.575e+01) + (dist*dist*-4.260e-02) + (dist*dist*dist*-1.446e-05) + (dist*dist*dist*dist*4.101e-09) + (dist*dist*dist*dist*dist*-6.753e-13) + (dist*dist*dist*dist*dist*dist*5.074e-17) + (crz*-2.573e+01) + (dist*crz*-1.583e-01) + (dist*dist*crz*8.147e-04) + (dist*dist*dist*crz*4.485e-08) + (dist*dist*dist*dist*crz*-7.656e-12) + (dist*dist*dist*dist*dist*crz*4.503e-16) + (crz*crz*4.427e-01) + (dist*crz*crz*-1.137e-03) + (dist*dist*crz*crz*-4.409e-06) + (dist*dist*dist*crz*crz*-3.345e-11) + (dist*dist*dist*dist*crz*crz*4.985e-15) + (crz*crz*crz*-2.471e-03) + (dist*crz*crz*crz*1.223e-05) + (dist*dist*crz*crz*crz*9.660e-09) + (dist*dist*dist*crz*crz*crz*-2.127e-14) + (crz*crz*crz*crz*5.714e-06) + (dist*crz*crz*crz*crz*-3.546e-08) + (dist*dist*crz*crz*crz*crz*-7.536e-12) + (crz*crz*crz*crz*crz*-4.061e-09) + (dist*crz*crz*crz*crz*crz*3.355e-11) + (crz*crz*crz*crz*crz*crz*-1.451e-12);
if (trip_fuel < 400) { if (trip_fuel < 400) {
trip_fuel = 400; trip_fuel = 400;
} else if (trip_fuel > 80000) { } elsif (trip_fuel > 80000) {
trip_fuel = 80000; trip_fuel = 80000;
} }
@ -425,7 +425,7 @@ var updateFuel = func {
trip_time = 9.095e-02 + (dist*-3.968e-02) + (dist*dist*4.302e-04) + (dist*dist*dist*2.005e-07) + (dist*dist*dist*dist*-6.876e-11) + (dist*dist*dist*dist*dist*1.432e-14) + (dist*dist*dist*dist*dist*dist*-1.177e-18) + (crz*7.348e-01) + (dist*crz*3.310e-03) + (dist*dist*crz*-8.700e-06) + (dist*dist*dist*crz*-4.214e-10) + (dist*dist*dist*dist*crz*5.652e-14) + (dist*dist*dist*dist*dist*crz*-6.379e-18) + (crz*crz*-1.449e-02) + (dist*crz*crz*-7.508e-06) + (dist*dist*crz*crz*4.529e-08) + (dist*dist*dist*crz*crz*3.699e-13) + (dist*dist*dist*dist*crz*crz*8.466e-18) + (crz*crz*crz*1.108e-04) + (dist*crz*crz*crz*-4.126e-08) + (dist*dist*crz*crz*crz*-9.645e-11) + (dist*dist*dist*crz*crz*crz*-1.544e-16) + (crz*crz*crz*crz*-4.123e-07) + (dist*crz*crz*crz*crz*1.831e-10) + (dist*dist*crz*crz*crz*crz*7.438e-14) + (crz*crz*crz*crz*crz*7.546e-10) + (dist*crz*crz*crz*crz*crz*-1.921e-13) + (crz*crz*crz*crz*crz*crz*-5.453e-13); trip_time = 9.095e-02 + (dist*-3.968e-02) + (dist*dist*4.302e-04) + (dist*dist*dist*2.005e-07) + (dist*dist*dist*dist*-6.876e-11) + (dist*dist*dist*dist*dist*1.432e-14) + (dist*dist*dist*dist*dist*dist*-1.177e-18) + (crz*7.348e-01) + (dist*crz*3.310e-03) + (dist*dist*crz*-8.700e-06) + (dist*dist*dist*crz*-4.214e-10) + (dist*dist*dist*dist*crz*5.652e-14) + (dist*dist*dist*dist*dist*crz*-6.379e-18) + (crz*crz*-1.449e-02) + (dist*crz*crz*-7.508e-06) + (dist*dist*crz*crz*4.529e-08) + (dist*dist*dist*crz*crz*3.699e-13) + (dist*dist*dist*dist*crz*crz*8.466e-18) + (crz*crz*crz*1.108e-04) + (dist*crz*crz*crz*-4.126e-08) + (dist*dist*crz*crz*crz*-9.645e-11) + (dist*dist*dist*crz*crz*crz*-1.544e-16) + (crz*crz*crz*crz*-4.123e-07) + (dist*crz*crz*crz*crz*1.831e-10) + (dist*dist*crz*crz*crz*crz*7.438e-14) + (crz*crz*crz*crz*crz*7.546e-10) + (dist*crz*crz*crz*crz*crz*-1.921e-13) + (crz*crz*crz*crz*crz*crz*-5.453e-13);
if (trip_time < 10) { if (trip_time < 10) {
trip_time = 10; trip_time = 10;
} else if (trip_time > 480) { } elsif (trip_time > 480) {
trip_time = 480; trip_time = 480;
} }
# if (low air conditioning) { # if (low air conditioning) {
@ -433,7 +433,7 @@ var updateFuel = func {
#} #}
# if (total anti-ice) { # if (total anti-ice) {
# trip_fuel = trip_fuel * 1.045; # trip_fuel = trip_fuel * 1.045;
#} else if (engine anti-ice) { #} elsif (engine anti-ice) {
# trip_fuel = trip_fuel * 1.02; # trip_fuel = trip_fuel * 1.02;
#} #}
@ -442,7 +442,7 @@ var updateFuel = func {
trip_fuel = trip_fuel + (landing_weight_correction * (FMGCInternal.lw * 1000 - 121254.24421) / 2204.622622); trip_fuel = trip_fuel + (landing_weight_correction * (FMGCInternal.lw * 1000 - 121254.24421) / 2204.622622);
if (trip_fuel < 400) { if (trip_fuel < 400) {
trip_fuel = 400; trip_fuel = 400;
} else if (trip_fuel > 80000) { } elsif (trip_fuel > 80000) {
trip_fuel = 80000; trip_fuel = 80000;
} }
@ -470,7 +470,7 @@ var updateFuel = func {
FMGCInternal.rtePercent = 15.0; # need reasearch on this value FMGCInternal.rtePercent = 15.0; # need reasearch on this value
} }
} }
} else if (FMGCInternal.rtePercentSet) { } elsif (FMGCInternal.rtePercentSet) {
FMGCInternal.rteRsv = num(FMGCInternal.tripFuel * FMGCInternal.rtePercent / 100.0); FMGCInternal.rteRsv = num(FMGCInternal.tripFuel * FMGCInternal.rtePercent / 100.0);
} else { } else {
if (num(FMGCInternal.tripFuel) <= 0.0) { if (num(FMGCInternal.tripFuel) <= 0.0) {
@ -500,7 +500,7 @@ var updateFuel = func {
extra_time = extra_fuel / (2.0 * ((lw*lw*-2e-10) + (lw*0.0003) + 2.8903)); # x2 for 2 engines extra_time = extra_fuel / (2.0 * ((lw*lw*-2e-10) + (lw*0.0003) + 2.8903)); # x2 for 2 engines
if (extra_time < 0) { if (extra_time < 0) {
extra_time = 0; extra_time = 0;
} else if (extra_time > 480) { } elsif (extra_time > 480) {
extra_time = 480; extra_time = 480;
} }
if (num(extra_time) >= 60) { if (num(extra_time) >= 60) {
@ -608,76 +608,47 @@ var radios = maketimer(1, func() {
adf1(); adf1();
}); });
var newphase = nil;
var prop_n1_left = pts.Engines.Engine.n1Actual[0];
var prop_n1_right = pts.Engines.Engine.n1Actual[1];
#var prop_nmodelat = Modes.PFD.FMA.rollMode;
#var prop_mode = Modes.PFD.FMA.pitchMode;
var prop_gs = pts.Velocities.groundspeed;
var prop_alt = pts.Instrumentation.Altimeter.indicatedFt;
var prop_state1 = pts.Systems.Thrust.state[0];
var prop_state2 = pts.Systems.Thrust.state[1];
#var prop_accel_agl_ft = Setting.reducAglFt;
var prop_gear0 = pts.Gear.wow[0];
#var prop_altSel = Input.alt;
var masterFMGC = maketimer(0.2, func { var masterFMGC = maketimer(0.2, func {
n1_left = prop_n1_left.getValue(); n1_left = pts.Engines.Engine.n1Actual[0].getValue();
n1_right = prop_n1_right.getValue(); n1_right = pts.Engines.Engine.n1Actual[1].getValue();
modelat = Modes.PFD.FMA.rollMode.getValue(); modelat = Modes.PFD.FMA.rollMode.getValue();
mode = Modes.PFD.FMA.pitchMode.getValue(); mode = Modes.PFD.FMA.pitchMode.getValue();
gs = prop_gs.getValue(); gs = pts.Velocities.groundspeed.getValue();
alt = prop_alt.getValue(); alt = pts.Instrumentation.Altimeter.indicatedFt.getValue();
# cruiseft = FMGCInternal.crzFt; # cruiseft = FMGCInternal.crzFt;
# cruiseft_b = FMGCInternal.crzFt - 200; # cruiseft_b = FMGCInternal.crzFt - 200;
state1 = prop_state1.getValue(); state1 = pts.Systems.Thrust.state[0].getValue();
state2 = prop_state2.getValue(); state2 = pts.Systems.Thrust.state[1].getValue();
accel_agl_ft = Setting.reducAglFt.getValue(); accel_agl_ft = Setting.reducAglFt.getValue();
gear0 = prop_gear0.getBoolValue(); gear0 = pts.Gear.wow[0].getValue();
altSel = Input.alt.getValue(); altSel = Input.alt.getValue();
var phase = FMGCInternal.phase; newphase = FMGCInternal.phase;
var newphase = phase;
if (phase == 0) {
if (FMGCInternal.phase == 0) {
if (gear0 and ((n1_left >= 85 and n1_right >= 85 and mode == "SRS") or gs >= 90)) { if (gear0 and ((n1_left >= 85 and n1_right >= 85 and mode == "SRS") or gs >= 90)) {
newphase = 1; newphase = 1;
systems.PNEU.pressMode.setValue("TO"); systems.PNEU.pressMode.setValue("TO");
} }
} elsif (FMGCInternal.phase == 1) {
}
else if (phase == 1) {
if (gear0) { if (gear0) {
if ((n1_left < 85 or n1_right < 85) and gs < 90 and mode == " ") { # rejected takeoff if ((n1_left < 85 or n1_right < 85) and gs < 90 and mode == " ") { # rejected takeoff
newphase = 0; newphase = 0;
systems.PNEU.pressMode.setValue("GN"); systems.PNEU.pressMode.setValue("GN");
} }
} elsif (((mode != "SRS" and mode != " ") or alt >= accel_agl_ft)) {
}
else if (((mode != "SRS" and mode != " ") or alt >= accel_agl_ft)) {
newphase = 2; newphase = 2;
systems.PNEU.pressMode.setValue("TO"); systems.PNEU.pressMode.setValue("TO");
} }
} elsif (FMGCInternal.phase == 2) {
}
else if (phase == 2) {
if ((mode == "ALT CRZ" or mode == "ALT CRZ*")) { if ((mode == "ALT CRZ" or mode == "ALT CRZ*")) {
newphase = 3; newphase = 3;
systems.PNEU.pressMode.setValue("CR"); systems.PNEU.pressMode.setValue("CR");
} }
} elsif (FMGCInternal.phase == 3) {
}
else if (phase == 3) {
if (FMGCInternal.crzFl >= 200) { if (FMGCInternal.crzFl >= 200) {
if ((flightPlanController.arrivalDist <= 200 or altSel < 20000)) { if ((flightPlanController.arrivalDist <= 200 or altSel < 20000)) {
newphase = 4; newphase = 4;
@ -689,44 +660,31 @@ var masterFMGC = maketimer(0.2, func {
systems.PNEU.pressMode.setValue("DE"); systems.PNEU.pressMode.setValue("DE");
} }
} }
} elsif (FMGCInternal.phase == 4) {
}
else if (phase == 4) {
if (getprop("/FMGC/internal/decel")) { if (getprop("/FMGC/internal/decel")) {
newphase = 5; newphase = 5;
} }
else if (altSel == (FMGCInternal.crzFl * 100)) { # back to CRZ state elsif (altSel == (FMGCInternal.crzFl * 100)) { # back to CRZ state
newphase = 3; newphase = 3;
systems.PNEU.pressMode.setValue("CR"); systems.PNEU.pressMode.setValue("CR");
} }
} elsif (FMGCInternal.phase == 5) {
}
else if (phase == 5) {
if (state1 == "TOGA" and state2 == "TOGA") { if (state1 == "TOGA" and state2 == "TOGA") {
newphase = 6; newphase = 6;
systems.PNEU.pressMode.setValue("TO"); systems.PNEU.pressMode.setValue("TO");
Input.toga.setValue(1); Input.toga.setValue(1);
} }
} elsif (FMGCInternal.phase == 6) {
}
else if (phase == 6) {
if (alt >= accel_agl_ft) { # todo when insert altn or new dest if (alt >= accel_agl_ft) { # todo when insert altn or new dest
newphase = 2; newphase = 2;
} }
} }
if (flightPlanController.num[2].getValue() > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and if (flightPlanController.num[2].getValue() > 0 and getprop("/FMGC/flightplan[2]/active") == 1 and
flightPlanController.arrivalDist <= 15 and (modelat == "NAV" or modelat == "LOC" or modelat == "LOC*") and pts.Position.gearAglFt.getValue() < 9500) { #todo decel pseudo waypoint flightPlanController.arrivalDist <= 15 and (modelat == "NAV" or modelat == "LOC" or modelat == "LOC*") and pts.Position.gearAglFt.getValue() < 9500) { #todo decel pseudo waypoint
setprop("/FMGC/internal/decel", 1); setprop("/FMGC/internal/decel", 1);
} else if (getprop("/FMGC/internal/decel") == 1 and (phase == 0 or phase == 6)) { } elsif (getprop("/FMGC/internal/decel") == 1 and (FMGCInternal.phase == 0 or FMGCInternal.phase == 6)) {
setprop("/FMGC/internal/decel", 0); setprop("/FMGC/internal/decel", 0);
} }
@ -740,7 +698,7 @@ var masterFMGC = maketimer(0.2, func {
FMGCInternal.maxspeed = fmgc.FMGCInternal.vmo_mmo; FMGCInternal.maxspeed = fmgc.FMGCInternal.vmo_mmo;
} }
if (newphase != phase) { # phase changed if (newphase != FMGCInternal.phase) { # phase changed
FMGCInternal.phase = newphase; FMGCInternal.phase = newphase;
FMGCNodes.phase.setValue(newphase); FMGCNodes.phase.setValue(newphase);
} }
@ -828,7 +786,7 @@ var masterFMGC = maketimer(0.2, func {
if (!fmgc.FMGCInternal.vappSpeedSet) { if (!fmgc.FMGCInternal.vappSpeedSet) {
if (FMGCInternal.destWind < 5) { if (FMGCInternal.destWind < 5) {
FMGCInternal.vapp = FMGCInternal.vls + 5; FMGCInternal.vapp = FMGCInternal.vls + 5;
} else if (FMGCInternal.destWind > 15) { } elsif (FMGCInternal.destWind > 15) {
FMGCInternal.vapp = FMGCInternal.vls + 15; FMGCInternal.vapp = FMGCInternal.vls + 15;
} else { } else {
FMGCInternal.vapp = FMGCInternal.vls + FMGCInternal.destWind; FMGCInternal.vapp = FMGCInternal.vls + FMGCInternal.destWind;
@ -836,7 +794,7 @@ var masterFMGC = maketimer(0.2, func {
} }
# predicted takeoff speeds # predicted takeoff speeds
if (phase == 1) { if (FMGCInternal.phase == 1) {
FMGCInternal.clean_to = FMGCInternal.clean; FMGCInternal.clean_to = FMGCInternal.clean;
FMGCInternal.vs1g_clean_to = FMGCInternal.vs1g_clean; FMGCInternal.vs1g_clean_to = FMGCInternal.vs1g_clean;
FMGCInternal.vs1g_conf_2_to = FMGCInternal.vs1g_conf_2; FMGCInternal.vs1g_conf_2_to = FMGCInternal.vs1g_conf_2;
@ -858,7 +816,7 @@ var masterFMGC = maketimer(0.2, func {
} }
# predicted approach (temp go-around) speeds # predicted approach (temp go-around) speeds
if (phase == 5 or phase == 6) { if (FMGCInternal.phase == 5 or FMGCInternal.phase == 6) {
FMGCInternal.clean_appr = FMGCInternal.clean; FMGCInternal.clean_appr = FMGCInternal.clean;
FMGCInternal.vs1g_clean_appr = FMGCInternal.vs1g_clean; FMGCInternal.vs1g_clean_appr = FMGCInternal.vs1g_clean;
FMGCInternal.vs1g_conf_2_appr = FMGCInternal.vs1g_conf_2; FMGCInternal.vs1g_conf_2_appr = FMGCInternal.vs1g_conf_2;
@ -892,7 +850,7 @@ var masterFMGC = maketimer(0.2, func {
if (!fmgc.FMGCInternal.vappSpeedSet) { if (!fmgc.FMGCInternal.vappSpeedSet) {
if (FMGCInternal.destWind < 5) { if (FMGCInternal.destWind < 5) {
FMGCInternal.vapp_appr = FMGCInternal.vls_appr + 5; FMGCInternal.vapp_appr = FMGCInternal.vls_appr + 5;
} else if (FMGCInternal.destWind > 15) { } elsif (FMGCInternal.destWind > 15) {
FMGCInternal.vapp_appr = FMGCInternal.vls_appr + 15; FMGCInternal.vapp_appr = FMGCInternal.vls_appr + 15;
} else { } else {
FMGCInternal.vapp_appr = FMGCInternal.vls_appr + FMGCInternal.destWind; FMGCInternal.vapp_appr = FMGCInternal.vls_appr + FMGCInternal.destWind;
@ -928,7 +886,7 @@ var masterFMGC = maketimer(0.2, func {
} else { } else {
FMGCInternal.vls_min = FMGCInternal.vs1g_clean * 1.23; FMGCInternal.vls_min = FMGCInternal.vs1g_clean * 1.23;
} }
} else if (flap == 1) { # 1 } elsif (flap == 1) { # 1
FMGCInternal.vsw = FMGCInternal.vs1g_conf_2; FMGCInternal.vsw = FMGCInternal.vs1g_conf_2;
FMGCInternal.minspeed = FMGCInternal.slat; FMGCInternal.minspeed = FMGCInternal.slat;
@ -937,7 +895,7 @@ var masterFMGC = maketimer(0.2, func {
} else { } else {
FMGCInternal.vls_min = FMGCInternal.vs1g_conf_1 * 1.23; FMGCInternal.vls_min = FMGCInternal.vs1g_conf_1 * 1.23;
} }
} else if (flap == 2) { # 1+F } elsif (flap == 2) { # 1+F
FMGCInternal.vsw = FMGCInternal.vs1g_conf_1f; FMGCInternal.vsw = FMGCInternal.vs1g_conf_1f;
FMGCInternal.minspeed = FMGCInternal.slat; FMGCInternal.minspeed = FMGCInternal.slat;
@ -946,7 +904,7 @@ var masterFMGC = maketimer(0.2, func {
} else { } else {
FMGCInternal.vls_min = FMGCInternal.vs1g_conf_1f * 1.23; FMGCInternal.vls_min = FMGCInternal.vs1g_conf_1f * 1.23;
} }
} else if (flap == 3) { # 2 } elsif (flap == 3) { # 2
FMGCInternal.vsw = FMGCInternal.vs1g_conf_2; FMGCInternal.vsw = FMGCInternal.vs1g_conf_2;
FMGCInternal.minspeed = FMGCInternal.flap2; FMGCInternal.minspeed = FMGCInternal.flap2;
@ -955,7 +913,7 @@ var masterFMGC = maketimer(0.2, func {
} else { } else {
FMGCInternal.vls_min = FMGCInternal.vs1g_conf_2 * 1.23; FMGCInternal.vls_min = FMGCInternal.vs1g_conf_2 * 1.23;
} }
} else if (flap == 4) { # 3 } elsif (flap == 4) { # 3
FMGCInternal.vsw = FMGCInternal.vs1g_conf_3; FMGCInternal.vsw = FMGCInternal.vs1g_conf_3;
FMGCInternal.minspeed = FMGCInternal.flap3; FMGCInternal.minspeed = FMGCInternal.flap3;
@ -964,7 +922,7 @@ var masterFMGC = maketimer(0.2, func {
} else { } else {
FMGCInternal.vls_min = FMGCInternal.vs1g_conf_3 * 1.23; FMGCInternal.vls_min = FMGCInternal.vs1g_conf_3 * 1.23;
} }
} else if (flap == 5) { # FULL } elsif (flap == 5) { # FULL
FMGCInternal.vsw = FMGCInternal.vs1g_conf_full; FMGCInternal.vsw = FMGCInternal.vs1g_conf_full;
if (FMGCInternal.vappSpeedSet) { if (FMGCInternal.vappSpeedSet) {
FMGCInternal.minspeed = FMGCInternal.vapp_appr; FMGCInternal.minspeed = FMGCInternal.vapp_appr;
@ -979,7 +937,6 @@ var masterFMGC = maketimer(0.2, func {
} }
} }
#if (gear0 and pts.Controls.Flight.flapsPos.getValue() < 5 and (state1 == "MCT" or state1 == "MAN THR" or state1 == "TOGA") and (state2 == "MCT" or state2 == "MAN THR" or state2 == "TOGA")) {
if (gear0 and flap < 5 and (state1 == "MCT" or state1 == "MAN THR" or state1 == "TOGA") and (state2 == "MCT" or state2 == "MAN THR" or state2 == "TOGA")) { if (gear0 and flap < 5 and (state1 == "MCT" or state1 == "MAN THR" or state1 == "TOGA") and (state2 == "MCT" or state2 == "MAN THR" or state2 == "TOGA")) {
if (!FMGCInternal.takeoffState) { if (!FMGCInternal.takeoffState) {
fmgc.FMGCNodes.toState.setValue(1); fmgc.FMGCNodes.toState.setValue(1);
@ -1011,26 +968,26 @@ var updateAirportRadios = func {
runway_ils = destination_rwy.ils_frequency_mhz; runway_ils = destination_rwy.ils_frequency_mhz;
if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set") and !getprop("/FMGC/internal/ils1crs-set")) { if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set") and !getprop("/FMGC/internal/ils1crs-set")) {
setprop("/FMGC/internal/ils1freq-calculated", runway_ils); setprop("/FMGC/internal/ils1freq-calculated", runway_ils);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils);
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
} else if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) { } elsif (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) {
setprop("/FMGC/internal/ils1freq-calculated", runway_ils); setprop("/FMGC/internal/ils1freq-calculated", runway_ils);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils);
} else if (!getprop("/FMGC/internal/ils1crs-set")) { } elsif (!getprop("/FMGC/internal/ils1crs-set")) {
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
} }
} else if (airportRadiosPhase <= 1 and departure_rwy != nil) { } elsif (airportRadiosPhase <= 1 and departure_rwy != nil) {
magnetic_hdg = geo.normdeg(departure_rwy.heading - getprop("/environment/magnetic-variation-deg")); magnetic_hdg = geo.normdeg(departure_rwy.heading - getprop("/environment/magnetic-variation-deg"));
runway_ils = departure_rwy.ils_frequency_mhz; runway_ils = departure_rwy.ils_frequency_mhz;
if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set") and !getprop("/FMGC/internal/ils1crs-set")) { if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set") and !getprop("/FMGC/internal/ils1crs-set")) {
setprop("/FMGC/internal/ils1freq-calculated", runway_ils); setprop("/FMGC/internal/ils1freq-calculated", runway_ils);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils);
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
} else if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) { } elsif (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) {
setprop("/FMGC/internal/ils1freq-calculated", runway_ils); setprop("/FMGC/internal/ils1freq-calculated", runway_ils);
setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils);
} else if (!getprop("/FMGC/internal/ils1crs-set")) { } elsif (!getprop("/FMGC/internal/ils1crs-set")) {
setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg);
} }
} }
@ -1120,59 +1077,59 @@ var ManagedSPD = maketimer(0.25, func {
if (FMGCInternal.mngSpdCmd != srsSPD) { if (FMGCInternal.mngSpdCmd != srsSPD) {
FMGCInternal.mngSpdCmd = srsSPD; FMGCInternal.mngSpdCmd = srsSPD;
} }
} else if ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude <= 10050) { } elsif ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude <= 10050) {
if (FMGCInternal.mngKtsMach) { if (FMGCInternal.mngKtsMach) {
FMGCInternal.mngKtsMach = 0; FMGCInternal.mngKtsMach = 0;
} }
if (FMGCInternal.mngSpdCmd != 250 and !decel) { if (FMGCInternal.mngSpdCmd != 250 and !decel) {
FMGCInternal.mngSpdCmd = 250; FMGCInternal.mngSpdCmd = 250;
} else if (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { } elsif (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) {
FMGCInternal.mngSpdCmd = FMGCInternal.minspeed; FMGCInternal.mngSpdCmd = FMGCInternal.minspeed;
} }
} else if ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude > 10070 and !FMGCInternal.machSwitchover) { } elsif ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude > 10070 and !FMGCInternal.machSwitchover) {
if (FMGCInternal.mngKtsMach) { if (FMGCInternal.mngKtsMach) {
FMGCInternal.mngKtsMach = 0; FMGCInternal.mngKtsMach = 0;
} }
if (FMGCInternal.mngSpdCmd != mng_alt_spd) { if (FMGCInternal.mngSpdCmd != mng_alt_spd) {
FMGCInternal.mngSpdCmd = mng_alt_spd; FMGCInternal.mngSpdCmd = mng_alt_spd;
} }
} else if ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude > 10070 and FMGCInternal.machSwitchover) { } elsif ((FMGCInternal.phase == 2 or FMGCInternal.phase == 3) and altitude > 10070 and FMGCInternal.machSwitchover) {
if (!FMGCInternal.mngKtsMach) { if (!FMGCInternal.mngKtsMach) {
FMGCInternal.mngKtsMach = 1; FMGCInternal.mngKtsMach = 1;
} }
if (FMGCInternal.mngSpdCmd != mng_alt_mach) { if (FMGCInternal.mngSpdCmd != mng_alt_mach) {
FMGCInternal.mngSpdCmd = mng_alt_mach; FMGCInternal.mngSpdCmd = mng_alt_mach;
} }
} else if (FMGCInternal.phase == 4 and altitude > 11000 and !FMGCInternal.machSwitchover) { } elsif (FMGCInternal.phase == 4 and altitude > 11000 and !FMGCInternal.machSwitchover) {
if (FMGCInternal.mngKtsMach) { if (FMGCInternal.mngKtsMach) {
FMGCInternal.mngKtsMach = 0; FMGCInternal.mngKtsMach = 0;
} }
if (FMGCInternal.mngSpdCmd != mng_alt_spd) { if (FMGCInternal.mngSpdCmd != mng_alt_spd) {
FMGCInternal.mngSpdCmd = mng_alt_spd; FMGCInternal.mngSpdCmd = mng_alt_spd;
} }
} else if (FMGCInternal.phase == 4 and altitude > 11000 and FMGCInternal.machSwitchover) { } elsif (FMGCInternal.phase == 4 and altitude > 11000 and FMGCInternal.machSwitchover) {
if (!FMGCInternal.mngKtsMach) { if (!FMGCInternal.mngKtsMach) {
FMGCInternal.mngKtsMach = 1; FMGCInternal.mngKtsMach = 1;
} }
if (FMGCInternal.mngSpdCmd != mng_alt_mach) { if (FMGCInternal.mngSpdCmd != mng_alt_mach) {
FMGCInternal.mngSpdCmd = mng_alt_mach; FMGCInternal.mngSpdCmd = mng_alt_mach;
} }
} else if ((FMGCInternal.phase == 4 or FMGCInternal.phase == 5 or FMGCInternal.phase == 6) and altitude > 11000 and !FMGCInternal.machSwitchover) { } elsif ((FMGCInternal.phase == 4 or FMGCInternal.phase == 5 or FMGCInternal.phase == 6) and altitude > 11000 and !FMGCInternal.machSwitchover) {
if (FMGCInternal.mngKtsMach) { if (FMGCInternal.mngKtsMach) {
FMGCInternal.mngKtsMach = 0; FMGCInternal.mngKtsMach = 0;
} }
if (FMGCInternal.mngSpdCmd != mng_alt_spd and !decel) { if (FMGCInternal.mngSpdCmd != mng_alt_spd and !decel) {
FMGCInternal.mngSpdCmd = mng_alt_spd; FMGCInternal.mngSpdCmd = mng_alt_spd;
} else if (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { } elsif (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) {
FMGCInternal.mngSpdCmd = FMGCInternal.minspeed; FMGCInternal.mngSpdCmd = FMGCInternal.minspeed;
} }
} else if ((FMGCInternal.phase == 4 or FMGCInternal.phase == 5 or FMGCInternal.phase == 6) and altitude <= 10980) { } elsif ((FMGCInternal.phase == 4 or FMGCInternal.phase == 5 or FMGCInternal.phase == 6) and altitude <= 10980) {
if (FMGCInternal.mngKtsMach) { if (FMGCInternal.mngKtsMach) {
FMGCInternal.mngKtsMach = 0; FMGCInternal.mngKtsMach = 0;
} }
if (FMGCInternal.mngSpdCmd != 250 and !decel) { if (FMGCInternal.mngSpdCmd != 250 and !decel) {
FMGCInternal.mngSpdCmd = 250; FMGCInternal.mngSpdCmd = 250;
} else if (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { } elsif (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) {
FMGCInternal.mngSpdCmd = FMGCInternal.minspeed; FMGCInternal.mngSpdCmd = FMGCInternal.minspeed;
} }
} }
@ -1185,13 +1142,13 @@ var ManagedSPD = maketimer(0.25, func {
if (ktsmach and !FMGCInternal.mngKtsMach) { if (ktsmach and !FMGCInternal.mngKtsMach) {
Input.ktsMach.setValue(0); Input.ktsMach.setValue(0);
} else if (!ktsmach and FMGCInternal.mngKtsMach) { } elsif (!ktsmach and FMGCInternal.mngKtsMach) {
Input.ktsMach.setValue(1); Input.ktsMach.setValue(1);
} }
if (kts_sel != FMGCInternal.mngSpd and !ktsmach) { if (kts_sel != FMGCInternal.mngSpd and !ktsmach) {
Input.kts.setValue(FMGCInternal.mngSpd); Input.kts.setValue(FMGCInternal.mngSpd);
} else if (mach_sel != FMGCInternal.mngSpd and ktsmach) { } elsif (mach_sel != FMGCInternal.mngSpd and ktsmach) {
Input.mach.setValue(FMGCInternal.mngSpd); Input.mach.setValue(FMGCInternal.mngSpd);
} }
} else { } else {
@ -1233,9 +1190,9 @@ setlistener("/systems/navigation/adr/operating-1", func() {
timer48gpsAlign1.stop(); timer48gpsAlign1.stop();
} }
if (getprop("/FMGC/internal/align1-time") == -99) { if (FMGCAlignTime[0].getValue() == -99) {
timer48gpsAlign1.start(); timer48gpsAlign1.start();
setprop("/FMGC/internal/align1-time", pts.Sim.Time.elapsedSec.getValue()); FMGCAlignTime[0].setValue(pts.Sim.Time.elapsedSec.getValue());
} }
}, 0, 0); }, 0, 0);
@ -1245,9 +1202,9 @@ setlistener("/systems/navigation/adr/operating-2", func() {
timer48gpsAlign2.stop(); timer48gpsAlign2.stop();
} }
if (getprop("/FMGC/internal/align2-time") == -99) { if (FMGCAlignTime[1].getValue() == -99) {
timer48gpsAlign2.start(); timer48gpsAlign2.start();
setprop("/FMGC/internal/align2-time", pts.Sim.Time.elapsedSec.getValue()); FMGCAlignTime[1].setValue(pts.Sim.Time.elapsedSec.getValue());
} }
}, 0, 0); }, 0, 0);
@ -1257,9 +1214,9 @@ setlistener("/systems/navigation/adr/operating-3", func() {
timer48gpsAlign3.stop(); timer48gpsAlign3.stop();
} }
if (getprop("/FMGC/internal/align3-time") == -99) { if (FMGCAlignTime[2].getValue() == -99) {
timer48gpsAlign3.start(); timer48gpsAlign3.start();
setprop("/FMGC/internal/align3-time", pts.Sim.Time.elapsedSec.getValue()); FMGCAlignTime[2].setValue(pts.Sim.Time.elapsedSec.getValue());
} }
}, 0, 0); }, 0, 0);
@ -1306,25 +1263,25 @@ var timer30secLanding = maketimer(1, func() {
}); });
var timer48gpsAlign1 = maketimer(1, func() { var timer48gpsAlign1 = maketimer(1, func() {
if (pts.Sim.Time.elapsedSec.getValue() > getprop("/FMGC/internal/align1-time") + 48 or getprop("/systems/acconfig/options/adirs-skip")) { if (pts.Sim.Time.elapsedSec.getValue() > (FMGCAlignTime[0].getValue() + 48) or adirsSkip.getValue()) {
setprop("/FMGC/internal/align1-done", 1); FMGCAlignDone[0].setValue(1);
setprop("/FMGC/internal/align1-time", -99); FMGCAlignTime[0].setValue(-99);
timer48gpsAlign1.stop(); timer48gpsAlign1.stop();
} }
}); });
var timer48gpsAlign2 = maketimer(1, func() { var timer48gpsAlign2 = maketimer(1, func() {
if (pts.Sim.Time.elapsedSec.getValue() > getprop("/FMGC/internal/align2-time") + 48 or getprop("/systems/acconfig/options/adirs-skip")) { if (pts.Sim.Time.elapsedSec.getValue() > (FMGCAlignTime[1].getValue() + 48) or adirsSkip.getValue()) {
setprop("/FMGC/internal/align2-done", 1); FMGCAlignDone[1].setValue(1);
setprop("/FMGC/internal/align2-time", -99); FMGCAlignTime[1].setValue(-99);
timer48gpsAlign2.stop(); timer48gpsAlign2.stop();
} }
}); });
var timer48gpsAlign3 = maketimer(1, func() { var timer48gpsAlign3 = maketimer(1, func() {
if (pts.Sim.Time.elapsedSec.getValue() > getprop("/FMGC/internal/align3-time") + 48 or getprop("/systems/acconfig/options/adirs-skip")) { if (pts.Sim.Time.elapsedSec.getValue() > (FMGCAlignTime[2].getValue() + 48) or adirsSkip.getValue()) {
setprop("/FMGC/internal/align3-done", 1); FMGCAlignDone[2].setValue(1);
setprop("/FMGC/internal/align3-time", -99); FMGCAlignTime[2].setValue(-99);
timer48gpsAlign3.stop(); timer48gpsAlign3.stop();
} }
}); });

View file

@ -128,15 +128,17 @@ var doorR4_pos = props.globals.getNode("/sim/model/door-positions/doorr4/positio
# Detect OFF without IN # Detect OFF without IN
var lastgs0 = 0; var lastgs0 = 0;
#var lastgear0 = 0; var phase = 0;
var gs = 0;
var gear0 = 0;
var lastgsrestart = 0; var lastgsrestart = 0;
# Check for A/C state change - advice me for a better method, please :/ # Check for A/C state change - advice me for a better method, please :/
var waitingOOOIChange = maketimer(1, func(){ # 1sec precision var waitingOOOIChange = maketimer(1, func(){ # 1sec precision
var phase = fmgc.FMGCInternal.phase; phase = fmgc.FMGCInternal.phase;
var gs = pts.Velocities.groundspeed.getValue(); gs = pts.Velocities.groundspeed.getValue();
var gear0 = pts.Gear.wow[0].getBoolValue(); gear0 = pts.Gear.wow[0].getBoolValue();
#print(sprintf("OOOI check: %d %d %.2f %s",expectedOOOIState,phase,gs,gear0)); #print(sprintf("OOOI check: %d %d %.2f %s",expectedOOOIState,phase,gs,gear0));
@ -183,14 +185,14 @@ var waitingOOOIChange = maketimer(1, func(){ # 1sec precision
expectedOOOIState = 1; # go on to OFF state expectedOOOIState = 1; # go on to OFF state
} }
else if (gs > 9 and lastgsrestart == 0) { # try to detect OFF without IN else if (gs > 9 and lastgsrestart == 0) { # try to detect OFF without IN
lastgsrestart = int(getprop("/sim/time/elapsed-sec")); lastgsrestart = int(pts.Sim.Time.elapsedSec.getValue());
} }
} }
}); });
var engine_one_chk_OOOI = setlistener("/engines/engine[0]/state", func { var engine_one_chk_OOOI = setlistener("/engines/engine[0]/state", func {
if (getprop("/engines/engine[0]/state") == 3) { if (pts.Engines.Engine.state[0].getValue() == 3) {
removelistener(engine_one_chk_OOOI); removelistener(engine_one_chk_OOOI);
waitingOOOIChange.start(); waitingOOOIChange.start();
} }