From 49559e5a681fb42da6f68de7aba51b33ff32ab17 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 8 Feb 2021 15:45:57 +0000 Subject: [PATCH 1/3] Emesary system update framework: this works towards reducing property IO by only ever caling a property once. --- Models/Instruments/IESI/IESI.nas | 2 - Models/Instruments/Lower-ECAM/Lower-ECAM.nas | 2 +- Nasal/FMGC/FCU.nas | 6 +- Nasal/Libraries/libraries.nas | 13 ++- Nasal/Panels/atc.nas | 9 +- Nasal/Systems/ADIRS/ADR.nas | 3 +- Nasal/Systems/FADEC/fadec-common.nas | 2 +- Nasal/Systems/brakesystem.nas | 24 ++--- Nasal/Systems/electrical.nas | 73 ++++++++++----- Nasal/Systems/hydraulics.nas | 94 ++++++++++++-------- Nasal/Systems/pneumatics.nas | 6 +- Nasal/emesary/M_frame_notification.nas | 26 +++++- Nasal/emesary/exec.nas | 11 +-- Systems/a320-hydraulic.xml | 4 +- 14 files changed, 167 insertions(+), 108 deletions(-) diff --git a/Models/Instruments/IESI/IESI.nas b/Models/Instruments/IESI/IESI.nas index 4ad0a965..63415808 100644 --- a/Models/Instruments/IESI/IESI.nas +++ b/Models/Instruments/IESI/IESI.nas @@ -261,8 +261,6 @@ var input = { "altitude_ind": "/instrumentation/altimeter/indicated-altitude-ft-pfd", "altimeter_mode": "/instrumentation/altimeter[0]/std", "attReset": "/instrumentation/iesi/att-reset", - "dcEss": "/systems/electrical/bus/dc-ess", - "dcHot1": "/systems/electrical/bus/dc-hot-1", "iesiBrt": "/controls/lighting/DU/iesi", "iesiInit": "/instrumentation/iesi/iesi-init", "mach": "/instrumentation/airspeed-indicator/indicated-mach", diff --git a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas index cbfddbc6..feaae20f 100644 --- a/Models/Instruments/Lower-ECAM/Lower-ECAM.nas +++ b/Models/Instruments/Lower-ECAM/Lower-ECAM.nas @@ -3010,7 +3010,7 @@ var canvas_lowerECAM_wheel = { rightdoor = gear_door_R.getValue(); nosedoor = gear_door_N.getValue(); gearlvr = gear_down.getValue(); - askidsw = systems.HYD.Brakes.askidSw.getBoolValue(); + askidsw = systems.HYD.Switch.nwsSwitch.getBoolValue(); brakemode = systems.HYD.Brakes.mode.getBoolValue(); accum = systems.HYD.Brakes.accumPressPsi.getBoolValue(); diff --git a/Nasal/FMGC/FCU.nas b/Nasal/FMGC/FCU.nas index 8a2a6a78..2ca20a91 100644 --- a/Nasal/FMGC/FCU.nas +++ b/Nasal/FMGC/FCU.nas @@ -66,7 +66,7 @@ var FCUController = { me.FCU2 = FCU.new(systems.ELEC.Bus.dc2); me._init = 1; }, - loop: func() { + loop: func(notification) { if (me._init == 0) { return; } # Update FCU Power @@ -82,11 +82,11 @@ var FCUController = { } foreach (var update_item; me.update_items) { - update_item.update(nil); + update_item.update(notification); } }, update_items: [ - props.UpdateManager.FromPropertyHashList(["/it-autoflight/output/fd1","/it-autoflight/output/fd2", "/it-autoflight/output/ap1", "/it-autoflight/output/ap2"], 1, func(notification) + props.UpdateManager.FromPropertyHashList(["/it-autoflight/output/fd1","/it-autoflight/output/fd2", "/it-autoflight/output/ap1", "/it-autoflight/output/ap2"], nil, func(notification) { updateActiveFMGC(); } diff --git a/Nasal/Libraries/libraries.nas b/Nasal/Libraries/libraries.nas index c5b05971..f632f7d0 100644 --- a/Nasal/Libraries/libraries.nas +++ b/Nasal/Libraries/libraries.nas @@ -174,19 +174,18 @@ var update_items = [ var systemsLoop = func(notification) { if (!systemsInitialized) { return; } - systems.ELEC.loop(); - systems.PNEU.loop(); - systems.HYD.loop(); - systems.ADIRS.loop(); + systems.PNEU.loop(notification); + systems.ADIRS.loop(notification); + systems.BrakeSys.update(notification); + systems.HFLoop(notification); systems.APUController.loop(); - systems.BrakeSys.update(); fadec.FADEC.loop(); rmp.rmpUpdate(); - fcu.FCUController.loop(); + fcu.FCUController.loop(notification); + atc.Transponders.vector[atc.transponderPanel.atcSel - 1].update(notification); dmc.DMController.loop(); atsu.ATSU.loop(); libraries.BUTTONS.update(); - systems.HFLoop(notification); if ((notification.engine1State == 2 or notification.engine1State == 3) and collectorTankL.getValue() < 1) { systems.cutoff_one(); diff --git a/Nasal/Panels/atc.nas b/Nasal/Panels/atc.nas index e6b192dc..d5abadfb 100644 --- a/Nasal/Panels/atc.nas +++ b/Nasal/Panels/atc.nas @@ -24,7 +24,6 @@ var Transponder = { serviceableNode: props.globals.getNode("/instrumentation/transponder/serviceable", 1), knobNode: props.globals.getNode("/instrumentation/transponder/inputs/knob-mode", 1), identNode: props.globals.getNode("/instrumentation/transponder/inputs/ident-btn", 1), - ac1Node: props.globals.getNode("/systems/electrical/bus/ac-1", 1), tcasNode: props.globals.getNode("/instrumentation/tcas/inputs/mode"), aglNode: props.globals.getNode("/position/gear-agl-ft", 1), electricNode: props.globals.getNode("/systems/electrical/outputs/transponder", 1), # communicate to generic systems @@ -40,9 +39,9 @@ var Transponder = { return t; }, - update: func() { + update: func(notification) { # TCAS - on seperate electrical source, so has to be before transponder electrical checking - if (me.ac1Node.getValue() < 110) { + if (notification.elecAC1 < 110) { me.tcasNode.setValue(0); # off } else { if (me.mode >= 1 and me.mode <= 3) { @@ -285,7 +284,6 @@ var transponderPanel = { var init = func() { transponderPanel.atcSwitch(1); transponderPanel.updateAirData(); - transponderTimer.start(); } # Handler for code change from generic dialog @@ -297,9 +295,6 @@ setlistener("/instrumentation/transponder/id-code", func { var Transponders = std.Vector.new([Transponder.new("/systems/electrical/bus/ac-ess-shed", 1), Transponder.new("/systems/electrical/bus/ac-2", 2)]); -var transponderTimer = maketimer(0.1, func() { - Transponders.vector[transponderPanel.atcSel - 1].update(); -}); setlistener("/systems/navigation/adr/operating-1", func() { transponderPanel.updateADR1(systems.ADIRS.Operating.adr[0].getValue()); diff --git a/Nasal/Systems/ADIRS/ADR.nas b/Nasal/Systems/ADIRS/ADR.nas index ad82e383..08d6d57d 100644 --- a/Nasal/Systems/ADIRS/ADR.nas +++ b/Nasal/Systems/ADIRS/ADR.nas @@ -324,7 +324,7 @@ var ADIRS = { } ), ], - loop: func() { + loop: func(notification) { if (me._init) { for (i = 0; i < _NUMADIRU; i = i + 1) { # update ADR units power @@ -348,7 +348,6 @@ var ADIRS = { } # Update VFE - notification = nil; foreach (var update_item; me.update_items) { update_item.update(notification); } diff --git a/Nasal/Systems/FADEC/fadec-common.nas b/Nasal/Systems/FADEC/fadec-common.nas index 60a49de4..64d7bf0b 100644 --- a/Nasal/Systems/FADEC/fadec-common.nas +++ b/Nasal/Systems/FADEC/fadec-common.nas @@ -448,4 +448,4 @@ setlistener("/systems/thrust/thr-locked", func { }, 0, 0); var lockTimer = maketimer(0.1, checkLockThr); -var lockTimer2 = maketimer(0.1, checkLockThr2); +var lockTimer2 = maketimer(0.1, checkLockThr2); \ No newline at end of file diff --git a/Nasal/Systems/brakesystem.nas b/Nasal/Systems/brakesystem.nas index ca021df9..b460b2cc 100755 --- a/Nasal/Systems/brakesystem.nas +++ b/Nasal/Systems/brakesystem.nas @@ -111,7 +111,7 @@ var BrakeSystem = }, # update brake energy - update : func() + update : func(notification) { if (me.counter == 0) { me.counter = 1; @@ -122,10 +122,10 @@ var BrakeSystem = LThermalEnergy = me.thermalEnergy[0]; RThermalEnergy = me.thermalEnergy[1]; - me.CurrentTime = pts.Sim.Time.elapsedSec.getValue(); + me.CurrentTime = notification.elapsedTime; dt = me.CurrentTime - me.LastSimTime; - LBrakeLevel = pts.Fdm.JSBsim.Fcs.brake[0].getValue(); - RBrakeLevel = pts.Fdm.JSBsim.Fcs.brake[1].getValue(); + LBrakeLevel = notification.leftBrakeFCS; + RBrakeLevel = notification.rightBrakeFCS; tatdegc = pts.Fdm.JSBsim.Propulsion.tatC.getValue() or 0; if (pts.Sim.replayState.getValue() == 0 and dt < 1.0) { @@ -137,7 +137,7 @@ var BrakeSystem = LCoolingRatio = LCoolingRatio * 3; RCoolingRatio = RCoolingRatio * 3; }; - airspeed = pts.Velocities.airspeed.getValue(); + airspeed = notification.airspeedV; if (pts.Gear.position[1].getValue()) { #increase CoolingRatio if gear down according to airspeed LCoolingRatio = LCoolingRatio * airspeed; @@ -168,7 +168,7 @@ var BrakeSystem = L_Thrust = 0; R_Thrust = 0; - if (pts.Gear.wow[1].getValue()) { + if (notification.gear1Wow) { var V1 = pts.Velocities.groundspeed.getValue(); var Mass = pts.Fdm.JSBsim.Inertia.weightLbs.getValue() * me.ScalingDivisor; @@ -179,7 +179,7 @@ var BrakeSystem = LThermalEnergy += (Mass * pts.Gear.compression[1].getValue() * (math.pow(V1, 2) - math.pow(V2_L, 2)) / 2); if (pts.Controls.Gear.chocks.getValue()) { - if (!pts.Controls.Gear.parkingBrake.getValue()) { + if (!notification.parkingBrake) { # cooling effect: reduce thermal energy by (LnCoolFactor) * dt LThermalEnergy = LThermalEnergy * math.exp(LnCoolFactor * dt); } else { @@ -188,7 +188,7 @@ var BrakeSystem = LThermalEnergy = (LThermalEnergy * math.exp(LnCoolFactor * dt)) + (L_Thrust * dt); }; } else { - if (!pts.Controls.Gear.parkingBrake.getValue()) { + if (!notification.parkingBrake) { if (LBrakeLevel>0) { if (V2_L>0) { #LThermalEnergy += (Mass * (math.pow(V1, 2) - math.pow(V2_L, 2)) / 2) + L_thrust; @@ -212,7 +212,7 @@ var BrakeSystem = RThermalEnergy += (Mass * pts.Gear.compression[2].getValue() * (math.pow(V1, 2) - math.pow(V2_R, 2)) / 2); if (pts.Controls.Gear.chocks.getValue()) { - if (!pts.Controls.Gear.parkingBrake.getValue()) { + if (!notification.parkingBrake) { # cooling effect: reduce thermal energy by (RnCoolFactor) * dt RThermalEnergy = RThermalEnergy * math.exp(RnCoolFactor * dt); } else { @@ -221,7 +221,7 @@ var BrakeSystem = RThermalEnergy = (RThermalEnergy * math.exp(RnCoolFactor * dt)) + (R_Thrust * dt); }; } else { - if (!pts.Controls.Gear.parkingBrake.getValue()) { + if (!notification.parkingBrake) { if (RBrakeLevel>0) { if (V2_R>0) { #RThermalEnergy += (Mass * (math.pow(V1, 2) - math.pow(V2_R, 2)) / 2) + R_thrust; @@ -271,7 +271,7 @@ var BrakeSystem = if (LThermalEnergy>1 and !me.LSmokeActive) { # start smoke processing me.LSmokeActive = 1; - settimer(func { BrakeSys.Lsmoke(); },0); + settimer(func { BrakeSys.Lsmoke(); },0); # is settimer needed? }; if (RThermalEnergy>1 and !me.RSmokeActive) { # start smoke processing @@ -406,7 +406,7 @@ var Autobrake = { me._mode = me.mode.getValue(); me._active = me.active.getBoolValue(); if (me._gnd_speed > 72) { - if (me._mode != 0 and pts.Controls.Engines.Engine.throttle[0].getValue() < 0.15 and pts.Controls.Engines.Engine.throttle[1].getValue() < 0.15 and me._wow0 and systems.HYD.Brakes.askidSw.getValue() and systems.HYD.Psi.green.getValue() >= 2500 ) { + if (me._mode != 0 and pts.Controls.Engines.Engine.throttle[0].getValue() < 0.15 and pts.Controls.Engines.Engine.throttle[1].getValue() < 0.15 and me._wow0 and systems.HYD.Switch.nwsSwitch.getBoolValue() and systems.HYD.Psi.green.getValue() >= 2500 ) { me.active.setBoolValue(1); } elsif (me._active) { me.active.setBoolValue(0); diff --git a/Nasal/Systems/electrical.nas b/Nasal/Systems/electrical.nas index 6ccf5253..6fc42666 100644 --- a/Nasal/Systems/electrical.nas +++ b/Nasal/Systems/electrical.nas @@ -13,8 +13,6 @@ var dc2 = 0; # Main class var ELEC = { - _timer1On: 0, - _timer2On: 0, EmerElec: props.globals.getNode("/systems/electrical/some-electric-thingie/emer-elec-config"), Bus: { acEss: props.globals.getNode("/systems/electrical/bus/ac-ess"), @@ -207,36 +205,65 @@ var ELEC = { me.Fail.tr1Fault.setBoolValue(0); me.Fail.tr2Fault.setBoolValue(0); }, - loop: func() { + _FMGC1: 0, + _FMGC2: 0, + _activeFMGC: nil, + _timer1On: 0, + _timer2On: 0, + loop: func(notification) { # Autopilot Disconnection routines - if (me.Bus.dcEssShed.getValue() < 25) { - if (fmgc.Output.ap1.getValue() and !me._timer1On) { + me._activeFMGC = fcu.FCUController.activeFMGC.getValue(); + me._FMGC1 = fmgc.Output.ap1.getValue(); + me._FMGC2 = fmgc.Output.ap2.getValue(); + + if (notification.dcEssShed < 25) { + if (me._FMGC1 and !me._timer1On) { # delay 1 cycle to avoid spurious me._timer1On = 1; - settimer(func() { - if (me.Bus.dcEssShed.getValue() < 25) { - fcu.apOff("hard", 1); - if (fcu.FCUController.activeFMGC.getValue() == 1) { - fcu.athrOff("hard"); - } + } elsif (me._FMGC1) { + if (notification.dcEssShed < 25) { + fcu.apOff("hard", 1); + if (me._activeFMGC == 1) { + fcu.athrOff("hard"); } - me._timer1On = 0; - }, 0.1); + } + me._timer1On = 0; } } - if (me.Bus.dc2.getValue() < 25) { - if (fmgc.Output.ap2.getValue() and !me._timer2On) { + if (notification.dc2 < 25) { + if (me._FMGC2 and !me._timer2On) { # delay 1 cycle to avoid spurious me._timer2On = 1; - settimer(func() { - if (me.Bus.dc2.getValue() < 25) { - fcu.apOff("hard", 2); - if (fcu.FCUController.activeFMGC.getValue() == 2) { - fcu.athrOff("hard"); - } + } elsif (me._FMGC2) { + if (notification.dc2 < 25) { + fcu.apOff("hard", 2); + if (me._activeFMGC == 2) { + fcu.athrOff("hard"); } - me._timer2On = 0; - }, 0.1); + } + me._timer2On = 0; } } }, +}; + +# Emesary +var A320Electrical = notifications.SystemRecipient.new("A320 Electrical",ELEC.loop,ELEC); +emesary.GlobalTransmitter.Register(A320Electrical); + +var input = { + "elecAC1": "/systems/electrical/bus/ac-1", + "elecAC2": "/systems/electrical/bus/ac-2", + "elecACEss": "/systems/electrical/bus/ac-ess", + "elecACEssShed": "/systems/electrical/bus/ac-ess-shed", + "dc1": "/systems/electrical/bus/dc-1", + "dc2": "/systems/electrical/bus/dc-2", + "dcBat": "/systems/electrical/bus/dc-bat", + "dcEss": "/systems/electrical/bus/dc-ess", + "dcEssShed": "/systems/electrical/bus/dc-ess-shed", + "dcHot1": "/systems/electrical/bus/dc-hot-1", + "dcHot2": "/systems/electrical/bus/dc-hot-2", +}; + +foreach (var name; keys(input)) { + emesary.GlobalTransmitter.NotifyAll(notifications.FrameNotificationAddProperty.new("A320 Electrical", name, input[name])); } \ No newline at end of file diff --git a/Nasal/Systems/hydraulics.nas b/Nasal/Systems/hydraulics.nas index c3cb02c2..204c40b5 100644 --- a/Nasal/Systems/hydraulics.nas +++ b/Nasal/Systems/hydraulics.nas @@ -10,7 +10,6 @@ var HYD = { accumPressPsi: props.globals.initNode("/systems/hydraulic/yellow-accumulator-psi-cmd", 0, "INT"), leftPressPsi: props.globals.initNode("/systems/hydraulic/brakes/pressure-left-psi", 0, "INT"), rightPressPsi: props.globals.initNode("/systems/hydraulic/brakes/pressure-right-psi", 0, "INT"), - askidSw: props.globals.initNode("/systems/hydraulic/brakes/askidnwssw", 1, "BOOL"), mode: props.globals.initNode("/systems/hydraulic/brakes/mode", 0, "INT"), leftbrake: props.globals.getNode("/controls/gear/brake-left"), rightbrake: props.globals.getNode("/controls/gear/brake-right"), @@ -57,6 +56,7 @@ var HYD = { rat: props.globals.getNode("/controls/hydraulic/switches/rat-man"), yellowEDP: props.globals.getNode("/controls/hydraulic/switches/yellow-edp"), yellowElec: props.globals.getNode("/controls/hydraulic/switches/yellow-elec"), + nwsSwitch: props.globals.getNode("/controls/gear/nws-switch"), }, Valve: { yellowFire: props.globals.getNode("/systems/hydraulic/sources/yellow-edp/fire-valve"), @@ -85,97 +85,91 @@ var HYD = { me.Fail.yellowElec.setBoolValue(0); me.Fail.yellowLeak.setBoolValue(0); }, - loop: func() { - if (props.globals.getValue("/controls/gear/nws-switch") == 1) { - me.Brakes.askidSw.setBoolValue(1); #true - } else { - me.Brakes.askidSw.setBoolValue(0); #false - } - + loop: func(notification) { # Decrease accumPressPsi when green and yellow hydraulic's aren't pressurized - if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { + if (me.Brakes.leftbrake.getValue() > 0 or notification.brakesMode == 0) { lcont = lcont + 1; } else { lcont = 0; } - if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { + if (me.Brakes.rightbrake.getValue() > 0 or notification.brakesMode == 0) { rcont = rcont + 1; } else { rcont = 0; } - if (me.Psi.yellow.getValue() < me.Brakes.accumPressPsi.getValue() and me.Brakes.accumPressPsi.getValue() > 0) { + if (notification.yellow < notification.accumPressPsi and notification.accumPressPsi > 0) { if (lcont == 1) { - me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - 200); + me.Brakes.accumPressPsi.setValue(notification.accumPressPsi - 200); } if (rcont == 1) { - me.Brakes.accumPressPsi.setValue(me.Brakes.accumPressPsi.getValue() - 200); + me.Brakes.accumPressPsi.setValue(notification.accumPressPsi - 200); } - if (me.Brakes.accumPressPsi.getValue() < 0) { + if (notification.accumPressPsi < 0) { me.Brakes.accumPressPsi.setValue(0); } } # Braking Pressure - if (me.Brakes.mode.getValue() == 1 or (me.Brakes.mode.getValue() == 2 and me.Psi.green.getValue() >= 2500)) { + if (notification.brakesMode == 1 or (notification.brakesMode == 2 and notification.green >= 2500)) { # Normal braking - Green OK - if (me.Brakes.leftbrake.getValue() > 0) { - me.Brakes.leftPressPsi.setValue(me.Psi.green.getValue() * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); + if (notification.leftBrake > 0) { + me.Brakes.leftPressPsi.setValue(notification.green * notification.leftBrakeFCS); } else { me.Brakes.leftPressPsi.setValue(0); } - if (me.Brakes.rightbrake.getValue() > 0) { - me.Brakes.rightPressPsi.setValue(me.Psi.green.getValue() * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); + if (notification.rightBrake > 0) { + me.Brakes.rightPressPsi.setValue(notification.green * notification.rightBrakeFCS); } else { me.Brakes.rightPressPsi.setValue(0); } } else { - if ((me.Brakes.mode.getValue() == 2 and me.Psi.green.getValue() < 2500) or me.Brakes.mode.getValue() == 0) { + if ((notification.brakesMode == 2 and notification.green < 2500) or notification.brakesMode == 0) { # Alternate Braking (Yellow OK + Antiskid ON + electric OK) - missing condition: BSCU OK-KO - if (me.Psi.yellow.getValue() >= 2500 and me.Brakes.askidSw.getValue() and (systems.ELEC.Bus.dc1.getValue() >= 24 or systems.ELEC.Bus.dc2.getValue() >= 24 or systems.ELEC.Bus.dcEss.getValue() >= 24)) { - if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.leftPressPsi.setValue(me.Psi.yellow.getValue() * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); + if (notification.yellow >= 2500 and notification.NWSSwitch and (notification.dc1 >= 24 or notification.dc2 >= 24 or notification.dcEss >= 24)) { + if (notification.leftBrake > 0 or notification.brakesMode == 0) { + me.Brakes.leftPressPsi.setValue(notification.yellow * notification.leftBrakeFCS); } else { me.Brakes.leftPressPsi.setValue(0); } - if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.rightPressPsi.setValue(me.Psi.yellow.getValue() * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); + if (notification.rightBrake > 0 or notification.brakesMode == 0) { + me.Brakes.rightPressPsi.setValue(notification.yellow * notification.rightBrakeFCS); } else { me.Brakes.rightPressPsi.setValue(0); } } else { # Alternate Braking (Yellow OK + Antiskid OFF + electric OK) - missing condition: BSCU OK-KO - if (me.Psi.yellow.getValue() >= 2500 and !me.Brakes.askidSw.getValue() and (systems.ELEC.Bus.dc1.getValue() >= 24 or systems.ELEC.Bus.dc2.getValue() >= 24 or systems.ELEC.Bus.dcEss.getValue() >= 24)) { - if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.leftPressPsi.setValue(1000 * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); + if (notification.yellow >= 2500 and !notification.NWSSwitch and (notification.dc1 >= 24 or notification.dc2 >= 24 or notification.dcEss >= 24)) { + if (notification.leftBrake > 0 or notification.brakesMode == 0) { + me.Brakes.leftPressPsi.setValue(1000 * notification.leftBrakeFCS); } else { me.Brakes.leftPressPsi.setValue(0); } - if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.rightPressPsi.setValue(1000 * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); + if (notification.rightBrake > 0 or notification.brakesMode == 0) { + me.Brakes.rightPressPsi.setValue(1000 * notification.rightBrakeFCS); } else { me.Brakes.rightPressPsi.setValue(0); } } else { # Alternate Braking (Yellow KO or Antiskid KO or electric KO) - missing condition: BSCU OK-KO - if (me.Brakes.accumPressPsi.getValue() < 1000 and (me.Psi.yellow.getValue() < 2500 or !me.Brakes.askidSw.getValue() or (systems.ELEC.Bus.dc1.getValue() < 24 and systems.ELEC.Bus.dc2.getValue() < 24 and systems.ELEC.Bus.dcEss.getValue() < 24))) { - if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.leftPressPsi.setValue(me.Brakes.accumPressPsi.getValue() * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); + if (notification.accumPressPsi < 1000 and (notification.yellow < 2500 or !notification.NWSSwitch or (notification.dc1 < 24 and notification.dc2 < 24 and notification.dcEss < 24))) { + if (notification.leftBrake > 0 or notification.brakesMode == 0) { + me.Brakes.leftPressPsi.setValue(notification.accumPressPsi * notification.leftBrakeFCS); } else { me.Brakes.leftPressPsi.setValue(0); } - if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.rightPressPsi.setValue(me.Brakes.accumPressPsi.getValue() * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); + if (notification.rightBrake > 0 or notification.brakesMode == 0) { + me.Brakes.rightPressPsi.setValue(notification.accumPressPsi * notification.rightBrakeFCS); } else { me.Brakes.rightPressPsi.setValue(0); } } else { - if (me.Brakes.leftbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.leftPressPsi.setValue(1000 * pts.Fdm.JSBsim.Fcs.brake[0].getValue()); + if (notification.leftBrake > 0 or notification.brakesMode == 0) { + me.Brakes.leftPressPsi.setValue(1000 * notification.leftBrakeFCS); } else { me.Brakes.leftPressPsi.setValue(0); } - if (me.Brakes.rightbrake.getValue() > 0 or me.Brakes.mode.getValue() == 0) { - me.Brakes.rightPressPsi.setValue(1000 * pts.Fdm.JSBsim.Fcs.brake[1].getValue()); + if (notification.rightBrake > 0 or notification.brakesMode == 0) { + me.Brakes.rightPressPsi.setValue(1000 * notification.rightBrakeFCS); } else { me.Brakes.rightPressPsi.setValue(0); } @@ -192,3 +186,25 @@ setlistener("/controls/gear/gear-down", func { pts.Controls.Gear.gearDown.setValue(1); } }); + +# Emesary +var A320Hydraulic = notifications.SystemRecipient.new("A320 Hydraulic",HYD.loop,HYD); +emesary.GlobalTransmitter.Register(A320Hydraulic); + +var input = { + "blue": "/systems/hydraulic/blue-psi", + "green": "/systems/hydraulic/green-psi", + "yellow": "/systems/hydraulic/yellow-psi", + + "brakesMode": "/systems/hydraulic/brakes/mode", + "accumPressPsi": "/systems/hydraulic/yellow-accumulator-psi-cmd", + "leftBrake": "/controls/gear/brake-left", + "rightBrake": "/controls/gear/brake-right", + "leftBrakeFCS": "/fdm/jsbsim/fcs/left-brake-cmd-norm", + "rightBrakeFCS": "/fdm/jsbsim/fcs/right-brake-cmd-norm", + "NWSSwitch": "/controls/gear/nws-switch", +}; + +foreach (var name; keys(input)) { + emesary.GlobalTransmitter.NotifyAll(notifications.FrameNotificationAddProperty.new("A320 Hydraulic", name, input[name])); +} \ No newline at end of file diff --git a/Nasal/Systems/pneumatics.nas b/Nasal/Systems/pneumatics.nas index eeb18b2e..97425c63 100644 --- a/Nasal/Systems/pneumatics.nas +++ b/Nasal/Systems/pneumatics.nas @@ -161,9 +161,9 @@ var PNEU = { me.Fail.trimValveFwd.setBoolValue(0); me.Fail.xbleed.setBoolValue(0); }, - loop: func() { - wowl = getprop("gear/gear[1]/wow"); - wowr = getprop("gear/gear[2]/wow"); + loop: func(notification) { + wowl = notification.gear1Wow; + wowr = notification.gear2Wow; # Legacy pressurization cabinalt = getprop("/systems/pressurization/cabinalt"); diff --git a/Nasal/emesary/M_frame_notification.nas b/Nasal/emesary/M_frame_notification.nas index 228b79c1..cb44c3e3 100644 --- a/Nasal/emesary/M_frame_notification.nas +++ b/Nasal/emesary/M_frame_notification.nas @@ -100,4 +100,28 @@ var frameNotification = FrameNotification.new(1); # Frame count # 5 = ECAM # 7 = FWC phases -# 10 = ECAM messages \ No newline at end of file +# 10 = ECAM messages + + +var SystemRecipient = +{ + new: func(_ident,loopFunc, instance) + { + var NewSystemRecipient = emesary.Recipient.new(_ident); + NewSystemRecipient.Receive = func(notification) + { + if (notification.NotificationType == "FrameNotification") + { + if (math.mod(notifications.frameNotification.FrameCount,5) == 0) { + call(loopFunc,[notification],instance, nil, var errors = []); + if (size(errors) > 0) { + debug.printerror(errors); + } + } + return emesary.Transmitter.ReceiptStatus_OK; + } + return emesary.Transmitter.ReceiptStatus_NotProcessed; + }; + return NewSystemRecipient; + }, +}; \ No newline at end of file diff --git a/Nasal/emesary/exec.nas b/Nasal/emesary/exec.nas index af3ad265..eda3c5e9 100644 --- a/Nasal/emesary/exec.nas +++ b/Nasal/emesary/exec.nas @@ -42,13 +42,14 @@ input = { frame_rate: "/sim/frame-rate", elapsedTime: "/sim/time/elapsed-sec", FWCPhase: "/ECAM/warning-phase", - gear0Wow: "/gear/gear[0]/wow", # Just about everything uses these properties at some stage, lets add them here! - elecAC1: "/systems/electrical/bus/ac-1", - elecAC2: "/systems/electrical/bus/ac-2", - elecACEss: "/systems/electrical/bus/ac-ess", - elecACEssShed: "/systems/electrical/bus/ac-ess-shed", + gear0Wow: "/gear/gear[0]/wow", + gear1Wow: "/gear/gear[1]/wow", + gear2Wow: "/gear/gear[2]/wow", + parkingBrake: "/controls/gear/brake-parking", + airspeedV: "/velocities/airspeed-kt", + groundspeed: "/velocities/groundspeed-kt", engine1State: "/engines/engine[0]/state", engine2State: "/engines/engine[1]/state", }; diff --git a/Systems/a320-hydraulic.xml b/Systems/a320-hydraulic.xml index 67e33fbb..30264be1 100644 --- a/Systems/a320-hydraulic.xml +++ b/Systems/a320-hydraulic.xml @@ -528,12 +528,12 @@ /controls/gear/brake-parking ne 1 - /systems/hydraulic/brakes/askidnwssw eq 1 + /controls/gear/nws-switch eq 1 /systems/hydraulic/green-psi ge 2500 /controls/gear/brake-parking ne 1 - /systems/hydraulic/brakes/askidnwssw eq 1 + /controls/gear/nws-switch eq 1 /systems/hydraulic/yellow-psi ge 2500 From cfc771e86d28a0254eaad8c9b4b09d55750a9310 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 8 Feb 2021 16:10:36 +0000 Subject: [PATCH 2/3] Help out CPU bound systems by reducing XML load and running ECAM at framerate rather than fdmrate --- A320-main.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/A320-main.xml b/A320-main.xml index 97c14b71..7bbbf383 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -237,12 +237,12 @@ Aircraft/A320-family/Systems/sound-common.xml - + Aircraft/A320-family/Systems/a320-lights-proprules.xml - - + + Aircraft/A320-family/Systems/ecam-proprules.xml - + Aircraft/A320-family/Systems/pitot-static.xml From d290701784c72bb89ae2e146f060359c97138fec Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Mon, 8 Feb 2021 16:14:41 +0000 Subject: [PATCH 3/3] Sound should also run at framerate as well --- A320-100-CFM-set.xml | 4 ++-- A320-200-CFM-set.xml | 6 +++--- A320-200-IAE-set.xml | 4 ++-- A320-main.xml | 4 ++-- A320neo-CFM-set.xml | 4 ++-- A320neo-PW-set.xml | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/A320-100-CFM-set.xml b/A320-100-CFM-set.xml index 3ab703be..c1c7fe31 100644 --- a/A320-100-CFM-set.xml +++ b/A320-100-CFM-set.xml @@ -206,9 +206,9 @@ Aircraft/A320-family/Systems/fadec-cfm.xml - + Aircraft/A320-family/Systems/cfm56-sound.xml - + diff --git a/A320-200-CFM-set.xml b/A320-200-CFM-set.xml index 3c94e222..d604b43b 100644 --- a/A320-200-CFM-set.xml +++ b/A320-200-CFM-set.xml @@ -206,9 +206,9 @@ Aircraft/A320-family/Systems/fadec-cfm.xml - - Aircraft/A320-family/Systems/cfm56-sound.xml - + + Aircraft/A320-family/Systems/cfm56-sound.xml + diff --git a/A320-200-IAE-set.xml b/A320-200-IAE-set.xml index 98fa97d7..7a0f577b 100644 --- a/A320-200-IAE-set.xml +++ b/A320-200-IAE-set.xml @@ -206,9 +206,9 @@ Aircraft/A320-family/Systems/fadec-iae.xml - + Aircraft/A320-family/Systems/v2500-sound.xml - + diff --git a/A320-main.xml b/A320-main.xml index 7bbbf383..6bf2f2aa 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -234,9 +234,9 @@ Aircraft/A320-family/Systems/pfd.xml - + Aircraft/A320-family/Systems/sound-common.xml - + Aircraft/A320-family/Systems/a320-lights-proprules.xml diff --git a/A320neo-CFM-set.xml b/A320neo-CFM-set.xml index 68a08ae9..a099581a 100644 --- a/A320neo-CFM-set.xml +++ b/A320neo-CFM-set.xml @@ -206,9 +206,9 @@ Aircraft/A320-family/Systems/fadec-cfm.xml - + Aircraft/A320-family/Systems/leapx-sound.xml - + diff --git a/A320neo-PW-set.xml b/A320neo-PW-set.xml index bd628100..323d8e85 100644 --- a/A320neo-PW-set.xml +++ b/A320neo-PW-set.xml @@ -206,9 +206,9 @@ Aircraft/A320-family/Systems/fadec-cfm.xml - + Aircraft/A320-family/Systems/leapx-sound.xml - +