From 079ed0b5633004bc7cec93c714052366bf170b64 Mon Sep 17 00:00:00 2001 From: "Hal V. Engel" Date: Sun, 19 Jun 2011 16:52:44 -0700 Subject: [PATCH] SCR-522C - Override defauilt radio menu item Add README file with info on how to use this. Modify radios.xml to match where properties are located. --- .../SCR-522C/Dialogs/radios.xml | 4 +- .../SCR-522C/Nasal/SCR-522C.nas | 150 ++++++++++++++++++ Aircraft/Instruments-3d/SCR-522C/README | 20 +++ 3 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 Aircraft/Instruments-3d/SCR-522C/Nasal/SCR-522C.nas create mode 100644 Aircraft/Instruments-3d/SCR-522C/README diff --git a/Aircraft/Instruments-3d/SCR-522C/Dialogs/radios.xml b/Aircraft/Instruments-3d/SCR-522C/Dialogs/radios.xml index 46dc1df03..b5dcfb37c 100755 --- a/Aircraft/Instruments-3d/SCR-522C/Dialogs/radios.xml +++ b/Aircraft/Instruments-3d/SCR-522C/Dialogs/radios.xml @@ -2,7 +2,7 @@ - radios + SCR-522C-radio 550 false vbox @@ -56,7 +56,7 @@ true - systems/comm/SCR-522C/frequencies/channel + /instrumentation/comm/SCR-522C/frequencies/channel diff --git a/Aircraft/Instruments-3d/SCR-522C/Nasal/SCR-522C.nas b/Aircraft/Instruments-3d/SCR-522C/Nasal/SCR-522C.nas new file mode 100644 index 000000000..c03d5ff71 --- /dev/null +++ b/Aircraft/Instruments-3d/SCR-522C/Nasal/SCR-522C.nas @@ -0,0 +1,150 @@ +##################################################################################### +# This script provides the gui to set up the TR1133/SCR-522C radio # +# using a BC-602-A control box # +# # +# Author Vivian Meazza June 2011 # +# # +# mods Hal V. Engel June 2011 # +# # +##################################################################################### + +# ================================ Initalize ====================================== +# Make sure all needed properties are present and accounted +# for, and that they have sane default values. + +var channelA_node = props.globals.initNode("instrumentation/comm/channels/A-mhz", 0, "DOUBLE"); +var channelB_node = props.globals.initNode("instrumentation/comm/channels/B-mhz", 0, "DOUBLE"); +var channelC_node = props.globals.initNode("instrumentation/comm/channels/C-mhz", 0, "DOUBLE"); +var channelD_node = props.globals.initNode("instrumentation/comm/channels/D-mhz", 0, "DOUBLE"); + +var channel_selected_node = props.globals.initNode("instrumentation/comm/SCR-522C/frequencies/channel-selected", 0, "INT"); +var tr_node = props.globals.initNode("instrumentation/comm/SCR-522C/tr", 0, "INT"); +props.globals.initNode("instrumentation/comm/SCR-522C/frequencies/channel", "", "STRING"); +props.globals.initNode("instrumentation/comm/SCR-522C/mask", 0, "BOOL"); +props.globals.initNode("instrumentation/comm/SCR-522C/tr-lock", 0, "BOOL"); + +var comm_selected_node = props.globals.getNode("instrumentation/comm/frequencies/selected-mhz", 1); +var comm_standby_node = props.globals.getNode("instrumentation/comm/frequencies/standby-mhz", 1); +var comm1_selected_node = props.globals.getNode("instrumentation/comm[1]/frequencies/selected-mhz", 1); +var comm1_standby_node = props.globals.getNode("instrumentation/comm[1]/frequencies/standby-mhz", 1); + +var channel = ["OFF","A","B","C","D"]; +setprop("instrumentation/comm/SCR-522C/frequencies/channel", channel[channel_selected_node.getValue()]); + +var Radio = gui.Dialog.new("sim/gui/dialogs/SCR-522C/dialog", + "Aircraft/Instruments-3d/SCR-522C/Dialogs/radios.xml"); + +# gui.menuBind("radio", "dialogs.Radio.open()"); + +# override controls.ptt + +controls.ptt = func { + # T/R/REM set to REM remote ptt switch controls transmitter + # print("intercept ptt for BC-602-A"); + if (getprop("instrumentation/comm/SCR-522C/tr") == 0 and # set in REMote ptt switch mode + getprop("instrumentation/comm/SCR-522C/frequencies/channel-selected") > 0) # and radio is on + setprop("instrumentation/comm/ptt", arg[0]); # let remote ptt control transmitter + else # otherwise + setprop("instrumentation/comm/ptt", 0); # the remote ptt does nothing +} + +# =============================== listeners =============================== +# + +var listenChannelSelected = func(n) { + var channel_no = n.getValue(); + + if (channel_no == nil) channel_no = 0; + + # print("channel", channel_no, " ", channel[channel_no]); + setprop("instrumentation/comm/SCR-522C/frequencies/channel", channel[channel_no]); + if (channel_no == 1) { + setprop("instrumentation/comm/frequencies/selected-mhz", getprop("instrumentation/comm/channels/A-mhz")); + setprop("instrumentation/comm/frequencies/standby-mhz", getprop("instrumentation/comm/channels/A-mhz")); + } + else if (channel_no == 2){ + setprop("instrumentation/comm/frequencies/selected-mhz", getprop("instrumentation/comm/channels/B-mhz")); + setprop("instrumentation/comm/frequencies/standby-mhz", getprop("instrumentation/comm/channels/B-mhz")); + } + if (channel_no == 3){ + setprop("instrumentation/comm/frequencies/selected-mhz", getprop("instrumentation/comm/channels/C-mhz")); + setprop("instrumentation/comm/frequencies/standby-mhz", getprop("instrumentation/comm/channels/C-mhz")); + } + else if (channel_no == 4){ + setprop("instrumentation/comm/frequencies/selected-mhz", getprop("instrumentation/comm/channels/D-mhz")); + setprop("instrumentation/comm/frequencies/standby-mhz", getprop("instrumentation/comm/channels/D-mhz")); + } +} + +var listenTr = func(t) { + var tr = t.getValue(); + # print("tr ",tr); + + if (tr == nil) tr = 0; + if (tr == 2 and getprop("instrumentation/comm/SCR-522C/frequencies/channel-selected") > 0) + setprop("instrumentation/comm/ptt", 1); + else if (tr == 1) + setprop("instrumentation/comm/ptt", 0); +} + +var listenTrLock = func(i) { + var tr_lock = i.getValue(); + # print("tr_lock"); + + if (tr_lock == nil) tr_lock = false; + if (tr_lock) + setprop("/instrumentation/comm/SCR-522C/tr", 2); + else if (getprop("/instrumentation/comm/SCR-522C/tr") == 2) + setprop("/instrumentation/comm/SCR-522C/tr", 1); + +} + +var SCR_522C_init = func(){ + + print ("initializing SCR-522C ..."); + + var channelA_init = comm_selected_node.getValue(); + var channelB_init = comm_standby_node.getValue(); + var channelC_init = comm1_selected_node.getValue(); + var channelD_init = comm1_standby_node.getValue(); + + channelA_node.setValue(channelA_init); + channelB_node.setValue(channelB_init); + channelC_node.setValue(channelC_init); + channelD_node.setValue(channelD_init); + + comm_selected_node.setValue(0); + comm_standby_node.setValue(0); + comm1_selected_node.setValue(0); + comm1_standby_node.setValue(0); + + # over ride F12 + setprop("input/keyboard/key[268]/binding/dialog-name", "SCR-522C-radio"); + setprop("input/keyboard/key[268]/binding/command", "dialog-show"); + + # Disable the menu item "Equipment > radio" so we use our own gui: " > Radio". + # print("Disabling Menu: Equipment -> Radios GUI"); + # override default radio menu + gui.menuEnable("radio",0); + setprop("sim/bindings/menu/binding[35]/dialog-name", "SCR-522C-radio"); + setprop("sim/menubar/default/menu[5]/item[3]/binding/dialog-name", "SCR-522C-radio"); + setprop("sim/menubar/default/menu[5]/item[3]/name", "SCR-522C-radio"); + gui.menuEnable("SCR-522C-radio",1); + + # gui.menuBind("radio", "dialogs.Radio.open()"); + + +# =============================== start listeners =============================== +# + + setlistener("instrumentation/comm/SCR-522C/frequencies/channel-selected", listenChannelSelected, 1, 0); + + setlistener("instrumentation/comm/SCR-522C/tr", listenTr, 1, 0); + + setlistener("instrumentation/comm/SCR-522C/tr-lock", listenTrLock, 1, 0); + + # print("... done"); + +} # end func initialize + +setlistener("sim/signals/fdm-initialized", SCR_522C_init); \ No newline at end of file diff --git a/Aircraft/Instruments-3d/SCR-522C/README b/Aircraft/Instruments-3d/SCR-522C/README new file mode 100644 index 000000000..fa025e145 --- /dev/null +++ b/Aircraft/Instruments-3d/SCR-522C/README @@ -0,0 +1,20 @@ +To enable full functionality of the SCR-522C/TR1133 radio there are several things +that you will need to do. + +First you will need to add the following to the section of your *set.xml +file. + +Aircraft/Instruments-3d/SCR-522C/Nasal/SCR-522C.nas + +This will enable the F12 key to bring up the frequencies dialog. It will also over ride the +Equipment --> radios menu item so that it brings up the correct menu for the SCR-522C/TR1133 +radios. + +For dark conditions when cabin/cockpit illumination is used all of the radio models object respond to + +/controls/lighting/cabin-norm + +If you are using a different property for you cabin/cockpit lights you will need to map your property +to /controls/lighting/cabin-norm. + + \ No newline at end of file