| 1 |
##################################################################################### |
| 2 |
# This script provides the gui to set up the TR1133 radio # |
| 3 |
# # |
| 4 |
# Author Vivian Meazza June 2011 # |
| 5 |
##################################################################################### |
| 6 |
|
| 7 |
# ================================ Initalize ====================================== |
| 8 |
# Make sure all needed properties are present and accounted |
| 9 |
# for, and that they have sane default values. |
| 10 |
|
| 11 |
var channelA_node = props.globals.initNode("instrumentation/comm/channels/A-mhz", 0, "DOUBLE"); |
| 12 |
var channelB_node = props.globals.initNode("instrumentation/comm/channels/B-mhz", 0, "DOUBLE"); |
| 13 |
var channelC_node = props.globals.initNode("instrumentation/comm/channels/C-mhz", 0, "DOUBLE"); |
| 14 |
var channelD_node = props.globals.initNode("instrumentation/comm/channels/D-mhz", 0, "DOUBLE"); |
| 15 |
|
| 16 |
var channel_selected_node = props.globals.initNode("systems/comm/SCR-522C/frequencies/channel-selected", 0, "INT"); |
| 17 |
var tr_node = props.globals.initNode("systems/comm/SCR-522C/tr", 1, "INT"); |
| 18 |
props.globals.initNode("systems/comm/SCR-522C/frequencies/channel", "", "STRING"); |
| 19 |
props.globals.initNode("systems/comm/SCR-522C/channel-dimmer", 0, "BOOL"); |
| 20 |
props.globals.initNode("systems/comm/SCR-522C/tr-lock", 1, "BOOL"); |
| 21 |
|
| 22 |
var comm_selected_node = props.globals.getNode("instrumentation/comm/frequencies/selected-mhz", 1); |
| 23 |
var comm_standby_node = props.globals.getNode("instrumentation/comm/frequencies/standby-mhz", 1); |
| 24 |
var comm1_selected_node = props.globals.getNode("instrumentation/comm[1]/frequencies/selected-mhz", 1); |
| 25 |
var comm1_standby_node = props.globals.getNode("instrumentation/comm[1]/frequencies/standby-mhz", 1); |
| 26 |
|
| 27 |
var radio_dlg = gui.Dialog.new("dialog","Aircraft/Instruments-3d/TR1133/Dialogs/radios.xml"); |
| 28 |
|
| 29 |
var channel = ["OFF","A","B","C","D"]; |
| 30 |
#getprop("systems/comm/SCR-522C/frequencies/channel", 1); |
| 31 |
setprop("systems/comm/SCR-522C/frequencies/channel", channel[channel_selected_node.getValue()]); |
| 32 |
|
| 33 |
var TR1133_init = func(){ |
| 34 |
|
| 35 |
print ("initializing TR1133 ..."); |
| 36 |
|
| 37 |
var channelA_init = comm_selected_node.getValue(); |
| 38 |
var channelB_init = comm_standby_node.getValue(); |
| 39 |
var channelC_init = comm1_selected_node.getValue(); |
| 40 |
var channelD_init = comm1_standby_node.getValue(); |
| 41 |
|
| 42 |
channelA_node.setValue(channelA_init); |
| 43 |
channelB_node.setValue(channelB_init); |
| 44 |
channelC_node.setValue(channelC_init); |
| 45 |
channelD_node.setValue(channelD_init); |
| 46 |
|
| 47 |
comm_selected_node.setValue(0); |
| 48 |
comm_standby_node.setValue(0); |
| 49 |
comm1_selected_node.setValue(0); |
| 50 |
comm1_standby_node.setValue(0); |
| 51 |
|
| 52 |
# override F12 |
| 53 |
setprop("input/keyboard/key[268]/binding/command", "nasal"); |
| 54 |
setprop("input/keyboard/key[268]/binding/script", "TR1133.radio_dlg.open()"); |
| 55 |
|
| 56 |
# Disable the menu item "Equipment > radio" so we use our own gui: " > Radio". |
| 57 |
print("Disabling Menu: Equipment -> Radios GUI using TR1133 -> Radio"); |
| 58 |
|
| 59 |
gui.menuBind("radio", "TR1133.radio_dlg.open()"); |
| 60 |
|
| 61 |
|
| 62 |
# =============================== listeners =============================== |
| 63 |
# |
| 64 |
|
| 65 |
setlistener("systems/comm/SCR-522C/frequencies/channel-selected", func(n) { |
| 66 |
var channel_no = n.getValue(); |
| 67 |
|
| 68 |
if (channel_no == nil) channel_no = 0; |
| 69 |
|
| 70 |
# print("channel", channel_no, " ", channel[channel_no]); |
| 71 |
setprop("systems/comm/SCR-522C/frequencies/channel", channel[channel_no]); |
| 72 |
}, |
| 73 |
1, |
| 74 |
0); #end listener |
| 75 |
|
| 76 |
setlistener("systems/comm/SCR-522C/tr", func(t) { |
| 77 |
var tr = t.getValue(); |
| 78 |
# print("tr ",tr); |
| 79 |
|
| 80 |
if (tr == nil) tr = 1; |
| 81 |
|
| 82 |
if (tr == 0) |
| 83 |
setprop("instrumentation/comm/ptt", 1); |
| 84 |
else |
| 85 |
setprop("instrumentation/comm/ptt", 0); |
| 86 |
|
| 87 |
|
| 88 |
}, |
| 89 |
1, |
| 90 |
0); # end listener |
| 91 |
|
| 92 |
print("... done"); |
| 93 |
|
| 94 |
}#end func initialize |
| 95 |
|
| 96 |
setlistener("sim/signals/fdm-initialized", TR1133_init); |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|