From 6b6c8296098e8ffcd2dd7d4e9c2d881434ac59ad Mon Sep 17 00:00:00 2001 From: Tag Date: Sun, 27 Nov 2022 13:51:21 -0800 Subject: [PATCH] More chat fixes and CQ tracking in WSJT-X --- package.nw/lib/adif.js | 3 +- package.nw/lib/gt.js | 505 ++++++++++++++--------------------------- package.nw/lib/gtws.js | 53 +++-- 3 files changed, 200 insertions(+), 361 deletions(-) diff --git a/package.nw/lib/adif.js b/package.nw/lib/adif.js index 5dc3b00..69a09b9 100644 --- a/package.nw/lib/adif.js +++ b/package.nw/lib/adif.js @@ -2394,8 +2394,7 @@ function sendLotwLogEntry(report) lotwStation.value.length > 0 ) { - var header = - "Generated " + userTimeString(null) + " for " + myDEcall + "\r\n\r\n"; + var header = "Generated " + userTimeString(null) + " for " + myDEcall + "\r\n\r\n"; var pid = "GridTracker"; var pver = String(gtVersion); header += "" + pid + "\r\n"; diff --git a/package.nw/lib/gt.js b/package.nw/lib/gt.js index 2e201a7..18813d0 100644 --- a/package.nw/lib/gt.js +++ b/package.nw/lib/gt.js @@ -175,6 +175,7 @@ loadAllSettings(); var myDEcall = g_appSettings.myDEcall; var myDEGrid = g_appSettings.myDEGrid; +var myDXGrid = ""; var myMode = g_appSettings.myMode; var myBand = g_appSettings.myBand; var myRawFreq = g_appSettings.myRawFreq; @@ -1823,67 +1824,19 @@ function createFlagTipTable(toolElement) workColor = "#00FF00"; } - worker += - "
" + - g_gtFlagPins[key].call.formatCallsign() + - "
"; + worker += "
" + g_gtFlagPins[key].call.formatCallsign() + "
"; worker += ""; + worker += ""; + worker += ""; + worker += ""; + worker += ""; - worker += - ""; - - worker += - ""; - - worker += - ""; - - worker += - ""; - - var LL = squareToLatLongAll(g_gtFlagPins[key].grid); - - var bearing = parseInt( - MyCircle.bearing( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2 - ) - ); - worker += - ""; - worker += - ""; - + var LL = squareToCenter(g_gtFlagPins[key].grid); + var bearing = parseInt(MyCircle.bearing(g_myLat, g_myLon, LL.a, LL.o)); + + worker += ""; + worker += ""; worker += "
DXCC" + dxccName + " (" + g_dxccInfo[dxcc].pp + ")
Grid" + g_gtFlagPins[key].grid + "
Freq" + Number(g_gtFlagPins[key].freq / 1000).formatMhz(3, 3) + " (" + Number(g_gtFlagPins[key].freq / 1000000).formatBand() + ")
Mode" + g_gtFlagPins[key].mode + "
DXCC" + - dxccName + - " (" + - g_dxccInfo[dxcc].pp + - ")
Grid" + - g_gtFlagPins[key].grid + - "
Freq" + - Number(g_gtFlagPins[key].freq / 1000).formatMhz(3, 3) + - " (" + - Number(g_gtFlagPins[key].freq / 1000000).formatBand() + - ")
Mode" + - g_gtFlagPins[key].mode + - "
Dist" + - parseInt( - MyCircle.distance( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2, - distanceUnit.value - ) * MyCircle.validateRadius(distanceUnit.value) - ) + - distanceUnit.value.toLowerCase() + - "
Azim" + - bearing + - "°
Dist" + parseInt(MyCircle.distance(g_myLat, g_myLon, LL.a, LL.o, distanceUnit.value) * MyCircle.validateRadius(distanceUnit.value)) + distanceUnit.value.toLowerCase() + "
Azim" + bearing + "°
"; } else if (toolElement.size == 73) @@ -1992,94 +1945,35 @@ function createSpotTipTable(toolElement) g_layerSources["psk-hop"].clear(); var report = g_receptionReports.spots[toolElement.spot]; - var LL = squareToLatLongAll(myRawGrid); - var Lat = LL.la2 - (LL.la2 - LL.la1) / 2; - var Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; - var fromPoint = ol.proj.fromLonLat([Lon, Lat]); + var LL = squareToCenter(myRawGrid); + var fromPoint = ol.proj.fromLonLat([LL.o, LL.a]); - worker = - ""; - worker += - ""; - worker += - ""; - worker += - ""; + worker = "
Rx Spot
Age" + - Number(now - report.when).toDHMS() + - "
dB" + - Number(report.snr).formatSignalReport() + - "
Call" + - report.call.formatCallsign() + - "
"; + worker += ""; + worker += ""; + worker += ""; if (report.dxcc > 0) { - worker += - ""; + worker += ""; } - worker += - ""; - worker += - ""; - worker += - ""; + worker += ""; + worker += ""; + worker += ""; - LL = squareToLatLongAll(report.grid); - - report.bearing = parseInt( - MyCircle.bearing( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2 - ) - ); - worker += - ""; - worker += - ""; - - worker += - ""; + LL = squareToCenter(report.grid); + report.bearing = parseInt(MyCircle.bearing(g_myLat, g_myLon, LL.a, LL.o)); + worker += ""; + worker += ""; + worker += ""; worker += "
Rx Spot
Age" + Number(now - report.when).toDHMS() + "
dB" + Number(report.snr).formatSignalReport() + "
Call" + report.call.formatCallsign() + "
DXCC" + - g_dxccToAltName[report.dxcc] + - " (" + - g_dxccInfo[report.dxcc].pp + - ")
DXCC" + g_dxccToAltName[report.dxcc] + " (" + g_dxccInfo[report.dxcc].pp + ")
Grid" + - report.grid + - "
Freq" + - report.freq.formatMhz() + - " (" + - report.band + - ")
Mode" + - report.mode + - "
Grid" + report.grid + "
Freq" + report.freq.formatMhz() + " (" + report.band + ")
Mode" + report.mode + "
Dist" + - parseInt( - MyCircle.distance( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2, - distanceUnit.value - ) * MyCircle.validateRadius(distanceUnit.value) - ) + - distanceUnit.value.toLowerCase() + - "
Azim" + - report.bearing + - "°
Time" + - userTimeString(report.when * 1000) + - "
Dist" + parseInt(MyCircle.distance(g_myLat, g_myLon, LL.a, LL.o, distanceUnit.value) * MyCircle.validateRadius(distanceUnit.value)) + distanceUnit.value.toLowerCase() + "
Azim" + report.bearing + "°
Time" + userTimeString(report.when * 1000) + "
"; var strokeWeight = pathWidthValue.value; + var toPoint = ol.proj.fromLonLat([LL.o, LL.a]); - Lat = LL.la2 - (LL.la2 - LL.la1) / 2; - Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; - - var toPoint = ol.proj.fromLonLat([Lon, Lat]); - - var feature = flightFeature( + flightFeature( [fromPoint, toPoint], { weight: strokeWeight, @@ -4087,6 +3981,15 @@ function twoWideToLatLong(qth) return LatLong; } +function squareToCenter(qth) +{ + var LL = squareToLatLongAll(qth); + var obj = {}; + obj.a = LL.la2 - (LL.la2 - LL.la1) / 2; + obj.o = LL.lo2 - (LL.lo2 - LL.lo1) / 2; + return obj; +} + function squareToLatLongAll(qth) { qth = qth.toUpperCase(); @@ -6155,15 +6058,9 @@ function haltAllTx(allTx = false) function initiateQso(thisCall) { - if ( - thisCall in g_callRoster && - g_callRoster[thisCall].message.instance in g_instances - ) + if (thisCall in g_callRoster && g_callRoster[thisCall].message.instance in g_instances) { - if ( - g_mapSettings.focusRig && - g_activeInstance != g_callRoster[thisCall].message.instance - ) + if (g_mapSettings.focusRig && g_activeInstance != g_callRoster[thisCall].message.instance) { activeRig(g_callRoster[thisCall].message.instance); } @@ -6204,11 +6101,7 @@ function spotLookupAndSetCall(spot) var mode = g_receptionReports.spots[spot].mode; for (var instance in g_instances) { - if ( - g_instances[instance].valid && - g_instances[instance].status.Band == band && - g_instances[instance].status.MO == mode - ) + if (g_instances[instance].valid && g_instances[instance].status.Band == band && g_instances[instance].status.MO == mode) { setCallAndGrid(call, grid, instance); return; @@ -6217,7 +6110,7 @@ function spotLookupAndSetCall(spot) setCallAndGrid(call, grid, null); } -function setCallAndGrid(callsign, grid, instance = null) +function setCallAndGrid(callsign, grid, instance = null, genMessages = true) { var thisInstance = null; var port; @@ -6230,7 +6123,10 @@ function setCallAndGrid(callsign, grid, instance = null) port = g_instances[instance].remote.port; address = g_instances[instance].remote.address; } - else alert("major instance error"); + else + { + alert("major instance error"); + } } else { @@ -6241,7 +6137,7 @@ function setCallAndGrid(callsign, grid, instance = null) address = g_instances[g_activeInstance].remote.address; } } - if (thisInstance && thisInstance.TxEnabled == 0) + if (thisInstance && (thisInstance.TxEnabled == 0 || genMessages == false)) { var responseArray = Buffer.alloc(1024); var length = 0; @@ -6255,25 +6151,50 @@ function setCallAndGrid(callsign, grid, instance = null) length = encodeQBOOL(responseArray, length, thisInstance.Fastmode); length = encodeQUINT32(responseArray, length, thisInstance.TRP); length = encodeQUINT32(responseArray, length, thisInstance.RxDF); - length = encodeQUTF8(responseArray, length, callsign); + + if (genMessages == true) + { + length = encodeQUTF8(responseArray, length, callsign); - var hash = liveHash(callsign, thisInstance.Band, thisInstance.MO); - if (hash in g_liveCallsigns && g_liveCallsigns[hash].grid.length > 1) { grid = g_liveCallsigns[hash].grid; } + var hash = liveHash(callsign, thisInstance.Band, thisInstance.MO); + if (hash in g_liveCallsigns && g_liveCallsigns[hash].grid.length > 1) { grid = g_liveCallsigns[hash].grid; } - if (grid.length == 0) grid = " "; + if (grid.length == 0) grid = " "; - length = encodeQUTF8(responseArray, length, grid); - length = encodeQBOOL(responseArray, length, 1); + length = encodeQUTF8(responseArray, length, grid); + length = encodeQBOOL(responseArray, length, 1); + + responseArray = responseArray.slice(0, length); + wsjtUdpMessage(responseArray, responseArray.length, port, address); + addLastTraffic("Generated Msgs"); + } + else + { + // Callsign + length = encodeQUTF8(responseArray, length, " "); + // Grid + length = encodeQUTF8(responseArray, length, " "); + length = encodeQBOOL(responseArray, length, 1); + + responseArray = responseArray.slice(0, length); + wsjtUdpMessage(responseArray, responseArray.length, port, address); - responseArray = responseArray.slice(0, length); - wsjtUdpMessage(responseArray, responseArray.length, port, address); - addLastTraffic("Generated Msgs"); + responseArray = Buffer.alloc(1024); + length = 0; + length = encodeQUINT32(responseArray, length, thisInstance.magic_key); + length = encodeQUINT32(responseArray, length, thisInstance.schema_number); + length = encodeQUINT32(responseArray, length, 9); + length = encodeQUTF8(responseArray, length, thisInstance.Id); + length = encodeQUTF8(responseArray, length, ""); + length = encodeQBOOL(responseArray, length, 0); + + responseArray = responseArray.slice(0, length); + wsjtUdpMessage(responseArray, responseArray.length, port, address); + } } - if (thisInstance && thisInstance.TxEnabled == 1) + if (thisInstance && thisInstance.TxEnabled == 1 && genMessages == true) { - addLastTraffic( - "Transmit Enabled!
Generate Msgs Aborted" - ); + addLastTraffic("Transmit Enabled!
Generate Msgs Aborted"); } } @@ -6321,7 +6242,6 @@ function handleWsjtxQSO(newMessage) function handleWsjtxNotSupported(newMessage) { } -var g_gtShareCount = 0; var g_lastBand = ""; var g_lastMode = ""; @@ -6389,9 +6309,9 @@ function activeRig(instance) } } -var g_lastDecodeCallsign = ""; var g_lastTransmitCallsign = {}; var g_lastStatusCallsign = {}; +var g_lastTxMessage = ""; function handleWsjtxStatus(newMessage) { @@ -6431,11 +6351,7 @@ function handleWsjtxStatus(newMessage) if (!(newMessage.instance in g_lastStatusCallsign)) { g_lastStatusCallsign[newMessage.instance] = ""; } - if ( - lookupOnTx.checked == true && - newMessage.Transmitting == 1 && - g_lastTransmitCallsign[newMessage.instance] != DXcall - ) + if (lookupOnTx.checked == true && newMessage.Transmitting == 1 && g_lastTransmitCallsign[newMessage.instance] != DXcall) { openLookupWindow(true); g_lastTransmitCallsign[newMessage.instance] = DXcall; @@ -6470,8 +6386,7 @@ function handleWsjtxStatus(newMessage) var bandChange = false; var modeChange = false; - var origMode = g_lastMode; - var origBand = g_lastBand; + wsjtxMode.innerHTML = "" + newMessage.MO + ""; myMode = newMessage.MO; myBand = newMessage.Band; @@ -6505,28 +6420,20 @@ function handleWsjtxStatus(newMessage) redrawParks(); redrawPins(); - var msg = ""; - - msg += "" + myBand + " / "; - msg += "" + myMode + ""; + var msg = "" + myBand + " / " + myMode + ""; addLastTraffic(msg); ackAlerts(); updateChatWindow(); } - myRawFreq = newMessage.Frequency; - frequency.innerHTML = - "" + - Number(newMessage.Frequency / 1000).formatMhz(3, 3) + - " Hz (" + - myBand + - ")"; - myRawCall = newMessage.DEcall.trim(); + myRawFreq = newMessage.Frequency; + frequency.innerHTML = "" + Number(newMessage.Frequency / 1000).formatMhz(3, 3) + " Hz (" + myBand + ")"; + myRawCall = newMessage.DEcall.trim(); myRawGrid = newMessage.DEgrid.trim().substr(0, 6); - var LL = squareToLatLongAll(myRawGrid); - g_mapSettings.latitude = g_myLat = LL.la2 - (LL.la2 - LL.la1) / 2; - g_mapSettings.longitude = g_myLon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; + var LL = squareToCenter(myRawGrid); + g_mapSettings.latitude = g_myLat = LL.a; + g_mapSettings.longitude = g_myLon = LL.o; if (myRawGrid != g_lastRawGrid) { g_lastRawGrid = myRawGrid; @@ -6545,6 +6452,18 @@ function handleWsjtxStatus(newMessage) dxCallBoxDiv.className = "DXCallBoxConfirmed"; } + if (newMessage.Transmitting == 1 && newMessage.TxMessage && g_lastTxMessage != newMessage.TxMessage) + { + g_lastTxMessage = newMessage.TxMessage; + addLastTraffic(newMessage.TxMessage); + if (newMessage.TxMessage.substr(0, 2) == "CQ" && DXcall.length > 0) + { + setCallAndGrid("", "", newMessage.instance, false); + DXcall = ""; + newMessage.DXgrid = ""; + } + } + g_localDXcall = DXcall; localDXcall.innerHTML = DXcall.formatCallsign(); if (localDXcall.innerHTML.length == 0) @@ -6556,10 +6475,7 @@ function handleWsjtxStatus(newMessage) if (myDXGrid.length == 0 && hash in g_liveCallsigns) { - localDXGrid.innerHTML = myDXGrid = g_liveCallsigns[hash].grid.substr( - 0, - 4 - ); + localDXGrid.innerHTML = myDXGrid = g_liveCallsigns[hash].grid.substr(0, 4); } if (localDXGrid.innerHTML.length == 0) @@ -6570,39 +6486,28 @@ function handleWsjtxStatus(newMessage) } else { - var LL = squareToLatLongAll(myDXGrid); - localDXDistance.innerHTML = - parseInt( - MyCircle.distance( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2, - distanceUnit.value - ) * MyCircle.validateRadius(distanceUnit.value) - ) + distanceUnit.value.toLowerCase(); - localDXAzimuth.innerHTML = - parseInt( - MyCircle.bearing( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2 - ) - ) + "°"; + var LL = squareToCenter(myDXGrid); + localDXDistance.innerHTML = parseInt(MyCircle.distance(g_myLat, g_myLon, LL.a, distanceUnit.value) * MyCircle.validateRadius(distanceUnit.value)) + distanceUnit.value.toLowerCase(); + localDXAzimuth.innerHTML = parseInt(MyCircle.bearing(g_myLat, g_myLon, LL.a, LL.o)) + "°"; } + if (localDXcall.innerHTML != "-") { - localDXReport.innerHTML = Number( - newMessage.Report.trim() - ).formatSignalReport(); - if (DXcall.length > 0) { localDXCountry.innerHTML = g_dxccToAltName[callsignToDxcc(DXcall)]; } - else localDXCountry.innerHTML = " "; + localDXReport.innerHTML = Number(newMessage.Report.trim()).formatSignalReport(); + if (DXcall.length > 0) + { + localDXCountry.innerHTML = g_dxccToAltName[callsignToDxcc(DXcall)]; + } + else + { + localDXCountry.innerHTML = " "; + } } else { localDXReport.innerHTML = localDXCountry.innerHTML = ""; } + myDEcall = newMessage.DEcall; myDEGrid = newMessage.DEgrid.trim().substr(0, 6); if (myDEGrid.length > 0) setHomeGridsquare(); @@ -6632,37 +6537,24 @@ function handleWsjtxStatus(newMessage) if (g_appSettings.gtShareEnable == "true") { g_gtLiveStatusUpdate = true; - g_gtShareCount++; } - else g_gtShareCount = 0; if (bandChange || modeChange) reloadInfo(bandChange || modeChange); var worker = ""; - worker += - "
"; + worker += "
"; worker += ""; - worker += - ""; - worker += - ""; + worker += ""; + worker += ""; worker += g_lastMessages.join(""); worker += "
Last " + - g_lastMessages.length + - " Decoded Messages
TimedBDTFreqModeMessageDXCC
Last " + g_lastMessages.length + " Decoded Messages
TimedBDTFreqModeMessageDXCC
"; setStatsDiv("decodeLastListDiv", worker); - setStatsDivHeight( - "decodeLastListDiv", - getStatsWindowHeight() + 26 + "px" - ); + setStatsDivHeight("decodeLastListDiv", getStatsWindowHeight() + 26 + "px"); - if ( - g_appSettings.gtShareEnable === true && - Object.keys(g_spotCollector).length > 0 - ) + if (g_appSettings.gtShareEnable === true && Object.keys(g_spotCollector).length > 0) { gtChatSendSpots(g_spotCollector, g_spotDetailsCollector); g_spotCollector = {}; @@ -6677,10 +6569,7 @@ function handleWsjtxStatus(newMessage) if (newMessage.TxEnabled) { - if ( - g_mapSettings.fitQRZ && - (!g_spotsEnabled || g_receptionSettings.mergeSpots) - ) + if (g_mapSettings.fitQRZ && (!g_spotsEnabled || g_receptionSettings.mergeSpots)) { if (g_lastMapView == null) { @@ -6692,19 +6581,12 @@ function handleWsjtxStatus(newMessage) { fitViewBetweenPoints([getPoint(myRawGrid), getPoint(myDXGrid)]); } - else if ( - g_mapSettings.qrzDxccFallback && - DXcall.length > 0 && - callsignToDxcc(DXcall) > 0 - ) + else if (g_mapSettings.qrzDxccFallback && DXcall.length > 0 && callsignToDxcc(DXcall) > 0) { var dxcc = callsignToDxcc(DXcall); var Lat = g_dxccInfo[dxcc].lat; var Lon = g_dxccInfo[dxcc].lon; - fitViewBetweenPoints( - [getPoint(myRawGrid), ol.proj.fromLonLat([Lon, Lat])], - 15 - ); + fitViewBetweenPoints([getPoint(myRawGrid), ol.proj.fromLonLat([Lon, Lat])], 15); } } } @@ -6721,6 +6603,7 @@ function handleWsjtxStatus(newMessage) if (newMessage.Transmitting == 0) { // Not Transmitting + g_lastTxMessage = ""; g_layerSources.transmit.clear(); g_transmitFlightPath = null; } @@ -6733,53 +6616,31 @@ function handleWsjtxStatus(newMessage) txrxdec.innerHTML = "TRANSMIT"; g_layerSources.transmit.clear(); g_transmitFlightPath = null; - if ( - qrzPathWidthValue.value != 0 && - g_appSettings.gridViewMode != 2 && - validateGridFromString(myRawGrid) - ) + + if (qrzPathWidthValue.value != 0 && g_appSettings.gridViewMode != 2 && validateGridFromString(myRawGrid)) { var strokeColor = getQrzPathColor(); var strokeWeight = qrzPathWidthValue.value; - var LL = squareToLatLongAll(myRawGrid); - var Lat = LL.la2 - (LL.la2 - LL.la1) / 2; - var Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; - var fromPoint = ol.proj.fromLonLat([Lon, Lat]); + var LL = squareToCenter(myRawGrid); + var fromPoint = ol.proj.fromLonLat([LL.o, LL.a]); var toPoint = null; if (validateGridFromString(myDXGrid)) { - LL = squareToLatLongAll(myDXGrid); - Lat = LL.la2 - (LL.la2 - LL.la1) / 2; - Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; - - toPoint = ol.proj.fromLonLat([Lon, Lat]); + LL = squareToCenter(myDXGrid); + toPoint = ol.proj.fromLonLat([LL.o, LL.a]); } - else if ( - g_mapSettings.qrzDxccFallback && - DXcall.length > 0 && - callsignToDxcc(DXcall) > 0 - ) + else if (g_mapSettings.qrzDxccFallback && DXcall.length > 0 && callsignToDxcc(DXcall) > 0) { var dxcc = callsignToDxcc(DXcall); - Lat = g_dxccInfo[dxcc].lat; - Lon = g_dxccInfo[dxcc].lon; - - toPoint = ol.proj.fromLonLat([Lon, Lat]); + toPoint = ol.proj.fromLonLat([g_dxccInfo[dxcc].lon, g_dxccInfo[dxcc].lat]); var locality = g_dxccInfo[dxcc].geo; if (locality == "deleted") locality = null; if (locality != null) { - var feature = shapeFeature( - "qrz", - locality, - "qrz", - "#FFFF0010", - "#FF0000FF", - 1.0 - ); + var feature = shapeFeature("qrz", locality, "qrz", "#FFFF0010", "#FF0000FF", 1.0); g_layerSources.transmit.addFeature(feature); } } @@ -6847,14 +6708,12 @@ function drawTraffic() } trafficDiv.innerHTML = worker; } + function getPoint(grid) { - var LL = squareToLatLongAll(grid); - var Lat = LL.la2 - (LL.la2 - LL.la1) / 2; - var Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; - return ol.proj.fromLonLat([Lon, Lat]); + var LL = squareToCenter(grid); + return ol.proj.fromLonLat([LL.o, LL.a]); } -var g_showCQRU = true; function fitViewBetweenPoints(points, maxZoom = 20) { @@ -7143,25 +7002,13 @@ function handleWsjtxDecode(newMessage) callsign.CQ = CQ; callsign.RR73 = RR73; - if (msgDXcallsign == myDEcall) callsign.qrz = true; - else callsign.qrz = false; + callsign.qrz = (msgDXcallsign == myDEcall); if (callsign.grid.length > 0 && callsign.distance == 0) { - var LL = squareToLatLongAll(callsign.grid); - callsign.distance = MyCircle.distance( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2, - distanceUnit.value - ); - callsign.heading = MyCircle.bearing( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2 - ); + var LL = squareToCenter(callsign.grid); + callsign.distance = MyCircle.distance(g_myLat, g_myLon, LL.a, LL.o, distanceUnit.value); + callsign.heading = MyCircle.bearing(g_myLat, g_myLon, LL.a, LL.o); } if (g_appSettings.potaEnabled == 1) @@ -9524,16 +9371,8 @@ function renderStatsBox() if (finalGrid.length > 0) { - LL = squareToLatLongAll(finalGrid); - unit = parseInt( - MyCircle.distance( - g_myLat, - g_myLon, - LL.la2 - (LL.la2 - LL.la1) / 2, - LL.lo2 - (LL.lo2 - LL.lo1) / 2, - distanceUnit.value - ) * MyCircle.validateRadius(distanceUnit.value) - ); + LL = squareToCenter(finalGrid); + unit = parseInt(MyCircle.distance(g_myLat, g_myLon, LL.a, LL.o, distanceUnit.value) * MyCircle.validateRadius(distanceUnit.value)); if (unit > long_distance.worked_unit) { @@ -12324,9 +12163,7 @@ function drawAllGrids() } } - var LL = twoWideToLatLong( - String.fromCharCode(x) + String.fromCharCode(y) - ); + var LL = twoWideToLatLong(String.fromCharCode(x) + String.fromCharCode(y)); var Lat = LL.la2 - (LL.la2 - LL.la1) / 2; var Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; var point = ol.proj.fromLonLat([Lon, Lat]); @@ -13914,6 +13751,15 @@ function updateWsjtxListener(port) { newMessage.ConfName = null; } + if (message.length > 0) + { + newMessage.TxMessage = decodeQUTF8(message); + message = message.slice(g_qtToSplice); + } + else + { + newMessage.TxMessage = null; + } g_instances[instanceId].oldStatus = g_instances[instanceId].status; g_instances[instanceId].status = newMessage; g_instances[instanceId].valid = true; @@ -15945,38 +15791,33 @@ function createSpot(report, key, fromPoint, addToLayer = true) { try { - var LL = squareToLatLongAll(report.grid); + var LL = squareToCenter(report.grid); - if (isNaN(LL.la1)) + if (isNaN(LL.a)) { // Bad value in grid, don't map // return; } - var Lat = LL.la2 - (LL.la2 - LL.la1) / 2; - var Lon = LL.lo2 - (LL.lo2 - LL.lo1) / 2; - - var spot = spotFeature([Lon, Lat]); + var spot = spotFeature([LL.o, LL.a]); var colorNoAlpha = "#" + g_bandToColor[report.band]; var colorAlpha = intAlphaToRGB(colorNoAlpha, report.color); var spotColor = colorAlpha; - var workingColor = - g_mapSettings.nightMapEnable && g_nightTime - ? g_receptionSettings.pathNightColor - : g_receptionSettings.pathColor; + var workingColor = g_mapSettings.nightMapEnable && g_nightTime ? g_receptionSettings.pathNightColor : g_receptionSettings.pathColor; if (workingColor != -1) { - var testColor = - workingColor < 1 - ? "#0000000" - : workingColor == 361 - ? "#FFFFFF" - : "hsla(" + workingColor + ", 100%, 50%," + report.color / 255 + ")"; - if (workingColor < 1 || workingColor == 361) { spotColor = intAlphaToRGB(testColor.substr(0, 7), report.color); } - else spotColor = testColor; + var testColor = workingColor < 1 ? "#0000000" : workingColor == 361 ? "#FFFFFF" : "hsla(" + workingColor + ", 100%, 50%," + report.color / 255 + ")"; + if (workingColor < 1 || workingColor == 361) + { + spotColor = intAlphaToRGB(testColor.substr(0, 7), report.color); + } + else + { + spotColor = testColor; + } } featureStyle = new ol.style.Style({ @@ -15993,7 +15834,7 @@ function createSpot(report, key, fromPoint, addToLayer = true) spot.size = 6; // Mouseover detection g_layerSources["psk-spots"].addFeature(spot); - var toPoint = ol.proj.fromLonLat([Lon, Lat]); + var toPoint = ol.proj.fromLonLat([LL.o, LL.a]); var lonLat = new ol.geom.Point(toPoint); @@ -16015,7 +15856,7 @@ function createSpot(report, key, fromPoint, addToLayer = true) ? g_spotNightFlightColor : g_spotFlightColor; - var feature = flightFeature( + flightFeature( [fromPoint, toPoint], { weight: strokeWeight, diff --git a/package.nw/lib/gtws.js b/package.nw/lib/gtws.js index 66d8c5b..1eeb449 100644 --- a/package.nw/lib/gtws.js +++ b/package.nw/lib/gtws.js @@ -165,17 +165,23 @@ function gtClosedSocket() g_gtState = ChatState.none; } +var g_lastConnectAttempt = 0; + function gtCanConnect() { + g_lastConnectAttempt = timeNowSec(); g_gtState = ChatState.connect; } function gtSetIdle() { - g_gtStatusCount = 0; - g_gtNeedUsersList = true; - g_gtState = ChatState.idle; - g_lastGtStatus = ""; + if (timeNowSec() - g_lastConnectAttempt >= 30) + { + g_gtStatusCount = 0; + g_gtNeedUsersList = true; + g_gtState = ChatState.idle; + g_lastGtStatus = ""; + } } function gtStatusCheck() @@ -220,7 +226,8 @@ function sendGtJson(json) } } } - else g_gtState = ChatState.closed; + // if we don't have a socketHandle, don't go changing the state willy nilly! + // else g_gtState = ChatState.closed; } var g_lastGtStatus = ""; @@ -370,7 +377,9 @@ function redrawPins() makeGtPin(g_gtFlagPins[cid]); if (g_gtFlagPins[cid].pin != null) - { g_layerSources.gtflags.addFeature(g_gtFlagPins[cid].pin); } + { + g_layerSources.gtflags.addFeature(g_gtFlagPins[cid].pin); + } } } @@ -381,7 +390,9 @@ function makeGtPin(obj) if (obj.pin) { if (g_layerSources.gtflags.hasFeature(obj.pin)) - { g_layerSources.gtflags.removeFeature(obj.pin); } + { + g_layerSources.gtflags.removeFeature(obj.pin); + } delete obj.pin; obj.pin = null; } @@ -394,19 +405,13 @@ function makeGtPin(obj) if (validateGridFromString(obj.grid) == false) return; - if ( - g_appSettings.gtFlagImgSrc == 2 && - (obj.mode != myMode || obj.band != myBand) - ) - { return; } + if (g_appSettings.gtFlagImgSrc == 2 && (obj.mode != myMode || obj.band != myBand)) + { + return; + } - var LL = squareToLatLongAll(obj.grid); - var myLonLat = [ - LL.lo2 - (LL.lo2 - LL.lo1) / 2, - LL.la2 - (LL.la2 - LL.la1) / 2 - ]; - - obj.pin = iconFeature(ol.proj.fromLonLat(myLonLat), g_gtFlagIcon, 100); + var LL = squareToCenter(obj.grid); + obj.pin = iconFeature(ol.proj.fromLonLat([LL.o, LL.a]), g_gtFlagIcon, 100); obj.pin.key = obj.cid; obj.pin.isGtFlag = true; obj.pin.size = 1; @@ -570,10 +575,7 @@ function gtChatSetUUID(jsmesg) function gtChatStateMachine() { - if ( - g_appSettings.gtShareEnable == true && - g_mapSettings.offlineMode == false - ) + if (g_appSettings.gtShareEnable == true && g_mapSettings.offlineMode == false) { var now = timeNowSec(); g_gtStateToFunction[g_gtState](); @@ -584,10 +586,7 @@ function gtChatStateMachine() } else msgImg.style.webkitFilter = ""; - if ( - g_msgSettings.msgFrequencySelect > 0 && - Object.keys(g_gtUnread).length > 0 - ) + if (g_msgSettings.msgFrequencySelect > 0 && Object.keys(g_gtUnread).length > 0) { if (now - g_lastChatMsgAlert > g_msgSettings.msgFrequencySelect * 60) {