diff --git a/gui/main.js b/gui/main.js index 8d77bfad..21bd4507 100644 --- a/gui/main.js +++ b/gui/main.js @@ -801,12 +801,84 @@ ipcMain.on('request-stop-rigctld',(event,data)=>{ if(os.platform()=='linux'){ exec('pkill', ['-9', 'rigctld']) + } if(os.platform()=='darwin'){ exec('pkill', ['-9', 'rigctld']) + } + } catch (e) { + mainLog.error(e) + } +}); + + + +// CHECK RIGCTLD +ipcMain.on('request-check-rigctld',(event,data)=>{ + try { + + if(os.platform()=='win32' || os.platform()=='win64'){ + var state = exec('tasklist', ['/svc', '/FI', 'ImageName eq rigctld*']) + state.on('close', function(code) { + if(code == 0){ + let Data = { + state: "running", + }; + win.webContents.send('action-check-rigctld', Data); + + } else { + let Data = { + state: "unknown", + }; + win.webContents.send('action-check-rigctld', Data); + + } + }); + } + + if(os.platform()=='linux'){ + + var state = exec('pgrep', ['rigctld']) + state.on('close', function(code) { + if(code == 0){ + let Data = { + state: "running", + }; + win.webContents.send('action-check-rigctld', Data); + + } else { + let Data = { + state: "unknown", + }; + win.webContents.send('action-check-rigctld', Data); + + } + }); + + } + + if(os.platform()=='darwin'){ + + var state = exec('pgrep', ['rigctld']) + state.on('close', function(code) { + if(code == 0){ + let Data = { + state: "running", + }; + win.webContents.send('action-check-rigctld', Data); + + } else { + let Data = { + state: "unknown", + }; + win.webContents.send('action-check-rigctld', Data); + + } + }); + } } catch (e) { mainLog.error(e) diff --git a/gui/preload-main.js b/gui/preload-main.js index 8e24d9a5..5fd99678 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -527,16 +527,27 @@ document.getElementById('hamlib_rigctld_path').addEventListener('click', () => { document.getElementById('hamlib_rigctld_start').addEventListener('click', () => { var rigctldPath = document.getElementById("hamlib_rigctld_path").value; + + + + var paramList = [] + var hamlib_deviceid = document.getElementById("hamlib_deviceid").value; - var hamlib_deviceport = document.getElementById("hamlib_deviceport").value; + paramList = paramList.concat('-m', hamlib_deviceid) + + if (document.getElementById('enable_hamlib_deviceport').checked){ + var hamlib_deviceport = document.getElementById("hamlib_deviceport").value; + paramList = paramList.concat('-r', hamlib_deviceport) + } + document.getElementById('hamlib_rigctld_command').value = paramList + + console.log(paramList) ipcRenderer.send('request-start-rigctld',{ path: rigctldPath, - parameters: ['-m', hamlib_deviceid, - '-r', hamlib_deviceport - ] + parameters: paramList }); @@ -2155,4 +2166,13 @@ function enable_setting(enable_switch, enable_object){ function set_setting_switch(setting_switch, enable_object, state){ document.getElementById(setting_switch).checked = state enable_setting(setting_switch, enable_object) - } \ No newline at end of file + } + +setInterval(checkRigctld, 500) +function checkRigctld(){ + ipcRenderer.send('request-check-rigctld'); +} +ipcRenderer.on('action-check-rigctld', (event, data) => { + console.log(data) + document.getElementById("hamlib_rigctld_status").value = data["state"]; +}); \ No newline at end of file diff --git a/gui/src/index.html b/gui/src/index.html index 9e0d393b..b84ed9d8 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -721,14 +721,13 @@
- Rigctld Status - - Rigctld Version - + Cmd +
start + stop