SVN r8748
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>@WSJTX_BUNDLE_NAME@</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>@WSJTX_BUNDLE_NAME@</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>True</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,148 @@
|
||||
module ft8_decode
|
||||
|
||||
parameter (MAXFOX=1000)
|
||||
character*12 c2fox(MAXFOX)
|
||||
character*4 g2fox(MAXFOX)
|
||||
integer nsnrfox(MAXFOX)
|
||||
integer nfreqfox(MAXFOX)
|
||||
integer n30fox(MAXFOX)
|
||||
integer n30z
|
||||
integer nfox
|
||||
|
||||
type :: ft8_decoder
|
||||
procedure(ft8_decode_callback), pointer :: callback
|
||||
contains
|
||||
procedure :: decode
|
||||
end type ft8_decoder
|
||||
|
||||
abstract interface
|
||||
subroutine ft8_decode_callback (this,sync,snr,dt,freq,decoded,nap,qual)
|
||||
import ft8_decoder
|
||||
implicit none
|
||||
class(ft8_decoder), intent(inout) :: this
|
||||
real, intent(in) :: sync
|
||||
integer, intent(in) :: snr
|
||||
real, intent(in) :: dt
|
||||
real, intent(in) :: freq
|
||||
character(len=37), intent(in) :: decoded
|
||||
integer, intent(in) :: nap
|
||||
real, intent(in) :: qual
|
||||
end subroutine ft8_decode_callback
|
||||
end interface
|
||||
|
||||
contains
|
||||
|
||||
subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, &
|
||||
nutc,nfa,nfb,nexp_decode,ndepth,nagain,lft8apon,lapcqonly,napwid, &
|
||||
mycall12,mygrid6,hiscall12,hisgrid6)
|
||||
! use wavhdr
|
||||
use timer_module, only: timer
|
||||
include 'ft8/ft8_params.f90'
|
||||
! type(hdr) h
|
||||
|
||||
class(ft8_decoder), intent(inout) :: this
|
||||
procedure(ft8_decode_callback) :: callback
|
||||
real s(NH1,NHSYM)
|
||||
real sbase(NH1)
|
||||
real candidate(3,200)
|
||||
real dd(15*12000)
|
||||
logical, intent(in) :: lft8apon,lapcqonly,nagain
|
||||
logical newdat,lsubtract,ldupe,bcontest
|
||||
character*12 mycall12, hiscall12
|
||||
character*6 mygrid6,hisgrid6
|
||||
integer*2 iwave(15*12000)
|
||||
integer apsym(KK)
|
||||
character datetime*13,message*22,msg37*37
|
||||
character*22 allmessages(100)
|
||||
integer allsnrs(100)
|
||||
save s,dd
|
||||
|
||||
bcontest=iand(nexp_decode,128).ne.0
|
||||
this%callback => callback
|
||||
write(datetime,1001) nutc !### TEMPORARY ###
|
||||
1001 format("000000_",i6.6)
|
||||
|
||||
call ft8apset(mycall12,mygrid6,hiscall12,hisgrid6,bcontest,apsym,iaptype)
|
||||
dd=iwave
|
||||
ndecodes=0
|
||||
allmessages=' '
|
||||
allsnrs=0
|
||||
ifa=nfa
|
||||
ifb=nfb
|
||||
if(nagain) then
|
||||
ifa=nfqso-10
|
||||
ifb=nfqso+10
|
||||
endif
|
||||
|
||||
! For now:
|
||||
! ndepth=1: no subtraction, 1 pass, belief propagation only
|
||||
! ndepth=2: subtraction, 3 passes, belief propagation only
|
||||
! ndepth=3: subtraction, 3 passes, bp+osd
|
||||
if(ndepth.eq.1) npass=1
|
||||
if(ndepth.ge.2) npass=3
|
||||
do ipass=1,npass
|
||||
newdat=.true. ! Is this a problem? I hijacked newdat.
|
||||
syncmin=1.5
|
||||
if(ipass.eq.1) then
|
||||
lsubtract=.true.
|
||||
if(ndepth.eq.1) lsubtract=.false.
|
||||
elseif(ipass.eq.2) then
|
||||
n2=ndecodes
|
||||
if(ndecodes.eq.0) cycle
|
||||
lsubtract=.true.
|
||||
elseif(ipass.eq.3) then
|
||||
if((ndecodes-n2).eq.0) cycle
|
||||
lsubtract=.false.
|
||||
endif
|
||||
|
||||
call timer('sync8 ',0)
|
||||
call sync8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
|
||||
call timer('sync8 ',1)
|
||||
do icand=1,ncand
|
||||
sync=candidate(3,icand)
|
||||
f1=candidate(1,icand)
|
||||
xdt=candidate(2,icand)
|
||||
xbase=10.0**(0.1*(sbase(nint(f1/3.125))-40.0))
|
||||
nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ###
|
||||
call timer('ft8b ',0)
|
||||
call ft8b(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
|
||||
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, &
|
||||
hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, &
|
||||
nbadcrc,iappass,iera,msg37,xsnr)
|
||||
message=msg37(1:22) !###
|
||||
nsnr=nint(xsnr)
|
||||
xdt=xdt-0.5
|
||||
hd=nharderrors+dmin
|
||||
call timer('ft8b ',1)
|
||||
if(nbadcrc.eq.0) then
|
||||
! call jtmsg(message,iflag)
|
||||
if(bcontest) then
|
||||
call fix_contest_msg(mygrid6,message)
|
||||
msg37(1:22)=message
|
||||
endif
|
||||
! if(iand(iflag,31).ne.0) message(22:22)='?'
|
||||
ldupe=.false.
|
||||
do id=1,ndecodes
|
||||
if(message.eq.allmessages(id).and.nsnr.le.allsnrs(id)) ldupe=.true.
|
||||
enddo
|
||||
if(.not.ldupe) then
|
||||
ndecodes=ndecodes+1
|
||||
allmessages(ndecodes)=message
|
||||
allsnrs(ndecodes)=nsnr
|
||||
endif
|
||||
! write(81,1004) nutc,ncand,icand,ipass,iaptype,iappass, &
|
||||
! nharderrors,dmin,hd,min(sync,999.0),nint(xsnr), &
|
||||
! xdt,nint(f1),message
|
||||
!1004 format(i6.6,2i4,3i2,i3,3f6.1,i4,f6.2,i5,2x,a22)
|
||||
! flush(81)
|
||||
if(.not.ldupe .and. associated(this%callback)) then
|
||||
qual=1.0-(nharderrors+dmin)/60.0 ! scale qual to [0.0,1.0]
|
||||
call this%callback(sync,nsnr,xdt,f1,msg37,iaptype,qual)
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
return
|
||||
end subroutine decode
|
||||
|
||||
end module ft8_decode
|
||||
@@ -0,0 +1,217 @@
|
||||
#include "decodedtext.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QRegularExpression>
|
||||
#include <QDebug>
|
||||
|
||||
extern "C" {
|
||||
bool stdmsg_(char const * msg, bool contest_mode, char const * mygrid, fortran_charlen_t, fortran_charlen_t);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
QRegularExpression words_re {R"(^(?:(?<word1>(?:CQ|DE|QRZ)(?:\s?DX|\s(?:[A-Z]{2}|\d{3}))|[A-Z0-9/]+)\s)(?:(?<word2>[A-Z0-9/]+)(?:\s(?<word3>[-+A-Z0-9]+)(?:\s(?<word4>(?:OOO|(?!RR73)[A-R]{2}[0-9]{2})))?)?)?)"};
|
||||
}
|
||||
|
||||
DecodedText::DecodedText (QString const& the_string, bool contest_mode, QString const& my_grid)
|
||||
: string_ {the_string.left (the_string.indexOf (QChar::Nbsp))} // discard appended info
|
||||
, padding_ {string_.indexOf (" ") > 4 ? 2 : 0} // allow for
|
||||
// seconds
|
||||
, contest_mode_ {contest_mode}
|
||||
, message_ {string_.mid (column_qsoText + padding_).trimmed ()}
|
||||
, is_standard_ {false}
|
||||
{
|
||||
if (message_.length() >= 1)
|
||||
{
|
||||
message_ = message_.left (21).remove (QRegularExpression {"[<>]"});
|
||||
int i1 = message_.indexOf ('\r');
|
||||
if (i1 > 0)
|
||||
{
|
||||
message_ = message_.left (i1 - 1);
|
||||
}
|
||||
if (message_.contains (QRegularExpression {"^(CQ|QRZ)\\s"}))
|
||||
{
|
||||
// TODO this magic position 16 is guaranteed to be after the
|
||||
// last space in a decoded CQ or QRZ message but before any
|
||||
// appended DXCC entity name or worked before information
|
||||
auto eom_pos = message_.indexOf (' ', 16);
|
||||
// we always want at least the characters to position 16
|
||||
if (eom_pos < 16) eom_pos = message_.size () - 1;
|
||||
// remove DXCC entity and worked B4 status. TODO need a better way to do this
|
||||
message_ = message_.left (eom_pos + 1);
|
||||
}
|
||||
// stdmsg is a fortran routine that packs the text, unpacks it
|
||||
// and compares the result
|
||||
auto message_c_string = message_.toLocal8Bit ();
|
||||
message_c_string += QByteArray {22 - message_c_string.size (), ' '};
|
||||
auto grid_c_string = my_grid.toLocal8Bit ();
|
||||
grid_c_string += QByteArray {6 - grid_c_string.size (), ' '};
|
||||
is_standard_ = stdmsg_ (message_c_string.constData ()
|
||||
, contest_mode_
|
||||
, grid_c_string.constData ()
|
||||
, 22, 6);
|
||||
}
|
||||
};
|
||||
|
||||
QStringList DecodedText::messageWords () const
|
||||
{
|
||||
if (is_standard_)
|
||||
{
|
||||
// extract up to the first four message words
|
||||
return words_re.match (message_).capturedTexts ();
|
||||
}
|
||||
// simple word split for free text messages
|
||||
auto words = message_.split (' ', QString::SkipEmptyParts);
|
||||
// add whole message as item 0 to mimic RE capture list
|
||||
words.prepend (message_);
|
||||
return words;
|
||||
}
|
||||
|
||||
QString DecodedText::CQersCall() const
|
||||
{
|
||||
QRegularExpression callsign_re {R"(^(CQ|DE|QRZ)(\s?DX|\s([A-Z]{2}|\d{3}))?\s(?<callsign>[A-Z0-9/]{2,})(\s[A-R]{2}[0-9]{2})?)"};
|
||||
return callsign_re.match (message_).captured ("callsign");
|
||||
}
|
||||
|
||||
|
||||
bool DecodedText::isJT65() const
|
||||
{
|
||||
return string_.indexOf("#") == column_mode + padding_;
|
||||
}
|
||||
|
||||
bool DecodedText::isJT9() const
|
||||
{
|
||||
return string_.indexOf("@") == column_mode + padding_;
|
||||
}
|
||||
|
||||
bool DecodedText::isTX() const
|
||||
{
|
||||
int i = string_.indexOf("Tx");
|
||||
return (i >= 0 && i < 15); // TODO guessing those numbers. Does Tx ever move?
|
||||
}
|
||||
|
||||
bool DecodedText::isLowConfidence () const
|
||||
{
|
||||
return QChar {'?'} == string_.mid (padding_ + column_qsoText + 21, 1);
|
||||
}
|
||||
|
||||
int DecodedText::frequencyOffset() const
|
||||
{
|
||||
return string_.mid(column_freq + padding_,4).toInt();
|
||||
}
|
||||
|
||||
int DecodedText::snr() const
|
||||
{
|
||||
int i1=string_.indexOf(" ")+1;
|
||||
return string_.mid(i1,3).toInt();
|
||||
}
|
||||
|
||||
float DecodedText::dt() const
|
||||
{
|
||||
return string_.mid(column_dt + padding_,5).toFloat();
|
||||
}
|
||||
|
||||
/*
|
||||
2343 -11 0.8 1259 # YV6BFE F6GUU R-08
|
||||
2343 -19 0.3 718 # VE6WQ SQ2NIJ -14
|
||||
2343 -7 0.3 815 # KK4DSD W7VP -16
|
||||
2343 -13 0.1 3627 @ CT1FBK IK5YZT R+02
|
||||
|
||||
0605 Tx 1259 # CQ VK3ACF QF22
|
||||
*/
|
||||
|
||||
// find and extract any report. Returns true if this is a standard message
|
||||
bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, /*mod*/QString& report) const
|
||||
{
|
||||
if (message_.size () < 1) return false;
|
||||
|
||||
QStringList const& w = message_.split(" ",QString::SkipEmptyParts);
|
||||
if (w.size ()
|
||||
&& is_standard_ && (w[0] == myBaseCall
|
||||
|| w[0].endsWith ("/" + myBaseCall)
|
||||
|| w[0].startsWith (myBaseCall + "/")
|
||||
|| (w.size () > 1 && !dxBaseCall.isEmpty ()
|
||||
&& (w[1] == dxBaseCall
|
||||
|| w[1].endsWith ("/" + dxBaseCall)
|
||||
|| w[1].startsWith (dxBaseCall + "/")))))
|
||||
{
|
||||
QString tt="";
|
||||
if(w.size() > 2) tt=w[2];
|
||||
bool ok;
|
||||
auto i1=tt.toInt(&ok);
|
||||
if (ok and i1>=-50 and i1<50)
|
||||
{
|
||||
report = tt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tt.mid(0,1)=="R")
|
||||
{
|
||||
i1=tt.mid(1).toInt(&ok);
|
||||
if(ok and i1>=-50 and i1<50)
|
||||
{
|
||||
report = tt.mid(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_standard_;
|
||||
}
|
||||
|
||||
// get the first text word, usually the call
|
||||
QString DecodedText::call() const
|
||||
{
|
||||
return words_re.match (message_).captured ("word1");
|
||||
}
|
||||
|
||||
// get the second word, most likely the de call and the third word, most likely grid
|
||||
void DecodedText::deCallAndGrid(/*out*/QString& call, QString& grid) const
|
||||
{
|
||||
auto const& match = words_re.match (message_);
|
||||
call = match.captured ("word2");
|
||||
grid = match.captured ("word3");
|
||||
if (contest_mode_ && "R" == grid)
|
||||
{
|
||||
grid = match.captured ("word4");
|
||||
}
|
||||
}
|
||||
|
||||
unsigned DecodedText::timeInSeconds() const
|
||||
{
|
||||
return 3600 * string_.mid (column_time, 2).toUInt ()
|
||||
+ 60 * string_.mid (column_time + 2, 2).toUInt()
|
||||
+ (padding_ ? string_.mid (column_time + 2 + padding_, 2).toUInt () : 0U);
|
||||
}
|
||||
|
||||
/*
|
||||
2343 -11 0.8 1259 # YV6BFE F6GUU R-08
|
||||
2343 -19 0.3 718 # VE6WQ SQ2NIJ -14
|
||||
2343 -7 0.3 815 # KK4DSD W7VP -16
|
||||
2343 -13 0.1 3627 @ CT1FBK IK5YZT R+02
|
||||
|
||||
0605 Tx 1259 # CQ VK3ACF QF22
|
||||
*/
|
||||
|
||||
QString DecodedText::report() const // returns a string of the SNR field with a leading + or - followed by two digits
|
||||
{
|
||||
int sr = snr();
|
||||
if (sr<-50)
|
||||
sr = -50;
|
||||
else
|
||||
if (sr > 49)
|
||||
sr = 49;
|
||||
|
||||
QString rpt;
|
||||
rpt.sprintf("%d",abs(sr));
|
||||
if (sr > 9)
|
||||
rpt = "+" + rpt;
|
||||
else
|
||||
if (sr >= 0)
|
||||
rpt = "+0" + rpt;
|
||||
else
|
||||
if (sr >= -9)
|
||||
rpt = "-0" + rpt;
|
||||
else
|
||||
rpt = "-" + rpt;
|
||||
return rpt;
|
||||
}
|
||||
Reference in New Issue
Block a user