From f68ad95db5d5faead6161538eca4ebfaeea9a9f3 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Tue, 21 Apr 2020 16:35:11 +0100 Subject: [PATCH] Electrical supply --- Nasal/Sim/libraries.nas | 1 + Nasal/Systems/Comm/HF.nas | 43 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Nasal/Sim/libraries.nas b/Nasal/Sim/libraries.nas index 7c4c0b8f..f974a4a8 100644 --- a/Nasal/Sim/libraries.nas +++ b/Nasal/Sim/libraries.nas @@ -244,6 +244,7 @@ var systemsLoop = maketimer(0.1, func { fcu.FCUController.loop(); dmc.DMController.loop(); systems.APUController.loop(); + systems.HFLoop(); if ((getprop("controls/pneumatic/switches/groundair") or getprop("controls/electrical/ground-cart")) and ((getprop("velocities/groundspeed-kt") > 2) or (getprop("controls/gear/brake-parking") == 0 and getprop("services/chocks/nose") == 0 and getprop("services/chocks/left") == 0 and getprop("services/chocks/right") == 0))) { setprop("controls/electrical/ground-cart", 0); diff --git a/Nasal/Systems/Comm/HF.nas b/Nasal/Systems/Comm/HF.nas index e085672b..1a4257ff 100644 --- a/Nasal/Systems/Comm/HF.nas +++ b/Nasal/Systems/Comm/HF.nas @@ -115,6 +115,46 @@ var highFrequencyRadio = { var HFS = [highFrequencyRadio.new(systems.ELEC.Bus.acEssShed, 0), highFrequencyRadio.new(systems.ELEC.Bus.ac2, 1)]; +# Can't use setlistener on the voltage as it always gets written to by JSB (and changes according to engine rpm) + +var update_items_HF_radio = [ + props.UpdateManager.FromProperty("/systems/electrical/bus/ac-ess-shed", 0.1, func(notification) + { + if (systems.ELEC.Bus.acEssShed.getValue() < 110) { + HFS[0].transmit = 0; + HFS[0].receptionProp.setValue(0); + toneTimer1.stop(); + transmitTimer1.stop(); + HFS[0].toneControl.setValue(0); + HFS[0]._toneTime = nil; + ecam.transmitFlag1 = 0; + } else { + HFS[0].receptionProp.setValue(1); + } + } + ), + props.UpdateManager.FromProperty("/systems/electrical/bus/ac-2", 0.1, func(notification) + { + if (systems.ELEC.Bus.ac2.getValue() < 110) { + HFS[1].transmit = 0; + HFS[1].receptionProp.setValue(0); + toneTimer2.stop(); + transmitTimer2.stop(); + HFS[1].toneControl.setValue(0); + HFS[1]._toneTime = nil; + ecam.transmitFlag2 = 0; + } else { + HFS[1].receptionProp.setValue(1); + } + } + ), +]; + +var HFLoop = func() { + foreach (var update_item_HF; update_items_HF_radio) { + update_item_HF.update(nil); + } +} var toneTimer1 = maketimer(1, func() { if (pts.Sim.Time.elapsedSec.getValue() > HFS[0]._toneTime) { @@ -135,6 +175,7 @@ var toneTimer2 = maketimer(1, func() { var transmitTimer1 = maketimer(1, func() { HFS[0].monitorPTT(); }); + var transmitTimer2 = maketimer(1, func() { HFS[1].monitorPTT(); -}); \ No newline at end of file +});