enable/disable settings

This commit is contained in:
dj2ls 2022-09-23 11:17:59 +02:00
parent 9eccc82c5e
commit d0f0031ca4
3 changed files with 158 additions and 57 deletions

View file

@ -49,22 +49,28 @@ const configDefaultSettings = '{\
"daemon_port": "3001",\
"mycall": "AA0AA-0",\
"mygrid": "JN40aa",\
"deviceid": "RIG_MODEL_DUMMY_NOVFO",\
"deviceport": "/dev/ttyACM1",\
"serialspeed_direct": "9600",\
"radiocontrol" : "disabled",\
"hamlib_deviceid": "RIG_MODEL_DUMMY_NOVFO",\
"enable_hamlib_deviceport" : "False",\
"hamlib_deviceport": "/dev/ttyACM1",\
"enable_hamlib_stop_bits" : "False",\
"hamlib_stop_bits" : "1",\
"enable_hamlib_data_bits" : "False",\
"hamlib_data_bits" : "8",\
"enable_hamlib_handshake" : "False",\
"hamlib_handshake" : "None",\
"enable_hamlib_serialspeed" : "False",\
"hamlib_serialspeed" : "9600",\
"enable_hamlib_pttprotocol" : "False",\
"hamlib_pttprotocol" : "USB",\
"enable_hamlib_pttport" : "False",\
"hamlib_pttport": "/dev/ttyACM1",\
"hamlbib_serialspeed_ptt": "9600",\
"hamlib_rigctld_port" : "4532",\
"hamlib_rigctld_ip" : "127.0.0.1",\
"hamlib_rigctld_path" : "",\
"spectrum": "waterfall",\
"tnclocation": "localhost",\
"stop_bits_direct" : "1",\
"data_bits_direct" : "8",\
"handshake_direct" : "None",\
"radiocontrol" : "disabled",\
"deviceport_rigctl" : "3",\
"deviceid_rigctl" : "3",\
"serialspeed_rigctl" : "9600",\
"pttprotocol_direct" : "USB",\
"pttprotocol_rigctl" : "USB",\
"rigctld_port" : "4532",\
"rigctld_ip" : "127.0.0.1",\
"enable_scatter" : "False",\
"enable_fft" : "False",\
"enable_fsk" : "False",\
@ -78,8 +84,7 @@ const configDefaultSettings = '{\
"tuning_range_fmin" : "-50.0",\
"tuning_range_fmax" : "50.0",\
"respond_to_cq" : "True",\
"rx_buffer_size" : "16" ,\
"hamlib_rigctld_path" : ""\
"rx_buffer_size" : "16" \
}';
if (!fs.existsSync(configPath)) {

View file

@ -84,18 +84,31 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', ()
document.getElementById("myCallSSID").value = ssid;
document.getElementById("myGrid").value = config.mygrid;
document.getElementById('hamlib_deviceid').value = config.deviceid;
document.getElementById('hamlib_serialspeed').value = config.serialspeed_direct;
document.getElementById('hamlib_ptt_protocol').value = config.pttprotocol_direct;
document.getElementById("hamlib_rigctld_ip").value = config.rigctld_ip;
document.getElementById("hamlib_rigctld_port").value = config.rigctld_port;
// hamlib settings
document.getElementById('hamlib_deviceid').value = config.hamlib_deviceid;
document.getElementById('hamlib_databits_advanced').value = config.data_bits_direct;
document.getElementById('hamlib_stopbits_advanced').value = config.stop_bits_direct;
document.getElementById('hamlib_handshake_advanced').value = config.handshake_direct;
set_setting_switch("enable_hamlib_deviceport", "hamlib_deviceport", config.enable_hamlib_deviceport)
set_setting_switch("enable_hamlib_ptt_port", "hamlib_ptt_port", config.enable_hamlib_ptt_port)
document.getElementById('hamlib_serialspeed').value = config.hamlib_serialspeed;
set_setting_switch("enable_hamlib_serialspeed", "hamlib_serialspeed", config.enable_hamlib_serialspeed)
document.getElementById('hamlib_pttprotocol').value = config.hamlib_pttprotocol;
set_setting_switch("enable_hamlib_pttprotocol", "hamlib_pttprotocol", config.enable_hamlib_pttprotocol)
document.getElementById('hamlib_databits').value = config.hamlib_data_bits;
set_setting_switch("enable_hamlib_databits", "hamlib_databits", config.enable_hamlib_databits)
document.getElementById('hamlib_stopbits').value = config.hamlib_stop_bits;
set_setting_switch("enable_hamlib_stopbits", "hamlib_stopbits", config.enable_hamlib_stopbits)
document.getElementById('hamlib_handshake').value = config.hamlib_handshake;
set_setting_switch("enable_hamlib_handshake", "hamlib_handshake", config.enable_hamlib_handshake)
document.getElementById("hamlib_rigctld_ip").value = config.hamlib_rigctld_ip;
document.getElementById("hamlib_rigctld_port").value = config.hamlib_rigctld_port;
document.getElementById("hamlib_rigctld_path").value = config.hamlib_rigctld_path;
document.getElementById("beaconInterval").value = config.beacon_interval;
@ -453,6 +466,42 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', ()
config.radiocontrol = 'rigctld';
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
});
// radio settings 'enable hamlib deviceport' event listener
document.getElementById("enable_hamlib_deviceport").addEventListener("change", () => {
enable_setting("enable_hamlib_deviceport", "hamlib_deviceport")
});
// radio settings 'enable hamlib serialspeed' event listener
document.getElementById("enable_hamlib_serialspeed").addEventListener("change", () => {
enable_setting("enable_hamlib_serialspeed", "hamlib_serialspeed")
});
// radio settings 'enable hamlib data bits' event listener
document.getElementById("enable_hamlib_databits").addEventListener("change", () => {
enable_setting("enable_hamlib_databits", "hamlib_databits")
});
// radio settings 'enable hamlib stop bits' event listener
document.getElementById("enable_hamlib_stopbits").addEventListener("change", () => {
enable_setting("enable_hamlib_stopbits", "hamlib_stopbits")
});
// radio settings 'enable hamlib handshake' event listener
document.getElementById("enable_hamlib_handshake").addEventListener("change", () => {
enable_setting("enable_hamlib_handshake", "hamlib_handshake")
});
// radio settings 'enable hamlib ptt port' event listener
document.getElementById("enable_hamlib_ptt_port").addEventListener("change", () => {
enable_setting("enable_hamlib_ptt_port", "hamlib_ptt_port")
});
// radio settings 'enable hamlib ptt protocol' event listener
document.getElementById("enable_hamlib_pttprotocol").addEventListener("change", () => {
enable_setting("enable_hamlib_pttprotocol", "hamlib_pttprotocol")
});
/*
document.getElementById('hamlib_rigctld_path').addEventListener('change', () => {
var fileList = document.getElementById("dataModalFile").files;
@ -788,7 +837,7 @@ document.getElementById('hamlib_rigctld_stop').addEventListener('click', () => {
var deviceid = document.getElementById("hamlib_deviceid").value;
var deviceport = document.getElementById("hamlib_deviceport").value;
var serialspeed = document.getElementById("hamlib_serialspeed").value;
var pttprotocol = document.getElementById("hamlib_ptt_protocol").value;
var pttprotocol = document.getElementById("hamlib_pttprotocol").value;
var mycall = document.getElementById("myCall").value;
var ssid = document.getElementById("myCallSSID").value;
@ -799,10 +848,10 @@ document.getElementById('hamlib_rigctld_stop').addEventListener('click', () => {
var rx_audio = document.getElementById("audio_input_selectbox").value;
var tx_audio = document.getElementById("audio_output_selectbox").value;
var pttport = document.getElementById("hamlib_ptt_port_advanced").value;
var data_bits = document.getElementById('hamlib_databits_advanced').value;
var stop_bits = document.getElementById('hamlib_stopbits_advanced').value;
var handshake = document.getElementById('hamlib_handshake_advanced').value;
var pttport = document.getElementById("hamlib_ptt_port").value;
var data_bits = document.getElementById('hamlib_databits').value;
var stop_bits = document.getElementById('hamlib_stopbits').value;
var handshake = document.getElementById('hamlib_handshake').value;
if (document.getElementById("scatterSwitch").checked == true){
var enable_scatter = "True";
@ -868,19 +917,19 @@ document.getElementById('hamlib_rigctld_stop').addEventListener('click', () => {
config.radiocontrol = radiocontrol;
config.mycall = callsign_ssid;
config.mygrid = mygrid;
config.deviceid = deviceid;
config.deviceport = deviceport;
config.serialspeed_direct = serialspeed;
config.pttprotocol_direct = pttprotocol;
config.pttport = pttport;
config.data_bits_direct = data_bits;
config.stop_bits_direct = stop_bits;
config.handshake_direct = handshake;
config.hamlib_deviceid = deviceid;
config.hamlib_deviceport = deviceport;
config.hamlib_serialspeed = serialspeed;
config.hamlib_pttprotocol = pttprotocol;
config.hamlib_pttport = pttport;
config.hamlib_data_bits = data_bits;
config.hamlib_stop_bits = stop_bits;
config.hamlib_handshake = handshake;
//config.deviceid_rigctl = deviceid_rigctl;
//config.serialspeed_rigctl = serialspeed_rigctl;
//config.pttprotocol_rigctl = pttprotocol_rigctl;
config.rigctld_port = rigctld_port;
config.rigctld_ip = rigctld_ip;
config.hamlib_rigctld_port = rigctld_port;
config.hamlib_rigctld_ip = rigctld_ip;
//config.deviceport_rigctl = deviceport_rigctl;
config.enable_scatter = enable_scatter;
config.enable_fft = enable_fft;
@ -967,10 +1016,10 @@ document.getElementById('hamlib_rigctld_stop').addEventListener('click', () => {
document.getElementById("testHamlib").addEventListener("click", () => {
var data_bits = document.getElementById("hamlib_databits_advanced").value;
var stop_bits = document.getElementById("hamlib_stopbits_advanced").value;
var handshake = document.getElementById("hamlib_handshake_advanced").value;
var pttport = document.getElementById("hamlib_ptt_port_advanced").value;
var data_bits = document.getElementById("hamlib_databits").value;
var stop_bits = document.getElementById("hamlib_stopbits").value;
var handshake = document.getElementById("hamlib_handshake").value;
var pttport = document.getElementById("hamlib_ptt_port").value;
var rigctld_ip = document.getElementById("hamlib_rigctld_ip").value;
var rigctld_port = document.getElementById("hamlib_rigctld_port").value;
@ -978,7 +1027,7 @@ document.getElementById('hamlib_rigctld_stop').addEventListener('click', () => {
var deviceid = document.getElementById("hamlib_deviceid").value;
var deviceport = document.getElementById("hamlib_deviceport").value;
var serialspeed = document.getElementById("hamlib_serialspeed").value;
var pttprotocol = document.getElementById("hamlib_ptt_protocol").value;
var pttprotocol = document.getElementById("hamlib_pttprotocol").value;
if (document.getElementById("radio-control-switch-disabled").checked) {
var radiocontrol = 'disabled';
@ -1569,8 +1618,8 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
}
if (arg.tnc_running_state == "stopped") {
if (document.getElementById("hamlib_ptt_port_advanced").length != arg.serial_devices.length) {
document.getElementById("hamlib_ptt_port_advanced").innerHTML = "";
if (document.getElementById("hamlib_ptt_port").length != arg.serial_devices.length) {
document.getElementById("hamlib_ptt_port").innerHTML = "";
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.serial_devices[i]['description'];
@ -1579,7 +1628,7 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
if(config.pttport == option.value){
option.setAttribute('selected', true);
}
document.getElementById("hamlib_ptt_port_advanced").add(option);
document.getElementById("hamlib_ptt_port").add(option);
}
}
}
@ -1636,6 +1685,7 @@ ipcRenderer.on('action-update-daemon-connection', (event, arg) => {
ipcRenderer.on('action-update-tnc-connection', (event, arg) => {
if (arg.tnc_connection == "open") {
/*
document.getElementById('hamlib_deviceid').disabled = true;
document.getElementById('hamlib_deviceport').disabled = true;
document.getElementById('testHamlib').disabled = true;
@ -1647,6 +1697,7 @@ ipcRenderer.on('action-update-tnc-connection', (event, arg) => {
document.getElementById('dxCall').disabled = false;
document.getElementById("hamlib_serialspeed").disabled = true;
document.getElementById("openDataModule").disabled = false;
*/
// collapse settings screen
var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false})
@ -1658,6 +1709,7 @@ ipcRenderer.on('action-update-tnc-connection', (event, arg) => {
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
collapseFourthRow.show();
} else {
/*
document.getElementById('hamlib_deviceid').disabled = false;
document.getElementById('hamlib_deviceport').disabled = false;
document.getElementById('testHamlib').disabled = false;
@ -1669,7 +1721,7 @@ ipcRenderer.on('action-update-tnc-connection', (event, arg) => {
document.getElementById('dxCall').disabled = true;
document.getElementById("hamlib_serialspeed").disabled = false;
document.getElementById("openDataModule").disabled = true;
*/
// collapse settings screen
var collapseFirstRow = new bootstrap.Collapse(document.getElementById('collapseFirstRow'), {toggle: false})
collapseFirstRow.show();
@ -2081,3 +2133,26 @@ ipcRenderer.on('action-show-arq-toast-session-failed', (event, data) => {
toast.show();
});
// enable or disable a setting by given switch and element
function enable_setting(enable_switch, enable_object){
if(document.getElementById(enable_switch).checked){
config[enable_switch] = true
document.getElementById(enable_object).removeAttribute("disabled","disabled");
} else {
config[enable_switch] = false
document.getElementById(enable_object).setAttribute("disabled","disabled");
}
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
}
// enable or disable a setting switch
function set_setting_switch(setting_switch, enable_object, state){
document.getElementById(setting_switch).checked = state
enable_setting(setting_switch, enable_object)
}

View file

@ -615,11 +615,17 @@
<span class="input-group-text" id="basic-addon1">
<i class="bi bi-usb-symbol" style="font-size: 1rem; color: black;"></i>
</span>
<span class="input-group-text" id="basic-addon1">
<input class="form-check-sm form-check-input" type="checkbox" id="enable_hamlib_deviceport">
</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_deviceport" style="width:7rem">
<!--<option selected value="/dev/ttyUSB0">/dev/ttyUSB0</option>
<option value="/dev/ttyUSB1">/dev/ttyUSB1</option>-->
</select>
<span class="input-group-text" id="basic-addon1"><i class="bi bi-speedometer" style="font-size: 1rem; color: black;"></i></span>
<span class="input-group-text" id="basic-addon1">
<input class="form-check-sm form-check-input" type="checkbox" id="enable_hamlib_serialspeed">
</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_serialspeed">
<option value="1200">1200</option>
<option value="2400">2400</option>
@ -635,17 +641,26 @@
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Data</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_databits_advanced">
<span class="input-group-text" id="basic-addon1">
<input class="form-check-sm form-check-input" type="checkbox" id="enable_hamlib_databits">
</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_databits">
<option value="7">7</option>
<option value="8">8 (Default)</option>
<option value="8">8</option>
</select>
<span class="input-group-text" id="basic-addon1">Stop</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_stopbits_advanced">
<option value="1">1 (Default)</option>
<span class="input-group-text" id="basic-addon1">
<input class="form-check-sm form-check-input" type="checkbox" id="enable_hamlib_stopbits">
</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_stopbits">
<option value="1">1</option>
<option value="2">2</option>
</select>
<span class="input-group-text" id="basic-addon1">HS</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_handshake_advanced">
<span class="input-group-text" id="basic-addon1">
<input class="form-check-sm form-check-input" type="checkbox" id="enable_hamlib_handshake">
</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_handshake">
<option value="None">None (Default)</option>
</select>
</div>
@ -656,11 +671,17 @@
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1"><i class="bi bi-usb-symbol" style="font-size: 1rem; color: black;"></i></span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_port_advanced">
<span class="input-group-text" id="basic-addon1">
<input class="form-check-sm form-check-input" type="checkbox" id="enable_hamlib_ptt_port">
</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_port">
<!--<option value="None">None</option>-->
</select>
<span class="input-group-text" id="basic-addon1">Type</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_protocol" style="width: 0.5rem">
<span class="input-group-text" id="basic-addon1">
<input class="form-check-sm form-check-input" type="checkbox" id="enable_hamlib_pttprotocol">
</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_pttprotocol" style="width: 0.5rem">
<option value="NONE">NONE</option>
<option value="RIG">RIG</option>
<option value="USB">USB</option>