From e4548f7eef439f8603a3e48d92bb31b661618c59 Mon Sep 17 00:00:00 2001 From: Inuyaksa Date: Mon, 14 Jun 2021 21:32:43 +0200 Subject: [PATCH 01/14] Restore style changes by legoboy --- Nasal/FMGC/FMGC.nas | 226 ++++++++++++++++++-------------------------- 1 file changed, 94 insertions(+), 132 deletions(-) diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index a69c99db..d6ece00e 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -31,6 +31,7 @@ var hdg = 0; var alt = 0; var altitude = 0; var flap = 0; +var flaps = 0; var freqnav0uf = 0; var freqnav0 = 0; var namenav0 = "XX"; @@ -69,8 +70,8 @@ setprop("position/gear-agl-ft", 0); 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/output/fma-pwr", 0); -setprop("instrumentation/nav[0]/nav-id", "XXX"); -setprop("instrumentation/nav[1]/nav-id", "XXX"); +setprop("/instrumentation/nav[0]/nav-id", "XXX"); +setprop("/instrumentation/nav[1]/nav-id", "XXX"); setprop("/FMGC/internal/ils1-mcdu", "XXX/999.99"); setprop("/FMGC/internal/ils2-mcdu", "XXX/999.99"); setprop("/FMGC/internal/vor1-mcdu", "XXX/999.99"); @@ -78,6 +79,9 @@ setprop("/FMGC/internal/vor2-mcdu", "999.99/XXX"); setprop("/FMGC/internal/adf1-mcdu", "XXX/999.99"); setprop("/FMGC/internal/adf2-mcdu", "999.99/XXX"); +var FMGCAlignDone = [props.globals.initNode("/FMGC/internal/align1-done", 0, "BOOL"), props.globals.initNode("/FMGC/internal/align2-done", 0, "BOOL"), props.globals.initNode("/FMGC/internal/align3-done", 0, "BOOL")]; +var FMGCAlignTime = [props.globals.initNode("/FMGC/internal/align1-time", 0, "DOUBLE"), props.globals.initNode("/FMGC/internal/align2-time", 0, "DOUBLE"), props.globals.initNode("/FMGC/internal/align3-time", 0, "DOUBLE")]; +var adirsSkip = props.globals.getNode("/systems/acconfig/options/adirs-skip"); var blockCalculating = props.globals.initNode("/FMGC/internal/block-calculating", 0, "BOOL"); var fuelCalculating = props.globals.initNode("/FMGC/internal/fuel-calculating", 0, "BOOL"); @@ -94,9 +98,9 @@ var FMGCinit = func { setprop("/FMGC/internal/loc-source", "NAV0"); setprop("/FMGC/internal/optalt", 0); setprop("/FMGC/internal/landing-time", -99); - setprop("/FMGC/internal/align1-time", -99); - setprop("/FMGC/internal/align2-time", -99); - setprop("/FMGC/internal/align3-time", -99); + FMGCAlignTime[0].setValue(-99); + FMGCAlignTime[1].setValue(-99); + FMGCAlignTime[2].setValue(-99); setprop("/FMGC/internal/block-fuel-time", -99); setprop("/FMGC/internal/fuel-pred-time", -99); masterFMGC.start(); @@ -333,7 +337,7 @@ var updateFuel = func { final_time = final_fuel / (2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903)); # x2 for 2 engines if (final_time < 0) { final_time = 0; - } else if (final_time > 480) { + } elsif (final_time > 480) { final_time = 480; } if (num(final_time) >= 60) { @@ -355,7 +359,7 @@ var updateFuel = func { final_fuel = final_time * 2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903); # x2 for 2 engines if (final_fuel < 0) { final_fuel = 0; - } else if (final_fuel > 80000) { + } elsif (final_fuel > 80000) { final_fuel = 80000; } FMGCInternal.finalFuel = final_fuel / 1000; @@ -364,14 +368,14 @@ var updateFuel = func { # Calculate alternate fuel if (!FMGCInternal.altFuelSet and FMGCInternal.altAirportSet) { #calc - } else if (FMGCInternal.altFuelSet and FMGCInternal.altAirportSet) { + } elsif (FMGCInternal.altFuelSet and FMGCInternal.altAirportSet) { #dummy calc for now alt_fuel = 1000 * num(FMGCInternal.altFuel); zfw = 1000 * FMGCInternal.zfw; alt_time = alt_fuel / (2.0 * ((zfw*zfw*-2e-10) + (zfw*0.0003) + 2.8903)); # x2 for 2 engines if (alt_time < 0) { alt_time = 0; - } else if (alt_time > 480) { + } elsif (alt_time > 480) { alt_time = 480; } if (num(alt_time) >= 60) { @@ -381,7 +385,7 @@ var updateFuel = func { } else { FMGCInternal.altTime = sprintf("%04d", alt_time); } - } else if (!FMGCInternal.altFuelSet) { + } elsif (!FMGCInternal.altFuelSet) { FMGCInternal.altFuel = 0.0; FMGCInternal.altTime = "0000"; } @@ -412,7 +416,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); if (trip_fuel < 400) { trip_fuel = 400; - } else if (trip_fuel > 80000) { + } elsif (trip_fuel > 80000) { trip_fuel = 80000; } @@ -422,7 +426,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); if (trip_time < 10) { trip_time = 10; - } else if (trip_time > 480) { + } elsif (trip_time > 480) { trip_time = 480; } # if (low air conditioning) { @@ -430,7 +434,7 @@ var updateFuel = func { #} # if (total anti-ice) { # trip_fuel = trip_fuel * 1.045; - #} else if (engine anti-ice) { + #} elsif (engine anti-ice) { # trip_fuel = trip_fuel * 1.02; #} @@ -439,7 +443,7 @@ var updateFuel = func { trip_fuel = trip_fuel + (landing_weight_correction * (FMGCInternal.lw * 1000 - 121254.24421) / 2204.622622); if (trip_fuel < 400) { trip_fuel = 400; - } else if (trip_fuel > 80000) { + } elsif (trip_fuel > 80000) { trip_fuel = 80000; } @@ -467,7 +471,7 @@ var updateFuel = func { 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); } else { if (num(FMGCInternal.tripFuel) <= 0.0) { @@ -497,7 +501,7 @@ var updateFuel = func { extra_time = extra_fuel / (2.0 * ((lw*lw*-2e-10) + (lw*0.0003) + 2.8903)); # x2 for 2 engines if (extra_time < 0) { extra_time = 0; - } else if (extra_time > 480) { + } elsif (extra_time > 480) { extra_time = 480; } if (num(extra_time) >= 60) { @@ -605,76 +609,48 @@ var radios = maketimer(1, func() { adf1(); }); - - -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 newphase = nil; var masterFMGC = maketimer(0.2, func { - n1_left = prop_n1_left.getValue(); - n1_right = prop_n1_right.getValue(); + n1_left = pts.Engines.Engine.n1Actual[0].getValue(); + n1_right = pts.Engines.Engine.n1Actual[1].getValue(); modelat = Modes.PFD.FMA.rollMode.getValue(); mode = Modes.PFD.FMA.pitchMode.getValue(); - gs = prop_gs.getValue(); - alt = prop_alt.getValue(); + gs = pts.Velocities.groundspeed.getValue(); + alt = pts.Instrumentation.Altimeter.indicatedFt.getValue(); # cruiseft = FMGCInternal.crzFt; # cruiseft_b = FMGCInternal.crzFt - 200; - state1 = prop_state1.getValue(); - state2 = prop_state2.getValue(); + state1 = pts.Systems.Thrust.state[0].getValue(); + state2 = pts.Systems.Thrust.state[1].getValue(); accel_agl_ft = Setting.reducAglFt.getValue(); - gear0 = prop_gear0.getBoolValue(); + gear0 = pts.Gear.wow[0].getValue(); altSel = Input.alt.getValue(); - var phase = FMGCInternal.phase; - var newphase = phase; - - if (phase == 0) { + newphase = FMGCInternal.phase; + if (FMGCInternal.phase == 0) { if (gear0 and ((n1_left >= 85 and n1_right >= 85 and mode == "SRS") or gs >= 90)) { newphase = 1; systems.PNEU.pressMode.setValue("TO"); } - - } - - else if (phase == 1) { - + } elsif (FMGCInternal.phase == 1) { if (gear0) { if ((n1_left < 85 or n1_right < 85) and gs < 90 and mode == " ") { # rejected takeoff newphase = 0; systems.PNEU.pressMode.setValue("GN"); } - - } - else if (((mode != "SRS" and mode != " ") or alt >= accel_agl_ft)) { + } elsif (((mode != "SRS" and mode != " ") or alt >= accel_agl_ft)) { newphase = 2; systems.PNEU.pressMode.setValue("TO"); } - - } - - else if (phase == 2) { - + } elsif (FMGCInternal.phase == 2) { if ((mode == "ALT CRZ" or mode == "ALT CRZ*")) { newphase = 3; systems.PNEU.pressMode.setValue("CR"); } - - } - - else if (phase == 3) { - + } elsif (FMGCInternal.phase == 3) { if (FMGCInternal.crzFl >= 200) { if ((flightPlanController.arrivalDist <= 200 or altSel < 20000)) { newphase = 4; @@ -686,33 +662,21 @@ var masterFMGC = maketimer(0.2, func { systems.PNEU.pressMode.setValue("DE"); } } - - } - - else if (phase == 4) { - + } elsif (FMGCInternal.phase == 4) { if (getprop("/FMGC/internal/decel")) { newphase = 5; } - else if (altSel == (FMGCInternal.crzFl * 100)) { # back to CRZ state + elsif (altSel == (FMGCInternal.crzFl * 100)) { # back to CRZ state newphase = 3; systems.PNEU.pressMode.setValue("CR"); } - - } - - else if (phase == 5) { - + } elsif (FMGCInternal.phase == 5) { if (state1 == "TOGA" and state2 == "TOGA") { newphase = 6; systems.PNEU.pressMode.setValue("TO"); Input.toga.setValue(1); } - - } - - else if (phase == 6) { - + } elsif (FMGCInternal.phase == 6) { if (alt >= accel_agl_ft) { # todo when insert altn or new dest newphase = 2; } @@ -723,7 +687,7 @@ var masterFMGC = maketimer(0.2, func { 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 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); } @@ -737,7 +701,7 @@ var masterFMGC = maketimer(0.2, func { FMGCInternal.maxspeed = fmgc.FMGCInternal.vmo_mmo; } - if (newphase != phase) { # phase changed + if (newphase != FMGCInternal.phase) { # phase changed FMGCInternal.phase = newphase; FMGCNodes.phase.setValue(newphase); } @@ -825,7 +789,7 @@ var masterFMGC = maketimer(0.2, func { if (!fmgc.FMGCInternal.vappSpeedSet) { if (FMGCInternal.destWind < 5) { FMGCInternal.vapp = FMGCInternal.vls + 5; - } else if (FMGCInternal.destWind > 15) { + } elsif (FMGCInternal.destWind > 15) { FMGCInternal.vapp = FMGCInternal.vls + 15; } else { FMGCInternal.vapp = FMGCInternal.vls + FMGCInternal.destWind; @@ -833,7 +797,7 @@ var masterFMGC = maketimer(0.2, func { } # predicted takeoff speeds - if (phase == 1) { + if (FMGCInternal.phase == 1) { FMGCInternal.clean_to = FMGCInternal.clean; FMGCInternal.vs1g_clean_to = FMGCInternal.vs1g_clean; FMGCInternal.vs1g_conf_2_to = FMGCInternal.vs1g_conf_2; @@ -855,7 +819,7 @@ var masterFMGC = maketimer(0.2, func { } # 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.vs1g_clean_appr = FMGCInternal.vs1g_clean; FMGCInternal.vs1g_conf_2_appr = FMGCInternal.vs1g_conf_2; @@ -889,7 +853,7 @@ var masterFMGC = maketimer(0.2, func { if (!fmgc.FMGCInternal.vappSpeedSet) { if (FMGCInternal.destWind < 5) { FMGCInternal.vapp_appr = FMGCInternal.vls_appr + 5; - } else if (FMGCInternal.destWind > 15) { + } elsif (FMGCInternal.destWind > 15) { FMGCInternal.vapp_appr = FMGCInternal.vls_appr + 15; } else { FMGCInternal.vapp_appr = FMGCInternal.vls_appr + FMGCInternal.destWind; @@ -925,7 +889,7 @@ var masterFMGC = maketimer(0.2, func { } else { FMGCInternal.vls_min = FMGCInternal.vs1g_clean * 1.23; } - } else if (flap == 1) { # 1 + } elsif (flap == 1) { # 1 FMGCInternal.vsw = FMGCInternal.vs1g_conf_2; FMGCInternal.minspeed = FMGCInternal.slat; @@ -934,7 +898,7 @@ var masterFMGC = maketimer(0.2, func { } else { 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.minspeed = FMGCInternal.slat; @@ -943,7 +907,7 @@ var masterFMGC = maketimer(0.2, func { } else { 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.minspeed = FMGCInternal.flap2; @@ -952,7 +916,7 @@ var masterFMGC = maketimer(0.2, func { } else { 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.minspeed = FMGCInternal.flap3; @@ -961,7 +925,7 @@ var masterFMGC = maketimer(0.2, func { } else { FMGCInternal.vls_min = FMGCInternal.vs1g_conf_3 * 1.23; } - } else if (flap == 5) { # FULL + } elsif (flap == 5) { # FULL FMGCInternal.vsw = FMGCInternal.vs1g_conf_full; if (FMGCInternal.vappSpeedSet) { FMGCInternal.minspeed = FMGCInternal.vapp_appr; @@ -976,7 +940,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 (!FMGCInternal.takeoffState) { fmgc.FMGCNodes.toState.setValue(1); @@ -994,49 +957,47 @@ var masterFMGC = maketimer(0.2, func { ############################ #handle radios, runways, v1/vr/v2 ############################ - +var airportRadiosPhase = nil; var updateAirportRadios = func { - var phase = FMGCInternal.phase; - - print("# Update airport radios"); + airportRadiosPhase = FMGCInternal.phase; departure_rwy = fmgc.flightPlanController.flightplans[2].departure_runway; destination_rwy = fmgc.flightPlanController.flightplans[2].destination_runway; - if (phase >= 2 and destination_rwy != nil) { + if (airportRadiosPhase >= 2 and destination_rwy != nil) { var airport = airportinfo(FMGCInternal.arrApt); setprop("/FMGC/internal/ldg-elev", airport.elevation * M2FT); # eventually should be runway elevation magnetic_hdg = geo.normdeg(destination_rwy.heading - getprop("/environment/magnetic-variation-deg")); runway_ils = destination_rwy.ils_frequency_mhz; if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set") and !getprop("/FMGC/internal/ils1crs-set")) { setprop("/FMGC/internal/ils1freq-calculated", runway_ils); - setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); - setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); - } else if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) { + setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); + setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); + } elsif (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) { setprop("/FMGC/internal/ils1freq-calculated", runway_ils); - setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); - } else if (!getprop("/FMGC/internal/ils1crs-set")) { - setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); + setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); + } elsif (!getprop("/FMGC/internal/ils1crs-set")) { + setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); } - } else if (phase <= 1 and departure_rwy != nil) { + } elsif (airportRadiosPhase <= 1 and departure_rwy != nil) { magnetic_hdg = geo.normdeg(departure_rwy.heading - getprop("/environment/magnetic-variation-deg")); runway_ils = departure_rwy.ils_frequency_mhz; if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set") and !getprop("/FMGC/internal/ils1crs-set")) { setprop("/FMGC/internal/ils1freq-calculated", runway_ils); - setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); - setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); - } else if (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) { + setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); + setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); + } elsif (runway_ils != nil and !getprop("/FMGC/internal/ils1freq-set")) { setprop("/FMGC/internal/ils1freq-calculated", runway_ils); - setprop("instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); - } else if (!getprop("/FMGC/internal/ils1crs-set")) { - setprop("instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); + setprop("/instrumentation/nav[0]/frequencies/selected-mhz", runway_ils); + } elsif (!getprop("/FMGC/internal/ils1crs-set")) { + setprop("/instrumentation/nav[0]/radials/selected-deg", magnetic_hdg); } } }; setlistener(FMGCNodes.phase, updateAirportRadios,0,0); -setlistener(flightPlanController.changed, updateAirportRadios); +setlistener(flightPlanController.changed, updateAirportRadios,0,0); var reset_FMGC = func { FMGCInternal.phase = 0; @@ -1054,6 +1015,7 @@ var reset_FMGC = func { windController.init(); mcdu.MCDU_reset(0); mcdu.MCDU_reset(1); + Simbrief.SimbriefParser.inhibit = 0; mcdu.ReceivedMessagesDatabase.clearDatabase(); mcdu.FlightLogDatabase.reset(); # track reset events without loosing recorded data @@ -1118,59 +1080,59 @@ var ManagedSPD = maketimer(0.25, func { if (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) { FMGCInternal.mngKtsMach = 0; } if (FMGCInternal.mngSpdCmd != 250 and !decel) { FMGCInternal.mngSpdCmd = 250; - } else if (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { + } elsif (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { 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) { FMGCInternal.mngKtsMach = 0; } if (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) { FMGCInternal.mngKtsMach = 1; } if (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) { FMGCInternal.mngKtsMach = 0; } if (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) { FMGCInternal.mngKtsMach = 1; } if (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) { FMGCInternal.mngKtsMach = 0; } if (FMGCInternal.mngSpdCmd != mng_alt_spd and !decel) { FMGCInternal.mngSpdCmd = mng_alt_spd; - } else if (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { + } elsif (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { 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) { FMGCInternal.mngKtsMach = 0; } if (FMGCInternal.mngSpdCmd != 250 and !decel) { FMGCInternal.mngSpdCmd = 250; - } else if (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { + } elsif (FMGCInternal.mngSpdCmd != FMGCInternal.minspeed and decel) { FMGCInternal.mngSpdCmd = FMGCInternal.minspeed; } } @@ -1183,13 +1145,13 @@ var ManagedSPD = maketimer(0.25, func { if (ktsmach and !FMGCInternal.mngKtsMach) { Input.ktsMach.setValue(0); - } else if (!ktsmach and FMGCInternal.mngKtsMach) { + } elsif (!ktsmach and FMGCInternal.mngKtsMach) { Input.ktsMach.setValue(1); } if (kts_sel != FMGCInternal.mngSpd and !ktsmach) { 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); } } else { @@ -1231,9 +1193,9 @@ setlistener("/systems/navigation/adr/operating-1", func() { timer48gpsAlign1.stop(); } - if (getprop("/FMGC/internal/align1-time") == -99) { + if (FMGCAlignTime[0].getValue() == -99) { timer48gpsAlign1.start(); - setprop("/FMGC/internal/align1-time", pts.Sim.Time.elapsedSec.getValue()); + FMGCAlignTime[0].setValue(pts.Sim.Time.elapsedSec.getValue()); } }, 0, 0); @@ -1243,9 +1205,9 @@ setlistener("/systems/navigation/adr/operating-2", func() { timer48gpsAlign2.stop(); } - if (getprop("/FMGC/internal/align2-time") == -99) { + if (FMGCAlignTime[1].getValue() == -99) { timer48gpsAlign2.start(); - setprop("/FMGC/internal/align2-time", pts.Sim.Time.elapsedSec.getValue()); + FMGCAlignTime[1].setValue(pts.Sim.Time.elapsedSec.getValue()); } }, 0, 0); @@ -1255,9 +1217,9 @@ setlistener("/systems/navigation/adr/operating-3", func() { timer48gpsAlign3.stop(); } - if (getprop("/FMGC/internal/align3-time") == -99) { + if (FMGCAlignTime[2].getValue() == -99) { timer48gpsAlign3.start(); - setprop("/FMGC/internal/align3-time", pts.Sim.Time.elapsedSec.getValue()); + FMGCAlignTime[2].setValue(pts.Sim.Time.elapsedSec.getValue()); } }, 0, 0); @@ -1304,25 +1266,25 @@ var timer30secLanding = 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")) { - setprop("/FMGC/internal/align1-done", 1); - setprop("/FMGC/internal/align1-time", -99); + if (pts.Sim.Time.elapsedSec.getValue() > (FMGCAlignTime[0].getValue() + 48) or adirsSkip.getValue()) { + FMGCAlignDone[0].setValue(1); + FMGCAlignTime[0].setValue(-99); timer48gpsAlign1.stop(); } }); var timer48gpsAlign2 = maketimer(1, func() { - if (pts.Sim.Time.elapsedSec.getValue() > getprop("/FMGC/internal/align2-time") + 48 or getprop("/systems/acconfig/options/adirs-skip")) { - setprop("/FMGC/internal/align2-done", 1); - setprop("/FMGC/internal/align2-time", -99); + if (pts.Sim.Time.elapsedSec.getValue() > (FMGCAlignTime[1].getValue() + 48) or adirsSkip.getValue()) { + FMGCAlignDone[1].setValue(1); + FMGCAlignTime[1].setValue(-99); timer48gpsAlign2.stop(); } }); var timer48gpsAlign3 = maketimer(1, func() { - if (pts.Sim.Time.elapsedSec.getValue() > getprop("/FMGC/internal/align3-time") + 48 or getprop("/systems/acconfig/options/adirs-skip")) { - setprop("/FMGC/internal/align3-done", 1); - setprop("/FMGC/internal/align3-time", -99); + if (pts.Sim.Time.elapsedSec.getValue() > (FMGCAlignTime[2].getValue() + 48) or adirsSkip.getValue()) { + FMGCAlignDone[2].setValue(1); + FMGCAlignTime[2].setValue(-99); timer48gpsAlign3.stop(); } }); From a42edcfc1fa28b070887b9fbe02e7e4a91a0d0bf Mon Sep 17 00:00:00 2001 From: Inuyaksa Date: Mon, 14 Jun 2021 22:47:11 +0200 Subject: [PATCH 02/14] preliminary for holding pattern support --- .../ND/canvas/framework/canvas.nas | 67 ++++++++++++++ .../ND/canvas/map/HOLD.lcontroller | 91 +++++++++++++++++++ Models/Instruments/ND/canvas/map/HOLD.symbol | 46 ++++++++++ Models/Instruments/ND/canvas/style.nas | 13 +-- 4 files changed, 211 insertions(+), 6 deletions(-) create mode 100644 Models/Instruments/ND/canvas/map/HOLD.lcontroller create mode 100644 Models/Instruments/ND/canvas/map/HOLD.symbol diff --git a/Models/Instruments/ND/canvas/framework/canvas.nas b/Models/Instruments/ND/canvas/framework/canvas.nas index 402dff60..7dc6cf73 100644 --- a/Models/Instruments/ND/canvas/framework/canvas.nas +++ b/Models/Instruments/ND/canvas/framework/canvas.nas @@ -307,3 +307,70 @@ canvas.LineSymbol.draw = func() { me.callback("draw_after"); }; +# RacetrackSymbol + +canvas.RacetrackSymbol.new = func(group, layer, model, controller=nil) { + if (me == nil) __die("Need me reference for RacetrackSymbol.new()"); + if (typeof(model) != "vector") { + if(typeof(model) == "hash"){ + if(!contains(model, "path")) + canvas.__die("RacetrackSymbol.new(): model hash requires path"); + } + else canvas.__die("RacetrackSymbol.new(): need a vector of points or a hash"); + } + var m = { + parents: [me], + group: group, + layer: layer, + model: model, + controller: controller == nil ? me.df_controller : controller, + element: group.createChild( + "path", me.element_id + ), + }; + append(m.parents, m.element); + canvas.Symbol._new(m); + + m.init(); + return m; +}; + # Non-static: +canvas.RacetrackSymbol.draw = func() { + me.callback("draw_before"); + if (!me.needs_update) return; + #logprint(_MP_dbg_lvl, "redrawing a RacetrackSymbol "~me.layer.type); + me.element.reset(); + var cmds = []; + var coords = []; + var cmd = canvas.Path.VG_MOVE_TO; + var path = me.model; + if(typeof(path) == "hash"){ + path = me.model.path; + if(path == nil) + canvas.__die("RacetrackSymbol model requires a 'path' member (vector)"); + } + foreach (var m; path) { + if(size(keys(m)) >= 2){ + var (lat,lon) = me.controller.getpos(m); + append(coords,"N"~lat); + append(coords,"E"~lon); + append(cmds,cmd); + if (m[0] == 'R') cmd = canvas.Path.arcSmallCWTo; + else if (m[0] == 'L') cmd = canvas.Path.arcSmallCCWTo; + else cmd = canvas.Path.VG_LINE_TO; + } else { + cmd = canvas.Path.VG_MOVE_TO; + } + } + + # close racetrack + var (lat,lon) = me.controller.getpos(path[0]); + append(coords,"N"~lat); + append(coords,"E"~lon); + append(cmds,cmd); + + me.element.setDataGeo(cmds, coords); + me.element.update(); # this doesn"t help with flickering, it seems + me.callback("draw_after"); +}; + diff --git a/Models/Instruments/ND/canvas/map/HOLD.lcontroller b/Models/Instruments/ND/canvas/map/HOLD.lcontroller new file mode 100644 index 00000000..6189d87d --- /dev/null +++ b/Models/Instruments/ND/canvas/map/HOLD.lcontroller @@ -0,0 +1,91 @@ +# See: http://wiki.flightgear.org/MapStructure +# TODO: this layer doesn't make sense to support for AI/MP traffic, because we don't currently have access to flightplan/routing info +# that also applies to other layers like WPT or even navaid layers that handle station tuning based on local radio settings +# +# Class things: +var name = 'HOLD'; +var parents = [SymbolLayer.Controller]; +var __self__ = caller(0)[0]; +SymbolLayer.Controller.add(name, __self__); +SymbolLayer.add(name, { + parents: [MultiSymbolLayer], + type: name, # Symbol type + df_controller: __self__, # controller to use by default -- this one + df_options: { # default configuration options + active_node: "/FMGC/flightplan[2]/active", + #current_wp_node: "/FMGC/flightplan[2]/current-wp", + #wp_num: "/FMGC/flightplan[2]/num", + display_inactive_rte: 0 + } +}); +var new = func(layer) { + var m = { + parents: [__self__], + layer: layer, + map: layer.map, + listeners: [], + }; + layer.searcher._equals = func(l,r) 0; # TODO: create model objects instead? + append(m.listeners, setlistener(layer.options.active_node, func m.layer.update() ), setlistener(layer.options.wp_num, func m.layer.update() )); + m.addVisibilityListener(); + var driver = opt_member(m.layer.options, 'route_driver'); + if(driver == nil){ + driver = A3XXRouteDriver.new(); + } + var driver_listeners = driver.getListeners(); + foreach(var listener; driver_listeners){ + append(m.listeners, setlistener(listener, func m.layer.update())); + } + m.route_driver = driver; + return m; +}; +var del = func() { + foreach (var l; me.listeners) + removelistener(l); +}; + +var last_result = []; + +var searchCmd = func { + # FIXME: do we return the active route even if it isn't active? + logprint(_MP_dbg_lvl, "Running query: ", name); + var plans = []; + var driver = me.route_driver; + if(!driver.shouldUpdate()) return me.last_result; + driver.update(); + # http://wiki.flightgear.org/Nasal_Flightplan + var planCount = driver.getNumberOfFlightPlans(); + for(var idx = 0; idx < planCount; idx += 1){ + #var fp = driver.getFlightPlan(idx); + var fpSize = driver.getPlanSize(idx); + if(fpSize < 2) continue; + var type = driver.getFlightPlanType(idx); + if(type == nil) type = 'active'; + if (!getprop(me.layer.options.active_node) and + type == 'active' and + !me.layer.options.display_inactive_rte) fpSize = 0; + var coords = []; + #var hold_wp = me.layer.options.hold_wp; + var path = nil; + if (getprop(me.layer.options.hold_wp) != nil) { + var pdir = (getprop(me.layer.options.hold_direction) == "Right") ? 'R' : 'L'; + for (var a = 0; a<6; a += 1) { + var point = props.globals.getNode(me.layer.options.points_node~'['~a~']'); + path = [(a==2 or a==5) ? '' : pdir, {lon:point.lon, lat:point.lat}]; + coords ~= path; + } + } + append(plans, { + id: type, + #name: type, + type: type, + path: coords, + #size: fpSize, + equals: func(o){ + me.id == o.id# and me.size == o.size + } + }); + } + me.last_result = plans; + return plans; +}; \ No newline at end of file diff --git a/Models/Instruments/ND/canvas/map/HOLD.symbol b/Models/Instruments/ND/canvas/map/HOLD.symbol new file mode 100644 index 00000000..15dfa1ed --- /dev/null +++ b/Models/Instruments/ND/canvas/map/HOLD.symbol @@ -0,0 +1,46 @@ +# See: http://wiki.flightgear.org/MapStructure + +# Class things: +var name = 'HOLD'; +var parents = [RacetrackSymbol]; +var __self__ = caller(0)[0]; +RacetrackSymbol.makeinstance( name, __self__ ); + +SymbolLayer.get(name).df_style = { # style to use by default + line_width: 5, + color: [1,0,1] +}; + +var getLineStyle = func(property, df_val){ + var type = nil; + if(typeof(me.model) == 'hash'){ + type = me.model.type; + } + if(type != nil and type != 'active'){ + var base_prop = property; + property = property~'_'~type; + me.getStyle(property, me.getStyle(base_prop, df_val)); + } else { + me.getStyle(property, df_val); + } +}; + +var setRouteStyle = func{ + var df_style = SymbolLayer.get(name).df_style; + var dash = me.getLineStyle('line_dash', []); + var color = me.getLineStyle('color', df_style.color); + var line_width = me.getLineStyle('line_width', df_style.line_width); + me.element.setColor(color) + .setStrokeLineWidth(line_width); + if(typeof(dash) == 'vector') + me.element.setStrokeDashArray(dash); +}; + +var init = func { + me.setRouteStyle(); +}; + +#var draw = func { +# me.setRouteStyle(); +#}; + diff --git a/Models/Instruments/ND/canvas/style.nas b/Models/Instruments/ND/canvas/style.nas index 7f4579f9..dd880013 100644 --- a/Models/Instruments/ND/canvas/style.nas +++ b/Models/Instruments/ND/canvas/style.nas @@ -459,12 +459,13 @@ canvas.NDStyles["Airbus"] = { } }, options: { - hold_node: "/flight-management/hold", - hold_init: "flight-management/hold/init", - points_node: "/flight-management/hold/points", - first_point_node: "/flight-management/hold/points/point/lat", - hold_wp: "/flight-management/hold/wp", - hold_wp_idx: "/flight-management/hold/wp_id", + hold_node: "/autopilot/hold/", + hold_init: "/autopilot/hold/init", #NOT EXISTS?? + hold_direction: "/autopilot/hold/hold-direction" + points_node: "autopilot/auto-hold/point", + first_point_node: "autopilot/hold/entry", #CHECKME + hold_wp: "autopilot/hold/fix", + #hold_wp_idx: "autopilot/hold/wp_id", range_dependant: 1, listen: [ "first_point_node", From 35b236ffa417933931da2d378284266ca748b05d Mon Sep 17 00:00:00 2001 From: Inuyaksa Date: Tue, 15 Jun 2021 20:07:56 +0200 Subject: [PATCH 03/14] Revert "preliminary for holding pattern support" This reverts commit a42edcfc1fa28b070887b9fbe02e7e4a91a0d0bf. --- .../ND/canvas/framework/canvas.nas | 67 -------------- .../ND/canvas/map/HOLD.lcontroller | 91 ------------------- Models/Instruments/ND/canvas/map/HOLD.symbol | 46 ---------- Models/Instruments/ND/canvas/style.nas | 13 ++- 4 files changed, 6 insertions(+), 211 deletions(-) delete mode 100644 Models/Instruments/ND/canvas/map/HOLD.lcontroller delete mode 100644 Models/Instruments/ND/canvas/map/HOLD.symbol diff --git a/Models/Instruments/ND/canvas/framework/canvas.nas b/Models/Instruments/ND/canvas/framework/canvas.nas index 7dc6cf73..402dff60 100644 --- a/Models/Instruments/ND/canvas/framework/canvas.nas +++ b/Models/Instruments/ND/canvas/framework/canvas.nas @@ -307,70 +307,3 @@ canvas.LineSymbol.draw = func() { me.callback("draw_after"); }; -# RacetrackSymbol - -canvas.RacetrackSymbol.new = func(group, layer, model, controller=nil) { - if (me == nil) __die("Need me reference for RacetrackSymbol.new()"); - if (typeof(model) != "vector") { - if(typeof(model) == "hash"){ - if(!contains(model, "path")) - canvas.__die("RacetrackSymbol.new(): model hash requires path"); - } - else canvas.__die("RacetrackSymbol.new(): need a vector of points or a hash"); - } - var m = { - parents: [me], - group: group, - layer: layer, - model: model, - controller: controller == nil ? me.df_controller : controller, - element: group.createChild( - "path", me.element_id - ), - }; - append(m.parents, m.element); - canvas.Symbol._new(m); - - m.init(); - return m; -}; - # Non-static: -canvas.RacetrackSymbol.draw = func() { - me.callback("draw_before"); - if (!me.needs_update) return; - #logprint(_MP_dbg_lvl, "redrawing a RacetrackSymbol "~me.layer.type); - me.element.reset(); - var cmds = []; - var coords = []; - var cmd = canvas.Path.VG_MOVE_TO; - var path = me.model; - if(typeof(path) == "hash"){ - path = me.model.path; - if(path == nil) - canvas.__die("RacetrackSymbol model requires a 'path' member (vector)"); - } - foreach (var m; path) { - if(size(keys(m)) >= 2){ - var (lat,lon) = me.controller.getpos(m); - append(coords,"N"~lat); - append(coords,"E"~lon); - append(cmds,cmd); - if (m[0] == 'R') cmd = canvas.Path.arcSmallCWTo; - else if (m[0] == 'L') cmd = canvas.Path.arcSmallCCWTo; - else cmd = canvas.Path.VG_LINE_TO; - } else { - cmd = canvas.Path.VG_MOVE_TO; - } - } - - # close racetrack - var (lat,lon) = me.controller.getpos(path[0]); - append(coords,"N"~lat); - append(coords,"E"~lon); - append(cmds,cmd); - - me.element.setDataGeo(cmds, coords); - me.element.update(); # this doesn"t help with flickering, it seems - me.callback("draw_after"); -}; - diff --git a/Models/Instruments/ND/canvas/map/HOLD.lcontroller b/Models/Instruments/ND/canvas/map/HOLD.lcontroller deleted file mode 100644 index 6189d87d..00000000 --- a/Models/Instruments/ND/canvas/map/HOLD.lcontroller +++ /dev/null @@ -1,91 +0,0 @@ -# See: http://wiki.flightgear.org/MapStructure -# TODO: this layer doesn't make sense to support for AI/MP traffic, because we don't currently have access to flightplan/routing info -# that also applies to other layers like WPT or even navaid layers that handle station tuning based on local radio settings -# -# Class things: -var name = 'HOLD'; -var parents = [SymbolLayer.Controller]; -var __self__ = caller(0)[0]; -SymbolLayer.Controller.add(name, __self__); -SymbolLayer.add(name, { - parents: [MultiSymbolLayer], - type: name, # Symbol type - df_controller: __self__, # controller to use by default -- this one - df_options: { # default configuration options - active_node: "/FMGC/flightplan[2]/active", - #current_wp_node: "/FMGC/flightplan[2]/current-wp", - #wp_num: "/FMGC/flightplan[2]/num", - display_inactive_rte: 0 - } -}); -var new = func(layer) { - var m = { - parents: [__self__], - layer: layer, - map: layer.map, - listeners: [], - }; - layer.searcher._equals = func(l,r) 0; # TODO: create model objects instead? - append(m.listeners, setlistener(layer.options.active_node, func m.layer.update() ), setlistener(layer.options.wp_num, func m.layer.update() )); - m.addVisibilityListener(); - var driver = opt_member(m.layer.options, 'route_driver'); - if(driver == nil){ - driver = A3XXRouteDriver.new(); - } - var driver_listeners = driver.getListeners(); - foreach(var listener; driver_listeners){ - append(m.listeners, setlistener(listener, func m.layer.update())); - } - m.route_driver = driver; - return m; -}; -var del = func() { - foreach (var l; me.listeners) - removelistener(l); -}; - -var last_result = []; - -var searchCmd = func { - # FIXME: do we return the active route even if it isn't active? - logprint(_MP_dbg_lvl, "Running query: ", name); - var plans = []; - var driver = me.route_driver; - if(!driver.shouldUpdate()) return me.last_result; - driver.update(); - # http://wiki.flightgear.org/Nasal_Flightplan - var planCount = driver.getNumberOfFlightPlans(); - for(var idx = 0; idx < planCount; idx += 1){ - #var fp = driver.getFlightPlan(idx); - var fpSize = driver.getPlanSize(idx); - if(fpSize < 2) continue; - var type = driver.getFlightPlanType(idx); - if(type == nil) type = 'active'; - if (!getprop(me.layer.options.active_node) and - type == 'active' and - !me.layer.options.display_inactive_rte) fpSize = 0; - var coords = []; - #var hold_wp = me.layer.options.hold_wp; - var path = nil; - if (getprop(me.layer.options.hold_wp) != nil) { - var pdir = (getprop(me.layer.options.hold_direction) == "Right") ? 'R' : 'L'; - for (var a = 0; a<6; a += 1) { - var point = props.globals.getNode(me.layer.options.points_node~'['~a~']'); - path = [(a==2 or a==5) ? '' : pdir, {lon:point.lon, lat:point.lat}]; - coords ~= path; - } - } - append(plans, { - id: type, - #name: type, - type: type, - path: coords, - #size: fpSize, - equals: func(o){ - me.id == o.id# and me.size == o.size - } - }); - } - me.last_result = plans; - return plans; -}; \ No newline at end of file diff --git a/Models/Instruments/ND/canvas/map/HOLD.symbol b/Models/Instruments/ND/canvas/map/HOLD.symbol deleted file mode 100644 index 15dfa1ed..00000000 --- a/Models/Instruments/ND/canvas/map/HOLD.symbol +++ /dev/null @@ -1,46 +0,0 @@ -# See: http://wiki.flightgear.org/MapStructure - -# Class things: -var name = 'HOLD'; -var parents = [RacetrackSymbol]; -var __self__ = caller(0)[0]; -RacetrackSymbol.makeinstance( name, __self__ ); - -SymbolLayer.get(name).df_style = { # style to use by default - line_width: 5, - color: [1,0,1] -}; - -var getLineStyle = func(property, df_val){ - var type = nil; - if(typeof(me.model) == 'hash'){ - type = me.model.type; - } - if(type != nil and type != 'active'){ - var base_prop = property; - property = property~'_'~type; - me.getStyle(property, me.getStyle(base_prop, df_val)); - } else { - me.getStyle(property, df_val); - } -}; - -var setRouteStyle = func{ - var df_style = SymbolLayer.get(name).df_style; - var dash = me.getLineStyle('line_dash', []); - var color = me.getLineStyle('color', df_style.color); - var line_width = me.getLineStyle('line_width', df_style.line_width); - me.element.setColor(color) - .setStrokeLineWidth(line_width); - if(typeof(dash) == 'vector') - me.element.setStrokeDashArray(dash); -}; - -var init = func { - me.setRouteStyle(); -}; - -#var draw = func { -# me.setRouteStyle(); -#}; - diff --git a/Models/Instruments/ND/canvas/style.nas b/Models/Instruments/ND/canvas/style.nas index dd880013..7f4579f9 100644 --- a/Models/Instruments/ND/canvas/style.nas +++ b/Models/Instruments/ND/canvas/style.nas @@ -459,13 +459,12 @@ canvas.NDStyles["Airbus"] = { } }, options: { - hold_node: "/autopilot/hold/", - hold_init: "/autopilot/hold/init", #NOT EXISTS?? - hold_direction: "/autopilot/hold/hold-direction" - points_node: "autopilot/auto-hold/point", - first_point_node: "autopilot/hold/entry", #CHECKME - hold_wp: "autopilot/hold/fix", - #hold_wp_idx: "autopilot/hold/wp_id", + hold_node: "/flight-management/hold", + hold_init: "flight-management/hold/init", + points_node: "/flight-management/hold/points", + first_point_node: "/flight-management/hold/points/point/lat", + hold_wp: "/flight-management/hold/wp", + hold_wp_idx: "/flight-management/hold/wp_id", range_dependant: 1, listen: [ "first_point_node", From 1878bcd02ac85b57faf098a57b1e6aa9e018815a Mon Sep 17 00:00:00 2001 From: Inuyaksa Date: Sat, 19 Jun 2021 23:36:49 +0200 Subject: [PATCH 04/14] ND: TCAS range ring 2.5 mn --- Models/Instruments/ND/canvas/res/airbusND.svg | 115 ++++++++++++++---- Models/Instruments/ND/canvas/style.nas | 20 +++ 2 files changed, 109 insertions(+), 26 deletions(-) diff --git a/Models/Instruments/ND/canvas/res/airbusND.svg b/Models/Instruments/ND/canvas/res/airbusND.svg index c93d3d05..cfa7496d 100644 --- a/Models/Instruments/ND/canvas/res/airbusND.svg +++ b/Models/Instruments/ND/canvas/res/airbusND.svg @@ -1,19 +1,19 @@ .9.9MAP NOT AVAILMAP NOT AVAILRANGE CHANGE + id="nd_msg_change" + inkscape:label="#text3401">RANGE CHANGE diff --git a/Models/Instruments/ND/canvas/style.nas b/Models/Instruments/ND/canvas/style.nas index 7f4579f9..0e65b7f1 100644 --- a/Models/Instruments/ND/canvas/style.nas +++ b/Models/Instruments/ND/canvas/style.nas @@ -1094,6 +1094,16 @@ canvas.NDStyles["Airbus"] = { is_false: func(nd) nd.symbols.planArcs.hide(), }, # of planArcs.impl }, # of planArcs + { + id:"rangeRingPlan", + impl: { + init: func(nd,symbol), + predicate: func(nd) (((nd.in_mode("toggle_display_mode", ["PLAN"])) or ((nd.get_switch("toggle_display_mode") == "MAP") and (nd.get_switch("toggle_centered")))) + and (pts.Instrumentation.TCAS.Inputs.mode.getValue() >= 2) and (nd.rangeNm() <= 20) and (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting))), + is_true: func(nd) nd.symbols.rangeRingPlan.show(), + is_false: func(nd) nd.symbols.rangeRingPlan.hide(), + }, # of rangeRingPlan.impl + }, # of rangeRingPlan { id:"rangeArcs", impl: { @@ -1104,6 +1114,16 @@ canvas.NDStyles["Airbus"] = { is_false: func(nd) nd.symbols.rangeArcs.hide(), }, # of rangeArcs.impl }, # of rangeArcs + { + id:"rangeRingMap", + impl: { + init: func(nd,symbol), + predicate: func(nd) ((nd.get_switch("toggle_display_mode") == "MAP") and (!nd.get_switch("toggle_centered")) + and (pts.Instrumentation.TCAS.Inputs.mode.getValue() >= 2) and (nd.rangeNm() <= 20) and (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting))), + is_true: func(nd) nd.symbols.rangeRingMap.show(), + is_false: func(nd) nd.symbols.rangeRingMap.hide(), + }, # of rangeRingMap.impl + }, # of rangeRingMap { id:"rangePln1", impl: { From 0c72d737ff7bb552ceac6aa11e704de7000d65d7 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sun, 20 Jun 2021 15:56:45 +0100 Subject: [PATCH 05/14] Bugfix --- Nasal/Systems/FADEC/fadec-common.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nasal/Systems/FADEC/fadec-common.nas b/Nasal/Systems/FADEC/fadec-common.nas index f0b29c17..d5799760 100644 --- a/Nasal/Systems/FADEC/fadec-common.nas +++ b/Nasal/Systems/FADEC/fadec-common.nas @@ -285,7 +285,7 @@ var thrust_loop = maketimer(0.04, func { togaLock = alphaProt - 1; if (!pts.Gear.wow[1].getValue() and !pts.Gear.wow[2].getValue() and fbw.FBW.activeLaw.getValue() == 0 and (!pts.Systems.Thrust.engOut.getValue() or (pts.Systems.Thrust.engOut.getValue() and flaps == 0)) and !Fadec.n1Mode[0].getValue() - and !Fadec.n1Mode[1].getValue() and fmgc.FCUworkingNode.getBoolValue()) { + and !Fadec.n1Mode[1].getValue() and fcu.FCUworkingNode.getBoolValue()) { if (alpha > alphaProt and pts.Position.gearAglFt.getValue() >= 100) { Thrust.alphaFloor.setValue(1); Thrust.togaLk.setValue(0); From 01018ef7430493f67b95d9caae01c3306ea0136b Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 21 Jun 2021 16:38:22 +0100 Subject: [PATCH 06/14] Rework the system display handler to properly handle failures and manual calling of pages --- A320-main.xml | 1 + Models/FlightDeck/a320.flightdeck.xml | 24 +- Nasal/ECAM/ECAM-main.nas | 149 +---------- Nasal/ECAM/SystemDisplay.nas | 332 ++++++++++++++++++++++++ Nasal/Libraries/property-tree-setup.nas | 3 + Systems/a320-apu.xml | 1 + 6 files changed, 357 insertions(+), 153 deletions(-) create mode 100644 Nasal/ECAM/SystemDisplay.nas diff --git a/A320-main.xml b/A320-main.xml index b8158454..79e43a8b 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -4656,6 +4656,7 @@ Aircraft/A320-family/Nasal/Systems/tyresmoke.nas + Aircraft/A320-family/Nasal/ECAM/SystemDisplay.nas Aircraft/A320-family/Nasal/ECAM/ECAM-main.nas Aircraft/A320-family/Nasal/ECAM/ECAM-controller.nas Aircraft/A320-family/Nasal/ECAM/ECAM-logic.nas diff --git a/Models/FlightDeck/a320.flightdeck.xml b/Models/FlightDeck/a320.flightdeck.xml index 6bc7fd11..0691d528 100644 --- a/Models/FlightDeck/a320.flightdeck.xml +++ b/Models/FlightDeck/a320.flightdeck.xml @@ -2157,7 +2157,7 @@ nasal - + @@ -2176,7 +2176,7 @@ nasal - + @@ -2195,7 +2195,7 @@ nasal - + @@ -2214,7 +2214,7 @@ nasal - + @@ -2233,7 +2233,7 @@ nasal - + @@ -2252,7 +2252,7 @@ nasal - + @@ -2271,7 +2271,7 @@ nasal - + @@ -2290,7 +2290,7 @@ nasal - + @@ -2309,7 +2309,7 @@ nasal - + @@ -2328,7 +2328,7 @@ nasal - + @@ -2347,7 +2347,7 @@ nasal - + @@ -2366,7 +2366,7 @@ nasal - + diff --git a/Nasal/ECAM/ECAM-main.nas b/Nasal/ECAM/ECAM-main.nas index 5a3f88b8..ab8f015d 100644 --- a/Nasal/ECAM/ECAM-main.nas +++ b/Nasal/ECAM/ECAM-main.nas @@ -5,9 +5,6 @@ var ap_active = 0; var athr_active = 0; -var engModeSel = 0; -var APUMaster = 0; -var APURPM = 0; var apOffTime = props.globals.initNode("/ECAM/warnings/ap-off-time", 0, "INT"); var athrOffTime = props.globals.initNode("/ECAM/warnings/athr-off-time", 0, "INT"); var engStrtTimeSw = props.globals.initNode("/ECAM/engine-start-time-switch", 0, "BOOL"); @@ -28,6 +25,7 @@ var ECAM = { engStrtTime.setValue(0); apWarnNode.setValue(0); athrWarnNode.setValue(0); + SystemDisplayController.init(); me.reset(); }, update_items: [ @@ -77,7 +75,6 @@ var ECAM = { setprop("ECAM/rightmsg/linec" ~ i, "w"); } - page.setValue("door"); me.lights.apu.setValue(0); me.lights.bleed.setValue(0); me.lights.cond.setValue(0); @@ -124,10 +121,8 @@ var ECAM = { update_item.update(notification); } - SystemDisplay.update(notification); - - if (me._cachePage != SystemDisplay.page) { - me.updateSDPage(SystemDisplay.page); + if (me._cachePage != SystemDisplayController.displayedPage.name) { + me.updateSDPage(SystemDisplayController.displayedPage.name); } }, updateSDPage: func(newPage) { @@ -139,128 +134,9 @@ var ECAM = { }, }; -var SystemDisplay = { - page: "", - - manShownPage: 0, - failShownPage: 0, - APU10sec: 9, - eng10sec: 9, - fctl20sc: 9, - _apuTime: 0, - _engTime: 0, - _fctlTime: 0, - - failCall: func(page) { - if (me.manShownPage) { - me.manShownPage = 0; - ECAMControlPanel.lightOff(me.page); - } - ECAMControlPanel.lightOn(page); - me.page = page; - me.failShownPage = 1; - }, - manCall: func(page) { - ECAMControlPanel.lightOff(me.page); - ECAMControlPanel.lightOn(page); - me.page = page; - me.manShownPage = 1; - }, - autoCall: func(page) { - if (me.manShownPage or me.failShownPage) { return; } - if (me.page != page) { - me.page = page; - } - }, - update: func(notification) { - APUMaster = systems.APUNodes.Controls.master.getValue(); - APURPM = pts.APU.rpm.getValue(); - engModeSel = pts.Controls.Engines.startSw.getValue(); - - if (APUMaster == 1 and me.APU10sec != 1) { - me.autoCall("apu"); - me.fctl20sec = 0; - - if (me.APU10sec == 9 and APURPM >= 95.0) { - me.APU10sec = 0; - me._apuTime = notification.elapsedTime; - } - - if (me.APU10sec != 9 and notification.elapsedTime > me._apuTime + 10) { - me.APU10sec = 1; - } - } elsif (engModeSel == 0 or engModeSel == 2 or (engModeSel == 1 and me.eng10sec == 0)) { - me.autoCall("eng"); - me.fctl20sec = 0; - - if (me.eng10sec == 9 and engModeSel == 1) { - me.eng10sec = 0; - me._engTime = notification.elapsedTime; - } - - if (me.eng10sec != 9 and notification.elapsedTime > me._engTime + 10) { - me.eng10sec = 1; - } - } else { - # Reset variables - if (APUMaster == 0) { - me.APU10sec = 9; - } - me.eng10sec = 9; - - # Phase logic - if (notification.FWCPhase == 1) { - me.autoCall("door"); - me.fctl20sec = 9; - } elsif (notification.FWCPhase == 2) { - if (notification.aileronFBW >= 0.15 or notification.elevatorFBW >= 0.15 and me.fctl20sec == 9) { - me.autoCall("fctl"); - - if (me.fctl20sec == 9) { - me.fctl20sec = 0; - me._fctlTime = notification.elapsedTime; - } - - if (me.fctl20sec != 9 and notification.elapsedTime > me._fctlTime + 20) { - me.fctl20sec = 1; - } - } elsif (me.fctl20sec == 0) { - if (me.fctl20sec != 9 and notification.elapsedTime > me._fctlTime + 20) { - me.fctl20sec = 1; - } - } else { - me.autoCall("wheel"); - me.fctl20sec = 9; - } - } elsif (notification.FWCPhase >= 3 and notification.FWCPhase <= 5) { - me.autoCall("eng"); - me.fctl20sec = 9; - } elsif (notification.FWCPhase == 6) { - if (notification.gearLever and notification.agl <= 16000) { - me.autoCall("wheel"); - } else { - me.autoCall("crz"); - } - me.fctl20sec = 9; - } elsif (notification.FWCPhase >= 7 and notification.FWCPhase <= 9) { - me.autoCall("wheel"); - me.fctl20sec = 9; - } elsif (notification.FWCPhase == 10) { - me.autoCall("door"); - me.fctl20sec = 9; - } - } - }, -}; - var ECAMControlPanel = { sysPageBtn: func(page) { - if (SystemDisplay.page != page) { - SystemDisplay.manCall(page); - } else { - me.lightOff(SystemDisplay.page); - SystemDisplay.manShownPage = 0; - } + SystemDisplayController.manCall(page); }, rclBtn: func() { ecam.ECAM_controller.recall(); @@ -278,22 +154,13 @@ var ECAMControlPanel = { return; } - if (SystemDisplay.manShownPage) { - me.lightOff(SystemDisplay.page); - SystemDisplay.manShownPage = 0; - return; - } - - if (SystemDisplay.failShownPage) { - me.lightOff(SystemDisplay.page); - SystemDisplay.failShownPage = 0; - return; - } - + SystemDisplayController.manCall("CLR"); ecam.ECAM_controller.clear(); }, stsBtn: func() { - SystemDisplay.manCall("sts"); + if (SystemDisplayController.displayedPage.name != "statusPage") { + SystemDisplayController.manCall("statusPage"); + } }, allBtn: func() { # todo diff --git a/Nasal/ECAM/SystemDisplay.nas b/Nasal/ECAM/SystemDisplay.nas new file mode 100644 index 00000000..23572e5c --- /dev/null +++ b/Nasal/ECAM/SystemDisplay.nas @@ -0,0 +1,332 @@ +var Page = { + new: func(name) { + var page = {parents:[Page]}; + page.name = name; + return page; + }, +}; + +var SystemDisplayController = { + PageList: { + apuPage: Page.new("apu"), + bleedPage: Page.new("bleed"), + cabPressPage: Page.new("press"), + condPage: Page.new("cond"), + cruisePage: Page.new("cruise"), + doorPage: Page.new("door"), + enginePage: Page.new("eng"), + elecPage: Page.new("elec"), + fctlPage: Page.new("fctl"), + fuelPage: Page.new("fuel"), + hydraulicPage: Page.new("hyd"), + statusPage: Page.new("sts"), + wheelPage: Page.new("wheel"), + }, + displayedPage: nil, + lastDisplayedPage: nil, + lastMode: nil, + mode: 0, # 0 = man, 1 = warning, 2 = advisory (not used yet), 3 = auto + tempFWCPhase: nil, + tempElapsedTime: nil, + tempEngineModeSel: nil, + init: func() { + me.displayedPage = me.PageList.doorPage; + ECAMTimer.start(); + }, + autoCallLoop: func() { + me.tempFWCPhase = pts.ECAM.fwcWarningPhase.getValue(); + + if (me.Display.APU) { + me.displayedPage = me.PageList.apuPage; + } else if (me.Display.Engine) { + me.displayedPage = me.PageList.enginePage; + } else if (me.tempFWCPhase == 1) { + if (me.Display.Elec) { + me.displayedPage = me.PageList.elecPage; + } else { + me.displayedPage = me.PageList.doorPage; + } + } else if (me.tempFWCPhase == 2) { + if (me.Display.Elec) { + me.displayedPage = me.PageList.elecPage; + } else if (me.Display.FCTL) { + me.displayedPage = me.PageList.fctlPage; + } else { + me.displayedPage = me.PageList.wheelPage; + } + } else if (me.tempFWCPhase == 3 or me.tempFWCPhase == 4 or me.tempFWCPhase == 5) { + me.displayedPage = me.PageList.enginePage; + } else if (me.tempFWCPhase == 6) { + if (pts.Controls.Gear.gearDown.getValue() and me.altitudeBelow16000) { + me.displayedPage = me.PageList.wheelPage; + } else if (me.Display.Cruise) { + me.displayedPage = me.PageList.cruisePage; + } else { + me.displayedPage = me.PageList.enginePage; + } + } else if (me.tempFWCPhase == 7) { + me.displayedPage = me.PageList.wheelPage; + } else if (me.tempFWCPhase == 8 or me.tempFWCPhase == 9) { + if (me.Display.Elec) { + me.displayedPage = me.PageList.elecPage; + } else { + me.displayedPage = me.PageList.wheelPage; + } + } else if (me.tempFWCPhase == 10) { + if (me.Display.Elec) { + me.displayedPage = me.PageList.elecPage; + } else { + me.displayedPage = me.PageList.doorPage; + } + } + }, + Timers: { + APUTimeOn: 0, + APUTime: 0, + CruiseTime: 0, + CruiseTimeOn: 0, + EngineTime: 0, + EngineTimeStart: 0, + EngineTimeOn: 0, + FCTLTimeStart: 0, + FCTLTimeOn: 0, + FCTLTime: 0, + }, + Display: { + APU: 0, + Cruise: 0, + Elec: 0, + Engine: 0, + FCTL: 0, + }, + altitudeBelow16000: 0, + update: func() { + me.tempElapsedTime = pts.Sim.Time.elapsedSec.getValue(); + + me.altitude = pts.Position.altitudeFt.getValue(); + if (me.altitude < 16000) { + if (!me.altitudeBelow16000) { + me.altitudeBelow16000 = 1; + me.autoCallLoop(); + } + } else { + if (me.altitudeBelow16000) { + me.altitudeBelow16000 = 0; + me.autoCallLoop(); + } + } + + if (systems.ELEC.Switch.emerGenTest.getValue()) { + if (!me.Display.Elec) { + me.Display.Elec = 1; + me.autoCallLoop(); + } + } else { + if (me.Display.Elec) { + me.Display.Elec = 0; + me.autoCallLoop(); + } + } + + if (systems.APUNodes.Controls.master.getValue()) { + if (pts.APU.rpm.getValue() > 95 and !me.Timers.APUTimeOn) { + me.Timers.APUTimeOn = 1; + me.Timers.APUTime = me.tempElapsedTime; + } + + if ((me.Timers.APUTimeOn and (me.tempElapsedTime - me.Timers.APUTime) < 10) or !me.Timers.APUTimeOn) { + if (!me.Display.APU) { + me.Display.APU = 1; + me.autoCallLoop(); + } + } else { + if (me.Display.APU) { + me.Display.APU = 0; + me.autoCallLoop(); + } + } + } else { + me.Timers.APUTimeOn = 0; + me.Timers.APUTime = 0; + if (me.Display.APU) { + me.Display.APU = 0; + me.autoCallLoop(); + } + } + + if (abs(pts.Controls.Flight.aileron.getValue()) > 0.05 or abs(pts.Controls.Flight.elevator.getValue()) > 0.05 or abs(pts.Controls.Flight.rudder.getValue()) > 0.50) { + me.Timers.FCTLTimeStart = 1; + if (!me.Display.FCTL) { + me.Display.FCTL = 1; + me.autoCallLoop(); + } + me.autoCallLoop(); + } else { + if (!me.Timers.FCTLTimeOn and me.Timers.FCTLTimeStart) { + me.Timers.FCTLTimeOn = 1; + me.Timers.FCTLTimeStart = 0; + me.Timers.FCTLTime = me.tempElapsedTime; + } else if (me.Timers.FCTLTimeOn) { + if ((me.tempElapsedTime - me.Timers.FCTLTime) < 20) { + if (!me.Display.FCTL) { + me.Display.FCTL = 1; + me.autoCallLoop(); + } + } else { + me.Timers.FCTLTimeOn = 0; + me.Timers.FCTLTime = 0; + } + } else { + if (me.Display.FCTL) { + me.Display.FCTL = 0; + me.autoCallLoop(); + } + me.Timers.FCTLTime = 0; + } + } + + me.tempFWCPhase = pts.ECAM.fwcWarningPhase.getValue(); + if (me.tempFWCPhase == 6) { + if (!ecam.FWC.toPower.getValue() and pts.Controls.Flight.flapsPos.getValue() == 0) { + if (!me.Display.Cruise) { + me.Display.Cruise = 1; + me.autoCallLoop(); + } + } else if (!me.Display.Cruise) { + if (!me.Timers.CruiseTimeOn) { + me.Timers.CruiseTimeOn = 1; + me.Timers.CruiseTime = me.tempElapsedTime; + } else { + if ((me.tempElapsedTime - me.Timers.CruiseTime) > 60) { + if (!me.Display.Cruise) { + me.Display.Cruise = 1; + me.autoCallLoop(); + } + } + } + } + } else { + me.Timers.CruiseTime = 0; + me.Timers.CruiseTimeOn = 0; + if (me.Display.Cruise) { + me.Display.Cruise = 0; + me.autoCallLoop(); + } + } + + me.tempEngineModeSel = pts.Controls.Engines.startSw.getValue(); + if (me.tempEngineModeSel == 0 or me.tempEngineModeSel == 2) { + if (!me.Display.Engine) { + me.Display.Engine = 1; + me.autoCallLoop(); + } + + if (me.tempEngineModeSel == 2) { + me.Timers.EngineTimeStart = 1; + } + } else { + if (me.Timers.EngineTimeStart and !me.Timers.EngineTimeOn) { + me.Timers.EngineTimeOn = 1; + me.Timers.EngineTime = me.tempElapsedTime; + } + + if (me.Timers.EngineTimeOn) { + if ((me.tempElapsedTime - me.Timers.EngineTime) < 10) { + if (!me.Display.Engine) { + me.Display.Engine = 1; + me.autoCallLoop(); + } + } else { + me.Timers.EngineTimeStart = 0; + me.Timers.EngineTimeOn = 0; + me.Timers.EngineTime = 0; + if (me.Display.Engine) { + me.Display.Engine = 0; + me.autoCallLoop(); + } + } + } else { + if (me.Display.Engine) { + me.Display.Engine = 0; + me.autoCallLoop(); + } + } + } + }, + autoCall: func() { + me.mode = 3; + me.autoCallLoop(); + }, + failureCall: func(newPage) { + if (contains(me.PageList, newPage)) { + me.lastDisplayedPage = me.displayedPage; + me.displayedPage = me.PageList[newPage]; + me.lastMode = me.mode; + me.mode = 1; + ECAMControlPanel.lightOff(me.lastDisplayedPage.name); + ECAMControlPanel.lightOn(me.displayedPage.name); + } else { + debug.dump("Attempted to set page to unknown page", newPage); + } + }, + manCall: func(newPage) { + if (contains(me.PageList, newPage)) { + if (me.displayedPage == me.PageList[newPage] and me.mode != 3) { + ECAMControlPanel.lightOff(me.displayedPage.name); + me.displayedPage = me.autoCall(); + } else { + ECAMControlPanel.lightOff(me.displayedPage.name); + if (me.mode == 1) { + me.lastDisplayedPage = me.displayedPage; + me.lastMode = me.mode; + } + me.displayedPage = me.PageList[newPage]; + me.mode = 0; + ECAMControlPanel.lightOn(me.displayedPage.name); + } + } elsif (newPage == "CLR") { + if (me.mode == 1) { + if (me.lastMode == 0) { + ECAMControlPanel.lightOff(me.displayedPage.name); + me.displayedPage = me.lastDisplayedPage; + ECAMControlPanel.lightOn(me.displayedPage.name); + me.lastDisplayedPage = nil; + me.mode = 0; + } else { + ECAMControlPanel.lightOff(me.displayedPage.name); + me.displayedPage = me.autoCall(); + } + } elsif (me.mode == 0) { + if (me.lastMode == 1) { + ECAMControlPanel.lightOff(me.displayedPage.name); + me.displayedPage = me.lastDisplayedPage; + ECAMControlPanel.lightOn(me.displayedPage.name); + me.lastDisplayedPage = nil; + me.mode = 1; + } else { + ECAMControlPanel.lightOff(me.displayedPage.name); + me.displayedPage = me.autoCall(); + } + } + } else { + debug.dump("Attempted to set page to unknown page", newPage); + } + }, +}; + +setlistener("/ECAM/warning-phase", func() { + if (SystemDisplayController.mode == 3) { + SystemDisplayController.autoCall(); + } +}, 0, 0); + +setlistener("/controls/gear/gear-down", func() { + if (SystemDisplayController.mode == 3) { + SystemDisplayController.autoCall(); + } +}, 0, 0); + + +var ECAMTimer = maketimer(1, func() { + SystemDisplayController.update(); +}); \ No newline at end of file diff --git a/Nasal/Libraries/property-tree-setup.nas b/Nasal/Libraries/property-tree-setup.nas index 85b13d6d..b64e56ca 100644 --- a/Nasal/Libraries/property-tree-setup.nas +++ b/Nasal/Libraries/property-tree-setup.nas @@ -50,6 +50,7 @@ var Controls = { aileron: props.globals.getNode("/controls/flight/aileron"), aileronDrivesTiller: props.globals.getNode("/controls/flight/aileron-drives-tiller"), autoCoordination: props.globals.getNode("/controls/flight/auto-coordination"), + elevator: props.globals.getNode("/controls/flight/elevator"), elevatorTrim: props.globals.getNode("/controls/flight/elevator-trim"), flaps: props.globals.getNode("/controls/flight/flaps"), flapsTemp: 0, @@ -57,6 +58,7 @@ var Controls = { flapsPos: props.globals.getNode("/controls/flight/flaps-pos"), speedbrake: props.globals.getNode("/controls/flight/speedbrake"), speedbrakeArm: props.globals.getNode("/controls/flight/speedbrake-arm"), + rudder: props.globals.getNode("/controls/flight/rudder"), rudderTrim: props.globals.getNode("/controls/flight/rudder-trim"), }, Gear: { @@ -217,6 +219,7 @@ var Orientation = { }; var Position = { + altitudeFt: props.globals.getNode("/position/altitude-ft"), gearAglFt: props.globals.getNode("/position/gear-agl-ft"), latitude: props.globals.getNode("/position/latitude-deg"), longitude: props.globals.getNode("/position/longitude-deg"), diff --git a/Systems/a320-apu.xml b/Systems/a320-apu.xml index 42691717..f6ad2161 100644 --- a/Systems/a320-apu.xml +++ b/Systems/a320-apu.xml @@ -182,6 +182,7 @@ /systems/apu/oil/level-l + From 11c230bdfe5bb00b0e7cd571c212e7afa78f059c Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 21 Jun 2021 16:41:29 +0100 Subject: [PATCH 07/14] Fix ECAM controller --- Nasal/ECAM/ECAM-controller.nas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index d84b680d..cb5ff9ab 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -243,7 +243,7 @@ var warning = { }, callPage: func() { if (me.sdPage == "nil" or me.hasCalled == 1) { return; } - ecam.SystemDisplay.failCall(me.sdPage); + ecam.SystemDisplayController.failureCall(me.sdPage); me.hasCalled = 1; } }; @@ -478,7 +478,7 @@ var ECAM_controller = { } if (statusFlag == 1 and lines[0].getValue() == "") { - ecam.SystemDisplay.manCall("sts"); + ecam.SystemDisplay.manCall("statusPage"); statusFlag = 0; } }, From 6f4865e5422ab55a3f93ba30851bf734aebd99c2 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 21 Jun 2021 16:42:36 +0100 Subject: [PATCH 08/14] ECAM controller fix #2 --- Nasal/ECAM/ECAM-controller.nas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index cb5ff9ab..23fefb7a 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -478,7 +478,7 @@ var ECAM_controller = { } if (statusFlag == 1 and lines[0].getValue() == "") { - ecam.SystemDisplay.manCall("statusPage"); + ecam.SystemDisplayController.manCall("statusPage"); statusFlag = 0; } }, From 1811431d00fe0f66e2b5ff8bb6dfc94b74be3e10 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 21 Jun 2021 16:51:31 +0100 Subject: [PATCH 09/14] First test of a warning triggering a failure page call --- Nasal/ECAM/ECAM-controller.nas | 1 + Nasal/ECAM/ECAM-logic.nas | 6 +++--- Nasal/ECAM/ECAM-messages.nas | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index 23fefb7a..00881a12 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -352,6 +352,7 @@ var ECAM_controller = { if (counter < 9) { w.write(); counter += 1; + w.callPage(); } w.warnlight(); w.sound(); diff --git a/Nasal/ECAM/ECAM-logic.nas b/Nasal/ECAM/ECAM-logic.nas index 670a67c9..a5b764c5 100644 --- a/Nasal/ECAM/ECAM-logic.nas +++ b/Nasal/ECAM/ECAM-logic.nas @@ -211,19 +211,19 @@ var messages_priority_3 = func { } # ENG FIRE - if ((eng1FireFlAgent2.clearFlag == 0 and systems.eng1FireWarn.getValue() == 1 and phaseVar3 >= 5 and phaseVar3 <= 7) or (eng1FireGnEvac.clearFlag == 0 and systems.eng1FireWarn.getValue() == 1 and (phaseVar3 < 5 or phaseVar3 > 7))) { + if ((eng1Fire.clearFlag == 0 and systems.eng1FireWarn.getValue() == 1 and phaseVar3 >= 5 and phaseVar3 <= 7) or (eng1FireGnEvac.clearFlag == 0 and systems.eng1FireWarn.getValue() == 1 and (phaseVar3 < 5 or phaseVar3 > 7))) { eng1Fire.active = 1; } else { ECAM_controller.warningReset(eng1Fire); } - if ((eng2FireFlAgent2.clearFlag == 0 and systems.eng2FireWarn.getValue() == 1 and phaseVar3 >= 5 and phaseVar3 <= 7) or (eng2FireGnEvac.clearFlag == 0 and systems.eng2FireWarn.getValue() == 1 and (phaseVar3 < 5 or phaseVar3 > 7))) { + if ((eng2Fire.clearFlag == 0 and systems.eng2FireWarn.getValue() == 1 and phaseVar3 >= 5 and phaseVar3 <= 7) or (eng2FireGnEvac.clearFlag == 0 and systems.eng2FireWarn.getValue() == 1 and (phaseVar3 < 5 or phaseVar3 > 7))) { eng2Fire.active = 1; } else { ECAM_controller.warningReset(eng2Fire); } - if (apuFireMaster.clearFlag == 0 and systems.apuFireWarn.getValue() == 1) { + if (apuFire.clearFlag == 0 and systems.apuFireWarn.getValue() == 1) { apuFire.active = 1; } else { ECAM_controller.warningReset(apuFire); diff --git a/Nasal/ECAM/ECAM-messages.nas b/Nasal/ECAM/ECAM-messages.nas index a0d2c854..5560b411 100644 --- a/Nasal/ECAM/ECAM-messages.nas +++ b/Nasal/ECAM/ECAM-messages.nas @@ -101,7 +101,7 @@ var warnings = std.Vector.new([ var ADR123FaultPROC = warning.new(msg: " -ALL ADR OFF PROC.APPLY", colour: "c"), # APU FIRE - var apuFire = warning.new(msg: "APU FIRE ", colour: "r", aural: 0, light: 0, isMainMsg: 1, sdPage: "apu"), + var apuFire = warning.new(msg: "APU FIRE ", colour: "r", aural: 0, light: 0, isMainMsg: 1, sdPage: "apuPage"), var apuFirePB = warning.new(msg: " -APU FIRE P/B......PUSH", colour: "c"), var apuFireAgentTimer = warning.new(msg: " -AGENT AFT 10 S...DISCH", colour: "c"), var apuFireAgent = warning.new(msg: " -AGENT............DISCH", colour: "c"), From 611cd9c74ca208bfec8ccf37cd094ee4de638980 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 21 Jun 2021 17:52:13 +0100 Subject: [PATCH 10/14] More stuff --- Models/Instruments/Lower-ECAM/Lower-ECAM.nas | 2 +- Nasal/ECAM/ECAM-controller.nas | 9 +++++++-- Nasal/ECAM/ECAM-logic.nas | 4 ++-- Nasal/ECAM/ECAM-main.nas | 5 ++--- Nasal/ECAM/SystemDisplay.nas | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas index ae1298d8..35e6d808 100644 --- a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas +++ b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas @@ -296,7 +296,7 @@ var canvas_lowerECAM_base = { lowerECAM_hyd.page.hide(); lowerECAM_wheel.page.hide(); lowerECAM_cond.update(); - } else if (page == "crz") { + } else if (page == "cruise") { lowerECAM_apu.page.hide(); lowerECAM_bleed.page.hide(); lowerECAM_cond.page.hide(); diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index 00881a12..b3628e89 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -478,9 +478,14 @@ var ECAM_controller = { } } - if (statusFlag == 1 and lines[0].getValue() == "") { - ecam.SystemDisplayController.manCall("statusPage"); + if (!hasCleared and statusFlag) { statusFlag = 0; + ecam.SystemDisplayController.manCall("statusPage"); + return; + } + + if (!hasCleared and !statusFlag) { + SystemDisplayController.manCall("CLR"); } }, recall: func() { diff --git a/Nasal/ECAM/ECAM-logic.nas b/Nasal/ECAM/ECAM-logic.nas index a5b764c5..90aa0205 100644 --- a/Nasal/ECAM/ECAM-logic.nas +++ b/Nasal/ECAM/ECAM-logic.nas @@ -551,13 +551,13 @@ var messages_priority_3 = func { apuFireAgentTimer.msg = " -AGENT AFT " ~ systems.apuAgentTimer.getValue() ~ " S...DISCH"; } - if (apuFireAgent.clearFlag == 0 and systems.APUNodes.Controls.fire.getValue() and !systems.extinguisherBottles.vector[5].lightProp.getValue() and systems.apuAgentTimer.getValue() != 0) { + if (apuFireAgent.clearFlag == 0 and systems.APUNodes.Controls.fire.getValue() and !systems.extinguisherBottles.vector[4].lightProp.getValue() and systems.apuAgentTimer.getValue() != 0) { apuFireAgentTimer.active = 1; } else { ECAM_controller.warningReset(apuFireAgentTimer); } - if (apuFireAgent.clearFlag == 0 and systems.APUNodes.Controls.fire.getValue() and !systems.extinguisherBottles.vector[5].lightProp.getValue() and systems.apuAgentTimer.getValue() == 0) { + if (apuFireAgent.clearFlag == 0 and systems.APUNodes.Controls.fire.getValue() and !systems.extinguisherBottles.vector[4].lightProp.getValue() and systems.apuAgentTimer.getValue() == 0) { apuFireAgent.active = 1; } else { ECAM_controller.warningReset(apuFireAgent); diff --git a/Nasal/ECAM/ECAM-main.nas b/Nasal/ECAM/ECAM-main.nas index ab8f015d..8ce03bed 100644 --- a/Nasal/ECAM/ECAM-main.nas +++ b/Nasal/ECAM/ECAM-main.nas @@ -154,7 +154,6 @@ var ECAMControlPanel = { return; } - SystemDisplayController.manCall("CLR"); ecam.ECAM_controller.clear(); }, stsBtn: func() { @@ -172,11 +171,11 @@ var ECAMControlPanel = { # todo }, lightOff: func(pageLightOff) { - if (pageLightOff == "crz") { return; } + if (pageLightOff == "cruise") { return; } ECAM.lights[pageLightOff].setBoolValue(0); }, lightOn: func(pageLightOn) { - if (pageLightOn == "crz") { return; } + if (pageLightOn == "cruise") { return; } ECAM.lights[pageLightOn].setBoolValue(1); }, }; diff --git a/Nasal/ECAM/SystemDisplay.nas b/Nasal/ECAM/SystemDisplay.nas index 23572e5c..e3f0f75e 100644 --- a/Nasal/ECAM/SystemDisplay.nas +++ b/Nasal/ECAM/SystemDisplay.nas @@ -259,11 +259,11 @@ var SystemDisplayController = { }, failureCall: func(newPage) { if (contains(me.PageList, newPage)) { + ECAMControlPanel.lightOff(me.displayedPage.name); me.lastDisplayedPage = me.displayedPage; me.displayedPage = me.PageList[newPage]; me.lastMode = me.mode; me.mode = 1; - ECAMControlPanel.lightOff(me.lastDisplayedPage.name); ECAMControlPanel.lightOn(me.displayedPage.name); } else { debug.dump("Attempted to set page to unknown page", newPage); From 10edd0fd0f5b018fab5ed6695e3c9b27fc817ee7 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 22 Jun 2021 15:26:56 +0100 Subject: [PATCH 11/14] ECAM phases: fix interaction of phase 1 / phase 10 and finish the move from Nasal --> jsb --- Nasal/ECAM/ECAM-main.nas | 11 ++-- Nasal/ECAM/ECAM-phases.nas | 119 +++++++++++++----------------------- Systems/a320-fwc-phases.xml | 85 ++++++++++++++++++++++++-- 3 files changed, 126 insertions(+), 89 deletions(-) diff --git a/Nasal/ECAM/ECAM-main.nas b/Nasal/ECAM/ECAM-main.nas index 8ce03bed..4c814e53 100644 --- a/Nasal/ECAM/ECAM-main.nas +++ b/Nasal/ECAM/ECAM-main.nas @@ -69,10 +69,10 @@ var ECAM = { }, reset: func() { for (var i = 0; i <= 8; i = i + 1) { - setprop("ECAM/msg/line" ~ i, ""); - setprop("ECAM/rightmsg/line" ~ i, ""); - setprop("ECAM/msg/linec" ~ i, "w"); - setprop("ECAM/rightmsg/linec" ~ i, "w"); + setprop("/ECAM/msg/line" ~ i, ""); + setprop("/ECAM/rightmsg/line" ~ i, ""); + setprop("/ECAM/msg/linec" ~ i, "w"); + setprop("/ECAM/rightmsg/linec" ~ i, "w"); } me.lights.apu.setValue(0); @@ -129,9 +129,6 @@ var ECAM = { me._cachePage = newPage; page.setValue(newPage); }, - clrLight: func() { - me.lights.clr.setValue(1); - }, }; var ECAMControlPanel = { diff --git a/Nasal/ECAM/ECAM-phases.nas b/Nasal/ECAM/ECAM-phases.nas index edccc4c4..3dea0097 100644 --- a/Nasal/ECAM/ECAM-phases.nas +++ b/Nasal/ECAM/ECAM-phases.nas @@ -2,7 +2,7 @@ # Copyright (c) 2019 Jonathan Redpath (legoboyvdlp) -var myPhase = nil; +var currentPhase = nil; var eng = nil; var eng1epr = nil; var eng2epr = nil; @@ -22,11 +22,16 @@ var FWC = { Monostable: { phase1: props.globals.initNode("/ECAM/phases/monostable/phase-1-300", 0, "BOOL"), phase5: props.globals.initNode("/ECAM/phases/monostable/phase-5", 0, "BOOL"), + phase5Temp: 0, phase7: props.globals.initNode("/ECAM/phases/monostable/phase-7", 0, "BOOL"), + phase7Temp: 0, phase9: props.globals.initNode("/ECAM/phases/monostable/phase-9", 0, "BOOL"), phase1Output: props.globals.initNode("/ECAM/phases/monostable/phase-1-300-output"), + phase1OutputTemp: 0, phase5Output: props.globals.initNode("/ECAM/phases/monostable/phase-5-output"), + phase5OutputTemp: 0, phase7Output: props.globals.initNode("/ECAM/phases/monostable/phase-7-output"), + phase7OutputTemp: 0, phase9Output: props.globals.initNode("/ECAM/phases/monostable/phase-9-output"), toPowerOutput: props.globals.getNode("/ECAM/phases/monostable/to-power-set-output"), m80kt: props.globals.getNode("/ECAM/phases/monostable-80kt"), @@ -38,12 +43,14 @@ var FWC = { phase2Set: props.globals.initNode("/ECAM/phases/flipflop/phase-2-set", 0, "BOOL"), phase2Reset: props.globals.initNode("/ECAM/phases/flipflop/phase-2-reset", 0, "BOOL"), phase2Output: props.globals.initNode("/ECAM/phases/flipflop/phase-2-output", 0, "BOOL"), + phase2OutputTemp: 0, phase10Set: props.globals.initNode("/ECAM/phases/flipflop/phase-10-set", 0, "BOOL"), phase10Reset: props.globals.initNode("/ECAM/phases/flipflop/phase-10-reset", 0, "BOOL"), phase10Output: props.globals.initNode("/ECAM/phases/flipflop/phase-10-output", 0, "BOOL"), recallSet: props.globals.initNode("/ECAM/flipflop/recall-set", 0, "BOOL"), recallReset: props.globals.initNode("/ECAM/flipflop/recall-reset", 0, "BOOL"), recallOutput: props.globals.initNode("/ECAM/flipflop/recall-output", 0, "BOOL"), + recallOutputTemp: 0, }, Logic: { gnd: props.globals.getNode("/ECAM/logic/ground-calc-immediate"), @@ -60,7 +67,9 @@ var FWC = { eng1idleOutput: props.globals.getNode("/ECAM/phases/timer/eng1idle-output"), eng2idleOutput: props.globals.getNode("/ECAM/phases/timer/eng2idle-output"), eng1and2Off: props.globals.getNode("/ECAM/phases/phase-calculation/engines-1-2-not-running"), + eng1and2OffTemp: 0, eng1or2Output: props.globals.getNode("/ECAM/phases/phase-calculation/engine-1-or-2-running"), + eng1or2OutputTemp: 0, toInhibitOutput: props.globals.getNode("/ECAM/phases/timer/to-inhibit-output"), ldgInhibitOutput: props.globals.getNode("/ECAM/phases/timer/ldg-inhibit-output"), gnd: props.globals.getNode("/ECAM/timer/ground-calc"), # ZGND @@ -68,7 +77,9 @@ var FWC = { gnd2SecHalf: props.globals.getNode("/ECAM/phases/monostable/gnd-output-2"), # hack to prevent getting confused between phase 5 / 6 }, speed80: props.globals.initNode("/ECAM/phases/speed-gt-80", 0, "BOOL"), + speed80Temp: 0, toPower: props.globals.getNode("/ECAM/phases/phase-calculation/takeoff-power"), + toPowerTemp: 0, altChg: props.globals.getNode("/it-autoflight/input/alt-is-changing", 1), }; @@ -79,124 +90,78 @@ var phaseLoop = func() { if ((systems.ELEC.Bus.acEss.getValue() < 110 and systems.ELEC.Bus.ac2.getValue() < 110) or pts.Acconfig.running.getBoolValue()) { return; } if (pts.Sim.Replay.replayActive.getBoolValue()) { return; } - myPhase = pts.ECAM.fwcWarningPhase.getValue(); - eng = pts.Options.eng.getValue(); - eng1epr = pts.Engines.Engine.eprActual[0].getValue(); - eng2epr = pts.Engines.Engine.eprActual[1].getValue(); - eng1n1 = pts.Engines.Engine.n1Actual[0].getValue(); - eng2n1 = pts.Engines.Engine.n1Actual[1].getValue(); - master1 = pts.Controls.Engines.Engine.cutoffSw[0].getBoolValue(); - master2 = pts.Controls.Engines.Engine.cutoffSw[1].getBoolValue(); + currentPhase = pts.ECAM.fwcWarningPhase.getValue(); gnd = FWC.Logic.gnd.getBoolValue(); gndTimer = FWC.Timer.gnd.getValue(); - FWC.Flipflop.recallReset.setValue(0); + + if (FWC.Flipflop.recallReset.getValue() != 0) { + FWC.Flipflop.recallReset.setValue(0); + } - # Various things - - if (myPhase == 9) { - FWC.Monostable.phase9.setBoolValue(1); - } else { - FWC.Monostable.phase9.setBoolValue(0); - } - - # Phase 1 / 10 flipflop - if (myPhase == 9) { - FWC.Flipflop.phase10Set.setBoolValue(1); - } else { - FWC.Flipflop.phase10Set.setBoolValue(0); - } - - if (gndTimer == 1 and pts.Controls.Engines.Engine.firePb[0].getBoolValue()) { - FWC.Flipflop.phase10Reset.setBoolValue(1); - } else { - FWC.Flipflop.phase10Reset.setBoolValue(0); - } - - if ((gnd and FWC.Timer.eng1and2Off.getValue() and myPhase == 9) and FWC.Flipflop.phase10Output.getBoolValue()) { - FWC.Monostable.phase1.setBoolValue(1); # true for 300 sec then false - } else { - FWC.Monostable.phase1.setBoolValue(0); - } - - # Phase 2 flipflop - if (myPhase == 3 or myPhase == 8) { - FWC.Flipflop.phase2Set.setBoolValue(1); - } else { - FWC.Flipflop.phase2Set.setBoolValue(0); - } - - if (!FWC.Monostable.m80kt.getBoolValue() and myPhase != 9 and ((!FWC.Monostable.phase9Output.getBoolValue() and gndTimer == 1) or (!FWC.Monostable.toPowerOutput.getBoolValue() and gndTimer == 1))) { - FWC.Flipflop.phase2Reset.setBoolValue(1); - } else { - FWC.Flipflop.phase2Reset.setBoolValue(0); - } - gear_agl_cur = pts.Position.gearAglFt.getValue(); + FWC.toPowerTemp = FWC.toPower.getBoolValue(); + FWC.Timer.eng1and2OffTemp = FWC.Timer.eng1and2Off.getValue(); + FWC.Timer.eng1or2OutputTemp = FWC.Timer.eng1or2Output.getBoolValue(); + FWC.speed80Temp = FWC.speed80.getBoolValue(); - # Phase 5 monostable - if (FWC.toPower.getBoolValue() and (!FWC.Logic.feet1500.getBoolValue() and !gnd and FWC.Timer.gnd2Sec.getValue() != 1)) { - FWC.Monostable.phase5.setBoolValue(1); - } else { - FWC.Monostable.phase5.setBoolValue(0); - } + FWC.Monostable.phase1OutputTemp = FWC.Monostable.phase1Output.getBoolValue(); + FWC.Flipflop.phase2OutputTemp = FWC.Flipflop.phase2Output.getBoolValue(); + FWC.Monostable.phase5Temp = FWC.Monostable.phase5.getBoolValue(); + FWC.Monostable.phase5OutputTemp = FWC.Monostable.phase5Output.getBoolValue(); + FWC.Monostable.phase7Temp = FWC.Monostable.phase7.getBoolValue(); + FWC.Monostable.phase7OutputTemp = FWC.Monostable.phase7Output.getBoolValue(); - # Phase 7 monostable - if (!FWC.toPower.getBoolValue() and !FWC.Logic.feet1500.getBoolValue() and !FWC.Logic.feet800.getBoolValue() and !gnd and FWC.Timer.gnd2Sec.getValue() != 1) { - FWC.Monostable.phase7.setBoolValue(1); - } else { - FWC.Monostable.phase7.setBoolValue(0); - } - - # Actual Phases - if ((gnd and FWC.Timer.eng1and2Off.getValue() and myPhase != 9) and !FWC.Monostable.phase1Output.getBoolValue()) { + # Set Phases + if ((gnd and FWC.Timer.eng1and2OffTemp and currentPhase != 9) and !FWC.Monostable.phase1OutputTemp) { setPhase(1); } - if (FWC.Timer.eng1or2Output.getBoolValue() and (gnd and !FWC.toPower.getBoolValue() and !FWC.speed80.getBoolValue()) and !FWC.Flipflop.phase2Output.getBoolValue()) { + if (FWC.Timer.eng1or2OutputTemp and (gnd and !FWC.toPowerTemp and !FWC.speed80Temp) and !FWC.Flipflop.phase2OutputTemp) { setPhase(2); } - if (FWC.Timer.eng1or2Output.getBoolValue() and (gndTimer == 1 and FWC.toPower.getBoolValue()) and !FWC.speed80.getBoolValue()) { + if (FWC.Timer.eng1or2OutputTemp and (gndTimer == 1 and FWC.toPowerTemp) and !FWC.speed80Temp) { setPhase(3); } - if ((gndTimer == 1 and FWC.toPower.getBoolValue()) and FWC.speed80.getBoolValue()) { + if ((gndTimer == 1 and FWC.toPowerTemp) and FWC.speed80Temp) { setPhase(4); } - if (FWC.Monostable.phase5.getBoolValue() and FWC.Monostable.phase5Output.getBoolValue()) { + if (FWC.Monostable.phase5Temp and FWC.Monostable.phase5OutputTemp) { setPhase(5); } - if (!gnd and FWC.Timer.gnd2SecHalf.getValue() != 1 and (!FWC.Monostable.phase5.getBoolValue() or !FWC.Monostable.phase5Output.getBoolValue()) and (!FWC.Monostable.phase7.getBoolValue() or !FWC.Monostable.phase7Output.getBoolValue())) { + if (!gnd and FWC.Timer.gnd2SecHalf.getValue() != 1 and (!FWC.Monostable.phase5Temp or !FWC.Monostable.phase5OutputTemp) and (!FWC.Monostable.phase7Temp or !FWC.Monostable.phase7OutputTemp)) { setPhase(6); } - if ((FWC.Monostable.phase7.getBoolValue() and FWC.Monostable.phase7Output.getBoolValue()) and myPhase != 8) { + if ((FWC.Monostable.phase7Temp and FWC.Monostable.phase7OutputTemp) and currentPhase != 8) { setPhase(7); } - if (!FWC.toPower.getBoolValue() and FWC.speed80.getBoolValue() and (gnd or FWC.Timer.gnd2Sec.getValue == 1)) { + if (!FWC.toPowerTemp and FWC.speed80Temp and (gnd or FWC.Timer.gnd2Sec.getValue() == 1)) { setPhase(8); } - if (FWC.Flipflop.phase2Output.getBoolValue() and (gnd and !FWC.toPower.getBoolValue() and !FWC.speed80.getBoolValue()) and FWC.Timer.eng1or2.getBoolValue()) { + if (FWC.Flipflop.phase2OutputTemp and (gnd and !FWC.toPowerTemp and !FWC.speed80Temp) and FWC.Timer.eng1or2.getBoolValue()) { setPhase(9); } - if ((gnd and FWC.Timer.eng1and2Off.getValue() and myPhase == 9) and FWC.Monostable.phase1Output.getBoolValue()) { + if ((gnd and FWC.Timer.eng1and2OffTemp and currentPhase == 9) and FWC.Monostable.phase1OutputTemp) { setPhase(10); } # FWC Inhibiting - myPhase = pts.ECAM.fwcWarningPhase.getValue(); - if (myPhase >= 3 and myPhase <= 5 and !FWC.Flipflop.recallOutput.getValue()) { + currentPhase = pts.ECAM.fwcWarningPhase.getValue(); + FWC.Flipflop.recallOutputTemp = FWC.Flipflop.recallOutput.getValue(); + if (currentPhase >= 3 and currentPhase <= 5 and !FWC.Flipflop.recallOutputTemp) { FWC.Timer.toInhibit.setValue(1); } else { FWC.Timer.toInhibit.setValue(0); } - if (myPhase == 7 or myPhase == 8 and !FWC.Flipflop.recallOutput.getValue()) { + if (currentPhase == 7 or currentPhase == 8 and !FWC.Flipflop.recallOutputTemp) { FWC.Timer.ldgInhibit.setValue(1); } else { FWC.Timer.ldgInhibit.setValue(0); diff --git a/Systems/a320-fwc-phases.xml b/Systems/a320-fwc-phases.xml index 0426d80a..5dbd7e02 100644 --- a/Systems/a320-fwc-phases.xml +++ b/Systems/a320-fwc-phases.xml @@ -19,10 +19,10 @@ 0.03333333333 - + /ECAM/phases/monostable/phase-1-300 - 0.00333333333 - 120 + 0.00333333333 + 120 @@ -95,8 +95,8 @@ - - /ECAM/phases/monostable/phase-1-300-output ne 1 + + /ECAM/phases/monostable/phase-1-300-timer ne 0 /ECAM/phases/monostable/phase-1-300 eq 1 @@ -229,6 +229,27 @@ + + + + + /ECAM/phases/phase-calculation/takeoff-power eq 1 + /ECAM/phases/phase-calculation/altitude-ge-1500 eq 0 + /ECAM/logic/ground-calc-immediate eq 0 + /ECAM/phases/monostable/gnd-output ne 1 + + + + + + + /ECAM/phases/phase-calculation/takeoff-power eq 0 + /ECAM/phases/phase-calculation/altitude-ge-1500 eq 0 + /ECAM/phases/phase-calculation/altitude-ge-800 eq 0 + /ECAM/logic/ground-calc-immediate eq 0 + /ECAM/phases/monostable/gnd-output ne 1 + + @@ -237,6 +258,60 @@ + + + + /ECAM/warning-phase eq 9 + + + + + + + /ECAM/warning-phase eq 9 + + + + + + + /ECAM/timer/ground-calc eq 1 + /controls/engines/engine[0]/fire-btn eq 1 + + + + + + + /ECAM/phases/phase-calculation/engines-1-2-not-running eq 1 + /ECAM/logic/ground-calc-immediate eq 1 + /ECAM/warning-phase eq 9 + /ECAM/phases/flipflop/phase-10-output eq 1 + + + + + + + /ECAM/warning-phase eq 3 + /ECAM/warning-phase eq 8 + + + + + + + /ECAM/phases/monostable-80kt eq 0 + /ECAM/warning-phase ne 9 + /ECAM/timer/ground-calc eq 1 + + /ECAM/phases/monostable/phase-9-output eq 0 + /ECAM/phases/monostable/to-power-set-output eq 0 + + + + + From 8002a2335c665ef0d8afd01bc289a0536b378a40 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 22 Jun 2021 15:33:17 +0100 Subject: [PATCH 12/14] Remove un-needed variables and unused code --- Nasal/ECAM/ECAM-phases.nas | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Nasal/ECAM/ECAM-phases.nas b/Nasal/ECAM/ECAM-phases.nas index 3dea0097..510a2503 100644 --- a/Nasal/ECAM/ECAM-phases.nas +++ b/Nasal/ECAM/ECAM-phases.nas @@ -3,14 +3,6 @@ # Copyright (c) 2019 Jonathan Redpath (legoboyvdlp) var currentPhase = nil; -var eng = nil; -var eng1epr = nil; -var eng2epr = nil; -var eng1n1 = nil; -var eng2n1 = nil; -var master1 = nil; -var master2 = nil; -var gear_agl_cur = nil; var FWC = { Btn: { @@ -98,7 +90,6 @@ var phaseLoop = func() { FWC.Flipflop.recallReset.setValue(0); } - gear_agl_cur = pts.Position.gearAglFt.getValue(); FWC.toPowerTemp = FWC.toPower.getBoolValue(); FWC.Timer.eng1and2OffTemp = FWC.Timer.eng1and2Off.getValue(); FWC.Timer.eng1or2OutputTemp = FWC.Timer.eng1or2Output.getBoolValue(); @@ -180,7 +171,3 @@ var setPhase = func(newPhase) { setlistener("/ECAM/buttons/recall-btn", func() { FWC.Flipflop.recallSet.setValue(FWC.Btn.recall.getBoolValue()); }, 0, 0); - -var clrBtn = func(btn) { - FWC.Btn.clr.setValue(btn); -} From 5bac220c4754026cf39b8422d380d1da5e6520ef Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 22 Jun 2021 15:39:48 +0100 Subject: [PATCH 13/14] Move nodes to a new file ECAM-nodes.nas --- A320-main.xml | 1 + Nasal/ECAM/ECAM-controller.nas | 141 +--------------------- Nasal/ECAM/ECAM-logic.nas | 3 +- Nasal/ECAM/ECAM-main.nas | 2 +- Nasal/ECAM/ECAM-messages.nas | 3 +- Nasal/ECAM/ECAM-nodes.nas | 212 +++++++++++++++++++++++++++++++++ Nasal/ECAM/ECAM-phases.nas | 74 +----------- Nasal/ECAM/SystemDisplay.nas | 3 + 8 files changed, 221 insertions(+), 218 deletions(-) create mode 100644 Nasal/ECAM/ECAM-nodes.nas diff --git a/A320-main.xml b/A320-main.xml index 79e43a8b..02cc8599 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -4657,6 +4657,7 @@ Aircraft/A320-family/Nasal/ECAM/SystemDisplay.nas + Aircraft/A320-family/Nasal/ECAM/ECAM-nodes.nas Aircraft/A320-family/Nasal/ECAM/ECAM-main.nas Aircraft/A320-family/Nasal/ECAM/ECAM-controller.nas Aircraft/A320-family/Nasal/ECAM/ECAM-logic.nas diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index b3628e89..8645f29c 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -1,5 +1,5 @@ # A3XX Electronic Centralised Aircraft Monitoring System -# Copyright (c) 2019 Jonathan Redpath (legoboyvdlp) +# Copyright (c) 2021 Jonathan Redpath (legoboyvdlp) 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)]; @@ -29,145 +29,6 @@ var counterClear = 0; var noMainMsg = 0; var storeFirstWarning = nil; -var warningNodes = { - Logic: { - 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"), - crossbleedFault: props.globals.initNode("/ECAM/warnings/logic/crossbleed-fault"), - crossbleedWai: props.globals.initNode("/ECAM/warnings/logic/crossbleed-wai"), - 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"), - 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"), - 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"), - cabinFans: props.globals.initNode("/ECAM/warnings/logic/cabin-fans-fault"), - 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"), - 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"), - stallWarn: props.globals.initNode("/ECAM/warnings/logic/stall/stall-warn-on"), - yawDamper12Fault: props.globals.initNode("/ECAM/warnings/logic/yaw-damper-12-fault"), - 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"), - 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"), - leftElevFail: props.globals.initNode("/ECAM/warnings/fctl/leftElevFault"), - rightElevFail: props.globals.initNode("/ECAM/warnings/fctl/rightElevFault"), - flapNotZero: props.globals.initNode("/ECAM/warnings/fctl/flaps-not-zero"), - 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"), - dcEssFuelConsumptionIncreased: props.globals.initNode("/ECAM/warnings/logic/dc-ess-fuel-consumption-increased"), - dcEssFMSPredictions: props.globals.initNode("/ECAM/warnings/logic/dc-ess-fms-predictions-unreliable"), - dc2FuelConsumptionIncreased: props.globals.initNode("/ECAM/warnings/logic/dc-2-fuel-consumption-increased"), - dc2FMSPredictions: props.globals.initNode("/ECAM/warnings/logic/dc-2-fms-predictions-unreliable"), - 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"), - eng1Shutdown: props.globals.initNode("/ECAM/warnings/logic/eng/eng-1-shutdown"), - eng2Shutdown: props.globals.initNode("/ECAM/warnings/logic/eng/eng-2-shutdown"), - acEssBusAltn: props.globals.initNode("/ECAM/warnings/logic/ac-ess-bus-altn-feed"), - gen1Off: props.globals.initNode("/ECAM/warnings/logic/elec/gen-1-off"), - gen2Off: props.globals.initNode("/ECAM/warnings/logic/elec/gen-2-off"), - spdBrkOut: props.globals.initNode("/ECAM/warnings/fctl/spd-brk-still-out"), - }, - Timers: { - apuFaultOutput: props.globals.initNode("/ECAM/warnings/timer/apu-fault-output"), - 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"), - 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"), - 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"), - 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"), - LRElevFault: props.globals.initNode("/ECAM/warnings/fctl/lrElevFault-output"), - altnLaw: props.globals.initNode("/ECAM/warnings/fctl/altn-law-output"), - directLaw: props.globals.initNode("/ECAM/warnings/fctl/direct-law-output"), - waiLhiPr: props.globals.initNode("/ECAM/warnings/timer/wing-hi-pr-left"), - waiRhiPr: props.globals.initNode("/ECAM/warnings/timer/wing-hi-pr-right"), - pack1Fault: props.globals.initNode("/ECAM/warnings/timer/pack-1-fault-2"), - pack2Fault: props.globals.initNode("/ECAM/warnings/timer/pack-2-fault-2"), - pack1Off: props.globals.initNode("/ECAM/warnings/timer/pack-1-off"), - pack2Off: props.globals.initNode("/ECAM/warnings/timer/pack-2-off"), - trimAirFault: props.globals.initNode("/ECAM/warnings/timer/trim-air-fault"), - yawDamper1Fault: props.globals.initNode("/ECAM/warnings/timer/yaw-damper-1-fault"), - yawDamper2Fault: props.globals.initNode("/ECAM/warnings/timer/yaw-damper-2-fault"), - navTerrFault: props.globals.initNode("/ECAM/warnings/timer/nav-gpws-terr-fault"), - leftElevFail: props.globals.initNode("/ECAM/warnings/fctl/leftElevFault-output"), - rightElevFail: props.globals.initNode("/ECAM/warnings/fctl/rightElevFault-output"), - staticInverter: props.globals.initNode("/systems/electrical/some-electric-thingie/static-inverter-timer"), - dcEmerConfig: props.globals.initNode("/ECAM/warnings/logic/dc-emer-config-output"), - dc12Fault: props.globals.initNode("/ECAM/warnings/logic/dc-1-2-output"), - dcEssFault: props.globals.initNode("/ECAM/warnings/logic/dc-ess-output"), - dc1Fault: props.globals.initNode("/ECAM/warnings/logic/dc-1-output"), - dc2Fault: props.globals.initNode("/ECAM/warnings/logic/dc-2-output"), - dcBatFault: props.globals.initNode("/ECAM/warnings/logic/dc-bat-output"), - ac1Fault: props.globals.initNode("/ECAM/warnings/logic/ac-1-output"), - ac2Fault: props.globals.initNode("/ECAM/warnings/logic/ac-2-output"), - acEssFault: props.globals.initNode("/ECAM/warnings/logic/ac-ess-output"), - dcEssShed: props.globals.initNode("/ECAM/warnings/logic/dc-ess-shed-output"), - acEssShed: props.globals.initNode("/ECAM/warnings/logic/ac-ess-shed-output"), - centerPumpsOff: props.globals.initNode("/ECAM/warnings/fuel/center-pumps-off-output"), - lowLevelBoth: props.globals.initNode("/ECAM/warnings/fuel/lo-level-l-r-output"), - }, - Flipflops: { - apuGenFault: props.globals.initNode("/ECAM/warnings/flipflop/apu-gen-fault"), - apuGenFaultOnOff: props.globals.initNode("/ECAM/warnings/flipflop/apu-gen-fault-on-off"), - 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"), - 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"), - pack1Ovht: props.globals.initNode("/ECAM/warnings/flipflop/pack-1-ovht"), - pack2Ovht: props.globals.initNode("/ECAM/warnings/flipflop/pack-2-ovht"), - parkBrk: props.globals.initNode("/ECAM/warnings/config/park-brk/park-brk-output"), - 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"), - }, -}; - var warning = { new: func(msg,colour = "g",aural = 9,light = 9,isMainMsg = 0,lastSubmsg = 0, sdPage = "nil", isMemo = 0) { var t = {parents:[warning]}; diff --git a/Nasal/ECAM/ECAM-logic.nas b/Nasal/ECAM/ECAM-logic.nas index 90aa0205..e5976e0c 100644 --- a/Nasal/ECAM/ECAM-logic.nas +++ b/Nasal/ECAM/ECAM-logic.nas @@ -1,6 +1,5 @@ # A3XX Electronic Centralised Aircraft Monitoring System - -# Copyright (c) 2019 Jonathan Redpath (legoboyvdlp) +# Copyright (c) 2021 Jonathan Redpath (legoboyvdlp) # props.nas: diff --git a/Nasal/ECAM/ECAM-main.nas b/Nasal/ECAM/ECAM-main.nas index 4c814e53..b1b619fe 100644 --- a/Nasal/ECAM/ECAM-main.nas +++ b/Nasal/ECAM/ECAM-main.nas @@ -1,7 +1,7 @@ # A3XX ECAM # Joshua Davidson (Octal450) and Jonathan Redpath (legoboyvdlp) -# Copyright (c) 2020 Josh Davidson (Octal450) and Jonathan Redpath (legoboyvdlp) +# Copyright (c) 2021 Josh Davidson (Octal450) and Jonathan Redpath (legoboyvdlp) var ap_active = 0; var athr_active = 0; diff --git a/Nasal/ECAM/ECAM-messages.nas b/Nasal/ECAM/ECAM-messages.nas index 5560b411..e36d11bb 100644 --- a/Nasal/ECAM/ECAM-messages.nas +++ b/Nasal/ECAM/ECAM-messages.nas @@ -1,6 +1,5 @@ # A3XX Electronic Centralised Aircraft Monitoring System - -# Copyright (c) 2019 Jonathan Redpath (legoboyvdlp) +# Copyright (c) 2021 Jonathan Redpath (legoboyvdlp) # messages stored in vectors diff --git a/Nasal/ECAM/ECAM-nodes.nas b/Nasal/ECAM/ECAM-nodes.nas new file mode 100644 index 00000000..21b38d32 --- /dev/null +++ b/Nasal/ECAM/ECAM-nodes.nas @@ -0,0 +1,212 @@ +# A3XX Electronic Centralised Aircraft Monitoring System +# Copyright (c) 2021 Jonathan Redpath (legoboyvdlp) + +var FWC = { + Btn: { + clr: props.globals.initNode("/ECAM/buttons/clear-btn", 0, "BOOL"), + recall: props.globals.initNode("/ECAM/buttons/recall-btn", 0, "BOOL"), + recallStsNormal: props.globals.initNode("/ECAM/buttons/recall-status-normal", 0, "BOOL"), + recallStsNormalOutput: props.globals.initNode("/ECAM/buttons/recall-status-normal-output", 0, "BOOL"), + }, + Monostable: { + phase1: props.globals.initNode("/ECAM/phases/monostable/phase-1-300", 0, "BOOL"), + phase5: props.globals.initNode("/ECAM/phases/monostable/phase-5", 0, "BOOL"), + phase5Temp: 0, + phase7: props.globals.initNode("/ECAM/phases/monostable/phase-7", 0, "BOOL"), + phase7Temp: 0, + phase9: props.globals.initNode("/ECAM/phases/monostable/phase-9", 0, "BOOL"), + phase1Output: props.globals.initNode("/ECAM/phases/monostable/phase-1-300-output"), + phase1OutputTemp: 0, + phase5Output: props.globals.initNode("/ECAM/phases/monostable/phase-5-output"), + phase5OutputTemp: 0, + phase7Output: props.globals.initNode("/ECAM/phases/monostable/phase-7-output"), + phase7OutputTemp: 0, + phase9Output: props.globals.initNode("/ECAM/phases/monostable/phase-9-output"), + toPowerOutput: props.globals.getNode("/ECAM/phases/monostable/to-power-set-output"), + m80kt: props.globals.getNode("/ECAM/phases/monostable-80kt"), + altAlert1: props.globals.initNode("/ECAM/altitude-alert-monostable-set", 0, "BOOL"), + altAlert1Output: props.globals.initNode("/ECAM/altitude-alert-monostable-output"), + altAlert2: props.globals.initNode("/ECAM/flipflop/altitude-alert-rs-set", 0, "BOOL"), + }, + Flipflop: { + phase2Set: props.globals.initNode("/ECAM/phases/flipflop/phase-2-set", 0, "BOOL"), + phase2Reset: props.globals.initNode("/ECAM/phases/flipflop/phase-2-reset", 0, "BOOL"), + phase2Output: props.globals.initNode("/ECAM/phases/flipflop/phase-2-output", 0, "BOOL"), + phase2OutputTemp: 0, + phase10Set: props.globals.initNode("/ECAM/phases/flipflop/phase-10-set", 0, "BOOL"), + phase10Reset: props.globals.initNode("/ECAM/phases/flipflop/phase-10-reset", 0, "BOOL"), + phase10Output: props.globals.initNode("/ECAM/phases/flipflop/phase-10-output", 0, "BOOL"), + recallSet: props.globals.initNode("/ECAM/flipflop/recall-set", 0, "BOOL"), + recallReset: props.globals.initNode("/ECAM/flipflop/recall-reset", 0, "BOOL"), + recallOutput: props.globals.initNode("/ECAM/flipflop/recall-output", 0, "BOOL"), + recallOutputTemp: 0, + }, + Logic: { + gnd: props.globals.getNode("/ECAM/logic/ground-calc-immediate"), + IRSinAlign: props.globals.initNode("/ECAM/irs-in-align", 0, "BOOL"), + feet1500: props.globals.getNode("/ECAM/phases/phase-calculation/altitude-ge-1500"), + feet800: props.globals.getNode("/ECAM/phases/phase-calculation/altitude-ge-800"), + }, + Timer: { + eng1idle: props.globals.getNode("/ECAM/phases/timer/eng1idle"), + eng2idle: props.globals.getNode("/ECAM/phases/timer/eng2idle"), + eng1or2: props.globals.getNode("/ECAM/phases/phase-calculation/one-engine-running"), + toInhibit: props.globals.initNode("/ECAM/phases/timer/to-inhibit", 0, "INT"), + ldgInhibit: props.globals.initNode("/ECAM/phases/timer/ldg-inhibit", 0, "INT"), + eng1idleOutput: props.globals.getNode("/ECAM/phases/timer/eng1idle-output"), + eng2idleOutput: props.globals.getNode("/ECAM/phases/timer/eng2idle-output"), + eng1and2Off: props.globals.getNode("/ECAM/phases/phase-calculation/engines-1-2-not-running"), + eng1and2OffTemp: 0, + eng1or2Output: props.globals.getNode("/ECAM/phases/phase-calculation/engine-1-or-2-running"), + eng1or2OutputTemp: 0, + toInhibitOutput: props.globals.getNode("/ECAM/phases/timer/to-inhibit-output"), + ldgInhibitOutput: props.globals.getNode("/ECAM/phases/timer/ldg-inhibit-output"), + gnd: props.globals.getNode("/ECAM/timer/ground-calc"), # ZGND + gnd2Sec: props.globals.getNode("/ECAM/phases/monostable/gnd-output"), + gnd2SecHalf: props.globals.getNode("/ECAM/phases/monostable/gnd-output-2"), # hack to prevent getting confused between phase 5 / 6 + }, + speed80: props.globals.initNode("/ECAM/phases/speed-gt-80", 0, "BOOL"), + speed80Temp: 0, + toPower: props.globals.getNode("/ECAM/phases/phase-calculation/takeoff-power"), + toPowerTemp: 0, + altChg: props.globals.getNode("/it-autoflight/input/alt-is-changing", 1), +}; + +var warningNodes = { + Logic: { + 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"), + crossbleedFault: props.globals.initNode("/ECAM/warnings/logic/crossbleed-fault"), + crossbleedWai: props.globals.initNode("/ECAM/warnings/logic/crossbleed-wai"), + 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"), + 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"), + 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"), + cabinFans: props.globals.initNode("/ECAM/warnings/logic/cabin-fans-fault"), + 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"), + 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"), + stallWarn: props.globals.initNode("/ECAM/warnings/logic/stall/stall-warn-on"), + yawDamper12Fault: props.globals.initNode("/ECAM/warnings/logic/yaw-damper-12-fault"), + 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"), + 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"), + leftElevFail: props.globals.initNode("/ECAM/warnings/fctl/leftElevFault"), + rightElevFail: props.globals.initNode("/ECAM/warnings/fctl/rightElevFault"), + flapNotZero: props.globals.initNode("/ECAM/warnings/fctl/flaps-not-zero"), + 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"), + dcEssFuelConsumptionIncreased: props.globals.initNode("/ECAM/warnings/logic/dc-ess-fuel-consumption-increased"), + dcEssFMSPredictions: props.globals.initNode("/ECAM/warnings/logic/dc-ess-fms-predictions-unreliable"), + dc2FuelConsumptionIncreased: props.globals.initNode("/ECAM/warnings/logic/dc-2-fuel-consumption-increased"), + dc2FMSPredictions: props.globals.initNode("/ECAM/warnings/logic/dc-2-fms-predictions-unreliable"), + 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"), + eng1Shutdown: props.globals.initNode("/ECAM/warnings/logic/eng/eng-1-shutdown"), + eng2Shutdown: props.globals.initNode("/ECAM/warnings/logic/eng/eng-2-shutdown"), + acEssBusAltn: props.globals.initNode("/ECAM/warnings/logic/ac-ess-bus-altn-feed"), + gen1Off: props.globals.initNode("/ECAM/warnings/logic/elec/gen-1-off"), + gen2Off: props.globals.initNode("/ECAM/warnings/logic/elec/gen-2-off"), + spdBrkOut: props.globals.initNode("/ECAM/warnings/fctl/spd-brk-still-out"), + }, + Timers: { + apuFaultOutput: props.globals.initNode("/ECAM/warnings/timer/apu-fault-output"), + 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"), + 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"), + 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"), + 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"), + LRElevFault: props.globals.initNode("/ECAM/warnings/fctl/lrElevFault-output"), + altnLaw: props.globals.initNode("/ECAM/warnings/fctl/altn-law-output"), + directLaw: props.globals.initNode("/ECAM/warnings/fctl/direct-law-output"), + waiLhiPr: props.globals.initNode("/ECAM/warnings/timer/wing-hi-pr-left"), + waiRhiPr: props.globals.initNode("/ECAM/warnings/timer/wing-hi-pr-right"), + pack1Fault: props.globals.initNode("/ECAM/warnings/timer/pack-1-fault-2"), + pack2Fault: props.globals.initNode("/ECAM/warnings/timer/pack-2-fault-2"), + pack1Off: props.globals.initNode("/ECAM/warnings/timer/pack-1-off"), + pack2Off: props.globals.initNode("/ECAM/warnings/timer/pack-2-off"), + trimAirFault: props.globals.initNode("/ECAM/warnings/timer/trim-air-fault"), + yawDamper1Fault: props.globals.initNode("/ECAM/warnings/timer/yaw-damper-1-fault"), + yawDamper2Fault: props.globals.initNode("/ECAM/warnings/timer/yaw-damper-2-fault"), + navTerrFault: props.globals.initNode("/ECAM/warnings/timer/nav-gpws-terr-fault"), + leftElevFail: props.globals.initNode("/ECAM/warnings/fctl/leftElevFault-output"), + rightElevFail: props.globals.initNode("/ECAM/warnings/fctl/rightElevFault-output"), + staticInverter: props.globals.initNode("/systems/electrical/some-electric-thingie/static-inverter-timer"), + dcEmerConfig: props.globals.initNode("/ECAM/warnings/logic/dc-emer-config-output"), + dc12Fault: props.globals.initNode("/ECAM/warnings/logic/dc-1-2-output"), + dcEssFault: props.globals.initNode("/ECAM/warnings/logic/dc-ess-output"), + dc1Fault: props.globals.initNode("/ECAM/warnings/logic/dc-1-output"), + dc2Fault: props.globals.initNode("/ECAM/warnings/logic/dc-2-output"), + dcBatFault: props.globals.initNode("/ECAM/warnings/logic/dc-bat-output"), + ac1Fault: props.globals.initNode("/ECAM/warnings/logic/ac-1-output"), + ac2Fault: props.globals.initNode("/ECAM/warnings/logic/ac-2-output"), + acEssFault: props.globals.initNode("/ECAM/warnings/logic/ac-ess-output"), + dcEssShed: props.globals.initNode("/ECAM/warnings/logic/dc-ess-shed-output"), + acEssShed: props.globals.initNode("/ECAM/warnings/logic/ac-ess-shed-output"), + centerPumpsOff: props.globals.initNode("/ECAM/warnings/fuel/center-pumps-off-output"), + lowLevelBoth: props.globals.initNode("/ECAM/warnings/fuel/lo-level-l-r-output"), + }, + Flipflops: { + apuGenFault: props.globals.initNode("/ECAM/warnings/flipflop/apu-gen-fault"), + apuGenFaultOnOff: props.globals.initNode("/ECAM/warnings/flipflop/apu-gen-fault-on-off"), + 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"), + 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"), + pack1Ovht: props.globals.initNode("/ECAM/warnings/flipflop/pack-1-ovht"), + pack2Ovht: props.globals.initNode("/ECAM/warnings/flipflop/pack-2-ovht"), + parkBrk: props.globals.initNode("/ECAM/warnings/config/park-brk/park-brk-output"), + 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"), + }, +}; \ No newline at end of file diff --git a/Nasal/ECAM/ECAM-phases.nas b/Nasal/ECAM/ECAM-phases.nas index 510a2503..6b959355 100644 --- a/Nasal/ECAM/ECAM-phases.nas +++ b/Nasal/ECAM/ECAM-phases.nas @@ -1,80 +1,8 @@ # A3XX FWC Phases - -# Copyright (c) 2019 Jonathan Redpath (legoboyvdlp) +# Copyright (c) 2021 Jonathan Redpath (legoboyvdlp) var currentPhase = nil; -var FWC = { - Btn: { - clr: props.globals.initNode("/ECAM/buttons/clear-btn", 0, "BOOL"), - recall: props.globals.initNode("/ECAM/buttons/recall-btn", 0, "BOOL"), - recallStsNormal: props.globals.initNode("/ECAM/buttons/recall-status-normal", 0, "BOOL"), - recallStsNormalOutput: props.globals.initNode("/ECAM/buttons/recall-status-normal-output", 0, "BOOL"), - }, - Monostable: { - phase1: props.globals.initNode("/ECAM/phases/monostable/phase-1-300", 0, "BOOL"), - phase5: props.globals.initNode("/ECAM/phases/monostable/phase-5", 0, "BOOL"), - phase5Temp: 0, - phase7: props.globals.initNode("/ECAM/phases/monostable/phase-7", 0, "BOOL"), - phase7Temp: 0, - phase9: props.globals.initNode("/ECAM/phases/monostable/phase-9", 0, "BOOL"), - phase1Output: props.globals.initNode("/ECAM/phases/monostable/phase-1-300-output"), - phase1OutputTemp: 0, - phase5Output: props.globals.initNode("/ECAM/phases/monostable/phase-5-output"), - phase5OutputTemp: 0, - phase7Output: props.globals.initNode("/ECAM/phases/monostable/phase-7-output"), - phase7OutputTemp: 0, - phase9Output: props.globals.initNode("/ECAM/phases/monostable/phase-9-output"), - toPowerOutput: props.globals.getNode("/ECAM/phases/monostable/to-power-set-output"), - m80kt: props.globals.getNode("/ECAM/phases/monostable-80kt"), - altAlert1: props.globals.initNode("/ECAM/altitude-alert-monostable-set", 0, "BOOL"), - altAlert1Output: props.globals.initNode("/ECAM/altitude-alert-monostable-output"), - altAlert2: props.globals.initNode("/ECAM/flipflop/altitude-alert-rs-set", 0, "BOOL"), - }, - Flipflop: { - phase2Set: props.globals.initNode("/ECAM/phases/flipflop/phase-2-set", 0, "BOOL"), - phase2Reset: props.globals.initNode("/ECAM/phases/flipflop/phase-2-reset", 0, "BOOL"), - phase2Output: props.globals.initNode("/ECAM/phases/flipflop/phase-2-output", 0, "BOOL"), - phase2OutputTemp: 0, - phase10Set: props.globals.initNode("/ECAM/phases/flipflop/phase-10-set", 0, "BOOL"), - phase10Reset: props.globals.initNode("/ECAM/phases/flipflop/phase-10-reset", 0, "BOOL"), - phase10Output: props.globals.initNode("/ECAM/phases/flipflop/phase-10-output", 0, "BOOL"), - recallSet: props.globals.initNode("/ECAM/flipflop/recall-set", 0, "BOOL"), - recallReset: props.globals.initNode("/ECAM/flipflop/recall-reset", 0, "BOOL"), - recallOutput: props.globals.initNode("/ECAM/flipflop/recall-output", 0, "BOOL"), - recallOutputTemp: 0, - }, - Logic: { - gnd: props.globals.getNode("/ECAM/logic/ground-calc-immediate"), - IRSinAlign: props.globals.initNode("/ECAM/irs-in-align", 0, "BOOL"), - feet1500: props.globals.getNode("/ECAM/phases/phase-calculation/altitude-ge-1500"), - feet800: props.globals.getNode("/ECAM/phases/phase-calculation/altitude-ge-800"), - }, - Timer: { - eng1idle: props.globals.getNode("/ECAM/phases/timer/eng1idle"), - eng2idle: props.globals.getNode("/ECAM/phases/timer/eng2idle"), - eng1or2: props.globals.getNode("/ECAM/phases/phase-calculation/one-engine-running"), - toInhibit: props.globals.initNode("/ECAM/phases/timer/to-inhibit", 0, "INT"), - ldgInhibit: props.globals.initNode("/ECAM/phases/timer/ldg-inhibit", 0, "INT"), - eng1idleOutput: props.globals.getNode("/ECAM/phases/timer/eng1idle-output"), - eng2idleOutput: props.globals.getNode("/ECAM/phases/timer/eng2idle-output"), - eng1and2Off: props.globals.getNode("/ECAM/phases/phase-calculation/engines-1-2-not-running"), - eng1and2OffTemp: 0, - eng1or2Output: props.globals.getNode("/ECAM/phases/phase-calculation/engine-1-or-2-running"), - eng1or2OutputTemp: 0, - toInhibitOutput: props.globals.getNode("/ECAM/phases/timer/to-inhibit-output"), - ldgInhibitOutput: props.globals.getNode("/ECAM/phases/timer/ldg-inhibit-output"), - gnd: props.globals.getNode("/ECAM/timer/ground-calc"), # ZGND - gnd2Sec: props.globals.getNode("/ECAM/phases/monostable/gnd-output"), - gnd2SecHalf: props.globals.getNode("/ECAM/phases/monostable/gnd-output-2"), # hack to prevent getting confused between phase 5 / 6 - }, - speed80: props.globals.initNode("/ECAM/phases/speed-gt-80", 0, "BOOL"), - speed80Temp: 0, - toPower: props.globals.getNode("/ECAM/phases/phase-calculation/takeoff-power"), - toPowerTemp: 0, - altChg: props.globals.getNode("/it-autoflight/input/alt-is-changing", 1), -}; - var gnd = nil; var gndTimer = nil; diff --git a/Nasal/ECAM/SystemDisplay.nas b/Nasal/ECAM/SystemDisplay.nas index e3f0f75e..7fa71d20 100644 --- a/Nasal/ECAM/SystemDisplay.nas +++ b/Nasal/ECAM/SystemDisplay.nas @@ -1,3 +1,6 @@ +# A3XX System Display Controller +# Copyright (c) 2021 Jonathan Redpath (legoboyvdlp) + var Page = { new: func(name) { var page = {parents:[Page]}; From 9b4a4de1b969547d96542fe7cc9f3973352f7a58 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 22 Jun 2021 17:52:24 +0100 Subject: [PATCH 14/14] Light Manager: rewrite to use more efficient and faster code --- Nasal/Effects/light-manager.nas | 614 +++++++++--------------- Nasal/Libraries/libraries.nas | 2 +- Nasal/Libraries/property-tree-setup.nas | 13 + 3 files changed, 244 insertions(+), 385 deletions(-) diff --git a/Nasal/Effects/light-manager.nas b/Nasal/Effects/light-manager.nas index 3e59a4ed..811dc02b 100644 --- a/Nasal/Effects/light-manager.nas +++ b/Nasal/Effects/light-manager.nas @@ -2,407 +2,253 @@ # in east/north/up coordinates the renderer uses # Thanks to BAWV12 / Thorsten - -var als_on = props.globals.getNode("/sim/rendering/shaders/skydome"); +var als_on = props.globals.getNode(""); var alt_agl = props.globals.getNode("position/gear-agl-ft"); var cur_alt = 0; -var light_manager = { +var Light = { + new: func(n) { + var light = {parents: [Light]}; + light.isOn = 0; + + light.Pos = { + x: 0, + y: 0, + z: 0, + }; + + light.Color = { + r: 0, + g: 0, + b: 0, + }; + + light.colorr = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[" ~ n ~ "]", 1); + light.colorg = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[" ~ n ~ "]", 1); + light.colorb = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[" ~ n ~ "]", 1); + light.dir = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/dir[" ~ n ~ "]", 1); + light.size = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/size[" ~ n ~ "]", 1); + light.posx = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[" ~ n ~ "]", 1); + light.posy = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[" ~ n ~ "]", 1); + light.posz = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[" ~ n ~ "]", 1); + + if (n <= 1) { + light.stretch = props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/stretch[" ~ n ~ "]", 1); + } + return light; + }, + setColor: func(r,g,b) { + me.Color.r = r; + me.Color.g = g; + me.Color.b = b; + }, + setDir: func(dir) { + me.dir.setValue(dir); + }, + setSize: func(size) { + me.size.setValue(size); + }, + setStretch: func(stretch) { + me.stretch.setValue(stretch); + }, + setPos: func(x,y,z) { + me.Pos.x = x; + me.Pos.y = y; + me.Pos.z = z; + }, + on: func() { + if (me.isOn) { return; } + me.colorr.setValue(me.Color.r); + me.colorg.setValue(me.Color.g); + me.colorb.setValue(me.Color.b); + me.isOn = 1; + }, + off: func() { + if (!me.isOn) { return; } + me.colorr.setValue(0); + me.colorg.setValue(0); + me.colorb.setValue(0); + me.isOn = 0; + }, +}; - run: 0, - +var lightManager = { lat_to_m: 110952.0, lon_to_m: 0.0, - - light1_xpos: 0.0, - light1_ypos: 0.0, - light1_zpos: 0.0, - light1_r: 0.0, - light1_g: 0.0, - light1_b: 0.0, - light1_size: 0.0, - light1_stretch: 0.0, - light1_is_on: 0, - - light2_xpos: 0.0, - light2_ypos: 0.0, - light2_zpos: 0.0, - light2_r: 0.0, - light2_g: 0.0, - light2_b: 0.0, - light2_size: 0.0, - light2_stretch: 0.0, - light2_is_on: 0, - light3_xpos: 0.0, - light3_ypos: 0.0, - light3_zpos: 0.0, - light3_r: 0.0, - light3_g: 0.0, - light3_b: 0.0, - light3_size: 0.0, - light3_stretch: 0.0, - light3_is_on: 0, - - light4_xpos: 0.0, - light4_ypos: 0.0, - light4_zpos: 0.0, - light4_r: 0.0, - light4_g: 0.0, - light4_b: 0.0, - light4_size: 0.0, - light4_stretch: 0.0, - light4_is_on: 0, - - light5_xpos: 0.0, - light5_ypos: 0.0, - light5_zpos: 0.0, - light5_r: 0.0, - light5_g: 0.0, - light5_b: 0.0, - light5_size: 0.0, - light5_stretch: 0.0, - light5_is_on: 0, - - flcpt: 0, - prev_view : 1, - - nd_ref_light1_x: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m", 1), - nd_ref_light1_y: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m", 1), - nd_ref_light1_z: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m", 1), - nd_ref_light1_dir: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/dir", 1), - - nd_ref_light2_x: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[1]", 1), - nd_ref_light2_y: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[1]", 1), - nd_ref_light2_z: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[1]", 1), - nd_ref_light2_dir: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/dir[1]", 1), - - nd_ref_light3_x: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[2]", 1), - nd_ref_light3_y: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[2]", 1), - nd_ref_light3_z: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[2]", 1), - nd_ref_light3_dir: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/dir[2]", 1), - - nd_ref_light4_x: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[3]", 1), - nd_ref_light4_y: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[3]", 1), - nd_ref_light4_z: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[3]", 1), - nd_ref_light4_dir: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/dir[3]", 1), - - nd_ref_light5_x: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[4]", 1), - nd_ref_light5_y: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[4]", 1), - nd_ref_light5_z: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[4]", 1), - nd_ref_light5_dir: props.globals.getNode("/sim/rendering/als-secondary-lights/lightspot/dir[4]", 1), - - init: func { - # define your lights here - - # lights ######## - # offsets to aircraft center - - me.light1_xpos = 100.0; - me.light1_ypos = 0.0; - me.light1_zpos = 2.0; - - me.light2_xpos = 60.0; - me.light2_ypos = 0.0; - me.light2_zpos = 2.0; - - me.light3_xpos = -2.0; - me.light3_ypos = 18.0; - me.light3_zpos = 2.0; - - me.light4_xpos = -2.0; - me.light4_ypos = -18.0; - me.light4_zpos = 2.0; - - me.light5_xpos = -25.0; - me.light5_ypos = 0.0; - me.light5_zpos = 2.0; - - - # color values - me.light1_r = 0.7; - me.light1_g = 0.7; - me.light1_b = 0.7; - me.light2_r = 0.6; - me.light2_g = 0.6; - me.light2_b = 0.6; - me.light3_r = 0.4; - me.light3_g = 0.0; - me.light3_b = 0.0; - me.light4_r = 0.0; - me.light4_g = 0.4; - me.light4_b = 0.0; - me.light5_r = 0.4; - me.light5_g = 0.4; - me.light5_b = 0.4; - - # spot size - me.light1_size = 12; - me.light1_stretch = 6; - me.light2_size = 6; - me.light2_stretch = 6; - me.light3_size = 4; - me.light4_size = 4; - me.light5_size = 5; - - - setprop("/sim/rendering/als-secondary-lights/flash-radius", 13); - - me.start(); + Lights: { + light1: Light.new(0), + light2: Light.new(1), + light3: Light.new(2), + light4: Light.new(3), + light5: Light.new(4), }, - - start: func { + + init: func() { + setprop("/sim/rendering/als-secondary-lights/flash-radius", 13); setprop("/sim/rendering/als-secondary-lights/num-lightspots", 5); - - setprop("/sim/rendering/als-secondary-lights/lightspot/size", me.light1_size); - setprop("/sim/rendering/als-secondary-lights/lightspot/size[1]", me.light2_size); - setprop("/sim/rendering/als-secondary-lights/lightspot/size[2]", me.light3_size); - setprop("/sim/rendering/als-secondary-lights/lightspot/size[3]", me.light4_size); - setprop("/sim/rendering/als-secondary-lights/lightspot/size[4]", me.light5_size); - - setprop("/sim/rendering/als-secondary-lights/lightspot/stretch", me.light1_stretch); - setprop("/sim/rendering/als-secondary-lights/lightspot/stretch[1]", me.light2_stretch); - - me.run = 1; + + me.Lights.light1.setPos(100,0,2); + me.Lights.light2.setPos(60,0,2); + me.Lights.light3.setPos(-2,18,2); + me.Lights.light4.setPos(-2,-18,2); + me.Lights.light5.setPos(-25,0,2); + + me.Lights.light1.setColor(0.7,0.7,0.7); + me.Lights.light2.setColor(0.7,0.7,0.7); + me.Lights.light3.setColor(0.4,0.0,0.0); + me.Lights.light4.setColor(0.0,0.4,0.0); + me.Lights.light5.setColor(0.4,0.4,0.4); + + me.Lights.light1.setSize(12); + me.Lights.light2.setSize(6); + me.Lights.light3.setSize(4); + me.Lights.light4.setSize(4); + me.Lights.light5.setSize(5); + + me.Lights.light1.setStretch(6); + me.Lights.light2.setStretch(6); me.update(); }, - - stop: func { - me.run = 0; + apos: 0, + curAlt: 0, + ELEC: [0, 0], + ll1: 0, + ll2: 0, + ll3: 0, + nav: 0, + run: 0, + vpos: 0, + Pos: { + alt: 0, + heading: 0, + headingSine: 0, + headingCosine: 0, + lat: 0, + lon: 0, }, - - update: func { - if (me.run == 0) { + update: func() { + if (!me.run) { + settimer ( func me.update(), 0.00); return; } - cur_alt = alt_agl.getValue(); - if (als_on.getValue() == 1 and alt_agl.getValue() < 100.0) { - ll1 = getprop("/controls/lighting/landing-lights[1]"); - ll2 = getprop("/controls/lighting/landing-lights[2]"); - ll3 = getprop("/sim/model/lights/nose-lights"); - nav = getprop("/sim/model/lights/nav-lights"); - - var apos = geo.aircraft_position(); - var vpos = geo.viewer_position(); - - me.lon_to_m = math.cos(apos.lat()*math.pi/180.0) * me.lat_to_m; - - var heading = getprop("orientation/heading-deg") * math.pi/180.0; - - var lat = apos.lat(); - var lon = apos.lon(); - var alt = apos.alt(); - - var sh = math.sin(heading); - var ch = math.cos(heading); - - if ((ll1 == 1 and systems.ELEC.Bus.ac1.getValue() != 0) and (ll2 == 1 and systems.ELEC.Bus.ac2.getValue() != 0)) { - me.light1_ypos = 0.0; - me.light1_setSize(16); - me.light1_on(); - } else if (ll1 == 1 and systems.ELEC.Bus.ac1.getValue() != 0) { - me.light1_ypos = 3.0; - me.light1_setSize(12); - me.light1_on(); - } else if (ll2 == 1 and systems.ELEC.Bus.ac2.getValue() != 0) { - me.light1_ypos = -3.0; - me.light1_setSize(12); - me.light1_on(); - } else { - me.light1_off(); - } - - if (ll3 != 0) { - me.light2_on(); - } else { - me.light2_off(); - } - - if (ll3 == 1) { - me.light2_setSize(8); - me.light2_xpos = 65.0; - } else { - me.light2_setSize(6); - me.light2_xpos = 60.0; - } - - if (nav == 1) { - me.light3_on(); - me.light4_on(); - me.light5_on(); - } else { - me.light3_off(); - me.light4_off(); - me.light5_off(); - } - - - # light 1 position - var proj_x = cur_alt; - var proj_z = cur_alt/10.0; - - apos.set_lat(lat + ((me.light1_xpos + proj_x) * ch + me.light1_ypos * sh) / me.lat_to_m); - apos.set_lon(lon + ((me.light1_xpos + proj_x)* sh - me.light1_ypos * ch) / me.lon_to_m); - - delta_x = (apos.lat() - vpos.lat()) * me.lat_to_m; - delta_y = -(apos.lon() - vpos.lon()) * me.lon_to_m; - var delta_z = apos.alt()- proj_z - vpos.alt(); - - me.nd_ref_light1_x.setValue(delta_x); - me.nd_ref_light1_y.setValue(delta_y); - me.nd_ref_light1_z.setValue(delta_z); - me.nd_ref_light1_dir.setValue(heading); - - - - # light 2 position - - apos.set_lat(lat + (me.light2_xpos * ch + me.light2_ypos * sh) / me.lat_to_m); - apos.set_lon(lon + (me.light2_xpos * sh - me.light2_ypos * ch) / me.lon_to_m); - - delta_x = (apos.lat() - vpos.lat()) * me.lat_to_m; - delta_y = -(apos.lon() - vpos.lon()) * me.lon_to_m; - delta_z = apos.alt() - vpos.alt(); - - me.nd_ref_light2_x.setValue(delta_x); - me.nd_ref_light2_y.setValue(delta_y); - me.nd_ref_light2_z.setValue(delta_z); - me.nd_ref_light2_dir.setValue(heading); - - - # light 3 position - - apos.set_lat(lat + (me.light3_xpos * ch + me.light3_ypos * sh) / me.lat_to_m); - apos.set_lon(lon + (me.light3_xpos * sh - me.light3_ypos * ch) / me.lon_to_m); - - delta_x = (apos.lat() - vpos.lat()) * me.lat_to_m; - delta_y = -(apos.lon() - vpos.lon()) * me.lon_to_m; - delta_z = apos.alt() - vpos.alt(); - - me.nd_ref_light3_x.setValue(delta_x); - me.nd_ref_light3_y.setValue(delta_y); - me.nd_ref_light3_z.setValue(delta_z); - me.nd_ref_light3_dir.setValue(heading); - - - # light 4 position - - apos.set_lat(lat + (me.light4_xpos * ch + me.light4_ypos * sh) / me.lat_to_m); - apos.set_lon(lon + (me.light4_xpos * sh - me.light4_ypos * ch) / me.lon_to_m); - - delta_x = (apos.lat() - vpos.lat()) * me.lat_to_m; - delta_y = -(apos.lon() - vpos.lon()) * me.lon_to_m; - delta_z = apos.alt() - vpos.alt(); - - me.nd_ref_light4_x.setValue(delta_x); - me.nd_ref_light4_y.setValue(delta_y); - me.nd_ref_light4_z.setValue(delta_z); - me.nd_ref_light4_dir.setValue(heading); - - # light 5 position - - apos.set_lat(lat + (me.light5_xpos * ch + me.light5_ypos * sh) / me.lat_to_m); - apos.set_lon(lon + (me.light5_xpos * sh - me.light5_ypos * ch) / me.lon_to_m); - - delta_x = (apos.lat() - vpos.lat()) * me.lat_to_m; - delta_y = -(apos.lon() - vpos.lon()) * me.lon_to_m; - delta_z = apos.alt() - vpos.alt(); - - me.nd_ref_light5_x.setValue(delta_x); - me.nd_ref_light5_y.setValue(delta_y); - me.nd_ref_light5_z.setValue(delta_z); - me.nd_ref_light5_dir.setValue(heading); + me.curAlt = pts.Position.gearAglFt.getValue(); + if (me.curAlt > 100) { + settimer ( func me.update(), 1); + return; } + me.ll1 = pts.Controls.Lighting.landingLights[1].getValue(); + me.ll2 = pts.Controls.Lighting.landingLights[2].getValue(); + me.ll3 = pts.Sim.Model.Lights.noseLights.getValue(); + me.nav = pts.Sim.Model.Lights.navLights.getValue(); + + me.apos = geo.aircraft_position(); + me.vpos = geo.viewer_position(); + + + me.Pos.lat = me.apos.lat(); + me.Pos.lon = me.apos.lon(); + me.Pos.alt = me.apos.alt(); + me.Pos.heading = pts.Orientation.heading.getValue() * D2R; + me.Pos.headingSine = math.sin(me.Pos.heading); + me.Pos.headingCosine = math.cos(me.Pos.heading); + me.lon_to_m = math.cos(me.Pos.lat*D2R) * me.lat_to_m; + + me.ELEC[0] = systems.ELEC.Bus.ac1.getValue(); + me.ELEC[1] = systems.ELEC.Bus.ac2.getValue(); + + if ((me.ll1 == 1 and me.ELEC[0] >= 110) and (me.ll2 == 1 and me.ELEC[1] >= 110)) { + me.Lights.light1.setPos(100,0,2); + me.Lights.light1.setSize(16); + me.Lights.light1.on(); + } else if (me.ll1 == 1 and me.ELEC[0] >= 110) { + me.Lights.light1.setPos(100,3,2); + me.Lights.light1.setSize(12); + me.Lights.light1.on(); + } else if (me.ll2 == 1 and me.ELEC[1] >= 110) { + me.Lights.light1.setPos(100,-3,2); + me.Lights.light1.setSize(12); + me.Lights.light1.on(); + } else { + me.Lights.light1.off(); + } + + if (me.ll3 != 0) { + me.Lights.light2.on(); + } else { + me.Lights.light2.off(); + } + + if (me.ll3 == 1) { + me.Lights.light2.setSize(8); + me.Lights.light2.setPos(65,0,2); + } else { + me.Lights.light2.setSize(6); + me.Lights.light2.setPos(60,0,2); + } + + if (me.nav == 1) { + me.Lights.light3.on(); + me.Lights.light4.on(); + me.Lights.light5.on(); + } else { + me.Lights.light3.off(); + me.Lights.light4.off(); + me.Lights.light5.off(); + } + + + # light 1 position + me.apos.set_lat(me.Pos.lat + ((me.Lights.light1.Pos.x + me.curAlt) * me.Pos.headingCosine + me.Lights.light1.Pos.y * me.Pos.headingSine) / me.lat_to_m); + me.apos.set_lon(me.Pos.lon + ((me.Lights.light1.Pos.x + me.curAlt) * me.Pos.headingSine - me.Lights.light1.Pos.y * me.Pos.headingCosine) / me.lon_to_m); + + me.Lights.light1.posx.setValue((me.apos.lat() - me.vpos.lat()) * me.lat_to_m); + me.Lights.light1.posy.setValue(-(me.apos.lon() - me.vpos.lon()) * me.lon_to_m); + me.Lights.light1.posz.setValue(me.apos.alt()- (me.curAlt / 10) - me.vpos.alt()); + me.Lights.light1.dir.setValue(me.Pos.heading); + + # light 2 position + me.apos.set_lat(me.Pos.lat + ((me.Lights.light2.Pos.x + me.curAlt) * me.Pos.headingCosine + me.Lights.light2.Pos.y * me.Pos.headingSine) / me.lat_to_m); + me.apos.set_lon(me.Pos.lon + ((me.Lights.light2.Pos.x + me.curAlt) * me.Pos.headingSine - me.Lights.light2.Pos.y * me.Pos.headingCosine) / me.lon_to_m); + + me.Lights.light2.posx.setValue((me.apos.lat() - me.vpos.lat()) * me.lat_to_m); + me.Lights.light2.posy.setValue(-(me.apos.lon() - me.vpos.lon()) * me.lon_to_m); + me.Lights.light2.posz.setValue(me.apos.alt()- (me.curAlt / 10) - me.vpos.alt()); + me.Lights.light2.dir.setValue(me.Pos.heading); + + # light 3 position + me.apos.set_lat(me.Pos.lat + ((me.Lights.light3.Pos.x + me.curAlt) * me.Pos.headingCosine + me.Lights.light3.Pos.y * me.Pos.headingSine) / me.lat_to_m); + me.apos.set_lon(me.Pos.lon + ((me.Lights.light3.Pos.x + me.curAlt) * me.Pos.headingSine - me.Lights.light3.Pos.y * me.Pos.headingCosine) / me.lon_to_m); + + me.Lights.light3.posx.setValue((me.apos.lat() - me.vpos.lat()) * me.lat_to_m); + me.Lights.light3.posy.setValue(-(me.apos.lon() - me.vpos.lon()) * me.lon_to_m); + me.Lights.light3.posz.setValue(me.apos.alt()- (me.curAlt / 10) - me.vpos.alt()); + me.Lights.light3.dir.setValue(me.Pos.heading); + + # light 4 position + me.apos.set_lat(me.Pos.lat + ((me.Lights.light4.Pos.x + me.curAlt) * me.Pos.headingCosine + me.Lights.light4.Pos.y * me.Pos.headingSine) / me.lat_to_m); + me.apos.set_lon(me.Pos.lon + ((me.Lights.light4.Pos.x + me.curAlt) * me.Pos.headingSine - me.Lights.light4.Pos.y * me.Pos.headingCosine) / me.lon_to_m); + + me.Lights.light4.posx.setValue((me.apos.lat() - me.vpos.lat()) * me.lat_to_m); + me.Lights.light4.posy.setValue(-(me.apos.lon() - me.vpos.lon()) * me.lon_to_m); + me.Lights.light4.posz.setValue(me.apos.alt()- (me.curAlt / 10) - me.vpos.alt()); + me.Lights.light4.dir.setValue(me.Pos.heading); + + # light 5 position + me.apos.set_lat(me.Pos.lat + ((me.Lights.light5.Pos.x + me.curAlt) * me.Pos.headingCosine + me.Lights.light5.Pos.y * me.Pos.headingSine) / me.lat_to_m); + me.apos.set_lon(me.Pos.lon + ((me.Lights.light5.Pos.x + me.curAlt) * me.Pos.headingSine - me.Lights.light5.Pos.y * me.Pos.headingCosine) / me.lon_to_m); + + me.Lights.light5.posx.setValue((me.apos.lat() - me.vpos.lat()) * me.lat_to_m); + me.Lights.light5.posy.setValue(-(me.apos.lon() - me.vpos.lon()) * me.lon_to_m); + me.Lights.light5.posz.setValue(me.apos.alt()- (me.curAlt / 10) - me.vpos.alt()); + me.Lights.light5.dir.setValue(me.Pos.heading); + settimer ( func me.update(), 0.00); }, +}; - light1_on : func { - if (me.light1_is_on == 1) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r", me.light1_r); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g", me.light1_g); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b", me.light1_b); - me.light1_is_on = 1; - }, - - light1_off : func { - if (me.light1_is_on == 0) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b", 0.0); - me.light1_is_on = 0; - }, - - light1_setSize : func(size) { - setprop("/sim/rendering/als-secondary-lights/lightspot/size[0]", size); - }, - - light2_on : func { - if (me.light2_is_on == 1) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[1]", me.light2_r); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[1]", me.light2_g); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[1]", me.light2_b); - me.light2_is_on = 1; - }, - - light2_off : func { - if (me.light2_is_on == 0) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[1]", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[1]", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[1]", 0.0); - me.light2_is_on = 0; - }, - - light2_setSize : func(size) { - setprop("/sim/rendering/als-secondary-lights/lightspot/size[1]", size); - }, - - light3_on : func { - if (me.light3_is_on == 1) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[2]", me.light3_r); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[2]", me.light3_g); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[2]", me.light3_b); - me.light3_is_on = 1; - }, - - light3_off : func { - if (me.light3_is_on == 0) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[2]", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[2]", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[2]", 0.0); - me.light3_is_on = 0; - }, - - light4_on : func { - if (me.light4_is_on == 1) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[3]", me.light4_r); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[3]", me.light4_g); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[3]", me.light4_b); - me.light4_is_on = 1; - }, - - light4_off : func { - if (me.light4_is_on == 0) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[3]", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[3]", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[3]", 0.0); - me.light4_is_on = 0; - }, - - light5_on : func { - if (me.light5_is_on == 1) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[4]", me.light5_r); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[4]", me.light5_g); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[4]", me.light5_b); - me.light5_is_on = 1; - }, - - light5_off : func { - if (me.light5_is_on == 0) {return;} - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-r[4]", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-g[4]", 0.0); - setprop("/sim/rendering/als-secondary-lights/lightspot/lightspot-b[4]", 0.0); - me.light5_is_on = 0; - }, -}; \ No newline at end of file +setlistener(pts.Sim.Rendering.Shaders.skydome, func(v) { + lightManager.run = v.getValue() ? 1 : 0; +}, 1, 0); \ No newline at end of file diff --git a/Nasal/Libraries/libraries.nas b/Nasal/Libraries/libraries.nas index 6c4636e0..f86ee125 100644 --- a/Nasal/Libraries/libraries.nas +++ b/Nasal/Libraries/libraries.nas @@ -88,7 +88,7 @@ var A320Libraries = nil; var systemsInit = func() { systemsInitialized = 0; fbw.FBW.init(); - effects.light_manager.init(); + effects.lightManager.init(); systems.ELEC.init(); systems.PNEU.init(); systems.HYD.init(); diff --git a/Nasal/Libraries/property-tree-setup.nas b/Nasal/Libraries/property-tree-setup.nas index b64e56ca..a4d5c988 100644 --- a/Nasal/Libraries/property-tree-setup.nas +++ b/Nasal/Libraries/property-tree-setup.nas @@ -67,6 +67,9 @@ var Controls = { parkingBrake: props.globals.getNode("/controls/gear/brake-parking"), chocks: props.globals.getNode("/services/chocks/enable"), }, + Lighting: { + landingLights: [props.globals.getNode("/controls/lighting/landing-lights[0]"),props.globals.getNode("/controls/lighting/landing-lights[1]"),props.globals.getNode("/controls/lighting/landing-lights[2]")], + }, Switches: { annunTest: props.globals.getNode("/controls/switches/annun-test"), }, @@ -213,6 +216,7 @@ var Options = { }; var Orientation = { + heading: props.globals.getNode("/orientation/heading-deg"), pitch: props.globals.getNode("/orientation/pitch-deg"), roll: props.globals.getNode("/orientation/roll-deg"), yaw: props.globals.getNode("/orientation/yaw-deg"), @@ -249,6 +253,12 @@ var Sim = { engine: [props.globals.getNode("/sim/input/selected/engine[0]", 1),props.globals.getNode("/sim/input/selected/engine[1]", 1)], } }, + Model: { + Lights: { + navLights: props.globals.getNode("/sim/model/lights/nav-lights"), + noseLights: props.globals.getNode("/sim/model/lights/nose-lights"), + }, + }, Multiplay: { online: props.globals.getNode("/sim/multiplay/online"), }, @@ -257,6 +267,9 @@ var Sim = { Headshake: { enabled: props.globals.getNode("/sim/rendering/headshake/enabled"), }, + Shaders: { + skydome: props.globals.getNode("/sim/rendering/shaders/skydome"), + }, }, replayState: props.globals.getNode("/sim/freeze/replay-state"), Replay: {