From b75fbce2a1499efe1312565e6fa43402e1188fcc Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 26 Nov 2020 19:24:42 +0000 Subject: [PATCH] Optimization --- Models/Instruments/Lower-ECAM/Lower-ECAM.nas | 46 ++++++++++++-------- Nasal/ECAM/ECAM-phases.nas | 32 ++++++++------ Nasal/emesary/exec.nas | 18 +------- 3 files changed, 46 insertions(+), 50 deletions(-) diff --git a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas index 19a0e054..889ca75c 100644 --- a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas +++ b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas @@ -36,6 +36,10 @@ var tr2_v = 0; var tr2_a = 0; var essTramps = 0; var essTrvolts = 0; +var elac1Node = 0; +var elac2Node = 0; +var sec1Node = 0; +var sec2Node = 0; # Conversion factor pounds to kilogram LBS2KGS = 0.4535924; @@ -1957,6 +1961,10 @@ var canvas_lowerECAM_fctl = { blue_psi = systems.HYD.Psi.blue.getValue(); green_psi = systems.HYD.Psi.green.getValue(); yellow_psi = systems.HYD.Psi.yellow.getValue(); + elac1Node = fbw.FBW.Computers.elac1.getValue(); + elac2Node = fbw.FBW.Computers.elac2.getValue(); + sec1Node = fbw.FBW.Computers.sec1.getValue(); + sec2Node = fbw.FBW.Computers.sec2.getValue(); # Pitch Trim me["PT"].setText(sprintf("%2.1f", math.round(elevator_trim_deg.getValue(), 0.1))); @@ -1987,13 +1995,13 @@ var canvas_lowerECAM_fctl = { me["ailL"].setTranslation(0, aileron_ind_left.getValue() * 100); me["ailR"].setTranslation(0, aileron_ind_right.getValue() * (-100)); - if ((blue_psi < 1500 or !fbw.FBW.Computers.elac1.getValue()) and (green_psi < 1500 or !fbw.FBW.Computers.elac2.getValue())) { + if ((blue_psi < 1500 or !elac1Node) and (green_psi < 1500 or !elac2Node)) { me["ailL"].setColor(0.7333,0.3803,0); } else { me["ailL"].setColor(0.0509,0.7529,0.2941); } - if ((green_psi < 1500 or !fbw.FBW.Computers.elac1.getValue()) and (blue_psi < 1500 or !fbw.FBW.Computers.elac2.getValue())) { + if ((green_psi < 1500 or !elac1Node) and (blue_psi < 1500 or !elac2Node)) { me["ailR"].setColor(0.7333,0.3803,0); } else { me["ailR"].setColor(0.0509,0.7529,0.2941); @@ -2003,13 +2011,13 @@ var canvas_lowerECAM_fctl = { me["elevL"].setTranslation(0, elevator_ind_left.getValue() * 100); me["elevR"].setTranslation(0, elevator_ind_right.getValue() * 100); - if ((blue_psi < 1500 or (!fbw.FBW.Computers.elac1.getValue() and !fbw.FBW.Computers.sec1.getValue())) and (green_psi < 1500 or (!fbw.FBW.Computers.elac2.getValue() and !fbw.FBW.Computers.sec2.getValue()))) { + if ((blue_psi < 1500 or (!elac1Node and !sec1Node)) and (green_psi < 1500 or (!elac2Node and !sec2Node))) { me["elevL"].setColor(0.7333,0.3803,0); } else { me["elevL"].setColor(0.0509,0.7529,0.2941); } - if ((blue_psi < 1500 or (!fbw.FBW.Computers.elac1.getValue() and !fbw.FBW.Computers.sec1.getValue())) and (yellow_psi < 1500 or (!fbw.FBW.Computers.elac2.getValue() and !fbw.FBW.Computers.sec2.getValue()))) { + if ((blue_psi < 1500 or (!elac1Node and !sec1Node)) and (yellow_psi < 1500 or (!elac2Node and !sec2Node))) { me["elevR"].setColor(0.7333,0.3803,0); } else { me["elevR"].setColor(0.0509,0.7529,0.2941); @@ -2247,34 +2255,34 @@ var canvas_lowerECAM_fctl = { } # Flight Computers - if (fbw.FBW.Computers.elac1.getValue()) { + if (elac1Node) { me["elac1"].setColor(0.0509,0.7529,0.2941); me["path4249"].setColor(0.0509,0.7529,0.2941); - } else if (!fbw.FBW.Computers.elac1.getValue() or fbw.FBW.Failures.elac1.getValue()) { + } else if (!elac1Node or fbw.FBW.Failures.elac1.getValue()) { me["elac1"].setColor(0.7333,0.3803,0); me["path4249"].setColor(0.7333,0.3803,0); } - if (fbw.FBW.Computers.elac2.getValue()) { + if (elac2Node) { me["elac2"].setColor(0.0509,0.7529,0.2941); me["path4249-3"].setColor(0.0509,0.7529,0.2941); - } else if (!fbw.FBW.Computers.elac2.getValue() or fbw.FBW.Failures.elac2.getValue()) { + } else if (!elac2Node or fbw.FBW.Failures.elac2.getValue()) { me["elac2"].setColor(0.7333,0.3803,0); me["path4249-3"].setColor(0.7333,0.3803,0); } - if (fbw.FBW.Computers.sec1.getValue()) { + if (sec1Node) { me["sec1"].setColor(0.0509,0.7529,0.2941); me["path4249-3-6-7"].setColor(0.0509,0.7529,0.2941); - } else if (!fbw.FBW.Computers.sec1.getValue() or fbw.FBW.Failures.sec1.getValue()) { + } else if (!sec1Node or fbw.FBW.Failures.sec1.getValue()) { me["sec1"].setColor(0.7333,0.3803,0); me["path4249-3-6-7"].setColor(0.7333,0.3803,0); } - if (fbw.FBW.Computers.sec2.getValue()) { + if (sec2Node) { me["sec2"].setColor(0.0509,0.7529,0.2941); me["path4249-3-6-7-5"].setColor(0.0509,0.7529,0.2941); - } else if (!fbw.FBW.Computers.sec2.getValue() or fbw.FBW.Failures.sec2.getValue()) { + } else if (!sec2Node or fbw.FBW.Failures.sec2.getValue()) { me["sec2"].setColor(0.7333,0.3803,0); me["path4249-3-6-7-5"].setColor(0.7333,0.3803,0); } @@ -2289,19 +2297,19 @@ var canvas_lowerECAM_fctl = { # Hydraulic Indicators if (blue_psi >= 1500) { - if (fbw.FBW.Computers.elac1.getValue()) { + if (elac1Node) { me["ailLblue"].setColor(0.0509,0.7529,0.2941); } else { me["ailLblue"].setColor(0.7333,0.3803,0); } - if (fbw.FBW.Computers.elac1.getValue() or fbw.FBW.Computers.sec1.getValue()) { + if (elac1Node or sec1Node) { me["elevLblue"].setColor(0.0509,0.7529,0.2941); me["elevRblue"].setColor(0.0509,0.7529,0.2941); } else { me["elevLblue"].setColor(0.7333,0.3803,0); me["elevRblue"].setColor(0.7333,0.3803,0); } - if (fbw.FBW.Computers.elac2.getValue()) { + if (elac2Node) { me["ailRblue"].setColor(0.0509,0.7529,0.2941); } else { me["ailRblue"].setColor(0.7333,0.3803,0); @@ -2318,18 +2326,18 @@ var canvas_lowerECAM_fctl = { } if (green_psi >= 1500) { - if (fbw.FBW.Computers.elac2.getValue() or fbw.FBW.Computers.sec2.getValue()) { + if (elac2Node or sec2Node) { me["elevLgreen"].setColor(0.0509,0.7529,0.2941); } else { me["elevLgreen"].setColor(0.7333,0.3803,0); } - if (fbw.FBW.Computers.elac2.getValue()) { + if (elac2Node) { me["ailLgreen"].setColor(0.0509,0.7529,0.2941); } else { me["ailLgreen"].setColor(0.7333,0.3803,0); } - if (fbw.FBW.Computers.elac1.getValue()) { + if (elac1Node) { me["ailRgreen"].setColor(0.0509,0.7529,0.2941); } else { me["ailRgreen"].setColor(0.7333,0.3803,0); @@ -2347,7 +2355,7 @@ var canvas_lowerECAM_fctl = { } if (yellow_psi >= 1500) { - if (fbw.FBW.Computers.elac2.getValue() or fbw.FBW.Computers.sec2.getValue()) { + if (elac2Node or sec2Node) { me["elevRyellow"].setColor(0.0509,0.7529,0.2941); } else { me["elevRyellow"].setColor(0.7333,0.3803,0); diff --git a/Nasal/ECAM/ECAM-phases.nas b/Nasal/ECAM/ECAM-phases.nas index 1c909150..edccc4c4 100644 --- a/Nasal/ECAM/ECAM-phases.nas +++ b/Nasal/ECAM/ECAM-phases.nas @@ -72,6 +72,9 @@ var FWC = { altChg: props.globals.getNode("/it-autoflight/input/alt-is-changing", 1), }; +var gnd = nil; +var gndTimer = nil; + 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; } @@ -84,7 +87,8 @@ var phaseLoop = func() { eng2n1 = pts.Engines.Engine.n1Actual[1].getValue(); master1 = pts.Controls.Engines.Engine.cutoffSw[0].getBoolValue(); master2 = pts.Controls.Engines.Engine.cutoffSw[1].getBoolValue(); - + gnd = FWC.Logic.gnd.getBoolValue(); + gndTimer = FWC.Timer.gnd.getValue(); FWC.Flipflop.recallReset.setValue(0); # Various things @@ -102,13 +106,13 @@ var phaseLoop = func() { FWC.Flipflop.phase10Set.setBoolValue(0); } - if (FWC.Timer.gnd.getValue() == 1 and pts.Controls.Engines.Engine.firePb[0].getBoolValue()) { + if (gndTimer == 1 and pts.Controls.Engines.Engine.firePb[0].getBoolValue()) { FWC.Flipflop.phase10Reset.setBoolValue(1); } else { FWC.Flipflop.phase10Reset.setBoolValue(0); } - if ((FWC.Logic.gnd.getBoolValue() and FWC.Timer.eng1and2Off.getValue() and myPhase == 9) and FWC.Flipflop.phase10Output.getBoolValue()) { + 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); @@ -121,7 +125,7 @@ var phaseLoop = func() { FWC.Flipflop.phase2Set.setBoolValue(0); } - if (!FWC.Monostable.m80kt.getBoolValue() and myPhase != 9 and ((!FWC.Monostable.phase9Output.getBoolValue() and FWC.Timer.gnd.getValue() == 1) or (!FWC.Monostable.toPowerOutput.getBoolValue() and FWC.Timer.gnd.getValue() == 1))) { + 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); @@ -130,33 +134,33 @@ var phaseLoop = func() { gear_agl_cur = pts.Position.gearAglFt.getValue(); # Phase 5 monostable - if (FWC.toPower.getBoolValue() and (!FWC.Logic.feet1500.getBoolValue() and !FWC.Logic.gnd.getBoolValue() and FWC.Timer.gnd2Sec.getValue() != 1)) { + 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); } # Phase 7 monostable - if (!FWC.toPower.getBoolValue() and !FWC.Logic.feet1500.getBoolValue() and !FWC.Logic.feet800.getBoolValue() and !FWC.Logic.gnd.getBoolValue() and FWC.Timer.gnd2Sec.getValue() != 1) { + 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 ((FWC.Logic.gnd.getBoolValue() and FWC.Timer.eng1and2Off.getValue() and myPhase != 9) and !FWC.Monostable.phase1Output.getBoolValue()) { + if ((gnd and FWC.Timer.eng1and2Off.getValue() and myPhase != 9) and !FWC.Monostable.phase1Output.getBoolValue()) { setPhase(1); } - if (FWC.Timer.eng1or2Output.getBoolValue() and (FWC.Logic.gnd.getBoolValue() and !FWC.toPower.getBoolValue() and !FWC.speed80.getBoolValue()) and !FWC.Flipflop.phase2Output.getBoolValue()) { + if (FWC.Timer.eng1or2Output.getBoolValue() and (gnd and !FWC.toPower.getBoolValue() and !FWC.speed80.getBoolValue()) and !FWC.Flipflop.phase2Output.getBoolValue()) { setPhase(2); } - if (FWC.Timer.eng1or2Output.getBoolValue() and (FWC.Timer.gnd.getValue() == 1 and FWC.toPower.getBoolValue()) and !FWC.speed80.getBoolValue()) { + if (FWC.Timer.eng1or2Output.getBoolValue() and (gndTimer == 1 and FWC.toPower.getBoolValue()) and !FWC.speed80.getBoolValue()) { setPhase(3); } - if ((FWC.Timer.gnd.getValue() == 1 and FWC.toPower.getBoolValue()) and FWC.speed80.getBoolValue()) { + if ((gndTimer == 1 and FWC.toPower.getBoolValue()) and FWC.speed80.getBoolValue()) { setPhase(4); } @@ -164,7 +168,7 @@ var phaseLoop = func() { setPhase(5); } - if (!FWC.Logic.gnd.getValue() 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.phase5.getBoolValue() or !FWC.Monostable.phase5Output.getBoolValue()) and (!FWC.Monostable.phase7.getBoolValue() or !FWC.Monostable.phase7Output.getBoolValue())) { setPhase(6); } @@ -172,15 +176,15 @@ var phaseLoop = func() { setPhase(7); } - if (!FWC.toPower.getBoolValue() and FWC.speed80.getBoolValue() and (FWC.Logic.gnd.getBoolValue() or FWC.Timer.gnd2Sec.getValue == 1)) { + if (!FWC.toPower.getBoolValue() and FWC.speed80.getBoolValue() and (gnd or FWC.Timer.gnd2Sec.getValue == 1)) { setPhase(8); } - if (FWC.Flipflop.phase2Output.getBoolValue() and (FWC.Logic.gnd.getBoolValue() and !FWC.toPower.getBoolValue() and !FWC.speed80.getBoolValue()) and FWC.Timer.eng1or2.getBoolValue()) { + if (FWC.Flipflop.phase2Output.getBoolValue() and (gnd and !FWC.toPower.getBoolValue() and !FWC.speed80.getBoolValue()) and FWC.Timer.eng1or2.getBoolValue()) { setPhase(9); } - if ((FWC.Logic.gnd.getBoolValue() and FWC.Timer.eng1and2Off.getValue() and myPhase == 9) and FWC.Monostable.phase1Output.getBoolValue()) { + if ((gnd and FWC.Timer.eng1and2Off.getValue() and myPhase == 9) and FWC.Monostable.phase1Output.getBoolValue()) { setPhase(10); } diff --git a/Nasal/emesary/exec.nas b/Nasal/emesary/exec.nas index 1e4ca7fd..3ea20548 100644 --- a/Nasal/emesary/exec.nas +++ b/Nasal/emesary/exec.nas @@ -30,23 +30,7 @@ var execLoop = func emesary.GlobalTransmitter.NotifyAll(notifications.frameNotification); notifications.frameNotification.FrameCount = notifications.frameNotification.FrameCount + 1; - - if (notifications.frameNotification.frame_rate < 5) { - frame_inc = 0.25;#4 Hz - } elsif (notifications.frameNotification.frame_rate < 10) { - frame_inc = 0.125;#8 Hz - } elsif (notifications.frameNotification.frame_rate < 15) { - frame_inc = 0.10;#10 Hz - } elsif (notifications.frameNotification.frame_rate < 20) { - frame_inc = 0.075;#13.3 Hz - } elsif (notifications.frameNotification.frame_rate < 25) { - frame_inc = 0.05;#20 Hz - } elsif (notifications.frameNotification.frame_rate < 40) { - frame_inc = 0.0333;#30 Hz - } else { - frame_inc = 0.02;#50 Hz - } - + frame_inc = 0.0333; #30 Hz if (frame_inc != cur_frame_inc) { cur_frame_inc = frame_inc; }