Skip to content

Commit 327c90f

Browse files
authored
Merge pull request #65 from wavelog/dev
Dev -> Master for 1.1.8
2 parents 21cd5be + b1d0148 commit 327c90f

File tree

4 files changed

+56
-33
lines changed

4 files changed

+56
-33
lines changed

main.js

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const http = require('http');
55
const xml = require("xml2js");
66
const net = require('net');
77

8+
const gotTheLock = app.requestSingleInstanceLock();
9+
810
let powerSaveBlockerId;
911
let tray;
1012
let s_mainWindow;
@@ -196,17 +198,25 @@ process.on('SIGINT', () => {
196198
});
197199

198200
app.on('will-quit', () => {
199-
powerSaveBlocker.stop(powerSaveBlockerId);
201+
try {
202+
powerSaveBlocker.stop(powerSaveBlockerId);
203+
} catch(e) {
204+
console.log(e);
205+
}
200206
});
201207

202-
app.whenReady().then(() => {
203-
powerSaveBlockerId = powerSaveBlocker.start('prevent-app-suspension');
204-
s_mainWindow=createWindow();
205-
createAdvancedWindow(s_mainWindow);
206-
globalShortcut.register('Control+Shift+I', () => { return false; });
207-
app.on('activate', function () {
208-
if (BrowserWindow.getAllWindows().length === 0) createWindow()
209-
});
208+
if (!gotTheLock) {
209+
app.quit();
210+
} else {
211+
startserver();
212+
app.whenReady().then(() => {
213+
powerSaveBlockerId = powerSaveBlocker.start('prevent-app-suspension');
214+
s_mainWindow=createWindow();
215+
createAdvancedWindow(s_mainWindow);
216+
globalShortcut.register('Control+Shift+I', () => { return false; });
217+
app.on('activate', function () {
218+
if (BrowserWindow.getAllWindows().length === 0) createWindow()
219+
});
210220
s_mainWindow.webContents.once('dom-ready', function() {
211221
if (msgbacklog.length>0) {
212222
s_mainWindow.webContents.send('updateMsg',msgbacklog.pop());
@@ -216,36 +226,37 @@ app.whenReady().then(() => {
216226
// Create the tray icon
217227
const path = require('path');
218228
const iconPath = path.join(__dirname, 'icon1616.png');
219-
tray = new Tray(iconPath);
229+
tray = new Tray(iconPath);
220230

221231
const contextMenu = Menu.buildFromTemplate([
222232
{ label: 'Show App', click: () => s_mainWindow.show() },
223-
{ label: 'Quit', click: () => {
233+
{ label: 'Quit', click: () => {
224234
console.log("Exiting");
225235
app.isQuitting = true;
226236
app.quit();
227237
}
228238
},
229239
]);
230240

231-
tray.setContextMenu(contextMenu);
232-
tray.setToolTip(require('./package.json').name + " V" + require('./package.json').version);
241+
tray.setContextMenu(contextMenu);
242+
tray.setToolTip(require('./package.json').name + " V" + require('./package.json').version);
233243

234-
s_mainWindow.on('minimize', (event) => {
235-
event.preventDefault();
236-
s_mainWindow.hide(); // Hides the window instead of minimizing it to the taskbar
237-
});
244+
s_mainWindow.on('minimize', (event) => {
245+
event.preventDefault();
246+
s_mainWindow.hide(); // Hides the window instead of minimizing it to the taskbar
247+
});
238248

239-
s_mainWindow.on('close', (event) => {
240-
if (!app.isQuitting) {
241-
event.preventDefault();
242-
s_mainWindow.hide();
243-
}
244-
});
245-
if (process.platform === 'darwin') {
246-
app.dock.hide();
249+
s_mainWindow.on('close', (event) => {
250+
if (!app.isQuitting) {
251+
event.preventDefault();
252+
s_mainWindow.hide();
247253
}
248-
})
254+
});
255+
if (process.platform === 'darwin') {
256+
app.dock.hide();
257+
}
258+
})
259+
}
249260

250261
app.on('window-all-closed', function () {
251262
if (process.platform !== 'darwin') app.quit();
@@ -299,6 +310,18 @@ function writeADIF(adifObject) {
299310
return adiWriter;
300311
}
301312

313+
function freqToBand(freq_mz) {
314+
const f = parseFloat(freq_mz);
315+
if (isNaN(f)) return null;
316+
317+
const bandMap = require('tcadif/lib/enums/Band');
318+
for (const [band, { lowerFreq, upperFreq }] of Object.entries(bandMap))
319+
if (f >= parseFloat(lowerFreq) && f <= parseFloat(upperFreq))
320+
return band;
321+
322+
return null;
323+
}
324+
302325
function send2wavelog(o_cfg,adif, dryrun = false) {
303326
let clpayload={};
304327
clpayload.key=o_cfg.wavelog_key.trim();
@@ -413,6 +436,8 @@ ports.forEach(port => {
413436
GRIDSQUARE: parsedXML.contactinfo.gridsquare[0],
414437
STATION_CALLSIGN: parsedXML.contactinfo.mycall[0]
415438
} ]};
439+
let band = freqToBand(adobject.qsos[0].FREQ);
440+
if (band) adobject.qsos[0].BAND = band;
416441
} catch (e) {}
417442
} else {
418443
try {
@@ -590,5 +615,3 @@ function fmt(spotDate) {
590615
retstr.t=h.padStart(2,'0')+i.padStart(2,'0')+s.padStart(2,'0');
591616
return retstr;
592617
}
593-
594-
startserver();

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Gateway for connecting WSJT-* and FLRig to Wavelog",
55
"keywords": [],
66
"main": "./main.js",
7-
"version": "1.1.7",
7+
"version": "1.1.8",
88
"author": "DJ7NT",
99
"scripts": {
1010
"start": "electron-forge start",

renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ window.TX_API.onUpdateMsg((value) => {
154154

155155
window.TX_API.onUpdateTX((value) => {
156156
if (value.created) {
157-
$("#log").html('<div class="alert alert-success" role="alert">'+value.qsos[0].TIME_ON+" "+value.qsos[0].CALL+" ("+(value.qsos[0].GRIDSQUARE || 'No Grid')+") on "+value.qsos[0].BAND+" (R:"+(value.qsos[0].RST_RCVD || 'No RST')+" / S:"+(value.qsos[0].RST_SENT || 'No RST')+') - OK</div>');
157+
$("#log").html('<div class="alert alert-success" role="alert">'+value.qsos[0].TIME_ON+" "+value.qsos[0].CALL+" ("+(value.qsos[0].GRIDSQUARE || 'No Grid')+") on "+(value.qsos[0].BAND || 'No BAND')+" (R:"+(value.qsos[0].RST_RCVD || 'No RST')+" / S:"+(value.qsos[0].RST_SENT || 'No RST')+') - OK</div>');
158158
} else {
159-
$("#log").html('<div class="alert alert-danger" role="alert">'+value.qsos[0].TIME_ON+" "+value.qsos[0].CALL+" ("+(value.qsos[0].GRIDSQUARE || 'No Grid')+") on "+value.qsos[0].BAND+" (R:"+(value.qsos[0].RST_RCVD || 'No RST')+" / S:"+(value.qsos[0].RST_SENT || 'No RST')+') - Error<br/>Reason: '+value.fail.payload.reason+'</div>');
159+
$("#log").html('<div class="alert alert-danger" role="alert">'+value.qsos[0].TIME_ON+" "+value.qsos[0].CALL+" ("+(value.qsos[0].GRIDSQUARE || 'No Grid')+") on "+(value.qsos[0].BAND || 'NO BAND')+" (R:"+(value.qsos[0].RST_RCVD || 'No RST')+" / S:"+(value.qsos[0].RST_SENT || 'No RST')+') - Error<br/>Reason: '+value.fail.payload.reason+'</div>');
160160
}
161161
})
162162

0 commit comments

Comments
 (0)