1
0
Fork 0

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.
This commit is contained in:
Hal V. Engel 2011-06-19 16:52:44 -07:00
parent 5e44f08181
commit 079ed0b563
3 changed files with 172 additions and 2 deletions

View file

@ -2,7 +2,7 @@
<PropertyList>
<name>radios</name>
<name>SCR-522C-radio</name>
<width>550</width>
<modal>false</modal>
<layout>vbox</layout>
@ -56,7 +56,7 @@
<label>Channel</label>
<live>true</live>
<!--<format>%.2f</format>-->
<property>systems/comm/SCR-522C/frequencies/channel</property>
<property>/instrumentation/comm/SCR-522C/frequencies/channel</property>
</text>
<text>
<!--<label>xxxxxxx</label>-->

View file

@ -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);

View file

@ -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 <nasal> section of your *set.xml
file.
<file>Aircraft/Instruments-3d/SCR-522C/Nasal/SCR-522C.nas</file>
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
<property>/controls/lighting/cabin-norm</property>
If you are using a different property for you cabin/cockpit lights you will need to map your property
to /controls/lighting/cabin-norm.