2022-02-08 14:27:34 +00:00
const path = require ( 'path' ) ;
2023-01-07 04:27:52 +00:00
const { ipcRenderer , shell } = require ( 'electron' ) ;
2022-09-20 17:24:07 +00:00
const exec = require ( 'child_process' ) . spawn ;
2021-09-04 18:23:58 +00:00
const sock = require ( './sock.js' ) ;
const daemon = require ( './daemon.js' ) ;
2021-07-23 15:40:44 +00:00
const fs = require ( 'fs' ) ;
2021-09-04 18:23:58 +00:00
const {
locatorToLatLng ,
distance ,
bearingDistance ,
latLngToLocator
} = require ( 'qth-locator' ) ;
2021-12-20 17:05:00 +00:00
const os = require ( 'os' ) ;
2021-09-04 18:23:58 +00:00
2022-11-17 21:17:50 +00:00
// split character used for appending additional data to files
2022-02-12 15:34:47 +00:00
const split _char = '\0;' ;
2022-02-02 20:12:16 +00:00
2021-09-04 18:23:58 +00:00
// https://stackoverflow.com/a/26227660
2022-02-08 14:27:34 +00:00
var appDataFolder = process . env . APPDATA || ( process . platform == 'darwin' ? process . env . HOME + '/Library/Application Support' : process . env . HOME + "/.config" ) ;
2021-09-13 16:27:50 +00:00
var configFolder = path . join ( appDataFolder , "FreeDATA" ) ;
2022-02-08 14:27:34 +00:00
var configPath = path . join ( configFolder , 'config.json' ) ;
2021-09-04 18:23:58 +00:00
const config = require ( configPath ) ;
2021-07-23 15:40:44 +00:00
2022-11-18 14:19:41 +00:00
// SET dbfs LEVEL GLOBAL
// this is an attempt of reducing CPU LOAD
// we are going to check if we have unequal values before we start calculating again
var dbfs _level _raw = 0
2023-01-22 19:36:05 +00:00
//Global version variable
var appVer = null ;
2022-11-18 14:19:41 +00:00
2021-07-23 15:40:44 +00:00
// START INTERVALL COMMAND EXECUTION FOR STATES
2022-03-12 14:06:49 +00:00
//setInterval(sock.getRxBuffer, 1000);
2021-11-07 11:17:23 +00:00
2021-07-24 07:06:22 +00:00
// WINDOW LISTENER
2021-07-23 15:40:44 +00:00
window . addEventListener ( 'DOMContentLoaded' , ( ) => {
2021-11-07 11:17:23 +00:00
2023-01-04 18:26:11 +00:00
// save frequency event listener
document . getElementById ( "saveFrequency" ) . addEventListener ( "click" , ( ) => {
var freq = document . getElementById ( "newFrequency" ) . value ;
console . log ( freq )
let Data = {
type : "set" ,
command : "frequency" ,
frequency : freq ,
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
2022-03-10 18:45:37 +00:00
2023-01-04 18:26:11 +00:00
} ) ;
2023-01-04 20:07:46 +00:00
// enter button for input field
document . getElementById ( "newFrequency" ) . addEventListener ( "keypress" , function ( event ) {
if ( event . key === "Enter" ) {
event . preventDefault ( ) ;
document . getElementById ( "saveFrequency" ) . click ( ) ;
}
} ) ;
2023-01-04 19:12:03 +00:00
// save mode event listener
document . getElementById ( "saveModePKTUSB" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "PKTUSB" ,
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
} ) ;
// save mode event listener
document . getElementById ( "saveModeUSB" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "USB" ,
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
} ) ;
// save mode event listener
document . getElementById ( "saveModeLSB" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "LSB" ,
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
} ) ;
2022-12-26 11:11:59 +00:00
2023-01-04 19:12:03 +00:00
// save mode event listener
document . getElementById ( "saveModeAM" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "AM" ,
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
} ) ;
// save mode event listener
document . getElementById ( "saveModeFM" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "mode" ,
mode : "FM" ,
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
} ) ;
2022-12-26 11:11:59 +00:00
// start stop audio recording event listener
document . getElementById ( "startStopRecording" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "record_audio" ,
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
} ) ;
2022-03-10 18:45:37 +00:00
document . getElementById ( 'received_files_folder' ) . addEventListener ( 'click' , ( ) => {
2022-03-10 19:46:34 +00:00
ipcRenderer . send ( 'get-folder-path' , {
2022-03-10 18:45:37 +00:00
title : 'Title' ,
} ) ;
ipcRenderer . on ( 'return-folder-paths' , ( event , data ) => {
document . getElementById ( "received_files_folder" ) . value = data . path . filePaths [ 0 ]
config . received _files _folder = data . path . filePaths [ 0 ]
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
} )
document . getElementById ( 'openReceivedFilesFolder' ) . addEventListener ( 'click' , ( ) => {
ipcRenderer . send ( 'open-folder' , {
path : config . received _files _folder ,
} ) ;
} )
2021-11-07 11:17:23 +00:00
/ *
// ENABLE BOOTSTRAP POPOVERS EVERYWHERE
// https://getbootstrap.com/docs/5.0/components/popovers/#example-enable-popovers-everywhere
var popoverTriggerList = [ ] . slice . call ( document . querySelectorAll ( '[data-bs-toggle="popover"]' ) )
var popoverList = popoverTriggerList . map ( function ( popoverTriggerEl ) {
return new bootstrap . Popover ( popoverTriggerEl )
} )
* /
2022-02-16 10:28:40 +00:00
2021-11-27 10:05:51 +00:00
// ENABLE TOOLTIPS EVERYWHERE
// https://getbootstrap.com/docs/5.1/components/tooltips/
var tooltipTriggerList = [ ] . slice . call ( document . querySelectorAll ( '[data-bs-toggle="tooltip"]' ) )
var tooltipList = tooltipTriggerList . map ( function ( tooltipTriggerEl ) {
2022-02-08 14:27:34 +00:00
return new bootstrap . Tooltip ( tooltipTriggerEl ) ;
2021-11-27 10:05:51 +00:00
} )
2021-07-24 07:06:22 +00:00
// LOAD SETTINGS
2022-02-08 14:27:34 +00:00
document . getElementById ( "tnc_adress" ) . value = config . tnc _host ;
document . getElementById ( "tnc_port" ) . value = config . tnc _port ;
2022-02-21 11:20:36 +00:00
callsign _and _ssid = config . mycall . split ( "-" ) ;
callsign = callsign _and _ssid [ 0 ] ;
ssid = callsign _and _ssid [ 1 ] ;
document . getElementById ( "myCall" ) . value = callsign ;
2023-01-20 02:24:07 +00:00
//document.title = document.title + ' - Call: ' + config.mycall;
updateTitle ( ) ;
2022-04-24 13:53:51 +00:00
2022-02-21 11:20:36 +00:00
document . getElementById ( "myCallSSID" ) . value = ssid ;
2022-02-08 14:27:34 +00:00
document . getElementById ( "myGrid" ) . value = config . mygrid ;
2021-07-25 16:19:51 +00:00
2022-09-23 09:17:59 +00:00
// hamlib settings
document . getElementById ( 'hamlib_deviceid' ) . value = config . hamlib _deviceid ;
2022-12-26 11:11:59 +00:00
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 )
2022-09-23 09:17:59 +00:00
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 )
2022-09-20 05:59:47 +00:00
2022-09-23 09:17:59 +00:00
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 )
2022-09-23 17:18:20 +00:00
document . getElementById ( 'hamlib_dcd' ) . value = config . hamlib _dcd ;
set _setting _switch ( "enable_hamlib_dcd" , "hamlib_dcd" , config . enable _hamlib _dcd )
2022-10-06 08:08:31 +00:00
document . getElementById ( 'hamlib_dtrstate' ) . value = config . hamlib _dtrstate ;
set _setting _switch ( "enable_hamlib_dtrstate" , "hamlib_dtrstate" , config . enable _hamlib _dtrstate )
2022-09-23 09:17:59 +00:00
document . getElementById ( "hamlib_rigctld_ip" ) . value = config . hamlib _rigctld _ip ;
document . getElementById ( "hamlib_rigctld_port" ) . value = config . hamlib _rigctld _port ;
2022-09-20 17:24:07 +00:00
document . getElementById ( "hamlib_rigctld_path" ) . value = config . hamlib _rigctld _path ;
2022-10-03 12:17:03 +00:00
document . getElementById ( "hamlib_rigctld_server_port" ) . value = config . hamlib _rigctld _server _port ;
2021-09-10 14:50:48 +00:00
2022-02-08 14:27:34 +00:00
document . getElementById ( "beaconInterval" ) . value = config . beacon _interval ;
2022-02-02 20:12:16 +00:00
2022-02-08 14:27:34 +00:00
document . getElementById ( "scatterSwitch" ) . value = config . enable _scatter ;
document . getElementById ( "fftSwitch" ) . value = config . enable _fft ;
2022-09-20 05:59:47 +00:00
2022-09-20 17:24:07 +00:00
2022-02-08 14:27:34 +00:00
2022-03-10 18:45:37 +00:00
document . getElementById ( "received_files_folder" ) . value = config . received _files _folder ;
2022-09-05 09:54:50 +00:00
2022-02-02 20:12:16 +00:00
if ( config . enable _scatter == 'True' ) {
2022-02-08 14:27:34 +00:00
document . getElementById ( "scatterSwitch" ) . checked = true ;
2022-02-02 20:12:16 +00:00
} else {
2022-02-08 14:27:34 +00:00
document . getElementById ( "scatterSwitch" ) . checked = false ;
2022-02-02 20:12:16 +00:00
}
if ( config . enable _fft == 'True' ) {
2022-02-08 14:27:34 +00:00
document . getElementById ( "fftSwitch" ) . checked = true ;
2022-02-02 20:12:16 +00:00
} else {
2022-02-08 14:27:34 +00:00
document . getElementById ( "fftSwitch" ) . checked = false ;
2022-02-02 20:12:16 +00:00
}
2022-05-28 12:08:33 +00:00
if ( config . low _bandwidth _mode == 'True' ) {
2022-02-08 14:27:34 +00:00
document . getElementById ( "500HzModeSwitch" ) . checked = true ;
} else {
document . getElementById ( "500HzModeSwitch" ) . checked = false ;
2022-03-31 10:45:44 +00:00
}
2023-01-27 03:55:55 +00:00
if ( config . high _graphics == 'True' ) {
document . getElementById ( "GraphicsSwitch" ) . checked = true ;
} else {
document . getElementById ( "GraphicsSwitch" ) . checked = false ;
}
2022-03-31 10:45:44 +00:00
if ( config . enable _fsk == 'True' ) {
document . getElementById ( "fskModeSwitch" ) . checked = true ;
} else {
document . getElementById ( "fskModeSwitch" ) . checked = false ;
}
2022-04-18 15:17:53 +00:00
if ( config . respond _to _cq == 'True' ) {
document . getElementById ( "respondCQSwitch" ) . checked = true ;
} else {
document . getElementById ( "respondCQSwitch" ) . checked = false ;
2022-11-05 21:27:33 +00:00
}
if ( config . enable _explorer == 'True' ) {
document . getElementById ( "ExplorerSwitch" ) . checked = true ;
} else {
document . getElementById ( "ExplorerSwitch" ) . checked = false ;
}
2022-02-10 13:38:55 +00:00
// theme selector
if ( config . theme != 'default' ) {
var theme _path = "../node_modules/bootswatch/dist/" + config . theme + "/bootstrap.min.css" ;
document . getElementById ( "theme_selector" ) . value = config . theme ;
2022-04-24 14:07:30 +00:00
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path ) ;
2022-02-10 13:38:55 +00:00
} else {
var theme _path = "../node_modules/bootstrap/dist/css/bootstrap.min.css" ;
document . getElementById ( "theme_selector" ) . value = 'default' ;
2022-04-24 14:07:30 +00:00
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path ) ;
2022-02-10 13:38:55 +00:00
}
2021-12-06 19:16:14 +00:00
2022-03-03 18:57:40 +00:00
// Update channel selector
document . getElementById ( "update_channel_selector" ) . value = config . update _channel ;
2022-04-24 14:07:30 +00:00
document . getElementById ( "updater_channel" ) . innerHTML = escape ( config . update _channel ) ;
2022-03-03 18:57:40 +00:00
2022-03-19 11:42:10 +00:00
// Update tuning range fmin fmax
document . getElementById ( "tuning_range_fmin" ) . value = config . tuning _range _fmin ;
document . getElementById ( "tuning_range_fmax" ) . value = config . tuning _range _fmax ;
2022-03-03 18:57:40 +00:00
2022-03-31 19:13:30 +00:00
// Update TX Audio Level
2022-04-08 09:35:13 +00:00
document . getElementById ( "audioLevelTXvalue" ) . innerHTML = parseInt ( config . tx _audio _level ) ;
document . getElementById ( "audioLevelTX" ) . value = parseInt ( config . tx _audio _level ) ;
2022-09-05 09:54:50 +00:00
// Update RX Buffer Size
document . getElementById ( "rx_buffer_size" ) . value = config . rx _buffer _size ;
2021-08-07 08:54:34 +00:00
if ( config . spectrum == 'waterfall' ) {
2022-02-08 14:27:34 +00:00
document . getElementById ( "waterfall-scatter-switch1" ) . checked = true ;
document . getElementById ( "waterfall-scatter-switch2" ) . checked = false ;
2023-01-12 23:14:42 +00:00
document . getElementById ( "waterfall-scatter-switch3" ) . checked = false ;
2021-08-07 08:54:34 +00:00
document . getElementById ( "waterfall" ) . style . visibility = 'visible' ;
2021-09-10 14:50:48 +00:00
document . getElementById ( "waterfall" ) . style . height = '100%' ;
2023-01-12 23:14:42 +00:00
document . getElementById ( "waterfall" ) . style . display = 'block' ;
document . getElementById ( "scatter" ) . style . height = '0px' ;
document . getElementById ( "scatter" ) . style . visibility = 'hidden' ;
document . getElementById ( "scatter" ) . style . display = 'none' ;
document . getElementById ( "chart" ) . style . height = '0px' ;
document . getElementById ( "chart" ) . style . visibility = 'hidden' ;
document . getElementById ( "chart" ) . style . display = 'none' ;
} else if ( config . spectrum == 'scatter' ) {
2021-07-25 16:19:51 +00:00
2022-02-08 14:27:34 +00:00
document . getElementById ( "waterfall-scatter-switch1" ) . checked = false ;
document . getElementById ( "waterfall-scatter-switch2" ) . checked = true ;
2023-01-12 23:14:42 +00:00
document . getElementById ( "waterfall-scatter-switch3" ) . checked = false ;
document . getElementById ( "waterfall" ) . style . visibility = 'hidden' ;
document . getElementById ( "waterfall" ) . style . height = '0px' ;
document . getElementById ( "waterfall" ) . style . display = 'none' ;
document . getElementById ( "scatter" ) . style . height = '100%' ;
2021-08-07 08:54:34 +00:00
document . getElementById ( "scatter" ) . style . visibility = 'visible' ;
2023-01-12 23:14:42 +00:00
document . getElementById ( "scatter" ) . style . display = 'block' ;
document . getElementById ( "chart" ) . style . visibility = 'hidden' ;
document . getElementById ( "chart" ) . style . height = '0px' ;
document . getElementById ( "chart" ) . style . display = 'none' ;
} else {
document . getElementById ( "waterfall-scatter-switch1" ) . checked = false ;
document . getElementById ( "waterfall-scatter-switch2" ) . checked = false ;
document . getElementById ( "waterfall-scatter-switch3" ) . checked = true ;
2021-08-07 08:54:34 +00:00
document . getElementById ( "waterfall" ) . style . visibility = 'hidden' ;
document . getElementById ( "waterfall" ) . style . height = '0px' ;
2023-01-12 23:14:42 +00:00
document . getElementById ( "waterfall" ) . style . display = 'none' ;
document . getElementById ( "scatter" ) . style . height = '0px' ;
document . getElementById ( "scatter" ) . style . visibility = 'hidden' ;
document . getElementById ( "scatter" ) . style . display = 'none' ;
document . getElementById ( "chart" ) . style . visibility = 'visible' ;
document . getElementById ( "chart" ) . style . height = '100%' ;
document . getElementById ( "chart" ) . style . display = 'block' ;
2021-08-07 08:54:34 +00:00
}
2021-07-25 16:19:51 +00:00
2022-01-18 18:38:05 +00:00
// radio control element
2022-09-20 05:59:47 +00:00
if ( config . radiocontrol == 'rigctld' ) {
2022-02-02 20:12:16 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-switch-disabled" ) . checked = false ;
document . getElementById ( "radio-control-switch-radio" ) . checked = true ;
document . getElementById ( "radio-control-switch-connect" ) . checked = false ;
document . getElementById ( "radio-control-switch-network" ) . checked = false ;
2022-02-02 20:12:16 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-disabled" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-disabled" ) . style . display = 'none' ;
2022-02-02 20:12:16 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-radio" ) . style . visibility = 'visible' ;
document . getElementById ( "radio-control-radio" ) . style . display = '100%' ;
2022-02-02 20:12:16 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-connection" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'none' ;
2022-02-02 20:12:16 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'none' ;
2022-01-18 18:38:05 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-network" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-network" ) . style . display = 'none' ;
2022-01-18 18:38:05 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'none' ;
2022-01-18 18:38:05 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'none' ;
2022-01-18 18:38:05 +00:00
} else {
2022-02-02 20:12:16 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-switch-disabled" ) . checked = true ;
document . getElementById ( "radio-control-switch-radio" ) . checked = false ;
document . getElementById ( "radio-control-switch-connect" ) . checked = false ;
document . getElementById ( "radio-control-switch-network" ) . checked = false ;
document . getElementById ( "radio-control-switch-rigctld" ) . checked = false ;
document . getElementById ( "radio-control-switch-rigctld-info" ) . checked = false ;
document . getElementById ( "radio-control-connection" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'none' ;
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'none' ;
2022-01-18 18:38:05 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-network" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . visibility = 'hidden' ;
2022-01-18 18:38:05 +00:00
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-radio" ) . style . display = 'none' ;
document . getElementById ( "radio-control-radio" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'none' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'none' ;
2022-01-18 18:38:05 +00:00
}
2021-09-13 16:27:50 +00:00
// remote tnc
2021-09-04 14:33:17 +00:00
if ( config . tnclocation == 'remote' ) {
2022-02-08 14:27:34 +00:00
document . getElementById ( "local-remote-switch1" ) . checked = false ;
document . getElementById ( "local-remote-switch2" ) . checked = true ;
2021-09-04 14:33:17 +00:00
document . getElementById ( "remote-tnc-field" ) . style . visibility = 'visible' ;
} else {
2022-02-08 14:27:34 +00:00
document . getElementById ( "local-remote-switch1" ) . checked = true ;
document . getElementById ( "local-remote-switch2" ) . checked = false ;
2021-09-04 18:23:58 +00:00
document . getElementById ( "remote-tnc-field" ) . style . visibility = 'hidden' ;
2021-09-04 14:33:17 +00:00
}
2021-08-06 20:10:45 +00:00
2021-09-04 18:23:58 +00:00
// Create spectrum object on canvas with ID "waterfall"
global . spectrum = new Spectrum (
"waterfall" , {
2023-01-16 22:34:42 +00:00
spectrumPercent : 0 ,
wf _rows : 192 //Assuming 1 row = 1 pixe1, 192 is the height of the spectrum container
2021-09-04 18:23:58 +00:00
} ) ;
2021-08-07 08:54:34 +00:00
2023-01-16 22:34:42 +00:00
//Set waterfalltheme
document . getElementById ( "wftheme_selector" ) . value = config . wftheme ;
spectrum . setColorMap ( config . wftheme ) ;
2021-11-07 11:17:23 +00:00
2022-01-18 18:38:05 +00:00
// on click radio control toggle view
2022-02-02 20:12:16 +00:00
// disabled
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-switch-disabled" ) . addEventListener ( "click" , ( ) => {
2022-10-03 12:02:58 +00:00
document . getElementById ( "hamlib_info_field" ) . innerHTML = 'Set hamlib related settings.' ;
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = 'block' ;
document . getElementById ( "radio-control-disabled" ) . style . visibility = 'visible' ;
document . getElementById ( "radio-control-radio" ) . style . display = 'none' ;
document . getElementById ( "radio-control-radio" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'none' ;
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'none' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'none' ;
2022-02-02 20:12:16 +00:00
config . radiocontrol = 'disabled'
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-09-20 05:59:47 +00:00
// radio settings event listener
document . getElementById ( "radio-control-switch-radio" ) . addEventListener ( "click" , ( ) => {
2022-10-03 12:02:58 +00:00
document . getElementById ( "hamlib_info_field" ) . innerHTML = 'Select your radio by searching for the name or ID.' ;
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = 'none' ;
document . getElementById ( "radio-control-disabled" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-radio" ) . style . display = 'block' ;
document . getElementById ( "radio-control-radio" ) . style . visibility = 'visible' ;
document . getElementById ( "radio-control-connection" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'none' ;
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'none' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'none' ;
config . radiocontrol = 'rigctld' ;
2022-01-18 18:38:05 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2021-08-07 08:54:34 +00:00
} ) ;
2021-10-17 13:57:41 +00:00
2022-09-20 05:59:47 +00:00
// radio settings 'connection' event listener
document . getElementById ( "radio-control-switch-connect" ) . addEventListener ( "click" , ( ) => {
2022-10-03 12:02:58 +00:00
document . getElementById ( "hamlib_info_field" ) . innerHTML = 'Setup the connection between rigctld and your radio' ;
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = 'none' ;
document . getElementById ( "radio-control-disabled" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-radio" ) . style . display = 'none' ;
document . getElementById ( "radio-control-radio" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . visibility = 'visible' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'block' ;
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'none' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'none' ;
config . radiocontrol = 'rigctld' ;
2022-01-18 18:38:05 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2021-10-17 13:57:41 +00:00
} ) ;
2022-09-20 05:59:47 +00:00
// radio settings 'ptt' event listener
document . getElementById ( "radio-control-switch-ptt" ) . addEventListener ( "click" , ( ) => {
2022-10-03 12:02:58 +00:00
document . getElementById ( "hamlib_info_field" ) . innerHTML = 'Set your PTT related settings.' ;
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = 'none' ;
document . getElementById ( "radio-control-disabled" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-radio" ) . style . display = 'none' ;
document . getElementById ( "radio-control-radio" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'none' ;
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'visible' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'block' ;
document . getElementById ( "radio-control-network" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'none' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'none' ;
config . radiocontrol = 'rigctld' ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
// // radio settings 'network' event listener
document . getElementById ( "radio-control-switch-network" ) . addEventListener ( "click" , ( ) => {
2022-10-03 12:02:58 +00:00
document . getElementById ( "hamlib_info_field" ) . innerHTML = 'Set the ip and port of a rigctld session' ;
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = 'none' ;
document . getElementById ( "radio-control-disabled" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-radio" ) . style . display = 'none' ;
document . getElementById ( "radio-control-radio" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'none' ;
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . display = 'block' ;
document . getElementById ( "radio-control-network" ) . style . visibility = 'visible' ;
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'none' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'none' ;
2022-02-08 14:27:34 +00:00
config . radiocontrol = 'rigctld' ;
2022-01-18 18:38:05 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2021-10-17 13:57:41 +00:00
2022-09-20 05:59:47 +00:00
// // radio settings 'rigctld' event listener
document . getElementById ( "radio-control-switch-rigctld" ) . addEventListener ( "click" , ( ) => {
2022-10-03 12:02:58 +00:00
document . getElementById ( "hamlib_info_field" ) . innerHTML = 'Define the rigctld path and port' ;
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = 'none' ;
document . getElementById ( "radio-control-disabled" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-radio" ) . style . display = 'none' ;
document . getElementById ( "radio-control-radio" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'none' ;
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'visible' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'block' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'none' ;
config . radiocontrol = 'rigctld' ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
// // radio settings 'rigctld' event listener
document . getElementById ( "radio-control-switch-rigctld-info" ) . addEventListener ( "click" , ( ) => {
2022-10-03 12:02:58 +00:00
document . getElementById ( "hamlib_info_field" ) . innerHTML = 'Start and stop rigctld .' ;
2022-09-20 05:59:47 +00:00
document . getElementById ( "radio-control-disabled" ) . style . display = 'none' ;
document . getElementById ( "radio-control-disabled" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-radio" ) . style . display = 'none' ;
document . getElementById ( "radio-control-radio" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-connection" ) . style . display = 'none' ;
document . getElementById ( "radio-control-ptt" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-ptt" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . display = 'none' ;
document . getElementById ( "radio-control-network" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . visibility = 'hidden' ;
document . getElementById ( "radio-control-rigctld" ) . style . display = 'none' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . visibility = 'visible' ;
document . getElementById ( "radio-control-rigctld-info" ) . style . display = 'block' ;
config . radiocontrol = 'rigctld' ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-09-23 09:17:59 +00:00
// 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" )
} ) ;
2022-09-23 17:18:20 +00:00
// radio settings 'enable hamlib dcd' event listener
document . getElementById ( "enable_hamlib_dcd" ) . addEventListener ( "change" , ( ) => {
enable _setting ( "enable_hamlib_dcd" , "hamlib_dcd" )
} ) ;
2022-10-03 12:17:03 +00:00
2022-10-06 08:08:31 +00:00
// radio settings 'enable hamlib dtr state' event listener
document . getElementById ( "enable_hamlib_dtrstate" ) . addEventListener ( "change" , ( ) => {
enable _setting ( "enable_hamlib_dtrstate" , "hamlib_dtrstate" )
} ) ;
2022-10-03 12:17:03 +00:00
2022-09-20 17:24:07 +00:00
/ *
document . getElementById ( 'hamlib_rigctld_path' ) . addEventListener ( 'change' , ( ) => {
var fileList = document . getElementById ( "dataModalFile" ) . files ;
console . log ( fileList )
} )
* /
document . getElementById ( 'hamlib_rigctld_path' ) . addEventListener ( 'click' , ( ) => {
ipcRenderer . send ( 'get-file-path' , {
title : 'Title' ,
} ) ;
ipcRenderer . on ( 'return-file-paths' , ( event , data ) => {
rigctldPath = data . path . filePaths [ 0 ]
document . getElementById ( "hamlib_rigctld_path" ) . value = rigctldPath
config . hamlib _rigctld _path = rigctldPath
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
} )
2022-10-03 12:17:03 +00:00
// radio settings 'hamlib_rigctld_server_port' event listener
document . getElementById ( "hamlib_rigctld_server_port" ) . addEventListener ( "change" , ( ) => {
config . hamlib _rigctld _server _port = document . getElementById ( "hamlib_rigctld_server_port" ) . value
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-09-20 17:24:07 +00:00
document . getElementById ( 'hamlib_rigctld_start' ) . addEventListener ( 'click' , ( ) => {
var rigctldPath = document . getElementById ( "hamlib_rigctld_path" ) . value ;
2022-09-23 12:06:13 +00:00
2022-10-03 12:17:03 +00:00
2022-09-23 12:06:13 +00:00
var paramList = [ ]
2022-09-20 17:37:54 +00:00
var hamlib _deviceid = document . getElementById ( "hamlib_deviceid" ) . value ;
2022-09-23 12:06:13 +00:00
paramList = paramList . concat ( '-m' , hamlib _deviceid )
2022-09-23 17:18:20 +00:00
// hamlib deviceport setting
2022-09-23 12:06:13 +00:00
if ( document . getElementById ( 'enable_hamlib_deviceport' ) . checked ) {
var hamlib _deviceport = document . getElementById ( "hamlib_deviceport" ) . value ;
paramList = paramList . concat ( '-r' , hamlib _deviceport )
}
2022-09-23 17:18:20 +00:00
// hamlib serialspeed setting
if ( document . getElementById ( 'enable_hamlib_serialspeed' ) . checked ) {
var hamlib _serialspeed = document . getElementById ( "hamlib_serialspeed" ) . value ;
paramList = paramList . concat ( '-s' , hamlib _serialspeed )
}
// hamlib databits setting
if ( document . getElementById ( 'enable_hamlib_databits' ) . checked ) {
var hamlib _databits = document . getElementById ( "hamlib_databits" ) . value ;
paramList = paramList . concat ( '--set-conf=data_bits=' + hamlib _databits )
}
// hamlib stopbits setting
if ( document . getElementById ( 'enable_hamlib_stopbits' ) . checked ) {
var hamlib _stopbits = document . getElementById ( "hamlib_stopbits" ) . value ;
paramList = paramList . concat ( '--set-conf=stop_bits=' + hamlib _stopbits )
}
// hamlib handshake setting
if ( document . getElementById ( 'enable_hamlib_handshake' ) . checked ) {
var hamlib _handshake = document . getElementById ( "hamlib_handshake" ) . value ;
paramList = paramList . concat ( '--set-conf=serial_handshake=' + hamlib _handshake )
}
// hamlib dcd setting
if ( document . getElementById ( 'enable_hamlib_dcd' ) . checked ) {
var hamlib _dcd = document . getElementById ( "hamlib_dcd" ) . value ;
paramList = paramList . concat ( '--dcd-type=' + hamlib _dcd )
}
// hamlib ptt port
if ( document . getElementById ( 'enable_hamlib_ptt_port' ) . checked ) {
var hamlib _ptt _port = document . getElementById ( "hamlib_ptt_port" ) . value ;
paramList = paramList . concat ( '-p' , hamlib _ptt _port )
}
2022-10-03 11:10:19 +00:00
// hamlib ptt type
if ( document . getElementById ( 'enable_hamlib_pttprotocol' ) . checked ) {
var hamlib _ptt _type = document . getElementById ( "hamlib_pttprotocol" ) . value ;
2022-10-06 08:21:12 +00:00
paramList = paramList . concat ( '--ptt-type=' + hamlib _ptt _type )
2022-10-03 11:10:19 +00:00
}
2022-10-06 08:08:31 +00:00
// hamlib dtr state
if ( document . getElementById ( 'enable_hamlib_dtrstate' ) . checked ) {
var hamlib _dtrstate = document . getElementById ( "hamlib_dtrstate" ) . value ;
paramList = paramList . concat ( '--set-conf=dtr_state=' + hamlib _dtrstate )
}
2022-10-03 12:17:03 +00:00
var hamlib _rigctld _server _port = document . getElementById ( "hamlib_rigctld_server_port" ) . value ;
2022-10-03 14:46:17 +00:00
paramList = paramList . concat ( '-t' , hamlib _rigctld _server _port )
2022-10-03 12:17:03 +00:00
2022-09-20 17:37:54 +00:00
2022-12-01 07:45:21 +00:00
document . getElementById ( 'hamlib_rigctld_command' ) . value = paramList . join ( " " ) // join removes the commas
2022-09-20 17:37:54 +00:00
2022-09-23 12:06:13 +00:00
console . log ( paramList )
2022-10-03 07:36:43 +00:00
console . log ( rigctldPath )
2022-09-20 17:37:54 +00:00
2022-10-03 07:36:43 +00:00
let Data = {
2022-09-20 17:24:07 +00:00
path : rigctldPath ,
2022-09-23 12:06:13 +00:00
parameters : paramList
2022-10-03 07:36:43 +00:00
} ;
ipcRenderer . send ( 'request-start-rigctld' , Data ) ;
2022-09-20 17:24:07 +00:00
} )
document . getElementById ( 'hamlib_rigctld_stop' ) . addEventListener ( 'click' , ( ) => {
ipcRenderer . send ( 'request-stop-rigctld' , {
path : '123' ,
parameters : '--version'
} ) ;
} )
2021-10-17 13:57:41 +00:00
2021-08-07 08:54:34 +00:00
// on click waterfall scatter toggle view
// waterfall
document . getElementById ( "waterfall-scatter-switch1" ) . addEventListener ( "click" , ( ) => {
2023-01-12 23:14:42 +00:00
document . getElementById ( "chart" ) . style . visibility = 'hidden' ;
document . getElementById ( "chart" ) . style . display = 'none' ;
document . getElementById ( "chart" ) . style . height = '0px' ;
document . getElementById ( "scatter" ) . style . height = '0px' ;
document . getElementById ( "scatter" ) . style . display = 'none' ;
2021-08-07 08:54:34 +00:00
document . getElementById ( "scatter" ) . style . visibility = 'hidden' ;
2023-01-12 23:14:42 +00:00
document . getElementById ( "waterfall" ) . style . display = 'block' ;
2021-08-07 08:54:34 +00:00
document . getElementById ( "waterfall" ) . style . visibility = 'visible' ;
2021-09-10 14:50:48 +00:00
document . getElementById ( "waterfall" ) . style . height = '100%' ;
2023-01-12 23:14:42 +00:00
2022-02-08 14:27:34 +00:00
config . spectrum = 'waterfall' ;
2021-08-07 08:54:34 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
// scatter
document . getElementById ( "waterfall-scatter-switch2" ) . addEventListener ( "click" , ( ) => {
2023-01-12 23:14:42 +00:00
document . getElementById ( "scatter" ) . style . display = 'block' ;
2021-08-07 08:54:34 +00:00
document . getElementById ( "scatter" ) . style . visibility = 'visible' ;
2023-01-12 23:14:42 +00:00
document . getElementById ( "scatter" ) . style . height = '100%' ;
2021-08-07 08:54:34 +00:00
document . getElementById ( "waterfall" ) . style . visibility = 'hidden' ;
document . getElementById ( "waterfall" ) . style . height = '0px' ;
2023-01-12 23:14:42 +00:00
document . getElementById ( "waterfall" ) . style . display = 'none' ;
document . getElementById ( "chart" ) . style . visibility = 'hidden' ;
document . getElementById ( "chart" ) . style . height = '0px' ;
document . getElementById ( "chart" ) . style . display = 'none' ;
2022-02-08 14:27:34 +00:00
config . spectrum = 'scatter' ;
2021-08-07 08:54:34 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2023-01-12 23:14:42 +00:00
// chart
document . getElementById ( "waterfall-scatter-switch3" ) . addEventListener ( "click" , ( ) => {
document . getElementById ( "waterfall" ) . style . visibility = 'hidden' ;
document . getElementById ( "waterfall" ) . style . height = '0px' ;
document . getElementById ( "waterfall" ) . style . display = 'none' ;
2021-07-17 07:03:40 +00:00
2023-01-12 23:14:42 +00:00
document . getElementById ( "scatter" ) . style . height = '0px' ;
document . getElementById ( "scatter" ) . style . visibility = 'hidden' ;
document . getElementById ( "scatter" ) . style . display = 'none' ;
document . getElementById ( "chart" ) . style . height = '100%' ;
document . getElementById ( "chart" ) . style . display = 'block' ;
document . getElementById ( "chart" ) . style . visibility = 'visible' ;
config . spectrum = 'chart' ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-02-08 14:27:34 +00:00
2021-09-04 14:33:17 +00:00
// on click remote tnc toggle view
document . getElementById ( "local-remote-switch1" ) . addEventListener ( "click" , ( ) => {
2022-02-08 14:27:34 +00:00
document . getElementById ( "local-remote-switch1" ) . checked = true ;
document . getElementById ( "local-remote-switch2" ) . checked = false ;
2021-09-04 14:33:17 +00:00
document . getElementById ( "remote-tnc-field" ) . style . visibility = 'hidden' ;
2022-02-08 14:27:34 +00:00
config . tnclocation = 'localhost' ;
2021-09-04 18:23:58 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
document . getElementById ( "local-remote-switch2" ) . addEventListener ( "click" , ( ) => {
2022-02-08 14:27:34 +00:00
document . getElementById ( "local-remote-switch1" ) . checked = false ;
document . getElementById ( "local-remote-switch2" ) . checked = true ;
2021-09-04 14:33:17 +00:00
document . getElementById ( "remote-tnc-field" ) . style . visibility = 'visible' ;
2022-02-08 14:27:34 +00:00
config . tnclocation = 'remote' ;
2021-09-04 18:23:58 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-11-25 11:04:15 +00:00
2021-07-23 15:40:44 +00:00
2021-09-24 14:43:45 +00:00
// on change ping callsign
document . getElementById ( "dxCall" ) . addEventListener ( "change" , ( ) => {
2022-02-08 14:27:34 +00:00
document . getElementById ( "dataModalDxCall" ) . value = document . getElementById ( "dxCall" ) . value ;
2021-09-24 14:43:45 +00:00
} ) ;
// on change ping callsign
document . getElementById ( "dataModalDxCall" ) . addEventListener ( "change" , ( ) => {
2022-02-08 14:27:34 +00:00
document . getElementById ( "dxCall" ) . value = document . getElementById ( "dataModalDxCall" ) . value ;
2022-03-14 19:21:15 +00:00
2021-09-24 14:43:45 +00:00
} ) ;
2022-11-25 11:04:15 +00:00
// on change port and host
document . getElementById ( "tnc_adress" ) . addEventListener ( "change" , ( ) => {
console . log ( document . getElementById ( "tnc_adress" ) . value ) ;
config . tnc _host = document . getElementById ( "tnc_adress" ) . value ;
config . daemon _host = document . getElementById ( "tnc_adress" ) . value ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
let Data = {
port : document . getElementById ( "tnc_port" ) . value ,
adress : document . getElementById ( "tnc_adress" ) . value ,
} ;
ipcRenderer . send ( 'request-update-tnc-ip' , Data ) ;
Data = {
port : parseInt ( document . getElementById ( "tnc_port" ) . value ) + 1 ,
adress : document . getElementById ( "tnc_adress" ) . value ,
} ;
ipcRenderer . send ( 'request-update-daemon-ip' , Data ) ;
} ) ;
2022-03-31 19:13:30 +00:00
// on change tnc port
2021-07-24 07:06:22 +00:00
document . getElementById ( "tnc_port" ) . addEventListener ( "change" , ( ) => {
2022-11-25 11:04:15 +00:00
2022-02-08 14:27:34 +00:00
config . tnc _port = document . getElementById ( "tnc_port" ) . value ;
config . daemon _port = parseInt ( document . getElementById ( "tnc_port" ) . value ) + 1 ;
2021-07-24 07:06:22 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2021-07-17 07:03:40 +00:00
2022-11-25 11:04:15 +00:00
let Data = {
port : document . getElementById ( "tnc_port" ) . value ,
adress : document . getElementById ( "tnc_adress" ) . value ,
} ;
ipcRenderer . send ( 'request-update-tnc-ip' , Data ) ;
Data = {
port : parseInt ( document . getElementById ( "tnc_port" ) . value ) + 1 ,
adress : document . getElementById ( "tnc_adress" ) . value ,
} ;
ipcRenderer . send ( 'request-update-daemon-ip' , Data ) ;
2021-07-24 07:06:22 +00:00
} ) ;
2022-03-31 19:13:30 +00:00
// on change audio TX Level
document . getElementById ( "audioLevelTX" ) . addEventListener ( "change" , ( ) => {
2022-04-08 09:35:13 +00:00
var tx _audio _level = parseInt ( document . getElementById ( "audioLevelTX" ) . value ) ;
2022-03-31 19:13:30 +00:00
document . getElementById ( "audioLevelTXvalue" ) . innerHTML = tx _audio _level ;
config . tx _audio _level = tx _audio _level ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
let Data = {
command : "set_tx_audio_level" ,
tx _audio _level : tx _audio _level
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
2021-07-17 07:03:40 +00:00
2022-03-31 19:13:30 +00:00
} ) ;
document . getElementById ( "sendTestFrame" ) . addEventListener ( "click" , ( ) => {
let Data = {
type : "set" ,
command : "send_test_frame"
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
} ) ;
2021-09-13 16:27:50 +00:00
// saveMyCall button clicked
2022-12-24 14:48:57 +00:00
document . getElementById ( "myCall" ) . addEventListener ( "input" , ( ) => {
2022-02-08 14:27:34 +00:00
callsign = document . getElementById ( "myCall" ) . value ;
2022-02-21 11:20:36 +00:00
ssid = document . getElementById ( "myCallSSID" ) . value ;
callsign _ssid = callsign . toUpperCase ( ) + '-' + ssid ;
config . mycall = callsign _ssid ;
2022-04-24 13:53:51 +00:00
// split document title by looking for Call then split and update it
2023-01-20 02:24:07 +00:00
//var documentTitle = document.title.split('Call:')
//document.title = documentTitle[0] + 'Call: ' + callsign_ssid;
updateTitle ( callsign _ssid ) ;
2021-07-23 15:40:44 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2022-02-21 11:20:36 +00:00
daemon . saveMyCall ( callsign _ssid ) ;
2021-07-24 07:06:22 +00:00
} ) ;
2021-09-13 16:27:50 +00:00
// saveMyGrid button clicked
2022-12-24 14:48:57 +00:00
document . getElementById ( "myGrid" ) . addEventListener ( "input" , ( ) => {
2022-02-08 14:27:34 +00:00
grid = document . getElementById ( "myGrid" ) . value ;
config . mygrid = grid ;
2021-07-23 15:40:44 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2022-02-08 14:27:34 +00:00
daemon . saveMyGrid ( grid ) ;
2021-07-24 07:06:22 +00:00
2021-07-23 15:40:44 +00:00
} ) ;
2021-12-06 19:16:14 +00:00
2021-07-24 07:06:22 +00:00
2021-09-13 16:27:50 +00:00
// startPing button clicked
2021-07-24 07:06:22 +00:00
document . getElementById ( "sendPing" ) . addEventListener ( "click" , ( ) => {
2023-01-21 05:40:01 +00:00
var dxcallsign = document . getElementById ( "dxCall" ) . value . toUpperCase ( ) ;
if ( dxcallsign == "" || dxcallsign == null || dxcallsign == undefined )
return ;
2023-01-22 16:08:35 +00:00
pauseButton ( document . getElementById ( "sendPing" ) , 2000 ) ;
2022-02-08 14:27:34 +00:00
sock . sendPing ( dxcallsign ) ;
2021-08-15 14:48:48 +00:00
} ) ;
2021-09-04 18:23:58 +00:00
2021-09-13 16:27:50 +00:00
// dataModalstartPing button clicked
2021-08-15 14:48:48 +00:00
document . getElementById ( "dataModalSendPing" ) . addEventListener ( "click" , ( ) => {
2022-02-08 14:27:34 +00:00
var dxcallsign = document . getElementById ( "dataModalDxCall" ) . value ;
dxcallsign = dxcallsign . toUpperCase ( ) ;
sock . sendPing ( dxcallsign ) ;
2021-07-24 07:06:22 +00:00
} ) ;
2022-03-04 15:50:32 +00:00
2022-04-24 13:34:59 +00:00
// close app, update and restart
document . getElementById ( "update_and_install" ) . addEventListener ( "click" , ( ) => {
ipcRenderer . send ( 'request-restart-and-install' ) ;
} ) ;
2022-03-04 15:50:32 +00:00
// open arq session
document . getElementById ( "openARQSession" ) . addEventListener ( "click" , ( ) => {
var dxcallsign = document . getElementById ( "dataModalDxCall" ) . value ;
dxcallsign = dxcallsign . toUpperCase ( ) ;
sock . connectARQ ( dxcallsign ) ;
} ) ;
// close arq session
document . getElementById ( "closeARQSession" ) . addEventListener ( "click" , ( ) => {
sock . disconnectARQ ( ) ;
} ) ;
2021-07-24 07:06:22 +00:00
2021-12-06 19:16:14 +00:00
2021-09-13 16:27:50 +00:00
// sendCQ button clicked
2021-07-24 07:06:22 +00:00
document . getElementById ( "sendCQ" ) . addEventListener ( "click" , ( ) => {
2023-01-22 16:08:35 +00:00
pauseButton ( document . getElementById ( "sendCQ" ) , 2000 ) ;
2022-02-08 14:27:34 +00:00
sock . sendCQ ( ) ;
2021-07-24 07:06:22 +00:00
} ) ;
2021-12-06 19:16:14 +00:00
// Start beacon button clicked
document . getElementById ( "startBeacon" ) . addEventListener ( "click" , ( ) => {
2022-02-08 14:27:34 +00:00
interval = document . getElementById ( "beaconInterval" ) . value ;
config . beacon _interval = interval ;
2021-12-06 19:16:14 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2022-02-08 14:27:34 +00:00
sock . startBeacon ( interval ) ;
2021-12-06 19:16:14 +00:00
} ) ;
2022-02-02 20:12:16 +00:00
// sendscatter Switch clicked
document . getElementById ( "scatterSwitch" ) . addEventListener ( "click" , ( ) => {
2022-02-08 14:27:34 +00:00
console . log ( document . getElementById ( "scatterSwitch" ) . checked ) ;
2022-02-02 20:12:16 +00:00
if ( document . getElementById ( "scatterSwitch" ) . checked == true ) {
2022-02-08 14:27:34 +00:00
config . enable _scatter = "True" ;
2022-02-02 20:12:16 +00:00
} else {
2022-02-08 14:27:34 +00:00
config . enable _scatter = "False" ;
2022-02-02 20:12:16 +00:00
}
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
// sendfft Switch clicked
document . getElementById ( "fftSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "fftSwitch" ) . checked == true ) {
2022-02-08 14:27:34 +00:00
config . enable _fft = "True" ;
2022-02-02 20:12:16 +00:00
} else {
2022-02-08 14:27:34 +00:00
config . enable _fft = "False" ;
2022-02-02 20:12:16 +00:00
}
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-02-08 14:27:34 +00:00
// enable 500z Switch clicked
document . getElementById ( "500HzModeSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "500HzModeSwitch" ) . checked == true ) {
2022-05-28 12:08:33 +00:00
config . low _bandwidth _mode = "True" ;
2022-02-08 14:27:34 +00:00
} else {
2022-05-28 12:08:33 +00:00
config . low _bandwidth _mode = "False" ;
2022-02-08 14:27:34 +00:00
}
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-04-18 15:17:53 +00:00
// enable response to cq clicked
document . getElementById ( "respondCQSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "respondCQSwitch" ) . checked == true ) {
config . respond _to _cq = "True" ;
} else {
config . respond _to _cq = "False" ;
}
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-11-05 21:27:33 +00:00
// enable explorer Switch clicked
document . getElementById ( "ExplorerSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "ExplorerSwitch" ) . checked == true ) {
config . enable _explorer = "True" ;
} else {
config . enable _explorer = "False" ;
}
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2023-01-27 03:55:55 +00:00
document . getElementById ( "GraphicsSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "GraphicsSwitch" ) . checked == true ) {
config . high _graphics = "True" ;
} else {
config . high _graphics = "False" ;
}
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
set _CPU _mode ( ) ;
} ) ;
2022-02-02 20:12:16 +00:00
2022-03-31 10:45:44 +00:00
// enable fsk Switch clicked
document . getElementById ( "fskModeSwitch" ) . addEventListener ( "click" , ( ) => {
if ( document . getElementById ( "fskModeSwitch" ) . checked == true ) {
config . enable _fsk = "True" ;
} else {
config . enable _fsk = "False" ;
}
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-02-02 20:12:16 +00:00
2022-03-19 11:42:10 +00:00
// Tuning range clicked
document . getElementById ( "tuning_range_fmin" ) . addEventListener ( "click" , ( ) => {
var tuning _range _fmin = document . getElementById ( "tuning_range_fmin" ) . value ;
config . tuning _range _fmin = tuning _range _fmin ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-02-10 13:38:55 +00:00
2022-03-19 11:42:10 +00:00
document . getElementById ( "tuning_range_fmax" ) . addEventListener ( "click" , ( ) => {
var tuning _range _fmax = document . getElementById ( "tuning_range_fmax" ) . value ;
config . tuning _range _fmax = tuning _range _fmax ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-02-02 20:12:16 +00:00
2022-03-19 11:42:10 +00:00
2022-02-10 13:38:55 +00:00
// Theme selector clicked
document . getElementById ( "theme_selector" ) . addEventListener ( "click" , ( ) => {
var theme = document . getElementById ( "theme_selector" ) . value ;
if ( theme != 'default' ) {
var theme _path = "../node_modules/bootswatch/dist/" + theme + "/bootstrap.min.css" ;
} else {
var theme _path = "../node_modules/bootstrap/dist/css/bootstrap.min.css" ;
}
2022-03-03 18:57:40 +00:00
//update path to css file
2022-04-24 14:07:30 +00:00
document . getElementById ( "bootstrap_theme" ) . href = escape ( theme _path )
2022-02-10 13:38:55 +00:00
config . theme = theme ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2023-01-16 22:34:42 +00:00
} ) ;
// Waterfall theme selector changed
document . getElementById ( "wftheme_selector" ) . addEventListener ( "change" , ( ) => {
var wftheme = document . getElementById ( "wftheme_selector" ) . value ;
spectrum . setColorMap ( wftheme ) ;
config . wftheme = wftheme ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2022-02-10 13:38:55 +00:00
} ) ;
2022-03-03 18:57:40 +00:00
2023-01-22 09:15:55 +00:00
// Update channel selector changed
document . getElementById ( "update_channel_selector" ) . addEventListener ( "change" , ( ) => {
2022-03-03 18:57:40 +00:00
config . update _channel = document . getElementById ( "update_channel_selector" ) . value ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2023-01-22 19:13:26 +00:00
console . log ( "Autoupdate channel changed to " , config . update _channel ) ;
2022-03-03 18:57:40 +00:00
} ) ;
2022-09-05 09:54:50 +00:00
// rx buffer size selector clicked
document . getElementById ( "rx_buffer_size" ) . addEventListener ( "click" , ( ) => {
var rx _buffer _size = document . getElementById ( "rx_buffer_size" ) . value ;
config . rx _buffer _size = rx _buffer _size ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2022-03-03 18:57:40 +00:00
2021-12-06 19:16:14 +00:00
2022-02-10 14:05:04 +00:00
//screen size
window . addEventListener ( 'resize' , ( ) => {
config . screen _height = window . innerHeight ;
config . screen _width = window . innerWidth ;
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
} ) ;
2021-12-06 19:16:14 +00:00
// Stop beacon button clicked
document . getElementById ( "stopBeacon" ) . addEventListener ( "click" , ( ) => {
2022-02-08 14:27:34 +00:00
sock . stopBeacon ( ) ;
2021-12-06 19:16:14 +00:00
} ) ;
2023-01-07 04:27:52 +00:00
// Explorer button clicked
document . getElementById ( "openExplorer" ) . addEventListener ( "click" , ( ) => {
shell . openExternal ( 'https://explorer.freedata.app/?myCall=' + document . getElementById ( "myCall" ) . value ) ;
} ) ;
2021-09-13 16:27:50 +00:00
// startTNC button clicked
2021-07-24 07:06:22 +00:00
document . getElementById ( "startTNC" ) . addEventListener ( "click" , ( ) => {
2022-01-18 18:38:05 +00:00
2022-03-19 11:42:10 +00:00
var tuning _range _fmin = document . getElementById ( "tuning_range_fmin" ) . value ;
var tuning _range _fmax = document . getElementById ( "tuning_range_fmax" ) . value ;
2022-02-08 14:27:34 +00:00
var rigctld _ip = document . getElementById ( "hamlib_rigctld_ip" ) . value ;
var rigctld _port = document . getElementById ( "hamlib_rigctld_port" ) . value ;
2022-10-03 12:17:03 +00:00
var hamlib _rigctld _server _port = document . getElementById ( "hamlib_rigctld_server_port" ) . value ;
2022-01-18 18:38:05 +00:00
2022-02-08 14:27:34 +00:00
var deviceid = document . getElementById ( "hamlib_deviceid" ) . value ;
var deviceport = document . getElementById ( "hamlib_deviceport" ) . value ;
var serialspeed = document . getElementById ( "hamlib_serialspeed" ) . value ;
2022-09-23 09:17:59 +00:00
var pttprotocol = document . getElementById ( "hamlib_pttprotocol" ) . value ;
2022-09-23 17:18:20 +00:00
var hamlib _dcd = document . getElementById ( "hamlib_dcd" ) . value ;
2022-01-18 18:38:05 +00:00
2022-02-08 14:27:34 +00:00
var mycall = document . getElementById ( "myCall" ) . value ;
2022-02-21 11:20:36 +00:00
var ssid = document . getElementById ( "myCallSSID" ) . value ;
callsign _ssid = mycall . toUpperCase ( ) + '-' + ssid ;
2022-02-02 20:12:16 +00:00
2022-02-08 14:27:34 +00:00
var mygrid = document . getElementById ( "myGrid" ) . value ;
2022-01-18 18:38:05 +00:00
2022-02-08 14:27:34 +00:00
var rx _audio = document . getElementById ( "audio_input_selectbox" ) . value ;
var tx _audio = document . getElementById ( "audio_output_selectbox" ) . value ;
2022-09-23 09:17:59 +00:00
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 ;
2021-10-17 13:57:41 +00:00
2022-02-02 20:12:16 +00:00
if ( document . getElementById ( "scatterSwitch" ) . checked == true ) {
2022-02-08 14:27:34 +00:00
var enable _scatter = "True" ;
2022-02-02 20:12:16 +00:00
} else {
2022-02-08 14:27:34 +00:00
var enable _scatter = "False" ;
2022-02-02 20:12:16 +00:00
}
if ( document . getElementById ( "fftSwitch" ) . checked == true ) {
2022-02-08 14:27:34 +00:00
var enable _fft = "True" ;
2022-02-02 20:12:16 +00:00
} else {
2022-02-08 14:27:34 +00:00
var enable _fft = "False" ;
2022-02-02 20:12:16 +00:00
}
2022-02-08 14:27:34 +00:00
if ( document . getElementById ( "500HzModeSwitch" ) . checked == true ) {
2022-05-28 12:08:33 +00:00
var low _bandwidth _mode = "True" ;
2022-02-08 14:27:34 +00:00
} else {
2022-05-28 12:08:33 +00:00
var low _bandwidth _mode = "False" ;
2022-02-08 14:27:34 +00:00
}
2022-03-31 10:45:44 +00:00
if ( document . getElementById ( "fskModeSwitch" ) . checked == true ) {
var enable _fsk = "True" ;
} else {
var enable _fsk = "False" ;
}
2022-04-18 15:17:53 +00:00
if ( document . getElementById ( "respondCQSwitch" ) . checked == true ) {
var respond _to _cq = "True" ;
} else {
var respond _to _cq = "False" ;
}
2022-11-05 21:27:33 +00:00
if ( document . getElementById ( "ExplorerSwitch" ) . checked == true ) {
var enable _explorer = "True" ;
} else {
var enable _explorer = "False" ;
}
2021-12-27 14:28:58 +00:00
// loop through audio device list and select
for ( i = 0 ; i < document . getElementById ( "audio_input_selectbox" ) . length ; i ++ ) {
device = document . getElementById ( "audio_input_selectbox" ) [ i ] ;
if ( device . value == rx _audio ) {
console . log ( device . text ) ;
2022-02-08 14:27:34 +00:00
config . rx _audio = device . text ;
2021-12-27 14:28:58 +00:00
}
}
// loop through audio device list and select
for ( i = 0 ; i < document . getElementById ( "audio_output_selectbox" ) . length ; i ++ ) {
device = document . getElementById ( "audio_output_selectbox" ) [ i ] ;
if ( device . value == tx _audio ) {
console . log ( device . text ) ;
2022-02-08 14:27:34 +00:00
config . tx _audio = device . text ;
2021-12-27 14:28:58 +00:00
}
}
2022-02-08 14:27:34 +00:00
2022-09-20 17:24:07 +00:00
if ( ! document . getElementById ( "radio-control-switch-disabled" ) . checked ) {
2022-02-08 14:27:34 +00:00
var radiocontrol = 'rigctld' ;
} else {
var radiocontrol = 'disabled' ;
}
2022-03-31 19:13:30 +00:00
var tx _audio _level = document . getElementById ( "audioLevelTX" ) . value ;
2022-09-05 09:54:50 +00:00
var rx _buffer _size = document . getElementById ( "rx_buffer_size" ) . value ;
2022-09-20 17:24:07 +00:00
2022-10-03 12:17:03 +00:00
2022-02-08 14:27:34 +00:00
config . radiocontrol = radiocontrol ;
2022-02-21 11:20:36 +00:00
config . mycall = callsign _ssid ;
2022-02-08 14:27:34 +00:00
config . mygrid = mygrid ;
2022-09-23 09:17:59 +00:00
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 ;
2022-09-23 17:18:20 +00:00
config . hamlib _dcd = hamlib _dcd ;
2022-03-11 12:10:46 +00:00
//config.deviceid_rigctl = deviceid_rigctl;
//config.serialspeed_rigctl = serialspeed_rigctl;
//config.pttprotocol_rigctl = pttprotocol_rigctl;
2022-09-23 09:17:59 +00:00
config . hamlib _rigctld _port = rigctld _port ;
config . hamlib _rigctld _ip = rigctld _ip ;
2022-10-03 12:17:03 +00:00
config . hamlib _rigctld _server _port = hamlib _rigctld _server _port ;
2022-03-11 12:10:46 +00:00
//config.deviceport_rigctl = deviceport_rigctl;
2022-02-08 14:27:34 +00:00
config . enable _scatter = enable _scatter ;
config . enable _fft = enable _fft ;
2022-03-31 10:45:44 +00:00
config . enable _fsk = enable _fsk ;
2022-05-28 12:08:33 +00:00
config . low _bandwidth _mode = low _bandwidth _mode ;
2022-03-31 19:13:30 +00:00
config . tx _audio _level = tx _audio _level ;
2022-04-18 15:17:53 +00:00
config . respond _to _cq = respond _to _cq ;
2022-09-05 09:54:50 +00:00
config . rx _buffer _size = rx _buffer _size ;
2022-11-05 21:27:33 +00:00
config . enable _explorer = enable _explorer ;
2023-01-23 23:23:28 +00:00
2021-07-25 16:19:51 +00:00
fs . writeFileSync ( configPath , JSON . stringify ( config , null , 2 ) ) ;
2021-11-07 11:17:23 +00:00
// collapse settings screen
2022-01-24 22:29:34 +00:00
// deactivated this part so start / stop is a little bit more smooth. We are getting problems because of network delay
/ *
2021-11-07 11:17:23 +00:00
var collapseFirstRow = new bootstrap . Collapse ( document . getElementById ( 'collapseFirstRow' ) , { toggle : false } )
collapseFirstRow . hide ( )
var collapseSecondRow = new bootstrap . Collapse ( document . getElementById ( 'collapseSecondRow' ) , { toggle : false } )
2021-12-20 17:05:00 +00:00
collapseSecondRow . hide ( )
2021-11-07 11:17:23 +00:00
var collapseThirdRow = new bootstrap . Collapse ( document . getElementById ( 'collapseThirdRow' ) , { toggle : false } )
collapseThirdRow . show ( )
2021-12-20 17:05:00 +00:00
var collapseFourthRow = new bootstrap . Collapse ( document . getElementById ( 'collapseFourthRow' ) , { toggle : false } )
collapseFourthRow . show ( )
2022-01-24 22:29:34 +00:00
* /
2022-01-18 18:38:05 +00:00
2021-11-07 11:17:23 +00:00
2023-01-23 23:23:28 +00:00
daemon . startTNC ( callsign _ssid , mygrid , rx _audio , tx _audio , radiocontrol , deviceid , deviceport , pttprotocol , pttport , serialspeed , data _bits , stop _bits , handshake , rigctld _ip , rigctld _port , enable _fft , enable _scatter , low _bandwidth _mode , tuning _range _fmin , tuning _range _fmax , enable _fsk , tx _audio _level , respond _to _cq , rx _buffer _size , enable _explorer ) ;
2023-01-27 03:55:55 +00:00
2022-01-05 13:15:59 +00:00
2021-07-24 07:06:22 +00:00
} )
2022-03-03 18:57:40 +00:00
document . getElementById ( "tncLog" ) . addEventListener ( "click" , ( ) => {
ipcRenderer . send ( 'request-open-tnc-log' ) ;
} )
2021-09-13 16:27:50 +00:00
// stopTNC button clicked
2021-07-24 07:06:22 +00:00
document . getElementById ( "stopTNC" ) . addEventListener ( "click" , ( ) => {
2022-01-05 13:15:59 +00:00
2022-02-08 14:27:34 +00:00
daemon . stopTNC ( ) ;
2021-11-07 11:17:23 +00:00
// collapse settings screen
2022-01-24 22:29:34 +00:00
// deactivated this part so start / stop is a little bit more smooth. We are getting problems because of network delay
/ *
2021-11-07 11:17:23 +00:00
var collapseFirstRow = new bootstrap . Collapse ( document . getElementById ( 'collapseFirstRow' ) , { toggle : false } )
collapseFirstRow . show ( )
var collapseSecondRow = new bootstrap . Collapse ( document . getElementById ( 'collapseSecondRow' ) , { toggle : false } )
2021-12-20 17:05:00 +00:00
collapseSecondRow . show ( )
2021-11-07 11:17:23 +00:00
var collapseThirdRow = new bootstrap . Collapse ( document . getElementById ( 'collapseThirdRow' ) , { toggle : false } )
2021-12-20 17:05:00 +00:00
collapseThirdRow . hide ( )
var collapseFourthRow = new bootstrap . Collapse ( document . getElementById ( 'collapseFourthRow' ) , { toggle : false } )
collapseFourthRow . hide ( )
2022-01-24 22:29:34 +00:00
* /
2021-12-20 17:05:00 +00:00
2021-07-24 07:06:22 +00:00
} )
2021-11-07 11:17:23 +00:00
2021-09-13 16:27:50 +00:00
// openDataModule button clicked
2021-11-07 11:17:23 +00:00
// not necessesary at this time beacuse bootstrap handles this
// document.getElementById("openDataModule").addEventListener("click", () => {
// var transmitFileSidebar = document.getElementById('transmitFileSidebar')
// var bstransmitFileSidebar = new bootstrap.Offcanvas(transmitFileSidebar)
// bstransmitFileSidebar.show()
//})
2021-07-17 07:03:40 +00:00
2021-10-17 13:57:41 +00:00
// openReceivedFiles button clicked
2021-11-07 11:17:23 +00:00
// not necessesary at this time beacuse bootstrap handles this
//document.getElementById("openReceivedFiles").addEventListener("click", () => {
// var transmitFileSidebar = document.getElementById('transmitFileSidebar')
// var bstransmitFileSidebar = new bootstrap.Offcanvas(transmitFileSidebar)
// bstransmitFileSidebar.show()
//})
2021-10-17 13:57:41 +00:00
// TEST HAMLIB
document . getElementById ( "testHamlib" ) . addEventListener ( "click" , ( ) => {
2022-01-18 18:38:05 +00:00
2021-10-17 13:57:41 +00:00
2022-09-23 09:17:59 +00:00
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 ;
2021-10-17 13:57:41 +00:00
2022-02-08 14:27:34 +00:00
var rigctld _ip = document . getElementById ( "hamlib_rigctld_ip" ) . value ;
var rigctld _port = document . getElementById ( "hamlib_rigctld_port" ) . value ;
2022-01-18 18:38:05 +00:00
2022-02-08 14:27:34 +00:00
var deviceid = document . getElementById ( "hamlib_deviceid" ) . value ;
var deviceport = document . getElementById ( "hamlib_deviceport" ) . value ;
var serialspeed = document . getElementById ( "hamlib_serialspeed" ) . value ;
2022-09-23 09:17:59 +00:00
var pttprotocol = document . getElementById ( "hamlib_pttprotocol" ) . value ;
2022-01-18 18:38:05 +00:00
2022-09-20 05:59:47 +00:00
if ( document . getElementById ( "radio-control-switch-disabled" ) . checked ) {
2022-02-08 14:27:34 +00:00
var radiocontrol = 'disabled' ;
2022-09-20 05:59:47 +00:00
} else {
var radiocontrol = 'rigctld' ;
2022-01-18 18:38:05 +00:00
}
daemon . testHamlib ( radiocontrol , deviceid , deviceport , serialspeed , pttprotocol , pttport , data _bits , stop _bits , handshake , rigctld _ip , rigctld _port )
} )
2021-10-17 13:57:41 +00:00
2021-09-13 16:27:50 +00:00
// START TRANSMISSION
2021-09-04 18:23:58 +00:00
document . getElementById ( "startTransmission" ) . addEventListener ( "click" , ( ) => {
2021-11-07 11:17:23 +00:00
//document.getElementById("transmitFileSidebar").style.width = "0px";
/ * n o t n e c c e s s a r y a t t h i s t i m e b e c a u s e h a n d l e d b y b o o t s t a p i n s i d e h t m l
var transmitFileSidebar = document . getElementById ( 'transmitFileSidebar' )
var bstransmitFileSidebar = new bootstrap . Offcanvas ( transmitFileSidebar )
bstransmitFileSidebar . show ( )
* /
2022-03-14 19:21:15 +00:00
2021-11-07 11:17:23 +00:00
2021-09-04 18:23:58 +00:00
var fileList = document . getElementById ( "dataModalFile" ) . files ;
2022-03-24 19:49:13 +00:00
console . log ( fileList )
2021-09-04 18:23:58 +00:00
var reader = new FileReader ( ) ;
2022-02-02 20:12:16 +00:00
reader . readAsBinaryString ( fileList [ 0 ] ) ;
//reader.readAsDataURL(fileList[0]);
2021-09-04 18:23:58 +00:00
reader . onload = function ( e ) {
// binary data
2022-02-08 14:27:34 +00:00
var data = e . target . result ;
console . log ( data ) ;
2022-02-02 20:12:16 +00:00
2021-09-04 18:23:58 +00:00
let Data = {
2022-01-28 19:07:39 +00:00
command : "send_file" ,
2021-10-02 09:29:08 +00:00
dxcallsign : document . getElementById ( "dataModalDxCall" ) . value . toUpperCase ( ) ,
2021-09-04 18:23:58 +00:00
mode : document . getElementById ( "datamode" ) . value ,
frames : document . getElementById ( "framesperburst" ) . value ,
filetype : fileList [ 0 ] . type ,
filename : fileList [ 0 ] . name ,
data : data ,
checksum : '123123123' ,
} ;
2022-03-14 19:21:15 +00:00
// only send command if dxcallsign entered and we have a file selected
if ( document . getElementById ( "dataModalDxCall" ) . value . length > 0 ) {
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
}
2021-09-04 18:23:58 +00:00
} ;
reader . onerror = function ( e ) {
// error occurred
console . log ( 'Error : ' + e . type ) ;
} ;
} )
2022-03-14 19:21:15 +00:00
// STOP TRANSMISSION
2021-10-02 09:29:08 +00:00
document . getElementById ( "stopTransmission" ) . addEventListener ( "click" , ( ) => {
let Data = {
2022-01-28 19:07:39 +00:00
command : "stop_transmission"
2021-10-02 09:29:08 +00:00
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
} )
2021-11-19 16:30:17 +00:00
2022-03-14 19:21:15 +00:00
// STOP TRANSMISSION AND CONNECRTION
document . getElementById ( "stop_transmission_connection" ) . addEventListener ( "click" , ( ) => {
let Data = {
command : "stop_transmission"
} ;
ipcRenderer . send ( 'run-tnc-command' , Data ) ;
sock . disconnectARQ ( ) ;
} )
2021-11-19 16:30:17 +00:00
// OPEN CHAT MODULE
document . getElementById ( "openRFChat" ) . addEventListener ( "click" , ( ) => {
let Data = {
command : "openRFChat"
} ;
ipcRenderer . send ( 'request-show-chat-window' , Data ) ;
2022-09-20 05:59:47 +00:00
} )
2021-09-04 18:23:58 +00:00
} )
2021-08-07 17:46:02 +00:00
2023-02-04 11:00:53 +00:00
//Listen for events caused by tnc 'tnc-message' receiving
ipcRenderer . on ( 'action-update-reception-status' , ( event , arg ) => {
var data = arg [ "data" ] [ 0 ] ;
//var txprog = document.getElementById("transmission_progress")
ipcRenderer . send ( 'request-show-electron-progressbar' , data . percent ) ;
// SET BYTES PER MINUTE
if ( typeof ( data . bytesperminute ) == 'undefined' ) {
var arq _bytes _per _minute = 0 ;
} else {
var arq _bytes _per _minute = data . bytesperminute ;
}
document . getElementById ( "bytes_per_min_rx" ) . textContent = arq _bytes _per _minute ;
// SET BYTES PER MINUTE COMPRESSED
var compress = data . compression ;
if ( isNaN ( compress ) ) {
compress = 1 ;
}
var arq _bytes _per _minute _compressed = Math . round ( arq _bytes _per _minute * compress ) ;
document . getElementById ( "bytes_per_min_rx" ) . setAttribute ( 'data-bs-original-title' , "raw data rate modem in bytes per minute (" + arq _bytes _per _minute _compressed + " compressed)" ) ;
if ( ! ( typeof ( data . dxcallsign ) == 'undefined' ) ) {
//console.log("Received dxcallsign(rx-status): ", data.dxcallsign);
document . getElementById ( "txtConnectedWith" ) . textContent = data . dxcallsign ;
}
} ) ;
2023-01-21 21:34:00 +00:00
//Listen for events caused by tnc 'tnc-message's
ipcRenderer . on ( 'action-update-transmission-status' , ( event , arg ) => {
var data = arg [ "data" ] [ 0 ] ;
var txprog = document . getElementById ( "transmission_progress" )
2023-01-22 06:01:13 +00:00
ipcRenderer . send ( 'request-show-electron-progressbar' , data . percent ) ;
2023-01-21 21:34:00 +00:00
txprog . setAttribute ( "aria-valuenow" , data . percent ) ;
txprog . setAttribute ( "style" , "width:" + data . percent + "%;" ) ;
2023-01-21 23:26:43 +00:00
// SET TIME LEFT UNTIL FINIHED
if ( typeof ( data . finished ) == 'undefined' ) {
var time _left = 0 ;
} else {
var arq _seconds _until _finish = data . finished
var hours = Math . floor ( arq _seconds _until _finish / 3600 ) ;
var minutes = Math . floor ( ( arq _seconds _until _finish % 3600 ) / 60 ) ;
var seconds = arq _seconds _until _finish % 60 ;
if ( hours < 0 ) {
hours = 0 ;
}
if ( minutes < 0 ) {
minutes = 0 ;
}
if ( seconds < 0 ) {
seconds = 0 ;
}
var time _left = "time left: ~ " + minutes + "min" + " " + seconds + "s" ;
}
document . getElementById ( "transmission_timeleft" ) . textContent = time _left ;
2023-01-23 03:31:13 +00:00
// SET BYTES PER MINUTE
if ( typeof ( data . bytesperminute ) == 'undefined' ) {
var arq _bytes _per _minute = 0 ;
} else {
var arq _bytes _per _minute = data . bytesperminute ;
}
document . getElementById ( "bytes_per_min" ) . textContent = arq _bytes _per _minute ;
// SET BYTES PER MINUTE COMPRESSED
2023-01-26 21:50:54 +00:00
var compress = data . compression ;
2023-01-27 19:44:36 +00:00
if ( isNaN ( compress ) ) {
compress = 1 ;
}
2023-01-24 02:15:05 +00:00
var arq _bytes _per _minute _compressed = Math . round ( arq _bytes _per _minute * compress ) ;
2023-02-04 11:00:53 +00:00
document . getElementById ( "bytes_per_min" ) . setAttribute ( 'data-bs-original-title' , "raw data rate modem in bytes per minute (" + arq _bytes _per _minute _compressed + " compressed)" ) ;
if ( ! ( typeof ( data . dxcallsign ) == 'undefined' ) ) {
//console.log("Received dxcallsign(tx-status): ", data.dxcallsign);
document . getElementById ( "txtConnectedWith" ) . textContent = data . dxcallsign ;
}
2023-01-23 03:31:13 +00:00
2023-01-21 21:34:00 +00:00
} ) ;
2021-10-02 09:29:08 +00:00
2023-01-25 03:35:58 +00:00
var slowRollTable = 4 ;
2021-07-24 07:06:22 +00:00
ipcRenderer . on ( 'action-update-tnc-state' , ( event , arg ) => {
2021-09-05 09:26:09 +00:00
// update FFT
if ( typeof ( arg . fft ) !== 'undefined' ) {
var array = JSON . parse ( "[" + arg . fft + "]" ) ;
spectrum . addData ( array [ 0 ] ) ;
2021-09-13 16:27:50 +00:00
}
2021-09-05 09:26:09 +00:00
2022-12-24 14:51:26 +00:00
if ( typeof ( arg . mycallsign ) !== 'undefined' ) {
2023-01-20 02:24:07 +00:00
updateTitle ( arg . mycallsign ) ;
2022-12-24 14:51:26 +00:00
}
2023-01-06 16:33:20 +00:00
// update mygrid information with data from tnc
if ( typeof ( arg . mygrid ) !== 'undefined' ) {
2023-01-07 11:01:54 +00:00
document . getElementById ( "myGrid" ) . value = arg . mygrid ;
2023-01-06 16:33:20 +00:00
}
2021-09-04 18:23:58 +00:00
// DATA STATE
global . rxBufferLengthTnc = arg . rx _buffer _length
2021-08-08 09:43:50 +00:00
2023-01-12 23:14:42 +00:00
// START OF SCATTER CHART
const scatterConfig = {
2021-09-05 07:26:14 +00:00
plugins : {
legend : {
2021-09-13 16:27:50 +00:00
display : false ,
2021-10-01 17:05:43 +00:00
} ,
tooltip : {
enabled : false
2021-09-13 16:27:50 +00:00
} ,
2021-10-02 07:41:41 +00:00
annotation : {
annotations : {
line1 : {
type : 'line' ,
yMin : 0 ,
yMax : 0 ,
borderColor : 'rgb(255, 99, 132)' ,
borderWidth : 2 ,
} ,
line2 : {
type : 'line' ,
xMin : 0 ,
xMax : 0 ,
borderColor : 'rgb(255, 99, 132)' ,
borderWidth : 2 ,
}
}
} ,
2021-09-05 07:26:14 +00:00
} ,
animations : false ,
scales : {
x : {
type : 'linear' ,
position : 'bottom' ,
2021-10-01 17:05:43 +00:00
display : true ,
2021-11-19 13:52:58 +00:00
min : - 80 ,
max : 80 ,
2021-10-01 17:05:43 +00:00
ticks : {
display : false
}
2021-09-05 07:26:14 +00:00
} ,
y : {
2021-10-01 17:05:43 +00:00
display : true ,
2021-11-19 13:52:58 +00:00
min : - 80 ,
max : 80 ,
2021-10-01 17:05:43 +00:00
ticks : {
2021-10-02 09:29:08 +00:00
display : false ,
2021-10-01 17:05:43 +00:00
}
2021-09-05 07:26:14 +00:00
}
}
}
2023-01-12 23:14:42 +00:00
var scatterData = arg . scatter
var newScatterData = {
2021-08-07 08:54:34 +00:00
datasets : [ {
2021-10-01 17:05:43 +00:00
//label: 'constellation diagram',
2023-01-12 23:14:42 +00:00
data : scatterData ,
options : scatterConfig ,
2021-08-07 08:54:34 +00:00
backgroundColor : 'rgb(255, 99, 132)'
} ] ,
} ;
2021-09-04 18:23:58 +00:00
if ( typeof ( arg . scatter ) == 'undefined' ) {
2022-02-08 14:27:34 +00:00
var scatterSize = 0 ;
2021-08-07 17:46:02 +00:00
} else {
2022-02-08 14:27:34 +00:00
var scatterSize = arg . scatter . length ;
2021-08-07 17:46:02 +00:00
}
2021-09-04 18:23:58 +00:00
2023-01-22 06:35:47 +00:00
if ( scatterSize > 0 && global . scatterData != newScatterData ) {
2023-01-12 23:14:42 +00:00
global . scatterData = newScatterData ;
2021-09-04 18:23:58 +00:00
2023-01-12 23:14:42 +00:00
if ( typeof ( global . scatterChart ) == 'undefined' ) {
var scatterCtx = document . getElementById ( 'scatter' ) . getContext ( '2d' ) ;
global . scatterChart = new Chart ( scatterCtx , {
2021-09-04 18:23:58 +00:00
type : 'scatter' ,
2023-01-12 23:14:42 +00:00
data : global . scatterData ,
options : scatterConfig
} ) ;
} else {
global . scatterChart . data = global . scatterData ;
global . scatterChart . update ( ) ;
}
}
// END OF SCATTER CHART
// START OF SPEED CHART
var speedDataTime = [ ]
if ( typeof ( arg . speed _list ) == 'undefined' ) {
var speed _listSize = 0 ;
} else {
var speed _listSize = arg . speed _list . length ;
}
for ( var i = 0 ; i < speed _listSize ; i ++ ) {
var timestamp = arg . speed _list [ i ] . timestamp * 1000
var h = new Date ( timestamp ) . getHours ( ) ;
var m = new Date ( timestamp ) . getMinutes ( ) ;
var s = new Date ( timestamp ) . getSeconds ( ) ;
var time = h + ':' + m + ':' + s ;
speedDataTime . push ( time )
}
var speedDataBpm = [ ]
for ( var i = 0 ; i < speed _listSize ; i ++ ) {
speedDataBpm . push ( arg . speed _list [ i ] . bpm )
}
var speedDataSnr = [ ]
for ( var i = 0 ; i < speed _listSize ; i ++ ) {
speedDataSnr . push ( arg . speed _list [ i ] . snr )
}
var speedChartConfig = {
type : 'line' ,
} ;
var newSpeedData = {
labels : speedDataTime ,
datasets : [
{
type : 'line' ,
label : 'SNR[dB]' ,
data : speedDataSnr ,
borderColor : 'rgb(255, 99, 132, 1.0)' ,
backgroundColor : 'rgba(255, 99, 132, 0.2)' ,
order : 1 ,
yAxisID : 'SNR' ,
} ,
{
type : 'bar' ,
label : 'Speed[bpm]' ,
data : speedDataBpm ,
borderColor : 'rgb(120, 100, 120, 1.0)' ,
backgroundColor : 'rgba(120, 100, 120, 0.2)' ,
order : 0 ,
yAxisID : 'SPEED' ,
}
] ,
} ;
var speedChartOptions = {
responsive : true ,
animations : true ,
cubicInterpolationMode : 'monotone' ,
tension : 0.4 ,
scales : {
SNR : {
type : 'linear' ,
ticks : { beginAtZero : true , color : 'rgb(255, 99, 132)' } ,
position : 'right' ,
} ,
SPEED : {
type : 'linear' ,
ticks : { beginAtZero : true , color : 'rgb(120, 100, 120)' } ,
position : 'left' ,
grid : {
drawOnChartArea : false , // only want the grid lines for one axis to show up
} ,
} ,
x : { ticks : { beginAtZero : true } } ,
}
}
if ( typeof ( global . speedChart ) == 'undefined' ) {
var speedCtx = document . getElementById ( 'chart' ) . getContext ( '2d' ) ;
global . speedChart = new Chart ( speedCtx , {
data : newSpeedData ,
options : speedChartOptions
2021-09-04 18:23:58 +00:00
} ) ;
2023-01-12 23:14:42 +00:00
} else {
2023-01-16 09:06:03 +00:00
if ( speedDataSnr . length > 0 ) {
2023-01-15 18:35:25 +00:00
global . speedChart . data = newSpeedData ;
global . speedChart . update ( ) ;
}
2021-08-07 17:46:02 +00:00
}
2023-01-12 23:14:42 +00:00
// END OF SPEED CHART
2021-07-24 07:06:22 +00:00
// PTT STATE
2023-01-27 07:47:55 +00:00
switch ( arg . ptt _state ) {
case 'True' :
document . getElementById ( "ptt_state" ) . className = "btn btn-sm btn-danger" ;
break ;
case 'False' :
document . getElementById ( "ptt_state" ) . className = "btn btn-sm btn-success" ;
break ;
default :
document . getElementById ( "ptt_state" ) . className = "btn btn-sm btn-secondary" ;
break ;
}
2023-02-04 05:28:28 +00:00
2022-12-26 11:11:59 +00:00
// AUDIO RECORDING
if ( arg . audio _recording == 'True' ) {
2023-01-22 06:35:47 +00:00
document . getElementById ( "startStopRecording" ) . textContent = "Stop Rec"
2022-12-26 11:11:59 +00:00
} else {
2023-01-22 06:35:47 +00:00
document . getElementById ( "startStopRecording" ) . textContent = "Start Rec"
2022-12-26 11:11:59 +00:00
}
2022-02-15 17:10:14 +00:00
// CHANNEL BUSY STATE
2023-01-27 07:47:55 +00:00
switch ( arg . channel _busy ) {
case 'True' :
document . getElementById ( "channel_busy" ) . className = "btn btn-sm btn-danger" ;
break ;
case 'False' :
document . getElementById ( "channel_busy" ) . className = "btn btn-sm btn-success" ;
break ;
default :
document . getElementById ( "channel_busy" ) . className = "btn btn-sm btn-secondary" ;
break ;
}
2022-02-15 17:10:14 +00:00
2021-07-24 07:06:22 +00:00
// BUSY STATE
2023-01-27 07:47:55 +00:00
switch ( arg . busy _state ) {
case 'BUSY' :
document . getElementById ( "busy_state" ) . className = "btn btn-sm btn-danger" ;
document . getElementById ( "startTransmission" ) . disabled = true ;
break ;
case 'IDLE' :
document . getElementById ( "busy_state" ) . className = "btn btn-sm btn-success" ;
break ;
default :
document . getElementById ( "busy_state" ) . className = "btn btn-sm btn-secondary" ;
document . getElementById ( "startTransmission" ) . disabled = true ;
break ;
}
2021-07-17 07:03:40 +00:00
2021-07-24 07:06:22 +00:00
// ARQ STATE
2023-01-27 07:47:55 +00:00
switch ( arg . arq _state ) {
case 'True' :
document . getElementById ( "arq_state" ) . className = "btn btn-sm btn-warning" ;
document . getElementById ( "startTransmission" ) . disabled = false ;
break ;
default :
document . getElementById ( "arq_state" ) . className = "btn btn-sm btn-secondary" ;
document . getElementById ( "startTransmission" ) . disabled = false ;
break ;
}
2022-03-04 15:50:32 +00:00
2023-02-04 11:00:53 +00:00
// ARQ SESSION
switch ( arg . arq _session ) {
case 'True' :
document . getElementById ( "arq_session" ) . className = "btn btn-sm btn-warning" ;
break ;
default :
document . getElementById ( "arq_session" ) . className = "btn btn-sm btn-secondary" ;
break ;
}
if ( arg . arq _state == 'True' || arg . arq _session == 'True' ) {
toggleClass ( "spnConnectedWith" , "text-success" , true ) ;
if ( ! ( typeof ( arg . dxcallsign ) == 'undefined' ) ) {
//console.log("Received dxcallsign: " + arg.dxcallsign);
document . getElementById ( "txtConnectedWith" ) . textContent = arg . dxcallsign ;
}
} else {
toggleClass ( "spnConnectedWith" , "text-success" , false ) ;
}
2022-03-04 15:50:32 +00:00
2022-11-18 12:08:37 +00:00
// HAMLIB STATUS
if ( arg . hamlib _status == 'connected' ) {
document . getElementById ( "rigctld_state" ) . className = "btn btn-success btn-sm" ;
} else {
document . getElementById ( "rigctld_state" ) . className = "btn btn-secondary btn-sm" ;
}
2023-02-04 05:28:28 +00:00
// BEACON
let bcn = document . getElementById ( "startBeacon" ) ;
2022-03-04 15:50:32 +00:00
2023-01-27 07:47:55 +00:00
switch ( arg . beacon _state ) {
case 'True' :
2023-02-04 11:00:53 +00:00
bcn . disabled = true ;
2023-02-03 22:14:02 +00:00
if ( config . high _graphics . toUpperCase ( ) == "TRUE" ) {
2023-02-04 05:28:28 +00:00
bcn . className = "btn btn-sm btn-success spinner-grow force-gpu" ;
2023-02-03 22:14:02 +00:00
document . getElementById ( "txtBeacon" ) . setAttribute ( "class" , "input-group-text p-1" ) ;
} else {
bcn . className = "btn btn-sm btn-success" ;
document . getElementById ( "txtBeacon" ) . setAttribute ( "class" , "input-group-text p-1 text-success text-uppercase" ) ;
}
2023-01-27 07:47:55 +00:00
document . getElementById ( "beaconInterval" ) . disabled = true ;
document . getElementById ( "stopBeacon" ) . disabled = false ;
break ;
default :
2023-02-03 22:14:02 +00:00
document . getElementById ( "txtBeacon" ) . setAttribute ( "class" , "input-group-text p-1" ) ;
bcn . className = "btn btn-sm btn-success" ;
2023-01-27 07:47:55 +00:00
document . getElementById ( "beaconInterval" ) . disabled = false ;
2023-02-03 22:14:02 +00:00
document . getElementById ( "stopBeacon" ) . disabled = true ;
2023-02-04 11:00:53 +00:00
bcn . disabled = false ;
2023-01-27 07:47:55 +00:00
break ;
}
2022-11-18 14:19:41 +00:00
// dbfs
// https://www.moellerstudios.org/converting-amplitude-representations/
if ( dbfs _level _raw != arg . dbfs _level ) {
dbfs _level _raw = arg . dbfs _level
dbfs _level = Math . pow ( 10 , arg . dbfs _level / 20 ) * 100
2022-11-18 14:20:10 +00:00
2023-01-22 06:35:47 +00:00
document . getElementById ( "dbfs_level_value" ) . textContent = Math . round ( arg . dbfs _level ) + ' dBFS'
2023-01-20 23:21:53 +00:00
var dbfscntrl = document . getElementById ( "dbfs_level" ) ;
dbfscntrl . setAttribute ( "aria-valuenow" , dbfs _level ) ;
dbfscntrl . setAttribute ( "style" , "width:" + dbfs _level + "%;" ) ;
2022-11-18 14:19:41 +00:00
}
2021-07-24 07:06:22 +00:00
// SET FREQUENCY
2023-01-04 18:26:11 +00:00
// https://stackoverflow.com/a/2901298
var freq = arg . frequency . toString ( ) . replace ( /\B(?=(\d{3})+(?!\d))/g , "." ) ;
2023-01-22 06:35:47 +00:00
document . getElementById ( "frequency" ) . textContent = freq ;
2023-01-04 19:47:00 +00:00
//document.getElementById("newFrequency").value = arg.frequency;
2021-07-24 07:06:22 +00:00
// SET MODE
2023-01-22 06:35:47 +00:00
document . getElementById ( "mode" ) . textContent = arg . mode ;
2021-07-24 07:06:22 +00:00
2022-05-28 12:08:33 +00:00
// SET bandwidth
2023-01-22 06:35:47 +00:00
document . getElementById ( "bandwidth" ) . textContent = arg . bandwidth ;
2021-09-04 18:23:58 +00:00
2022-02-22 20:05:48 +00:00
// SET SPEED LEVEL
2023-01-27 07:47:55 +00:00
switch ( arg . speed _level ) {
case '0' :
document . getElementById ( "speed_level" ) . className = "bi bi-reception-1" ;
break ;
case '1' :
document . getElementById ( "speed_level" ) . className = "bi bi-reception-2" ;
break ;
case '2' :
document . getElementById ( "speed_level" ) . className = "bi bi-reception-3" ;
break ;
default :
document . getElementById ( "speed_level" ) . className = "bi bi-reception-4" ;
break ;
}
2022-02-22 20:05:48 +00:00
2021-09-04 18:23:58 +00:00
// SET TOTAL BYTES
if ( typeof ( arg . total _bytes ) == 'undefined' ) {
2022-02-08 14:27:34 +00:00
var total _bytes = 0 ;
2021-08-15 14:48:48 +00:00
} else {
2022-02-08 14:27:34 +00:00
var total _bytes = arg . total _bytes ;
2021-09-04 18:23:58 +00:00
}
2023-01-22 06:35:47 +00:00
document . getElementById ( "total_bytes" ) . textContent = total _bytes ;
2023-01-21 21:34:00 +00:00
2021-09-04 18:23:58 +00:00
2023-01-25 03:35:58 +00:00
//Ensure heard station table is last so we can return if we don't want to update it
//Only update heard stations every 5 iterations
//Allows for single click event to work more reliabily to populate dxcall textbox
//Should also save some CPU
slowRollTable ++ ;
2023-01-27 19:44:36 +00:00
if ( slowRollTable != 5 ) {
2023-01-25 03:35:58 +00:00
return ;
2023-01-27 19:44:36 +00:00
}
2023-01-25 03:35:58 +00:00
slowRollTable = 0 ;
2021-09-13 16:27:50 +00:00
// UPDATE HEARD STATIONS
2021-09-04 18:23:58 +00:00
var tbl = document . getElementById ( "heardstations" ) ;
2022-02-08 14:27:34 +00:00
document . getElementById ( "heardstations" ) . innerHTML = '' ;
2021-08-07 18:57:36 +00:00
2021-09-04 18:23:58 +00:00
if ( typeof ( arg . stations ) == 'undefined' ) {
2022-02-08 14:27:34 +00:00
var heardStationsLength = 0 ;
2021-08-08 09:09:18 +00:00
} else {
2022-02-08 14:27:34 +00:00
var heardStationsLength = arg . stations . length ;
2021-08-08 09:09:18 +00:00
}
2021-08-07 18:57:36 +00:00
2021-09-04 18:23:58 +00:00
for ( i = 0 ; i < heardStationsLength ; i ++ ) {
2021-08-07 18:57:36 +00:00
// first we update the PING window
2023-01-21 08:25:45 +00:00
if ( arg . stations [ i ] [ 'dxcallsign' ] == document . getElementById ( "dxCall" ) . value . toUpperCase ( ) ) {
2022-02-08 14:27:34 +00:00
var dxGrid = arg . stations [ i ] [ 'dxgrid' ] ;
var myGrid = document . getElementById ( "myGrid" ) . value ;
2021-09-04 18:23:58 +00:00
try {
var dist = parseInt ( distance ( myGrid , dxGrid ) ) + ' km' ;
2023-01-22 06:35:47 +00:00
document . getElementById ( "dataModalPingDistance" ) . textContent = dist ;
2021-09-04 18:23:58 +00:00
} catch {
2023-01-22 06:35:47 +00:00
document . getElementById ( "dataModalPingDistance" ) . textContent = '---' ;
2021-09-04 18:23:58 +00:00
}
2023-01-22 06:35:47 +00:00
document . getElementById ( "dataModalPingDB" ) . textContent = arg . stations [ i ] [ 'snr' ] ;
2021-08-07 18:57:36 +00:00
}
// now we update the heard stations list
var row = document . createElement ( "tr" ) ;
2021-09-13 16:27:50 +00:00
//https://stackoverflow.com/q/51421470
2021-08-07 18:57:36 +00:00
2021-09-13 16:27:50 +00:00
//https://stackoverflow.com/a/847196
2022-02-08 14:27:34 +00:00
timestampRaw = arg . stations [ i ] [ 'timestamp' ] ;
2021-08-07 18:57:36 +00:00
var date = new Date ( timestampRaw * 1000 ) ;
var hours = date . getHours ( ) ;
var minutes = "0" + date . getMinutes ( ) ;
var seconds = "0" + date . getSeconds ( ) ;
var datetime = hours + ':' + minutes . substr ( - 2 ) + ':' + seconds . substr ( - 2 ) ;
var timestamp = document . createElement ( "td" ) ;
var timestampText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
timestampText . innerText = datetime ;
2021-08-07 18:57:36 +00:00
timestamp . appendChild ( timestampText ) ;
2021-10-24 12:44:55 +00:00
var frequency = document . createElement ( "td" ) ;
var frequencyText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
frequencyText . innerText = arg . stations [ i ] [ 'frequency' ] ;
2021-10-24 12:44:55 +00:00
frequency . appendChild ( frequencyText ) ;
2021-08-07 18:57:36 +00:00
var dxCall = document . createElement ( "td" ) ;
var dxCallText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
dxCallText . innerText = arg . stations [ i ] [ 'dxcallsign' ] ;
2023-01-25 03:30:15 +00:00
let dxCallTextCall = dxCallText . innerText ;
row . addEventListener ( "click" , function ( ) {
document . getElementById ( "dxCall" ) . value = dxCallTextCall ;
2023-01-21 08:25:45 +00:00
} ) ;
2021-08-07 18:57:36 +00:00
dxCall . appendChild ( dxCallText ) ;
var dxGrid = document . createElement ( "td" ) ;
var dxGridText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
dxGridText . innerText = arg . stations [ i ] [ 'dxgrid' ] ;
2021-08-07 18:57:36 +00:00
dxGrid . appendChild ( dxGridText ) ;
2021-08-08 17:29:18 +00:00
var gridDistance = document . createElement ( "td" ) ;
var gridDistanceText = document . createElement ( 'span' ) ;
2021-09-04 18:23:58 +00:00
try {
2023-02-04 11:22:26 +00:00
if ( arg . stations [ i ] [ 'dxgrid' ] . toString ( ) != "------" ) {
gridDistanceText . innerText = parseInt ( distance ( document . getElementById ( "myGrid" ) . value , arg . stations [ i ] [ 'dxgrid' ] ) ) + ' km' ;
} else {
gridDistanceText . innerText = '---' ;
}
2021-08-08 17:29:18 +00:00
} catch {
2022-02-08 14:27:34 +00:00
gridDistanceText . innerText = '---' ;
2021-08-08 17:29:18 +00:00
}
2021-09-04 18:23:58 +00:00
gridDistance . appendChild ( gridDistanceText ) ;
2021-08-07 18:57:36 +00:00
var dataType = document . createElement ( "td" ) ;
var dataTypeText = document . createElement ( 'span' ) ;
2022-02-21 11:20:36 +00:00
dataTypeText . innerText = arg . stations [ i ] [ 'datatype' ] ;
dataType . appendChild ( dataTypeText ) ;
2023-02-04 05:28:28 +00:00
2023-01-27 07:47:55 +00:00
switch ( arg . stations [ i ] [ 'datatype' ] ) {
case 'DATA-CHANNEL' :
dataTypeText . innerText = 'DATA-C' ;
dataType . appendChild ( dataTypeText ) ;
break ;
case 'SESSION-HB' :
dataTypeText . innerHTML = '<i class="bi bi-heart-pulse-fill"></i>' ;
dataType . appendChild ( dataTypeText ) ;
break ;
}
2021-09-04 18:23:58 +00:00
2023-01-27 07:47:55 +00:00
switch ( dataTypeText . innerText ) {
case 'CQ CQ CQ' :
row . classList . add ( "table-success" ) ;
break ;
case 'DATA-C' :
dataTypeText . innerHTML = '<i class="bi bi-file-earmark-binary-fill"></i>' ;
row . classList . add ( "table-warning" ) ;
break ;
case 'BEACON' :
row . classList . add ( "table-light" ) ;
break ;
case 'PING' :
row . classList . add ( "table-info" ) ;
break ;
case 'PING-ACK' :
row . classList . add ( "table-primary" ) ;
break ;
}
2021-08-07 18:57:36 +00:00
var snr = document . createElement ( "td" ) ;
var snrText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
snrText . innerText = arg . stations [ i ] [ 'snr' ] ;
2021-08-07 18:57:36 +00:00
snr . appendChild ( snrText ) ;
2021-09-04 18:23:58 +00:00
2021-10-24 12:44:55 +00:00
var offset = document . createElement ( "td" ) ;
var offsetText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
offsetText . innerText = arg . stations [ i ] [ 'offset' ] ;
2021-10-24 12:44:55 +00:00
offset . appendChild ( offsetText ) ;
2021-08-07 18:57:36 +00:00
row . appendChild ( timestamp ) ;
2021-10-24 12:44:55 +00:00
row . appendChild ( frequency ) ;
2021-08-07 18:57:36 +00:00
row . appendChild ( dxCall ) ;
row . appendChild ( dxGrid ) ;
2021-08-08 17:29:18 +00:00
row . appendChild ( gridDistance ) ;
2021-08-07 18:57:36 +00:00
row . appendChild ( dataType ) ;
row . appendChild ( snr ) ;
2021-10-24 12:44:55 +00:00
row . appendChild ( offset ) ;
2021-08-07 18:57:36 +00:00
tbl . appendChild ( row ) ;
}
2021-07-17 07:03:40 +00:00
2021-09-04 18:23:58 +00:00
} ) ;
2021-07-17 07:03:40 +00:00
ipcRenderer . on ( 'action-update-daemon-state' , ( event , arg ) => {
2021-11-07 11:17:23 +00:00
/ *
// deactivetd RAM und CPU view so we dont get errors. We need to find a new place for this feature
2021-07-25 14:18:29 +00:00
// RAM
document . getElementById ( "progressbar_ram" ) . setAttribute ( "aria-valuenow" , arg . ram _usage )
document . getElementById ( "progressbar_ram" ) . setAttribute ( "style" , "width:" + arg . ram _usage + "%;" )
document . getElementById ( "progressbar_ram_value" ) . innerHTML = arg . ram _usage + "%"
2021-08-07 08:54:34 +00:00
2021-07-25 14:18:29 +00:00
// CPU
document . getElementById ( "progressbar_cpu" ) . setAttribute ( "aria-valuenow" , arg . cpu _usage )
document . getElementById ( "progressbar_cpu" ) . setAttribute ( "style" , "width:" + arg . cpu _usage + "%;" )
document . getElementById ( "progressbar_cpu_value" ) . innerHTML = arg . cpu _usage + "%"
2021-11-07 11:17:23 +00:00
* /
2022-02-08 14:27:34 +00:00
/ *
2022-01-05 13:15:59 +00:00
document . getElementById ( "ram_load" ) . innerHTML = arg . ram _usage + "%"
document . getElementById ( "cpu_load" ) . innerHTML = arg . cpu _usage + "%"
2022-02-08 14:27:34 +00:00
* /
2021-12-20 17:05:00 +00:00
// OPERATING SYSTEM
2022-01-05 13:15:59 +00:00
//document.getElementById("operating_system").innerHTML = "OS " + os.type()
2021-12-20 17:05:00 +00:00
2022-02-02 20:12:16 +00:00
/ *
2021-12-20 17:05:00 +00:00
// PYTHON VERSION
document . getElementById ( "python_version" ) . innerHTML = "Python " + arg . python _version
document . getElementById ( "python_version" ) . className = "btn btn-sm btn-success" ;
2022-02-02 20:12:16 +00:00
* /
/ *
2021-12-20 17:05:00 +00:00
// HAMLIB VERSION
document . getElementById ( "hamlib_version" ) . innerHTML = "Hamlib " + arg . hamlib _version
document . getElementById ( "hamlib_version" ) . className = "btn btn-sm btn-success" ;
2022-02-02 20:12:16 +00:00
* /
/ *
2021-12-20 17:05:00 +00:00
// NODE VERSION
document . getElementById ( "node_version" ) . innerHTML = "Node " + process . version
document . getElementById ( "node_version" ) . className = "btn btn-sm btn-success" ;
2022-02-02 20:12:16 +00:00
* /
2021-12-20 17:05:00 +00:00
2021-07-24 07:06:22 +00:00
// UPDATE AUDIO INPUT
2021-10-07 19:04:23 +00:00
if ( arg . tnc _running _state == "stopped" ) {
if ( document . getElementById ( "audio_input_selectbox" ) . length != arg . input _devices . length ) {
2022-02-08 14:27:34 +00:00
document . getElementById ( "audio_input_selectbox" ) . innerHTML = "" ;
2021-10-07 19:04:23 +00:00
for ( i = 0 ; i < arg . input _devices . length ; i ++ ) {
var option = document . createElement ( "option" ) ;
2022-01-28 19:07:39 +00:00
option . text = arg . input _devices [ i ] [ 'name' ] ;
option . value = arg . input _devices [ i ] [ 'id' ] ;
2021-12-27 12:26:56 +00:00
// set device from config if available
2021-12-27 14:28:58 +00:00
2021-12-27 12:26:56 +00:00
if ( config . rx _audio == option . text ) {
option . setAttribute ( 'selected' , true ) ;
}
2021-10-07 19:04:23 +00:00
document . getElementById ( "audio_input_selectbox" ) . add ( option ) ;
}
2021-07-17 07:03:40 +00:00
}
}
// UPDATE AUDIO OUTPUT
2021-10-07 19:04:23 +00:00
if ( arg . tnc _running _state == "stopped" ) {
if ( document . getElementById ( "audio_output_selectbox" ) . length != arg . output _devices . length ) {
2022-02-08 14:27:34 +00:00
document . getElementById ( "audio_output_selectbox" ) . innerHTML = "" ;
2021-10-07 19:04:23 +00:00
for ( i = 0 ; i < arg . output _devices . length ; i ++ ) {
var option = document . createElement ( "option" ) ;
2022-01-28 19:07:39 +00:00
option . text = arg . output _devices [ i ] [ 'name' ] ;
option . value = arg . output _devices [ i ] [ 'id' ] ;
2021-12-27 12:26:56 +00:00
// set device from config if available
if ( config . tx _audio == option . text ) {
option . setAttribute ( 'selected' , true ) ;
}
2021-10-07 19:04:23 +00:00
document . getElementById ( "audio_output_selectbox" ) . add ( option ) ;
}
2021-07-17 07:03:40 +00:00
}
}
2021-07-24 07:06:22 +00:00
2021-09-04 20:27:01 +00:00
// UPDATE SERIAL DEVICES
2021-10-07 19:04:23 +00:00
if ( arg . tnc _running _state == "stopped" ) {
if ( document . getElementById ( "hamlib_deviceport" ) . length != arg . serial _devices . length ) {
2022-02-08 14:27:34 +00:00
document . getElementById ( "hamlib_deviceport" ) . innerHTML = "" ;
2021-10-07 19:04:23 +00:00
for ( i = 0 ; i < arg . serial _devices . length ; i ++ ) {
var option = document . createElement ( "option" ) ;
2022-03-26 09:10:03 +00:00
option . text = arg . serial _devices [ i ] [ 'port' ] + ' -- ' + arg . serial _devices [ i ] [ 'description' ] ;
2022-01-28 19:07:39 +00:00
option . value = arg . serial _devices [ i ] [ 'port' ] ;
2021-12-27 12:26:56 +00:00
// set device from config if available
2022-10-03 14:38:08 +00:00
if ( config . hamlib _deviceport == option . value ) {
2021-12-27 12:26:56 +00:00
option . setAttribute ( 'selected' , true ) ;
}
2021-10-07 19:04:23 +00:00
document . getElementById ( "hamlib_deviceport" ) . add ( option ) ;
2022-01-18 18:38:05 +00:00
2021-10-07 19:04:23 +00:00
}
2021-09-04 20:27:01 +00:00
}
2022-01-18 18:38:05 +00:00
2022-09-20 05:59:47 +00:00
2022-01-18 18:38:05 +00:00
2021-09-04 20:27:01 +00:00
}
2022-01-18 18:38:05 +00:00
2021-10-07 19:04:23 +00:00
if ( arg . tnc _running _state == "stopped" ) {
2022-09-23 09:17:59 +00:00
if ( document . getElementById ( "hamlib_ptt_port" ) . length != arg . serial _devices . length ) {
document . getElementById ( "hamlib_ptt_port" ) . innerHTML = "" ;
2021-10-07 19:04:23 +00:00
for ( i = 0 ; i < arg . serial _devices . length ; i ++ ) {
var option = document . createElement ( "option" ) ;
2022-01-28 19:07:39 +00:00
option . text = arg . serial _devices [ i ] [ 'description' ] ;
option . value = arg . serial _devices [ i ] [ 'port' ] ;
2021-12-27 12:26:56 +00:00
// set device from config if available
2022-10-03 14:38:08 +00:00
if ( config . hamlib _pttport == option . value ) {
2021-12-27 12:26:56 +00:00
option . setAttribute ( 'selected' , true ) ;
}
2022-09-23 09:17:59 +00:00
document . getElementById ( "hamlib_ptt_port" ) . add ( option ) ;
2021-10-07 19:04:23 +00:00
}
2021-10-17 13:57:41 +00:00
}
2021-09-13 18:02:14 +00:00
}
2022-02-12 15:34:47 +00:00
} ) ;
// ACTION UPDATE HAMLIB TEST
ipcRenderer . on ( 'action-update-hamlib-test' , ( event , arg ) => {
console . log ( arg . hamlib _result ) ;
if ( arg . hamlib _result == 'SUCCESS' ) {
document . getElementById ( "testHamlib" ) . className = "btn btn-sm btn-success" ;
// BUTTON HAS BEEN REMOVED
//document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-success";
}
if ( arg . hamlib _result == 'NOSUCCESS' ) {
document . getElementById ( "testHamlib" ) . className = "btn btn-sm btn-warning" ;
// BUTTON HAS BEEN REMOVED
//document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-warning";
}
if ( arg . hamlib _result == 'FAILED' ) {
document . getElementById ( "testHamlib" ) . className = "btn btn-sm btn-danger" ;
// BUTTON HAS BEEN REMOVED
//document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-danger";
}
} ) ;
ipcRenderer . on ( 'action-update-daemon-connection' , ( event , arg ) => {
if ( arg . daemon _connection == 'open' ) {
document . getElementById ( "daemon_connection_state" ) . className = "btn btn-success" ;
//document.getElementById("blurdiv").style.webkitFilter = "blur(0px)";
}
if ( arg . daemon _connection == 'opening' ) {
document . getElementById ( "daemon_connection_state" ) . className = "btn btn-warning" ;
//document.getElementById("blurdiv").style.webkitFilter = "blur(10px)";
}
if ( arg . daemon _connection == 'closed' ) {
document . getElementById ( "daemon_connection_state" ) . className = "btn btn-danger" ;
//document.getElementById("blurdiv").style.webkitFilter = "blur(10px)";
}
} ) ;
2022-10-05 10:41:36 +00:00
ipcRenderer . on ( 'action-update-tnc-connection' , ( event , arg ) => {
2022-02-12 15:34:47 +00:00
if ( arg . tnc _connection == "open" ) {
2022-09-23 09:17:59 +00:00
/ *
2022-02-08 14:27:34 +00:00
document . getElementById ( 'hamlib_deviceid' ) . disabled = true ;
document . getElementById ( 'hamlib_deviceport' ) . disabled = true ;
document . getElementById ( 'testHamlib' ) . disabled = true ;
document . getElementById ( 'hamlib_ptt_protocol' ) . disabled = true ;
document . getElementById ( 'audio_input_selectbox' ) . disabled = true ;
document . getElementById ( 'audio_output_selectbox' ) . disabled = true ;
2022-02-15 17:10:14 +00:00
//document.getElementById('stopTNC').disabled = false;
2022-02-08 14:27:34 +00:00
document . getElementById ( 'startTNC' ) . disabled = true ;
document . getElementById ( 'dxCall' ) . disabled = false ;
document . getElementById ( "hamlib_serialspeed" ) . disabled = true ;
document . getElementById ( "openDataModule" ) . disabled = false ;
2022-09-23 09:17:59 +00:00
* /
2021-08-28 16:46:49 +00:00
2021-11-07 11:17:23 +00:00
// collapse settings screen
var collapseFirstRow = new bootstrap . Collapse ( document . getElementById ( 'collapseFirstRow' ) , { toggle : false } )
2022-02-08 14:27:34 +00:00
collapseFirstRow . hide ( ) ;
2021-11-07 11:17:23 +00:00
var collapseSecondRow = new bootstrap . Collapse ( document . getElementById ( 'collapseSecondRow' ) , { toggle : false } )
2022-02-08 14:27:34 +00:00
collapseSecondRow . hide ( ) ;
2021-11-07 11:17:23 +00:00
var collapseThirdRow = new bootstrap . Collapse ( document . getElementById ( 'collapseThirdRow' ) , { toggle : false } )
2022-02-08 14:27:34 +00:00
collapseThirdRow . show ( ) ;
2021-12-20 17:05:00 +00:00
var collapseFourthRow = new bootstrap . Collapse ( document . getElementById ( 'collapseFourthRow' ) , { toggle : false } )
2023-01-27 03:55:55 +00:00
collapseFourthRow . show ( ) ;
//Set tuning for fancy graphics mode (high/low CPU)
set _CPU _mode ( ) ;
2021-07-17 07:03:40 +00:00
} else {
2022-09-23 09:17:59 +00:00
/ *
2022-02-08 14:27:34 +00:00
document . getElementById ( 'hamlib_deviceid' ) . disabled = false ;
document . getElementById ( 'hamlib_deviceport' ) . disabled = false ;
document . getElementById ( 'testHamlib' ) . disabled = false ;
document . getElementById ( 'hamlib_ptt_protocol' ) . disabled = false ;
document . getElementById ( 'audio_input_selectbox' ) . disabled = false ;
document . getElementById ( 'audio_output_selectbox' ) . disabled = false ;
2022-02-15 17:10:14 +00:00
//document.getElementById('stopTNC').disabled = true;
2022-02-08 14:27:34 +00:00
document . getElementById ( 'startTNC' ) . disabled = false ;
document . getElementById ( 'dxCall' ) . disabled = true ;
document . getElementById ( "hamlib_serialspeed" ) . disabled = false ;
document . getElementById ( "openDataModule" ) . disabled = true ;
2022-09-23 09:17:59 +00:00
* /
2021-11-07 11:17:23 +00:00
// collapse settings screen
var collapseFirstRow = new bootstrap . Collapse ( document . getElementById ( 'collapseFirstRow' ) , { toggle : false } )
2022-02-08 14:27:34 +00:00
collapseFirstRow . show ( ) ;
2021-11-07 11:17:23 +00:00
var collapseSecondRow = new bootstrap . Collapse ( document . getElementById ( 'collapseSecondRow' ) , { toggle : false } )
2022-02-08 14:27:34 +00:00
collapseSecondRow . show ( ) ;
2021-11-07 11:17:23 +00:00
var collapseThirdRow = new bootstrap . Collapse ( document . getElementById ( 'collapseThirdRow' ) , { toggle : false } )
2022-02-08 14:27:34 +00:00
collapseThirdRow . hide ( ) ;
2021-12-20 17:05:00 +00:00
var collapseFourthRow = new bootstrap . Collapse ( document . getElementById ( 'collapseFourthRow' ) , { toggle : false } )
2022-02-08 14:27:34 +00:00
collapseFourthRow . hide ( ) ;
2021-10-17 13:57:41 +00:00
}
2021-07-25 14:35:50 +00:00
2021-07-17 07:03:40 +00:00
2021-07-24 07:06:22 +00:00
} ) ;
2021-07-17 07:03:40 +00:00
2021-10-17 13:57:41 +00:00
2021-08-22 15:00:18 +00:00
ipcRenderer . on ( 'action-update-rx-buffer' , ( event , arg ) => {
2022-01-30 13:16:08 +00:00
2022-02-08 14:27:34 +00:00
var data = arg . data [ "data" ] ;
2021-08-22 15:00:18 +00:00
var tbl = document . getElementById ( "rx-data" ) ;
2022-02-08 14:27:34 +00:00
document . getElementById ( "rx-data" ) . innerHTML = '' ;
2021-08-22 15:32:56 +00:00
2022-01-30 13:16:08 +00:00
2021-08-23 14:24:49 +00:00
for ( i = 0 ; i < arg . data . length ; i ++ ) {
2021-08-22 15:32:56 +00:00
2021-08-07 08:54:34 +00:00
// first we update the PING window
2023-01-21 08:25:45 +00:00
if ( arg . data [ i ] [ 'dxcallsign' ] == document . getElementById ( "dxCall" ) . value . toUpperCase ( ) ) {
2021-09-24 14:43:45 +00:00
/ *
// if we are sending data without doing a ping before, we don't have a grid locator available. This could be a future feature for the TNC!
if ( arg . data [ i ] [ 'DXGRID' ] != '' ) {
document . getElementById ( "pingDistance" ) . innerHTML = arg . stations [ i ] [ 'DXGRID' ]
}
* /
2023-01-21 08:25:45 +00:00
//document.getElementById("pingDB").innerHTML = arg.stations[i]['snr'];
document . getElementById ( "dataModalPingDB" ) . innerHTML = arg . stations [ i ] [ 'snr' ] ;
2021-08-07 08:54:34 +00:00
}
2021-07-28 16:44:10 +00:00
2022-01-30 13:16:08 +00:00
2021-09-24 14:43:45 +00:00
// now we update the received files list
2021-07-19 19:01:38 +00:00
2021-08-07 08:54:34 +00:00
var row = document . createElement ( "tr" ) ;
2021-09-13 16:27:50 +00:00
//https://stackoverflow.com/q/51421470
2021-07-25 16:19:51 +00:00
2021-09-13 16:27:50 +00:00
//https://stackoverflow.com/a/847196
2022-01-28 19:07:39 +00:00
timestampRaw = arg . data [ i ] [ 'timestamp' ]
2021-08-07 08:54:34 +00:00
var date = new Date ( timestampRaw * 1000 ) ;
var hours = date . getHours ( ) ;
var minutes = "0" + date . getMinutes ( ) ;
var seconds = "0" + date . getSeconds ( ) ;
var datetime = hours + ':' + minutes . substr ( - 2 ) + ':' + seconds . substr ( - 2 ) ;
2021-07-25 16:19:51 +00:00
2021-08-07 08:54:34 +00:00
var timestamp = document . createElement ( "td" ) ;
var timestampText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
timestampText . innerText = datetime ;
2021-08-07 08:54:34 +00:00
timestamp . appendChild ( timestampText ) ;
2021-07-25 16:19:51 +00:00
2021-08-07 08:54:34 +00:00
var dxCall = document . createElement ( "td" ) ;
var dxCallText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
dxCallText . innerText = arg . data [ i ] [ 'dxcallsign' ] ;
2021-08-07 08:54:34 +00:00
dxCall . appendChild ( dxCallText ) ;
2021-07-25 16:19:51 +00:00
2021-09-04 18:23:58 +00:00
/ *
var dxGrid = document . createElement ( "td" ) ;
var dxGridText = document . createElement ( 'span' ) ;
dxGridText . innerText = arg . data [ i ] [ 'DXGRID' ]
dxGrid . appendChild ( dxGridText ) ;
* /
2021-08-07 08:54:34 +00:00
2022-02-08 14:27:34 +00:00
console . log ( arg . data ) ;
2022-02-02 20:12:16 +00:00
2022-02-08 14:27:34 +00:00
var encoded _data = atob ( arg . data [ i ] [ 'data' ] ) ;
var splitted _data = encoded _data . split ( split _char ) ;
console . log ( splitted _data ) ;
2022-02-02 20:12:16 +00:00
2021-08-22 15:23:36 +00:00
var fileName = document . createElement ( "td" ) ;
var fileNameText = document . createElement ( 'span' ) ;
2022-02-08 14:27:34 +00:00
//var fileNameString = arg.data[i]['data'][0]['fn'];
var fileNameString = splitted _data [ 1 ] ;
2022-02-02 20:12:16 +00:00
2022-01-30 13:16:08 +00:00
2022-02-08 14:27:34 +00:00
fileNameText . innerText = fileNameString ;
2021-08-22 15:23:36 +00:00
fileName . appendChild ( fileNameText ) ;
2021-08-07 08:54:34 +00:00
row . appendChild ( timestamp ) ;
row . appendChild ( dxCall ) ;
2021-09-04 18:23:58 +00:00
// row.appendChild(dxGrid);
2021-08-22 15:23:36 +00:00
row . appendChild ( fileName ) ;
2021-08-07 08:54:34 +00:00
tbl . appendChild ( row ) ;
2021-09-04 18:23:58 +00:00
2021-09-10 14:50:48 +00:00
// https://stackoverflow.com/a/26227660
2022-03-14 19:21:15 +00:00
//var appDataFolder = process.env.HOME;
//console.log("appDataFolder:" + appDataFolder);
//var applicationFolder = path.join(appDataFolder, "FreeDATA");
//console.log(applicationFolder);
2022-03-10 18:45:37 +00:00
//var receivedFilesFolder = path.join(applicationFolder, "receivedFiles");
var receivedFilesFolder = path . join ( config . received _files _folder ) ;
2022-03-14 19:21:15 +00:00
2022-02-08 14:27:34 +00:00
console . log ( "receivedFilesFolder: " + receivedFilesFolder ) ;
2021-09-10 15:59:33 +00:00
// Creates receivedFiles folder if not exists
2021-08-23 13:36:14 +00:00
// https://stackoverflow.com/a/13544465
2021-09-10 15:59:33 +00:00
fs . mkdir ( receivedFilesFolder , {
2021-09-04 18:23:58 +00:00
recursive : true
} , function ( err ) {
2021-08-23 13:36:14 +00:00
console . log ( err ) ;
2021-08-22 16:04:49 +00:00
} ) ;
2021-09-04 18:23:58 +00:00
2021-09-10 15:59:33 +00:00
2022-01-30 13:16:08 +00:00
// write file to data folder
2022-02-02 20:12:16 +00:00
////var base64String = arg.data[i]['data'][0]['d']
2021-08-23 13:36:14 +00:00
// remove header from base64 String
// https://www.codeblocq.com/2016/04/Convert-a-base64-string-to-a-file-in-Node/
2022-02-02 20:12:16 +00:00
////var base64Data = base64String.split(';base64,').pop()
2021-08-22 16:00:42 +00:00
//write data to file
2022-02-08 14:27:34 +00:00
var base64Data = splitted _data [ 4 ] ;
2021-09-10 15:59:33 +00:00
var receivedFile = path . join ( receivedFilesFolder , fileNameString ) ;
2022-02-08 14:27:34 +00:00
console . log ( receivedFile ) ;
2021-09-10 15:59:33 +00:00
2022-02-02 20:12:16 +00:00
require ( "fs" ) . writeFile ( receivedFile , base64Data , 'binary' , function ( err ) {
//require("fs").writeFile(receivedFile, base64Data, 'base64', function(err) {
2021-08-22 16:00:42 +00:00
console . log ( err ) ;
2021-09-04 18:23:58 +00:00
} ) ;
2021-08-07 08:54:34 +00:00
}
} ) ;
2021-08-22 15:00:18 +00:00
2021-07-24 07:06:22 +00:00
ipcRenderer . on ( 'run-tnc-command' , ( event , arg ) => {
2022-03-11 12:10:46 +00:00
2022-01-28 19:07:39 +00:00
if ( arg . command == 'save_my_call' ) {
2022-02-08 14:27:34 +00:00
sock . saveMyCall ( arg . callsign ) ;
2021-07-19 19:01:38 +00:00
}
2022-01-28 19:07:39 +00:00
if ( arg . command == 'save_my_grid' ) {
2022-02-08 14:27:34 +00:00
sock . saveMyGrid ( arg . grid ) ;
2021-07-19 19:01:38 +00:00
}
2021-07-24 07:06:22 +00:00
if ( arg . command == 'ping' ) {
2022-02-08 14:27:34 +00:00
sock . sendPing ( arg . dxcallsign ) ;
2021-07-24 07:06:22 +00:00
}
2021-08-07 08:54:34 +00:00
2022-01-28 19:07:39 +00:00
if ( arg . command == 'send_file' ) {
2022-02-08 14:27:34 +00:00
sock . sendFile ( arg . dxcallsign , arg . mode , arg . frames , arg . filename , arg . filetype , arg . data , arg . checksum ) ;
2021-07-26 16:09:04 +00:00
}
2022-01-28 19:07:39 +00:00
if ( arg . command == 'send_message' ) {
2022-03-14 19:21:15 +00:00
sock . sendMessage ( arg . dxcallsign , arg . mode , arg . frames , arg . data , arg . checksum , arg . uuid , arg . command ) ;
2021-08-07 08:54:34 +00:00
}
2022-01-28 19:07:39 +00:00
if ( arg . command == 'stop_transmission' ) {
2022-02-08 14:27:34 +00:00
sock . stopTransmission ( ) ;
2021-10-02 09:29:08 +00:00
}
2022-03-31 19:13:30 +00:00
if ( arg . command == 'set_tx_audio_level' ) {
sock . setTxAudioLevel ( arg . tx _audio _level ) ;
}
2022-12-26 11:27:13 +00:00
if ( arg . command == 'record_audio' ) {
sock . record _audio ( ) ;
}
2022-03-31 19:13:30 +00:00
if ( arg . command == 'send_test_frame' ) {
sock . sendTestFrame ( ) ;
2023-01-04 18:26:11 +00:00
}
if ( arg . command == 'frequency' ) {
sock . set _frequency ( arg . frequency ) ;
}
2023-01-04 19:12:03 +00:00
if ( arg . command == 'mode' ) {
sock . set _mode ( arg . mode ) ;
}
2022-03-31 19:13:30 +00:00
2022-01-28 19:07:39 +00:00
2021-09-05 09:26:09 +00:00
} ) ;
2022-02-22 14:40:33 +00:00
2022-02-22 14:53:55 +00:00
// IPC ACTION FOR AUTO UPDATER
2022-02-22 14:40:33 +00:00
ipcRenderer . on ( 'action-updater' , ( event , arg ) => {
if ( arg . status == "download-progress" ) {
2022-02-23 09:14:46 +00:00
2022-04-24 13:34:59 +00:00
var progressinfo = '('
+ Math . round ( arg . progress . transferred / 1024 )
+ 'kB /'
+ Math . round ( arg . progress . total / 1024 )
+ 'kB)'
+ ' @ '
+ Math . round ( arg . progress . bytesPerSecond / 1024 )
+ "kByte/s" ; ;
document . getElementById ( "UpdateProgressInfo" ) . innerHTML = progressinfo ;
2022-02-23 09:14:46 +00:00
2022-04-24 13:34:59 +00:00
document . getElementById ( "UpdateProgressBar" ) . setAttribute ( "aria-valuenow" , arg . progress . percent )
document . getElementById ( "UpdateProgressBar" ) . setAttribute ( "style" , "width:" + arg . progress . percent + "%;" )
2022-02-22 14:40:33 +00:00
}
if ( arg . status == "checking-for-update" ) {
2022-04-24 13:34:59 +00:00
2023-01-20 02:24:07 +00:00
//document.title = document.title + ' - v' + arg.version;
updateTitle ( config . myCall , config . tnc _host , config . tnc _port , " -v " + arg . version ) ;
document . getElementById ( "updater_status" ) . innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>'
2022-04-24 13:34:59 +00:00
document . getElementById ( "updater_status" ) . className = "btn btn-secondary btn-sm" ;
2022-04-18 09:13:53 +00:00
document . getElementById ( "update_and_install" ) . style . display = 'none' ;
2022-02-22 14:40:33 +00:00
}
if ( arg . status == "update-downloaded" ) {
2022-04-24 13:34:59 +00:00
document . getElementById ( "update_and_install" ) . removeAttribute ( "style" ) ;
document . getElementById ( "updater_status" ) . innerHTML = '<i class="bi bi-cloud-download ms-1 me-1" style="color: white;"></i>' ;
document . getElementById ( "updater_status" ) . className = "btn btn-success btn-sm" ;
2022-04-18 09:13:53 +00:00
// HERE WE NEED TO RUN THIS SOMEHOW...
//mainLog.info('quit application and install update');
//autoUpdater.quitAndInstall();
2022-02-22 14:40:33 +00:00
}
if ( arg . status == "update-not-available" ) {
2022-04-24 13:34:59 +00:00
document . getElementById ( "updater_status" ) . innerHTML = '<i class="bi bi-check2-square ms-1 me-1" style="color: white;"></i>' ;
document . getElementById ( "updater_status" ) . className = "btn btn-success btn-sm" ;
2022-04-18 09:13:53 +00:00
document . getElementById ( "update_and_install" ) . style . display = 'none' ;
2022-02-22 14:40:33 +00:00
}
if ( arg . status == "update-available" ) {
2022-04-24 13:34:59 +00:00
2022-05-01 07:44:30 +00:00
document . getElementById ( "updater_status" ) . innerHTML = '<i class="bi bi-hourglass-split ms-1 me-1" style="color: white;"></i>' ;
2022-04-24 13:34:59 +00:00
document . getElementById ( "updater_status" ) . className = "btn btn-warning btn-sm" ;
document . getElementById ( "update_and_install" ) . style . display = 'none' ;
2022-04-18 09:13:53 +00:00
2022-02-22 14:40:33 +00:00
}
if ( arg . status == "error" ) {
2022-04-24 13:34:59 +00:00
document . getElementById ( "updater_status" ) . innerHTML = '<i class="bi bi-exclamation-square ms-1 me-1" style="color: white;"></i>' ;
document . getElementById ( "updater_status" ) . className = "btn btn-danger btn-sm" ;
2022-04-18 09:13:53 +00:00
document . getElementById ( "update_and_install" ) . style . display = 'none' ;
2022-02-22 14:40:33 +00:00
}
} ) ;
2022-06-07 08:08:15 +00:00
// ----------- INFO MODAL ACTIONS -------------------------------
// CQ TRANSMITTING
ipcRenderer . on ( 'action-show-cq-toast-transmitting' , ( event , data ) => {
var toastCQsending = document . getElementById ( 'toastCQsending' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastCQsending ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// CQ RECEIVED
ipcRenderer . on ( 'action-show-cq-toast-received' , ( event , data ) => {
var toastCQreceiving = document . getElementById ( 'toastCQreceiving' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastCQreceiving ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// QRV TRANSMITTING
ipcRenderer . on ( 'action-show-qrv-toast-transmitting' , ( event , data ) => {
2022-06-09 19:31:12 +00:00
var toastQRVtransmitting = document . getElementById ( 'toastQRVtransmitting' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastQRVtransmitting ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
2022-06-07 08:08:15 +00:00
} ) ;
// QRV RECEIVED
ipcRenderer . on ( 'action-show-qrv-toast-received' , ( event , data ) => {
2022-06-09 19:31:12 +00:00
var toastQRVreceiving = document . getElementById ( 'toastQRVreceiving' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastQRVreceiving ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
2022-06-07 08:08:15 +00:00
} ) ;
// BEACON TRANSMITTING
ipcRenderer . on ( 'action-show-beacon-toast-transmitting' , ( event , data ) => {
} ) ;
// BEACON RECEIVED
ipcRenderer . on ( 'action-show-beacon-toast-received' , ( event , data ) => {
var toastBEACONreceiving = document . getElementById ( 'toastBEACONreceiving' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastBEACONreceiving ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// PING TRANSMITTING
ipcRenderer . on ( 'action-show-ping-toast-transmitting' , ( event , data ) => {
var toastPINGsending = document . getElementById ( 'toastPINGsending' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastPINGsending ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// PING RECEIVED
ipcRenderer . on ( 'action-show-ping-toast-received' , ( event , data ) => {
var toastPINGreceiving = document . getElementById ( 'toastPINGreceiving' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastPINGreceiving ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// PING RECEIVED ACK
ipcRenderer . on ( 'action-show-ping-toast-received-ack' , ( event , data ) => {
var toastPINGreceivedACK = document . getElementById ( 'toastPINGreceivedACK' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastPINGreceivedACK ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// DATA CHANNEL OPENING TOAST
ipcRenderer . on ( 'action-show-arq-toast-datachannel-opening' , ( event , data ) => {
var toastDATACHANNELopening = document . getElementById ( 'toastDATACHANNELopening' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastDATACHANNELopening ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
2022-11-17 21:17:50 +00:00
// DATA CHANNEL WAITING TOAST
ipcRenderer . on ( 'action-show-arq-toast-datachannel-waiting' , ( event , data ) => {
var toastDATACHANNELwaiting = document . getElementById ( 'toastDATACHANNELwaiting' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastDATACHANNELwaiting ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
2022-06-07 08:08:15 +00:00
// DATA CHANNEL OPEN TOAST
ipcRenderer . on ( 'action-show-arq-toast-datachannel-open' , ( event , data ) => {
var toastDATACHANNELopen = document . getElementById ( 'toastDATACHANNELopen' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastDATACHANNELopen ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// DATA CHANNEL RECEIVED OPENER TOAST
ipcRenderer . on ( 'action-show-arq-toast-datachannel-received-opener' , ( event , data ) => {
var toastDATACHANNELreceivedopener = document . getElementById ( 'toastDATACHANNELreceivedopener' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastDATACHANNELreceivedopener ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// ARQ TRANSMISSION FAILED
// TODO: use for both - transmitting and receiving --> we need to change the IDs
ipcRenderer . on ( 'action-show-arq-toast-transmission-failed' , ( event , data ) => {
document . getElementById ( "transmission_progress" ) . className = "progress-bar progress-bar-striped bg-danger" ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQtransmittingfailed ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
2023-01-22 04:13:23 +00:00
// ARQ TRANSMISSION FAILED (Version mismatch)
ipcRenderer . on ( 'action-show-arq-toast-transmission-failed-ver' , ( event , data ) => {
document . getElementById ( "transmission_progress" ) . className = "progress-bar progress-bar-striped bg-danger" ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQtransmittingfailedver ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
2022-06-07 08:08:15 +00:00
// ARQ TRANSMISSION STOPPED
// TODO: RENAME ID -- WRONG
ipcRenderer . on ( 'action-show-arq-toast-transmission-stopped' , ( event , data ) => {
var toastDATACHANNELreceivedopener = document . getElementById ( 'toastTRANSMISSIONstopped' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastDATACHANNELreceivedopener ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// ARQ TRANSMISSION FAILED
// TODO: USE FOR TX AND RX
ipcRenderer . on ( 'action-show-arq-toast-transmission-failed' , ( event , data ) => {
document . getElementById ( "transmission_progress" ) . className = "progress-bar progress-bar-striped bg-danger" ;
var toastARQreceivingfailed = document . getElementById ( 'toastARQreceivingfailed' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQreceivingfailed ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// ARQ TRANSMISSION TRANSMITTED
ipcRenderer . on ( 'action-show-arq-toast-transmission-transmitted' , ( event , data ) => {
document . getElementById ( "transmission_progress" ) . className = "progress-bar progress-bar-striped bg-success" ;
var toastARQtransmittingsuccess = document . getElementById ( 'toastARQtransmittingsuccess' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQtransmittingsuccess ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// ARQ TRANSMISSION TRANSMITTING
ipcRenderer . on ( 'action-show-arq-toast-transmission-transmitting' , ( event , data ) => {
2022-11-11 12:24:12 +00:00
//document.getElementById("toastARQtransmittingSNR").className = "progress-bar progress-bar-striped progress-bar-animated bg-primary";
var toastARQtransmittingSNR = document . getElementById ( 'toastARQtransmittingSNR' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQtransmittingSNR ) ; // Returns a Bootstrap toast instance
var irs _snr = data [ "data" ] [ 0 ] . irs _snr ;
2022-11-11 12:32:37 +00:00
2022-11-11 11:57:14 +00:00
if ( irs _snr <= 0 ) {
2022-11-11 12:24:12 +00:00
document . getElementById ( "toastARQtransmittingSNR" ) . className = "toast align-items-center text-white bg-danger border-0" ;
document . getElementById ( 'toastARQtransmittingSNRValue' ) . innerHTML = " low " + irs _snr ;
toast . show ( ) ;
2022-11-11 11:57:14 +00:00
} else if ( irs _snr > 0 && irs _snr <= 5 ) {
2022-11-11 12:24:12 +00:00
document . getElementById ( "toastARQtransmittingSNR" ) . className = "toast align-items-center text-white bg-warning border-0" ;
document . getElementById ( 'toastARQtransmittingSNRValue' ) . innerHTML = " okay " + irs _snr ;
toast . show ( ) ;
2022-11-11 13:32:08 +00:00
} else if ( irs _snr > 5 && irs _snr < 12.7 ) {
2022-11-11 12:24:12 +00:00
document . getElementById ( "toastARQtransmittingSNR" ) . className = "toast align-items-center text-white bg-success border-0" ;
2022-11-11 12:36:01 +00:00
document . getElementById ( 'toastARQtransmittingSNRValue' ) . innerHTML = " good " + irs _snr ;
toast . show ( ) ;
} else if ( irs _snr >= 12.7 ) {
document . getElementById ( "toastARQtransmittingSNR" ) . className = "toast align-items-center text-white bg-success border-0" ;
2022-11-11 14:53:29 +00:00
document . getElementById ( 'toastARQtransmittingSNRValue' ) . innerHTML = " really good 12.7+" ;
2022-11-11 12:24:12 +00:00
toast . show ( ) ;
2022-11-11 11:57:14 +00:00
} else {
console . log ( "no snr info available" )
2022-11-11 12:32:37 +00:00
document . getElementById ( "transmission_progress" ) . className = "progress-bar progress-bar-striped progress-bar-animated bg-primary" ;
var toastARQtransmitting = document . getElementById ( 'toastARQtransmitting' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQtransmitting ) ; // Returns a Bootstrap toast instance
2022-11-11 12:24:12 +00:00
toast . show ( ) ;
2022-11-11 11:57:14 +00:00
}
2022-06-07 08:08:15 +00:00
2022-11-11 12:24:12 +00:00
2022-11-11 12:32:37 +00:00
2022-06-07 08:08:15 +00:00
} ) ;
// ARQ TRANSMISSION RECEIVED
ipcRenderer . on ( 'action-show-arq-toast-transmission-received' , ( event , data ) => {
document . getElementById ( "transmission_progress" ) . className = "progress-bar progress-bar-striped bg-success" ;
var toastARQreceivingsuccess = document . getElementById ( 'toastARQreceivingsuccess' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQreceivingsuccess ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// ARQ TRANSMISSION RECEIVING
ipcRenderer . on ( 'action-show-arq-toast-transmission-receiving' , ( event , data ) => {
document . getElementById ( "transmission_progress" ) . className = "progress-bar progress-bar-striped progress-bar-animated bg-primary" ;
2022-11-17 23:03:18 +00:00
var toastARQsessionreceiving = document . getElementById ( 'toastARQreceiving' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQsessionreceiving ) ; // Returns a Bootstrap toast instance
2022-06-07 08:08:15 +00:00
toast . show ( ) ;
} ) ;
2022-06-07 09:31:59 +00:00
2022-06-15 08:51:19 +00:00
// ARQ SESSION CONNECTING
ipcRenderer . on ( 'action-show-arq-toast-session-connecting' , ( event , data ) => {
2022-11-17 23:03:18 +00:00
var toastARQsessionconnecting = document . getElementById ( 'toastARQsessionconnecting' ) ;
2022-06-15 08:51:19 +00:00
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQsessionconnecting ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// ARQ SESSION CONNECTED
ipcRenderer . on ( 'action-show-arq-toast-session-connected' , ( event , data ) => {
2022-11-17 23:03:18 +00:00
var toastARQsessionconnected = document . getElementById ( 'toastARQsessionconnected' ) ;
2022-06-15 08:51:19 +00:00
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQsessionconnected ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
2022-11-17 23:03:18 +00:00
// ARQ SESSION CONNECTED
ipcRenderer . on ( 'action-show-arq-toast-session-waiting' , ( event , data ) => {
var toastARQsessionwaiting = document . getElementById ( 'toastARQsessionwaiting' ) ;
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQsessionwaiting ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
2022-06-15 08:51:19 +00:00
// ARQ SESSION CLOSE
ipcRenderer . on ( 'action-show-arq-toast-session-close' , ( event , data ) => {
2022-11-17 23:03:18 +00:00
var toastARQsessionclose = document . getElementById ( 'toastARQsessionclose' ) ;
2022-06-15 08:51:19 +00:00
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQsessionclose ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
// ARQ SESSION FAILED
ipcRenderer . on ( 'action-show-arq-toast-session-failed' , ( event , data ) => {
2022-11-17 23:03:18 +00:00
var toastARQsessionfailed = document . getElementById ( 'toastARQsessionfailed' ) ;
2022-06-15 08:51:19 +00:00
var toast = bootstrap . Toast . getOrCreateInstance ( toastARQsessionfailed ) ; // Returns a Bootstrap toast instance
toast . show ( ) ;
} ) ;
2022-06-07 09:31:59 +00:00
2022-09-23 09:17:59 +00:00
// 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 )
2022-09-23 12:06:13 +00:00
}
setInterval ( checkRigctld , 500 )
function checkRigctld ( ) {
2022-11-08 13:54:27 +00:00
var rigctld _ip = document . getElementById ( "hamlib_rigctld_ip" ) . value ;
var rigctld _port = document . getElementById ( "hamlib_rigctld_port" ) . value ;
let Data = {
ip : rigctld _ip ,
port : rigctld _port
} ;
2023-01-27 06:55:16 +00:00
//Prevents an error on startup if hamlib settings aren't populated yet
2023-01-27 19:44:36 +00:00
if ( rigctld _port . length > 0 && rigctld _ip . length > 0 ) {
2023-01-27 06:55:16 +00:00
ipcRenderer . send ( 'request-check-rigctld' , Data ) ;
2023-01-27 19:44:36 +00:00
}
2022-09-23 12:06:13 +00:00
}
2022-11-08 13:54:27 +00:00
2022-09-23 12:06:13 +00:00
ipcRenderer . on ( 'action-check-rigctld' , ( event , data ) => {
document . getElementById ( "hamlib_rigctld_status" ) . value = data [ "state" ] ;
2022-11-08 13:54:27 +00:00
} ) ;
2023-01-22 19:36:05 +00:00
ipcRenderer . on ( 'action-set-app-version' , ( event , data ) => {
appVer = data ;
} ) ;
2023-01-20 02:24:07 +00:00
function updateTitle ( mycall = config . mycall , tnc = config . tnc _host , tncport = config . tnc _port , appender = "" ) {
//Multiple consecutive spaces get converted to a single space
2023-01-22 19:36:05 +00:00
var title = "FreeDATA " + appVer + " - Call: " + mycall + " - TNC: " + tnc + ":" + tncport + appender ;
2023-01-27 19:44:36 +00:00
if ( title != document . title ) {
2023-01-20 02:24:07 +00:00
document . title = title ;
2023-01-27 19:44:36 +00:00
}
2023-01-21 05:40:01 +00:00
}
2023-01-27 03:55:55 +00:00
//Set force to true to ensure a class is present on a control, other set to false to ensure it isn't present
function toggleClass ( control , classToToggle , force ) {
var cntrl = document . getElementById ( control ) ;
2023-01-27 19:44:36 +00:00
if ( cntrl == undefined ) {
2023-01-27 03:55:55 +00:00
//console.log("toggle class: unknown control", control);
return ;
}
var activeClasses = cntrl . getAttribute ( 'class' ) ;
//var oldactive = activeClasses;
2023-01-27 19:44:36 +00:00
if ( force == true && activeClasses . indexOf ( classToToggle ) >= 0 ) {
2023-01-27 03:55:55 +00:00
return ;
2023-01-27 19:44:36 +00:00
}
if ( force == false && activeClasses . indexOf ( classToToggle ) == - 1 ) {
2023-01-27 03:55:55 +00:00
return ;
2023-01-27 19:44:36 +00:00
}
if ( force == true ) {
2023-01-27 03:55:55 +00:00
activeClasses += " " + classToToggle ;
2023-01-27 19:44:36 +00:00
} else {
2023-01-27 03:55:55 +00:00
activeClasses = activeClasses . replace ( classToToggle , "" ) ;
2023-01-27 19:44:36 +00:00
}
2023-01-27 03:55:55 +00:00
activeClasses = activeClasses . replace ( " " , " " ) . trim ( ) ;
cntrl . setAttribute ( "class" , activeClasses ) ;
//console.log(control," toggleClass; force: ", force, "class: " ,classToToggle, " in: '" ,oldactive, "' out: '",activeClasses,"'");
}
function set _CPU _mode ( ) {
if ( config . high _graphics . toUpperCase ( ) == "FALSE" )
{
toggleClass ( "dbfs_level" , "disable-effects" , true ) ;
toggleClass ( "dbfs_level" , "progress-bar-striped" , false ) ;
toggleClass ( "waterfall" , "disable-effects" , true ) ;
toggleClass ( "transmission_progress" , "disable-effects" , true ) ;
toggleClass ( "transmission_progress" , "progress-bar-striped" , false ) ;
}
else
{
toggleClass ( "dbfs_level" , "disable-effects" , false ) ;
toggleClass ( "dbfs_level" , "progress-bar-striped" , true ) ;
toggleClass ( "waterfall" , "disable-effects" , false ) ;
toggleClass ( "transmission_progress" , "disable-effects" , false ) ;
toggleClass ( "transmission_progress" , "progress-bar-striped" , true ) ;
}
}
2023-02-03 22:14:02 +00:00
//Temporarily disable a button with timeout
2023-01-21 05:40:01 +00:00
function pauseButton ( btn , timems ) {
btn . disabled = true ;
var curText = btn . innerHTML ;
2023-02-03 22:14:02 +00:00
if ( config . high _graphics . toUpperCase ( ) == "TRUE" ) {
btn . innerHTML = "<span class=\"spinner-grow spinner-grow-sm force-gpu\" role=\"status\" aria-hidden=\"true\">" ;
}
2023-01-21 05:40:01 +00:00
setTimeout ( ( ) => {
btn . innerHTML = curText ;
btn . disabled = false ; } , timems )
2023-01-20 02:24:07 +00:00
}