Merged master 8748

This commit is contained in:
Jordan Sherer
2018-08-05 11:33:30 -04:00
parent 8f8772f1bd
commit 62899069bf
1095 changed files with 31298 additions and 367679 deletions
@@ -0,0 +1,550 @@
program wsprcpmd
! Decode WSPRCPM data read from *.c2 or *.wav files.
! WSPRCPM is a WSPR-like mode based on full-response CPM.
!
! Currently configured to use (204,68) r=1/3 LDPC code, regular column weight 3.
! 50 data bits + 14 bit CRC + 4 "0" bits. The 4 "0" bits are unused bits that
! are not transmitted. At the decoder, these bits are treated as "AP" bits.
! This shortens the code to (200,64) r=0.32, slightly decreasing the code rate.
!
! Frame format is:
! d100 p32 d100 (232) channel symbols
!
use crc
include 'wsprcpm_params.f90'
parameter(NMAX=120*12000)
character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11
character*22 decodes(100)
character*120 data_dir
character*32 uwbits
character*68 dmsg
complex c2(0:120*12000/32-1) !Complex waveform
complex cframe(0:216*200-1) !Complex waveform
complex cd(0:216*10-1) !Complex waveform
complex c1(0:9,0:1),c0(0:9,0:1)
complex ccor(0:1,216)
complex csum,cterm
real*8 fMHz
real rxdata(ND),llr(204) !Soft symbols
real sbits(216),sbits1(216),sbits3(216)
real ps(0:8191),psbest(0:8191)
real candidates(100,2)
integer iuniqueword0
integer isync(200) !Unique word
integer isync2(216)
integer ipreamble(16) !Preamble vector
integer ihdr(11)
integer*2 iwave(NMAX) !Generated full-length waveform
integer*1,target :: idat(9)
integer*1 decoded(68),apmask(204),cw(204)
integer*1 hbits(216),hbits1(216),hbits3(216)
data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
data iuniqueword0/z'30C9E8AD'/
write(uwbits,'(b32.32)') iuniqueword0
read(uwbits,'(32i1)') isync(1:32)
read(uwbits,'(32i1)') isync(33:64)
read(uwbits,'(32i1)') isync(65:96)
read(uwbits,'(32i1)') isync(97:128)
read(uwbits,'(32i1)') isync(129:160)
read(uwbits,'(32i1)') isync(161:192)
read(uwbits,'(8i1)') isync(193:200)
fs=12000.0/NDOWN !Sample rate
dt=1.0/fs !Sample interval (s)
tt=NSPS*dt !Duration of "itone" symbols (s)
baud=1.0/tt !Keying rate for "itone" symbols (baud)
txt=NZ*dt !Transmission length (s)
h=1.00 !h=0.8 seems to be optimum for AWGN sensitivity (not for fading)
twopi=8.0*atan(1.0)
isync2(1:100)=isync(1:100)
isync2(101:104)=0 ! This is *not* backwards.
isync2(105:112)=1
isync2(113:116)=0
isync2(117:216)=isync(101:200)
! data sync tone
! 0 0 0
! 0 1 1
! 1 0 2
! 1 1 3
dphi=twopi*baud*(h/2.0)*dt*20 ! dt*10 is samp interval after downsample
do j=0,1
if(j.eq.0) then
dphi0=-3*dphi
dphi1=+1*dphi
else
dphi0=-1*dphi
dphi1=+3*dphi
endif
phi0=0.0
phi1=0.0
do i=0,9
c1(i,j)=cmplx(cos(phi1),sin(phi1))
c0(i,j)=cmplx(cos(phi0),sin(phi0))
phi1=mod(phi1+dphi1,twopi)
phi0=mod(phi0+dphi0,twopi)
enddo
enddo
nargs=iargc()
if(nargs.lt.1) then
print*,'Usage: wsprcpmd [-a <data_dir>] [-f fMHz] [-c ncoh] file1 [file2 ...]'
go to 999
endif
iarg=1
data_dir="."
call getarg(iarg,arg)
if(arg(1:2).eq.'-a') then
call getarg(iarg+1,data_dir)
iarg=iarg+2
endif
call getarg(iarg,arg)
if(arg(1:2).eq.'-f') then
call getarg(iarg+1,arg)
read(arg,*) fMHz
iarg=iarg+2
endif
ncoh=1
npdi=16
if(arg(1:2).eq.'-c') then
call getarg(iarg+1,arg)
read(arg,*) ncoh
iarg=iarg+2
npdi=16/ncoh
endif
! write(*,*) 'ncoh: ',ncoh,' npdi: ',npdi
open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', &
position='append')
xs1=0.0
xs2=0.0
fr1=0.0
fr2=0.0
nav=0
ngood=0
do ifile=iarg,nargs
call getarg(ifile,infile)
open(10,file=infile,status='old',access='stream')
j1=index(infile,'.c2')
j2=index(infile,'.wav')
if(j1.gt.0) then
read(10,end=999) fname,ntrmin,fMHz,c2
read(fname(8:11),*) nutc
write(datetime,'(i11)') nutc
else if(j2.gt.0) then
read(10,end=999) ihdr,iwave
read(infile(j2-4:j2-1),*) nutc
datetime=infile(j2-11:j2-1)
call wsprcpm_downsample(iwave,c2)
else
print*,'Wrong file format?'
go to 999
endif
close(10)
fa=-100.0
fb=100.0
fs=12000.0/32.0
npts=120*12000.0/32.0
nsync=16
call getcandidate2(c2,npts,fs,fa,fb,ncand,candidates) !First approx for freq
ndecodes=0
do icand=1,ncand
fc0=candidates(icand,1)
xsnr=candidates(icand,2)
xmax=-1e32
do i=-5,5
ft=fc0+i*0.2
call noncoherent_frame_sync(c2,ft,isync2,is,xf1)
if(xf1.gt.xmax) then
xmax=xf1
fc1=ft
is0=is
endif
enddo
call coherent_preamble_fsync(c2,ipreamble,nsync,NSPS,is0,fc1,fcest,xp1)
call noncoherent_frame_sync(c2,fcest,isync2,istart,xf2)
write(*,'(i5,i5,i5,4(f11.5,2x))') ifile,iii,istart,fc0,fc1,fcest
do ijitter=0,4
io=-10*(ijitter/2+1)
if(mod(ijitter,2).eq.0) io=10*(ijitter/2)
ib=max(0,istart+io)
cframe=c2(ib:ib+216*200-1)
call downsample2(cframe,fcest,cd)
s2=sum(cd*conjg(cd))/(10*216)
cd=cd/sqrt(s2)
do nseq=1,7
if( nseq.eq.1 ) then ! noncoherent single-symbol detection
sbits1=0.0
do ibit=1,216
j=isync2(ibit)
ib=(ibit-1)*10
ccor(1,ibit)=sum(cd(ib:ib+9)*conjg(c1(0:9,j)))
ccor(0,ibit)=sum(cd(ib:ib+9)*conjg(c0(0:9,j)))
sbits1(ibit)=abs(ccor(1,ibit))-abs(ccor(0,ibit))
hbits1(ibit)=0
if(sbits1(ibit).gt.0) hbits1(ibit)=1
enddo
sbits=sbits1
hbits=hbits1
sbits3=sbits1
hbits3=hbits1
elseif( nseq.ge.2 ) then
ps=0
if( nseq.eq. 2 ) nbit=3
if( nseq.eq. 3 ) nbit=5
if( nseq.eq. 4 ) nbit=7
if( nseq.eq. 5 ) nbit=9
if( nseq.eq. 6 ) nbit=11
if( nseq.eq. 7 ) nbit=13
numseq=2**(nbit)
do ibit=nbit/2+1,216-nbit/2
ps=0.0
pmax=0.0
do iseq=0,numseq-1
csum=0.0
cterm=1.0
k=1
do i=nbit-1,0,-1
ibb=iand(iseq/(2**i),1)
csum=csum+ccor(ibb,ibit-(nbit/2+1)+k)*cterm
cterm=-cterm
k=k+1
enddo
ps(iseq)=abs(csum)
if( ps(iseq) .gt. pmax ) then
pmax=ps(iseq)
ibflag=1
endif
enddo
if( ibflag .eq. 1 ) then
psbest=ps
ibflag=0
endif
call getmetric2(2**(nbit/2),psbest,numseq,sbits3(ibit))
hbits3(ibit)=0
if(sbits3(ibit).gt.0) hbits3(ibit)=1
enddo
sbits=sbits3
hbits=hbits3
endif
rxdata(1:100)=sbits(1:100)
rxdata(101:200)=sbits(117:216);
rxav=sum(rxdata(1:200))/200.0
rx2av=sum(rxdata(1:200)*rxdata(1:200))/200.0
rxsig=sqrt(rx2av-rxav*rxav)
rxdata=rxdata/rxsig
sigma=0.90
llr(201:204)=-5.0
llr(1:200)=2*rxdata/(sigma*sigma)
apmask=0
apmask(201:204)=1
max_iterations=40
ifer=0
call bpdecode204(llr,apmask,max_iterations,decoded,cw,nharderror,niterations)
nhardmin=-1
if(nharderror.lt.0) call osd204(llr,apmask,5,decoded,cw,nhardmin,dmin)
if(sum(decoded).eq.0) cycle
if(nhardmin.ge.0 .or. nharderror.ge.0) then
idat=0
write(dmsg,'(68i1)') decoded
read(dmsg(1:50),'(6b8.8,b2.2)') idat(1:7)
idat(7)=idat(7)*64
read(dmsg(51:64),'(b14.14)') ndec_crc
ncalc_crc=iand(crc14(c_loc(idat),9),z'FFFF')
nbadcrc=1
if(ncalc_crc .eq. ndec_crc) nbadcrc=0
else
cycle
endif
if( nbadcrc.eq.0 ) then
write(cbits,1200) decoded(1:50)
1200 format(50i1)
read(cbits,1202) idat
1202 format(8b8,b4)
idat(7)=ishft(idat(7),6)
call wqdecode(idat,message,itype)
idupe=0
do i=1,ndecodes
if(decodes(i).eq.message) idupe=1
enddo
if(idupe.eq.1) goto 888
ndecodes=ndecodes+1
decodes(ndecodes)=message
nsnr=nint(xsnr)
freq=fMHz + 1.d-6*(fc1+fbest)
nfdot=0
write(13,1210) datetime,0,nsnr,xdt,freq,message,nfdot
1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3)
write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*',idf,nseq,ijitter,nharderror,nhardmin
1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1,i5,i5,i5,i5,i5)
goto 888
endif
enddo ! nseq
enddo !jitter
888 continue
enddo !candidate list
enddo !files
write(*,1120)
1120 format("<DecodeFinished>")
999 end program wsprcpmd
subroutine coherent_preamble_fsync(c2,ipreamble,nsync,nsps,istart,fc0,fc1,xmax)
complex c2(0:120*12000/32-1)
complex cpreamble(0:16*200-1)
complex ctmp1(0:4*16*200-1)
complex ctwkp(0:16*200-1)
complex ccohp(0:15)
integer ipreamble(nsync)
logical first/.true./
save dt,first,h,twopi,cpreamble
if(first) then
baud=12000.0/6400.0
dt=32.0/12000.0
h=1.00
twopi=8.0*atan(1.0)
k=0
phi=0.0
dphi=twopi*baud*0.5*h*dt
do i=1,16
dp=dphi
if(ipreamble(i).eq.0) dp=-dphi
do j=1,200
cpreamble(k)=cmplx(cos(phi),sin(phi))
phi=mod(phi+dp,twopi)
k=k+1
enddo
enddo
first=.false.
endif
dphi=twopi*fc0*dt
ctwkp=cmplx(0.0,0.0)
phi=0
do i=0,nsync*nsps-1
ctwkp(i)=cpreamble(i)*cmplx(cos(phi),sin(phi))
phi=mod(phi+dphi,twopi)
enddo
ipstart=istart+100*200
ctmp1=0.0
ctmp1(0:16*200-1)=c2(ipstart:ipstart+16*200-1)*conjg(ctwkp)
call four2a(ctmp1,4*16*200,1,-1,1) !c2c FFT to freq domain
xmax=0.0
ctmp1=cshift(ctmp1,-200)
dfp=1/(4*6400.0/12000.0*16)
do i=150,250
xa=abs(ctmp1(i))
if(xa.gt.xmax) then
ishift=i
xmax=xa
endif
enddo
delta=(ishift-200)*dfp
xm1=abs(ctmp1(ishift-1))
x0=abs(ctmp1(ishift))
xp1=abs(ctmp1(ishift+1))
xint=(log(xm1)-log(xp1))/(log(xm1)+log(xp1)-2*log(x0))
delta2=delta+xint*dfp/2.0
fc1=fc0+delta2
return
end subroutine coherent_preamble_fsync
subroutine noncoherent_frame_sync(c2,fc,isync2,istart,ssmax)
complex c2(0:120*12000/32-1)
complex ct0(0:199),ct1(0:199),ct2(0:199),ct3(0:199)
integer isync2(216)
twopi=8.0*atan(1.0)
h=1.0
dt=32.0/12000.0
baud=12000.0/6400.0
imax=370 ! defines dt search range (375 samples/s)
ssmax=-1e32
izero=375
do it = -imax,imax,10
! noncoherent wspr-type dt estimation
dp0=twopi*(fc-1.5*h*baud)*dt
dp1=twopi*(fc-0.5*h*baud)*dt
dp2=twopi*(fc+0.5*h*baud)*dt
dp3=twopi*(fc+1.5*h*baud)*dt
th0=0.0
th1=0.0
th2=0.0
th3=0.0
do i=0,199
ct0(i)=cmplx(cos(th0),sin(th0))
ct1(i)=cmplx(cos(th1),sin(th1))
ct2(i)=cmplx(cos(th2),sin(th2))
ct3(i)=cmplx(cos(th3),sin(th3))
th0=mod(th0+dp0,twopi)
th1=mod(th1+dp1,twopi)
th2=mod(th2+dp2,twopi)
th3=mod(th3+dp3,twopi)
enddo
ss=0.0
totp=0.0
do is=1,216
i0=izero+it+(is-1)*200
p0=abs(sum(c2(i0:i0+199)*conjg(ct0)))
p1=abs(sum(c2(i0:i0+199)*conjg(ct1)))
p2=abs(sum(c2(i0:i0+199)*conjg(ct2)))
p3=abs(sum(c2(i0:i0+199)*conjg(ct3)))
p0=sqrt(p0)
p1=sqrt(p1)
p2=sqrt(p2)
p3=sqrt(p3)
totp=totp+p0+p1+p2+p3
! cmet=(p1+p3)-(p0+p2)
cmet=max(p1,p3)-max(p0,p2) ! This works better near threshold SNR
if(isync2(is).eq.0) ss=ss-cmet
if(isync2(is).eq.1) ss=ss+cmet
enddo
ss=ss/totp
if(ss.gt.ssmax) then
ioffset=it
ssmax=ss
endif
enddo
istart=izero+ioffset
return
end subroutine noncoherent_frame_sync
subroutine getmetric2(ib,ps,ns,xmet)
real ps(0:ns-1)
xm1=0
xm0=0
do i=0,ns-1
if( iand(i/ib,1) .eq. 1 .and. ps(i) .gt. xm1 ) xm1=ps(i)
if( iand(i/ib,1) .eq. 0 .and. ps(i) .gt. xm0 ) xm0=ps(i)
enddo
xmet=xm1-xm0
return
end subroutine getmetric2
subroutine downsample2(ci,f0,co)
parameter(NI=216*200,NH=NI/2,NO=NI/20) ! downsample from 200 samples per symbol to 10
complex ci(0:NI-1),ct(0:NI-1)
complex co(0:NO-1)
fs=12000.0/32.0
df=fs/NI
ct=ci
call four2a(ct,NI,1,-1,1) !c2c FFT to freq domain
i0=nint(f0/df)
ct=cshift(ct,i0)
co=0.0
co(0)=ct(0)
b=8.0
do i=1,NO/2
arg=(i*df/b)**2
filt=exp(-arg)
co(i)=ct(i)*filt
co(NO-i)=ct(NI-i)*filt
enddo
co=co/NO
call four2a(co,NO,1,1,1) !c2c FFT back to time domain
return
end subroutine downsample2
subroutine getcandidate2(c,npts,fs,fa,fb,ncand,candidates)
parameter(NDAT=200,NFFT1=120*12000/32,NH1=NFFT1/2,NFFT2=120*12000/320,NH2=NFFT2/2)
complex c(0:npts-1) !Complex waveform
complex cc(0:NFFT1-1)
complex csfil(0:NFFT2-1)
complex cwork(0:NFFT2-1)
real bigspec(0:NFFT2-1)
complex c2(0:NFFT1-1) !Short spectra
real s(-NH1+1:NH1) !Coarse spectrum
real ss(-NH1+1:NH1) !Smoothed coarse spectrum
real candidates(100,2)
integer indx(NFFT2-1)
logical first
data first/.true./
save first,w,df,csfil
if(first) then
df=10*fs/NFFT1
csfil=cmplx(0.0,0.0)
do i=0,NFFT2-1
csfil(i)=exp(-((i-NH2)/20.0)**2)
enddo
csfil=cshift(csfil,NH2)
call four2a(csfil,NFFT2,1,-1,1)
first=.false.
endif
cc=cmplx(0.0,0.0)
cc(0:npts-1)=c;
call four2a(cc,NFFT1,1,-1,1)
cc=abs(cc)**2
call four2a(cc,NFFT1,1,-1,1)
cwork(0:NH2)=cc(0:NH2)*conjg(csfil(0:NH2))
cwork(NH2+1:NFFT2-1)=cc(NFFT1-NH2+1:NFFT1-1)*conjg(csfil(NH2+1:NFFT2-1))
call four2a(cwork,NFFT2,1,+1,1)
bigspec=cshift(real(cwork),-NH2)
il=NH2+fa/df
ih=NH2+fb/df
nnl=ih-il+1
call indexx(bigspec(il:il+nnl-1),nnl,indx)
xn=bigspec(il-1+indx(nint(0.3*nnl)))
bigspec=bigspec/xn
ncand=0
do i=il,ih
if((bigspec(i).gt.bigspec(i-1)).and. &
(bigspec(i).gt.bigspec(i+1)).and. &
(bigspec(i).gt.1.15).and.ncand.lt.100) then
ncand=ncand+1
candidates(ncand,1)=df*(i-NH2)
candidates(ncand,2)=10*log10(bigspec(i))-30.0
endif
enddo
! do i=1,ncand
! write(*,*) i,candidates(i,1),candidates(i,2)
! enddo
return
end subroutine getcandidate2
subroutine wsprcpm_downsample(iwave,c)
! Input: i*2 data in iwave() at sample rate 12000 Hz
! Output: Complex data in c(), sampled at 400 Hz
include 'wsprcpm_params.f90'
parameter (NMAX=120*12000,NFFT2=NMAX/32)
integer*2 iwave(NMAX)
complex c(0:NMAX/32-1)
complex c1(0:NFFT2-1)
complex cx(0:NMAX/2)
real x(NMAX)
equivalence (x,cx)
df=12000.0/NMAX
x=iwave
call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
i0=nint(1500.0/df)
c1(0)=cx(i0)
do i=1,NFFT2/2
c1(i)=cx(i0+i)
c1(NFFT2-i)=cx(i0-i)
enddo
c1=c1/NFFT2
call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain
c=c1(0:NMAX/32-1)
return
end subroutine wsprcpm_downsample
@@ -1,220 +0,0 @@
72 144
9 4
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
1 19 38 57 74 94 110 128 0
2 20 39 58 75 95 111 129 0
3 21 40 59 76 95 108 130 0
4 22 41 60 69 96 112 131 0
2 19 42 60 77 97 113 132 0
5 20 43 61 78 98 114 133 0
6 22 44 62 79 99 115 127 0
7 23 41 58 73 100 113 134 0
8 23 45 63 80 101 114 135 0
7 24 46 64 81 98 112 136 0
9 25 47 64 75 102 116 130 0
9 22 48 59 82 98 117 137 0
10 25 49 65 80 99 118 132 0
11 26 50 66 75 96 119 127 0
12 27 43 67 82 103 120 136 0
13 28 50 68 82 97 121 138 0
8 29 47 62 83 104 121 132 0
13 25 38 53 61 100 111 135 0
14 22 38 63 83 95 122 133 0
15 30 41 63 81 105 123 129 0
1 28 51 64 80 104 119 126 0
12 24 40 69 84 100 124 133 0
16 23 52 65 77 106 110 139 0
11 31 37 55 85 101 118 140 0
13 32 48 70 77 94 122 140 0
2 27 53 71 78 101 110 131 0
4 29 46 71 77 88 124 130 0
14 24 49 56 86 107 119 130 144
14 33 47 70 87 108 115 137 0
6 32 52 69 78 91 125 141 0
15 26 51 61 76 86 117 140 0
17 33 51 59 88 109 113 142 0
6 31 40 54 88 102 111 136 0
5 33 54 62 86 103 118 141 0
13 24 44 72 75 103 114 142 0
15 34 47 67 85 99 110 143 0
18 28 49 58 89 92 122 131 0
18 21 38 68 85 91 115 129 0
11 33 36 58 84 106 121 128 0
10 20 50 59 90 94 120 135 0
5 29 42 55 89 106 117 136 0
3 30 45 61 84 104 115 144 0
15 20 52 57 89 102 126 142 0
16 35 53 72 80 102 125 143 0
9 26 39 71 74 105 125 139 0
16 30 44 71 85 90 112 134 0
17 25 55 69 76 105 119 134 0
10 35 37 63 91 108 113 144 0
17 27 44 57 87 92 123 143 0
3 32 46 67 92 96 109 0 0
10 36 46 60 93 107 111 133 0
4 35 54 56 74 100 117 138 0
6 34 39 66 87 93 118 138 0
7 34 48 55 83 96 120 139 0
12 35 42 68 79 105 112 141 0
2 31 51 67 79 107 116 128 0
1 29 40 73 90 101 125 138 0
3 19 37 72 87 99 122 139 0
12 26 45 65 73 92 121 137 0
14 30 42 66 74 109 114 140 0
1 36 48 56 81 97 116 134 0
7 19 50 62 91 107 109 143 0
17 23 56 70 78 93 120 129 0
8 36 53 68 86 108 123 142 0
4 21 39 70 89 98 123 132 0
18 27 54 66 81 104 106 137 0
8 31 49 57 82 93 124 127 0
9 37 43 73 84 95 126 131 0
18 34 45 72 88 94 116 141 0
11 21 52 64 79 103 124 135 0
5 32 41 65 90 97 126 128 0
16 28 43 60 76 83 127 144 0
1 21 57 61
2 5 26 56
3 42 50 58
4 27 52 65
6 34 41 71
7 30 33 53
8 10 54 62
9 17 64 67
11 12 45 68
13 40 48 51
14 24 39 70
15 22 55 59
16 18 25 35
19 28 29 60
20 31 36 43
23 44 46 72
32 47 49 63
37 38 66 69
1 5 58 62
2 6 40 43
3 38 65 70
4 7 12 19
8 9 23 63
10 22 28 35
11 13 18 47
14 31 45 59
15 26 49 66
16 21 37 72
17 27 41 57
20 42 46 60
24 33 56 67
25 30 50 71
29 32 34 39
36 53 54 69
44 48 52 55
39 51 61 64
24 48 58 68
1 18 19 38
2 45 53 65
3 22 33 57
4 8 20 71
5 41 55 60
6 15 68 72
7 35 46 49
9 42 59 69
10 27 50 51
11 17 29 36
12 25 54 61
13 28 37 67
14 16 40 62
21 31 32 56
23 30 43 70
18 26 44 64
33 34 52 66
24 41 47 54
28 52 61 63
1 43 49 67
2 8 37 39
3 12 32 40
4 5 51 72
6 18 31 42
7 17 34 62
9 19 20 48
10 11 21 70
13 23 59 71
14 53 60 66
15 36 50 56
16 38 55 64
4 22 30 47
25 29 63 65
26 27 45 46
35 44 58 69
8 57 59 68
1 45 52 60
2 11 14 35
3 31 47 72
5 23 25 27
6 26 30 63
7 55 56 70
9 13 21 44
10 20 61 66
12 15 16 67
17 19 54 72
22 39 42 68
24 36 38 46
28 31 34 64
29 49 53 58
27 32 33 69
37 41 43 65
40 46 57 71
30 38 48 62
37 49 50 59
51 53 63 67
1 25 40 69
2 3 19 68
4 14 50 54
5 16 61 71
6 10 12 65
7 13 36 58
8 18 22 52
9 24 26 57
11 33 43 44
15 34 35 70
17 21 42 66
20 45 47 55
23 39 41 66
28 51 56 62
3 29 48 64
32 50 60 62
1 23 26 36
2 18 33 51
4 10 46 55
5 8 32 48
6 9 35 60
7 29 38 42
11 56 61 69
12 31 41 52
13 24 34 53
14 21 28 47
15 40 54 63
16 17 39 59
19 25 37 58
20 49 64 65
22 27 67 70
30 44 45 57
21 43 68 71
7 14 67 72
1 39 56 71
2 20 38 63
3 11 27 28
4 26 37 68
5 13 17 65
6 19 22 51
8 46 47 61
9 18 40 70
10 15 33 41
12 29 59 66
16 52 53 57
23 45 54 58
24 25 31 60
30 34 55 69
32 35 43 64
36 44 49 62
28 42 48 72
@@ -1,218 +0,0 @@
#include "displaytext.h"
#include <QMouseEvent>
#include <QDateTime>
#include <QTextCharFormat>
#include <QTextCursor>
#include <QTextBlock>
#include "qt_helpers.hpp"
#include "moc_displaytext.cpp"
DisplayText::DisplayText(QWidget *parent) :
QTextEdit(parent)
{
setReadOnly (true);
viewport ()->setCursor (Qt::ArrowCursor);
setWordWrapMode (QTextOption::NoWrap);
document ()->setMaximumBlockCount (5000); // max lines to limit heap usage
}
void DisplayText::setContentFont(QFont const& font)
{
char_font_ = font;
selectAll ();
auto cursor = textCursor ();
cursor.beginEditBlock ();
auto char_format = cursor.charFormat ();
char_format.setFont (char_font_);
cursor.mergeCharFormat (char_format);
cursor.clearSelection ();
cursor.movePosition (QTextCursor::End);
// position so viewport scrolled to left
cursor.movePosition (QTextCursor::Up);
cursor.movePosition (QTextCursor::StartOfLine);
cursor.endEditBlock ();
setTextCursor (cursor);
ensureCursorVisible ();
}
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
{
bool ctrl = (e->modifiers() & Qt::ControlModifier);
bool alt = (e->modifiers() & Qt::AltModifier);
emit(selectCallsign(alt,ctrl));
QTextEdit::mouseDoubleClickEvent(e);
}
void DisplayText::insertLineSpacer(QString const& line)
{
appendText (line, "#d3d3d3");
}
void DisplayText::appendText(QString const& text, QColor bg)
{
auto cursor = textCursor ();
cursor.movePosition (QTextCursor::End);
auto block_format = cursor.blockFormat ();
block_format.setBackground (bg);
if (0 == cursor.position ())
{
cursor.setBlockFormat (block_format);
auto char_format = cursor.charFormat ();
char_format.setFont (char_font_);
cursor.setCharFormat (char_format);
}
else
{
cursor.insertBlock (block_format);
}
cursor.insertText (text);
// position so viewport scrolled to left
cursor.movePosition (QTextCursor::StartOfLine);
setTextCursor (cursor);
ensureCursorVisible ();
document ()->setMaximumBlockCount (document ()->maximumBlockCount ());
}
QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg,
LogBook logBook, QColor color_CQ,
QColor color_DXCC,
QColor color_NewCall)
{
QString call = callsign;
QString countryName;
bool callWorkedBefore;
bool countryWorkedBefore;
if(call.length()==2) {
int i0=message.indexOf("CQ "+call);
call=message.mid(i0+6,-1);
i0=call.indexOf(" ");
call=call.mid(0,i0);
}
if(call.length()<3) return message;
if(!call.contains(QRegExp("[0-9]|[A-Z]"))) return message;
logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
int charsAvail = 48;
// the decoder (seems) to always generate 41 chars. For a normal CQ call, the last five are spaces
// TODO this magic 37 characters is also referenced in MainWindow::doubleClickOnCall()
int nmin=37;
int i=message.indexOf(" CQ ");
int k=message.mid(i+4,3).toInt();
if(k>0 and k<999) nmin += 4;
int s3 = message.indexOf(" ",nmin);
if (s3 < nmin) s3 = nmin; // always want at least the characters to position 35
s3 += 1; // convert the index into a character count
message = message.left(s3); // reduce trailing white space
charsAvail -= s3;
if (charsAvail > 4)
{
if (!countryWorkedBefore) // therefore not worked call either
{
message += "!";
*bg = color_DXCC;
}
else
if (!callWorkedBefore) // but have worked the country
{
message += "~";
*bg = color_NewCall;
}
else
{
message += " "; // have worked this call before
*bg = color_CQ;
}
charsAvail -= 1;
// do some obvious abbreviations
countryName.replace ("Islands", "Is.");
countryName.replace ("Island", "Is.");
countryName.replace ("North ", "N. ");
countryName.replace ("Northern ", "N. ");
countryName.replace ("South ", "S. ");
countryName.replace ("East ", "E. ");
countryName.replace ("Eastern ", "E. ");
countryName.replace ("West ", "W. ");
countryName.replace ("Western ", "W. ");
countryName.replace ("Central ", "C. ");
countryName.replace (" and ", " & ");
countryName.replace ("Republic", "Rep.");
countryName.replace ("United States", "U.S.A.");
countryName.replace ("Fed. Rep. of ", "");
countryName.replace ("French ", "Fr.");
countryName.replace ("Asiatic", "AS");
countryName.replace ("European", "EU");
countryName.replace ("African", "AF");
message += countryName;
}
return message;
}
void DisplayText::displayDecodedText(DecodedText decodedText, QString myCall,
bool displayDXCCEntity, LogBook logBook,
QColor color_CQ, QColor color_MyCall,
QColor color_DXCC, QColor color_NewCall)
{
QColor bg {Qt::white};
bool CQcall = false;
if (decodedText.string ().contains (" CQ ")
|| decodedText.string ().contains (" CQDX ")
|| decodedText.string ().contains (" QRZ "))
{
CQcall = true;
bg = color_CQ;
}
if (myCall != "" and (
decodedText.indexOf (" " + myCall + " ") >= 0
or decodedText.indexOf (" " + myCall + "/") >= 0
or decodedText.indexOf ("/" + myCall + " ") >= 0
or decodedText.indexOf ("<" + myCall + " ") >= 0
or decodedText.indexOf (" " + myCall + ">") >= 0)) {
bg = color_MyCall;
}
// if enabled add the DXCC entity and B4 status to the end of the
// preformated text line t1
auto message = decodedText.string ();
if (displayDXCCEntity && CQcall)
message = appendDXCCWorkedB4 (message, decodedText.CQersCall (), &bg, logBook, color_CQ,
color_DXCC, color_NewCall);
appendText (message, bg);
}
void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 txFreq,
QColor color_TxMsg, bool bFastMode)
{
QString t1=" @ ";
if(modeTx=="FT8") t1=" ~ ";
if(modeTx=="JT4") t1=" $ ";
if(modeTx=="JT65") t1=" # ";
if(modeTx=="MSK144") t1=" & ";
QString t2;
t2.sprintf("%4d",txFreq);
QString t;
if(bFastMode or modeTx=="FT8") {
t = QDateTime::currentDateTimeUtc().toString("hhmmss") + \
" Tx " + t2 + t1 + text;
} else {
t = QDateTime::currentDateTimeUtc().toString("hhmm") + \
" Tx " + t2 + t1 + text;
}
appendText (t, color_TxMsg);
}
void DisplayText::displayQSY(QString text)
{
QString t = QDateTime::currentDateTimeUtc().toString("hhmmss") + " " + text;
appendText (t, "hotpink");
}
@@ -1,87 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>wf_palette_design_dialog</class>
<widget class="QDialog" name="wf_palette_design_dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>181</width>
<height>209</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTableWidget" name="colour_table_widget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Double click a color to edit it.&lt;/p&gt;&lt;p&gt;Right click to insert or delete colors.&lt;/p&gt;&lt;p&gt;Colors at the top represent weak signals&lt;/p&gt;&lt;p&gt;and colors at the bottom represent strong&lt;/p&gt;&lt;p&gt;signals. You can have up to 256 colors.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="columnCount">
<number>1</number>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column/>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="button_box">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>button_box</sender>
<signal>accepted()</signal>
<receiver>wf_palette_design_dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_box</sender>
<signal>rejected()</signal>
<receiver>wf_palette_design_dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>