From 6bf4b413112dab1b959d3b915621c8e7b9b82d86 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Thu, 7 May 2020 15:32:28 -0400 Subject: [PATCH] Working automatic time sync based on syncStats --- commons.h | 2 +- lib/decoder.f90 | 12 +++--- lib/js8/js8a_params.f90 | 1 + lib/js8/js8b_params.f90 | 1 + lib/js8/js8c_params.f90 | 1 + lib/js8/js8dec.f90 | 13 +++--- lib/js8/js8e_params.f90 | 1 + lib/js8/js8i_params.f90 | 1 + lib/js8a_decode.f90 | 28 ++----------- lib/js8b_decode.f90 | 6 +-- lib/js8c_decode.f90 | 6 +-- lib/js8e_decode.f90 | 6 +-- lib/js8i_decode.f90 | 6 +-- lib/jt9.f90 | 8 ++-- lib/jt9com.f90 | 2 +- mainwindow.cpp | 87 ++++++++++++++++++++++------------------- widegraph.cpp | 2 + 17 files changed, 86 insertions(+), 97 deletions(-) diff --git a/commons.h b/commons.h index 0cc67f7..d7ec425 100644 --- a/commons.h +++ b/commons.h @@ -97,7 +97,7 @@ extern struct dec_data { int nfSplit; // JT65 | JT9 split frequency int nfb; // High decode limit (Hz) (filter max) int ntol; // +/- decoding range around fQSO (Hz) - bool synconly; // only compute sync candidates + bool syncStats; // only compute sync candidates int kin; // number of frames written to d2 int kposA; // starting position of decode for submode A int kposB; // starting position of decode for submode B diff --git a/lib/decoder.f90 b/lib/decoder.f90 index ab20fc6..593086b 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -94,7 +94,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) params%nftx,newdat,params%nutc,params%nfa,params%nfb, & params%nexp_decode,params%ndepth,logical(params%nagain), & logical(params%lft8apon),logical(params%lapcqonly),params%napwid, & - mycall,mygrid,hiscall,hisgrid) + mycall,mygrid,hiscall,hisgrid,logical(params%syncStats)) write(*,*) ' mode I decode finished' @@ -117,7 +117,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) params%nftx,newdat,params%nutc,params%nfa,params%nfb, & params%nexp_decode,params%ndepth,logical(params%nagain), & logical(params%lft8apon),logical(params%lapcqonly),params%napwid, & - mycall,mygrid,hiscall,hisgrid) + mycall,mygrid,hiscall,hisgrid,logical(params%syncStats)) write(*,*) ' mode E decode finished' @@ -140,7 +140,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) params%nftx,newdat,params%nutc,params%nfa,params%nfb, & params%nexp_decode,params%ndepth,logical(params%nagain), & logical(params%lft8apon),logical(params%lapcqonly),params%napwid, & - mycall,mygrid,hiscall,hisgrid) + mycall,mygrid,hiscall,hisgrid,logical(params%syncStats)) write(*,*) ' mode C decode finished' @@ -163,7 +163,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) params%nftx,newdat,params%nutc,params%nfa,params%nfb, & params%nexp_decode,params%ndepth,logical(params%nagain), & logical(params%lft8apon),logical(params%lapcqonly),params%napwid, & - mycall,mygrid,hiscall,hisgrid) + mycall,mygrid,hiscall,hisgrid,logical(params%syncStats)) write(*,*) ' mode B decode finished' @@ -197,7 +197,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) params%nftx,newdat,params%nutc,params%nfa,params%nfb, & params%nexp_decode,params%ndepth,logical(params%nagain), & logical(params%lft8apon),logical(params%lapcqonly),params%napwid, & - mycall,mygrid,hiscall,hisgrid,logical(params%synconly)) + mycall,mygrid,hiscall,hisgrid,logical(params%syncStats)) write(*,*) ' mode A decode finished' @@ -207,7 +207,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) write(*,*) ' finished' call flush(6) - ndecoded = my_js8a%decoded + my_js8b%decoded + my_js8c%decoded + my_js8e%decoded + ndecoded = my_js8a%decoded + my_js8b%decoded + my_js8c%decoded + my_js8e%decoded + my_js8i%decoded !call sleep_msec(3000) write(*,1010) ndecoded 1010 format('',i4) diff --git a/lib/js8/js8a_params.f90 b/lib/js8/js8a_params.f90 index e98959f..0092ae7 100644 --- a/lib/js8/js8a_params.f90 +++ b/lib/js8/js8a_params.f90 @@ -1,5 +1,6 @@ ! When modifying this file, please ensure the modifications are made in ft8_params.f90 too. +parameter (NSUBMODE=0) parameter (NCOSTAS=1) !Which JS8 Costas Arrays to use (1=original, 2=three symmetrical costas) parameter (NSPS=1920, NTXDUR=15, NDOWNSPS=32, NDD=100, JZ=36) ! 50 Hz 6.250 baud 16 wpm -25.0dB (1.0Eb/N0) 12.64s diff --git a/lib/js8/js8b_params.f90 b/lib/js8/js8b_params.f90 index 65aba11..8f98a3e 100644 --- a/lib/js8/js8b_params.f90 +++ b/lib/js8/js8b_params.f90 @@ -1,3 +1,4 @@ +parameter (NSUBMODE=1) parameter (NCOSTAS=2) !Which JS8 Costas Arrays to use (1=original, 2=three symmetrical costas) parameter (NSPS=1200, NTXDUR=10, NDOWNSPS=20, NDD=100, JZ=144) ! 80 Hz 10 baud 24 wpm -23.0dB (1.0Eb/N0) 7.90s diff --git a/lib/js8/js8c_params.f90 b/lib/js8/js8c_params.f90 index 7be1230..2cbb088 100644 --- a/lib/js8/js8c_params.f90 +++ b/lib/js8/js8c_params.f90 @@ -1,3 +1,4 @@ +parameter (NSUBMODE=2) parameter (NCOSTAS=2) !Which JS8 Costas Arrays to use (1=original, 2=three symmetrical costas) parameter (NSPS=600, NTXDUR=6, NDOWNSPS=12, NDD=120, JZ=172) ! 160 Hz 20 baud 40 wpm -20.0dB (1.0Eb/N0) 3.95s diff --git a/lib/js8/js8dec.f90 b/lib/js8/js8dec.f90 index d3e123c..df3dc2d 100644 --- a/lib/js8/js8dec.f90 +++ b/lib/js8/js8dec.f90 @@ -1,4 +1,4 @@ -subroutine js8dec(dd0,icos,newdat,synconly,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & +subroutine js8dec(dd0,icos,newdat,syncStats,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & napwid,lsubtract,nagain,iaptype,mycall12,mygrid6,hiscall12,bcontest, & sync0,f1,xdt,xbase,apsym,nharderrors,dmin,nbadcrc,ipass,iera,msg37,xsnr) @@ -14,7 +14,7 @@ subroutine js8dec(dd0,icos,newdat,synconly,nQSOProgress,nfqso,nftx,ndepth,lapon, character*12 mycall12,hiscall12 character*6 mycall6,mygrid6,hiscall6,c1,c2 character*87 cbits - logical bcontest,synconly + logical bcontest,syncStats real a(5) real s1(0:7,ND),s2(0:7,NN),s1sort(8*ND) real ps(0:7),psl(0:7) @@ -224,8 +224,8 @@ subroutine js8dec(dd0,icos,newdat,synconly,nQSOProgress,nfqso,nftx,ndepth,lapon, return endif - if(synconly) then - write(*,*) ' candidate X ', 'f1', f1, 'sync', nsync, 'xdt', xdt + if(syncStats) then + write(*,*) ' candidate ', NSUBMODE, 'f1', f1, 'sync', nsync, 'xdt', xdt flush(6) endif @@ -422,9 +422,8 @@ subroutine js8dec(dd0,icos,newdat,synconly,nQSOProgress,nfqso,nftx,ndepth,lapon, i3bit=4*decoded(73) + 2*decoded(74) + decoded(75) if(nbadcrc.eq.0) then - - if(synconly) then - write(*,*) ' decode X ', 'f1', f1, 'sync', (sync*10), 'xdt', xdt2 + if(syncStats) then + write(*,*) ' decode ', NSUBMODE, 'f1', f1, 'sync', (sync*10), 'xdt', xdt2 flush(6) endif diff --git a/lib/js8/js8e_params.f90 b/lib/js8/js8e_params.f90 index 9c9a6bd..9f444ff 100644 --- a/lib/js8/js8e_params.f90 +++ b/lib/js8/js8e_params.f90 @@ -1,3 +1,4 @@ +parameter (NSUBMODE=4) parameter (NCOSTAS=2) !Which JS8 Costas Arrays to use (1=original, 2=three symmetrical costas) parameter (NSPS=3840, NTXDUR=28, NDOWNSPS=32, NDD=90, JZ=32) ! 25 Hz 3.125 baud 8 wpm -28.0dB (1.0Eb/N0) 25.28s diff --git a/lib/js8/js8i_params.f90 b/lib/js8/js8i_params.f90 index 688a991..4aeaaf1 100644 --- a/lib/js8/js8i_params.f90 +++ b/lib/js8/js8i_params.f90 @@ -1,3 +1,4 @@ +parameter (NSUBMODE=8) parameter (NCOSTAS=2) !Which JS8 Costas Arrays to use (1=original, 2=three symmetrical costas) parameter (NSPS=384, NTXDUR=4, NDOWNSPS=12, NDD=125, JZ=250) ! 250 Hz 31.25 baud 60 wpm -18.0dB (1.0Eb/N0) 2.52s diff --git a/lib/js8a_decode.f90 b/lib/js8a_decode.f90 index ce47087..2ddd004 100644 --- a/lib/js8a_decode.f90 +++ b/lib/js8a_decode.f90 @@ -25,7 +25,7 @@ contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, & nutc,nfa,nfb,nexp_decode,ndepth,nagain,lft8apon,lapcqonly,napwid, & - mycall12,mygrid6,hiscall12,hisgrid6,synconly) + mycall12,mygrid6,hiscall12,hisgrid6,syncStats) ! use wavhdr use timer_module, only: timer ! type(hdr) h @@ -38,7 +38,7 @@ contains real candidate(3,NMAXCAND) real dd(NMAX) logical, intent(in) :: lft8apon,lapcqonly,nagain - logical newdat,lsubtract,ldupe,bcontest,synconly + logical newdat,lsubtract,ldupe,bcontest,syncStats character*12 mycall12, hiscall12 character*6 mygrid6,hisgrid6 integer*2 iwave(NMAX) @@ -93,32 +93,10 @@ contains lsubtract=.false. endif - if(synconly) then - if(NWRITELOG.eq.0) then - write(*,*) ' synconly' - flush(6) - endif - endif - call timer('syncjs8 ',0) call syncjs8(dd,icos,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase) call timer('syncjs8 ',1) - !if(NWRITELOG.eq.0) then - ! write(*,*) '', ncand, "candidates" - ! flush(6) - - ! do icand=1,ncand - ! sync=candidate(3,icand) - ! f1=candidate(1,icand) - ! xdt=candidate(2,icand) - ! xbase=10.0**(0.1*(sbase(nint(f1/(12000.0/NFFT1)))-40.0)) ! 3.125Hz - - ! write(*,*) ' candidate', icand, 'f1', f1, 'sync', sync, 'xdt', xdt, 'xbase', xbase - ! flush(6) - ! enddo - !endif - do icand=1,ncand sync=candidate(3,icand) f1=candidate(1,icand) @@ -131,7 +109,7 @@ contains endif call timer('js8dec ',0) - call js8dec(dd,icos,newdat,synconly,nQSOProgress,nfqso,nftx,ndepth,lft8apon, & + call js8dec(dd,icos,newdat,syncStats,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) diff --git a/lib/js8b_decode.f90 b/lib/js8b_decode.f90 index 99f1392..eab3524 100644 --- a/lib/js8b_decode.f90 +++ b/lib/js8b_decode.f90 @@ -25,7 +25,7 @@ contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, & nutc,nfa,nfb,nexp_decode,ndepth,nagain,lft8apon,lapcqonly,napwid, & - mycall12,mygrid6,hiscall12,hisgrid6) + mycall12,mygrid6,hiscall12,hisgrid6,syncStats) ! use wavhdr use timer_module, only: timer ! type(hdr) h @@ -38,7 +38,7 @@ contains real candidate(3,NMAXCAND) real dd(NMAX) logical, intent(in) :: lft8apon,lapcqonly,nagain - logical newdat,lsubtract,ldupe,bcontest + logical newdat,lsubtract,ldupe,bcontest,syncStats character*12 mycall12, hiscall12 character*6 mygrid6,hisgrid6 integer*2 iwave(NMAX) @@ -114,7 +114,7 @@ contains endif call timer('js8dec ',0) - call js8dec(dd,icos,newdat,.false.,nQSOProgress,nfqso,nftx,ndepth,lft8apon, & + call js8dec(dd,icos,newdat,syncStats,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) diff --git a/lib/js8c_decode.f90 b/lib/js8c_decode.f90 index 69377c6..df75c5a 100644 --- a/lib/js8c_decode.f90 +++ b/lib/js8c_decode.f90 @@ -25,7 +25,7 @@ contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, & nutc,nfa,nfb,nexp_decode,ndepth,nagain,lft8apon,lapcqonly,napwid, & - mycall12,mygrid6,hiscall12,hisgrid6) + mycall12,mygrid6,hiscall12,hisgrid6,syncStats) ! use wavhdr use timer_module, only: timer ! type(hdr) h @@ -38,7 +38,7 @@ contains real candidate(3,NMAXCAND) real dd(NMAX) logical, intent(in) :: lft8apon,lapcqonly,nagain - logical newdat,lsubtract,ldupe,bcontest + logical newdat,lsubtract,ldupe,bcontest,syncStats character*12 mycall12, hiscall12 character*6 mygrid6,hisgrid6 integer*2 iwave(NMAX) @@ -114,7 +114,7 @@ contains endif call timer('js8dec ',0) - call js8dec(dd,icos,newdat,.false.,nQSOProgress,nfqso,nftx,ndepth,lft8apon, & + call js8dec(dd,icos,newdat,syncStats,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) diff --git a/lib/js8e_decode.f90 b/lib/js8e_decode.f90 index aa73861..1461163 100644 --- a/lib/js8e_decode.f90 +++ b/lib/js8e_decode.f90 @@ -25,7 +25,7 @@ contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, & nutc,nfa,nfb,nexp_decode,ndepth,nagain,lft8apon,lapcqonly,napwid, & - mycall12,mygrid6,hiscall12,hisgrid6) + mycall12,mygrid6,hiscall12,hisgrid6,syncStats) ! use wavhdr use timer_module, only: timer ! type(hdr) h @@ -38,7 +38,7 @@ contains real candidate(3,NMAXCAND) real dd(NMAX) logical, intent(in) :: lft8apon,lapcqonly,nagain - logical newdat,lsubtract,ldupe,bcontest + logical newdat,lsubtract,ldupe,bcontest,syncStats character*12 mycall12, hiscall12 character*6 mygrid6,hisgrid6 integer*2 iwave(NMAX) @@ -114,7 +114,7 @@ contains endif call timer('js8dec ',0) - call js8dec(dd,icos,newdat,.false.,nQSOProgress,nfqso,nftx,ndepth,lft8apon, & + call js8dec(dd,icos,newdat,syncStats,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) diff --git a/lib/js8i_decode.f90 b/lib/js8i_decode.f90 index d5d0788..044522f 100644 --- a/lib/js8i_decode.f90 +++ b/lib/js8i_decode.f90 @@ -25,7 +25,7 @@ contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, & nutc,nfa,nfb,nexp_decode,ndepth,nagain,lft8apon,lapcqonly,napwid, & - mycall12,mygrid6,hiscall12,hisgrid6) + mycall12,mygrid6,hiscall12,hisgrid6,syncStats) ! use wavhdr use timer_module, only: timer ! type(hdr) h @@ -38,7 +38,7 @@ contains real candidate(3,NMAXCAND) real dd(NMAX) logical, intent(in) :: lft8apon,lapcqonly,nagain - logical newdat,lsubtract,ldupe,bcontest + logical newdat,lsubtract,ldupe,bcontest,syncStats character*12 mycall12, hiscall12 character*6 mygrid6,hisgrid6 integer*2 iwave(NMAX) @@ -114,7 +114,7 @@ contains endif call timer('js8dec ',0) - call js8dec(dd,icos,newdat,.false.,nQSOProgress,nfqso,nftx,ndepth,lft8apon, & + call js8dec(dd,icos,newdat,syncStats,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) diff --git a/lib/jt9.f90 b/lib/jt9.f90 index 30173ad..79aea64 100644 --- a/lib/jt9.f90 +++ b/lib/jt9.f90 @@ -21,7 +21,7 @@ program jt9 !### ndepth was defined as 60001. Why??? integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, & fhigh=4000,nrxfreq=1500,ntrperiod=1,ndepth=1,nexp_decode=0 - logical :: read_files = .true., tx9 = .false., display_help = .false., synconly = .false. + logical :: read_files = .true., tx9 = .false., display_help = .false., syncStats = .false. type (option) :: long_options(22) = [ & option ('help', .false., 'h', 'Display this help message', ''), & option ('shmem',.true.,'s','Use shared memory for sample data','KEY'), & @@ -50,7 +50,7 @@ program jt9 !option ('jt65', .false., '6', 'JT65 mode', ''), & !option ('jt9', .false., '9', 'JT9 mode', ''), & option ('js8', .false., '8', 'JS8 mode', ''), & - option ('synconly', .false., 'y', 'Sync only', ''), & + option ('syncStats', .false., 'y', 'Sync only', ''), & !option ('jt4', .false., '4', 'JT4 mode', ''), & !option ('qra64', .false., 'q', 'QRA64 mode', ''), & option ('sub-mode', .true., 'b', 'Sub mode, default SUBMODE=A', 'A'), & @@ -120,7 +120,7 @@ program jt9 case ('8') mode = 8 case ('y') - synconly = .true. + syncStats = .true. case ('T') tx9 = .true. case ('w') @@ -257,7 +257,7 @@ program jt9 shared_data%params%ljt65apon=.true. shared_data%params%napwid=75 shared_data%params%dttol=3. - shared_data%params%synconly=synconly + shared_data%params%syncStats=syncStats ! shared_data%params%minsync=0 !### TEST ONLY ! shared_data%params%nfqso=1500 !### TEST ONLY diff --git a/lib/jt9com.f90 b/lib/jt9com.f90 index 3999653..0a69ef2 100644 --- a/lib/jt9com.f90 +++ b/lib/jt9com.f90 @@ -18,7 +18,7 @@ integer(c_int) :: nfsplit integer(c_int) :: nfb integer(c_int) :: ntol - logical(c_bool) :: synconly + logical(c_bool) :: syncStats integer(c_int) :: kin integer(c_int) :: kposA integer(c_int) :: kposB diff --git a/mainwindow.cpp b/mainwindow.cpp index e313e71..ffc9743 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4267,39 +4267,21 @@ bool MainWindow::decodeEnqueueReady(qint32 k, qint32 k0){ // on an interval, issue a decode static qint32 lastDecodeStartA = -1; + static qint32 currentDecodeStartA = -1; + static qint32 nextDecodeStartA = -1; + qint32 startA = -1; qint32 szA = -1; qint32 cycleA = -1; bool couldDecodeA = false; - qint32 oneSecondFrames = computeFramesPerCycleForDecode(Varicode::JS8CallNormal)/computePeriodForSubmode(Varicode::JS8CallNormal); - if(lastDecodeStartA == -1 || k < k0 || k - lastDecodeStartA > oneSecondFrames){ - startA = k-computeFramesNeededForDecode(Varicode::JS8CallNormal); - if(startA < 0){ - // TODO: decoder doesn't copy wrap around ranges - startA += m_detector->period() * RX_SAMPLE_RATE; - } - - szA = computeFramesNeededForDecode(Varicode::JS8CallNormal); - lastDecodeStartA = k; - couldDecodeA = true; - qDebug() << "? NORMAL " << startA << k << k0; - } - -#if 0 - static qint32 currentDecodeStartA = -1; - static qint32 nextDecodeStartA = -1; - qint32 startA = -1; - qint32 szA = -1; - qint32 cycleA = -1; if(JS8_DEBUG_DECODE) qDebug() << "? NORMAL " << currentDecodeStartA << nextDecodeStartA; - bool couldDecodeA = isDecodeReady(Varicode::JS8CallNormal, k, k0, ¤tDecodeStartA, &nextDecodeStartA, &startA, &szA, &cycleA); + couldDecodeA = isDecodeReady(Varicode::JS8CallNormal, k, k0, ¤tDecodeStartA, &nextDecodeStartA, &startA, &szA, &cycleA); if(m_diskData){ startA = 0; szA = NTMAX*RX_SAMPLE_RATE-1; couldDecodeA = true; } -#endif static qint32 currentDecodeStartB = -1; static qint32 nextDecodeStartB = -1; @@ -4357,11 +4339,28 @@ bool MainWindow::decodeEnqueueReady(qint32 k, qint32 k0){ } #endif - - couldDecodeB = couldDecodeC = couldDecodeE = false; - int decodes = 0; + // default to including sync stats + dec_data.params.syncStats = true; + + // when no other mode is being decoded, do a sync stats decode for normal mode + if(!couldDecodeA && !couldDecodeB && !couldDecodeC && !couldDecodeE){ + qint32 oneSecondFrames = computeFramesPerCycleForDecode(Varicode::JS8CallNormal)/computePeriodForSubmode(Varicode::JS8CallNormal); + if(lastDecodeStartA == -1 || k < k0 || k - lastDecodeStartA > oneSecondFrames){ + startA = k-computeFramesNeededForDecode(Varicode::JS8CallNormal); + + if(startA < 0){ + // decoder wraps around ranges + startA += m_detector->period() * RX_SAMPLE_RATE; + } + + szA = computeFramesNeededForDecode(Varicode::JS8CallNormal); + lastDecodeStartA = k; + couldDecodeA = true; + } + } + if(couldDecodeA){ DecodeParams d; d.submode = Varicode::JS8CallNormal; @@ -4461,7 +4460,6 @@ bool MainWindow::decodeProcessQueue(qint32 *pSubmode){ if(JS8_DEBUG_DECODE) qDebug() << "--> decoder skipping at least 1 decode cycle" << "count" << count << "max" << maxDecodes; } - dec_data.params.synconly = true; dec_data.params.nsubmodes = 0; while(!m_decoderQueue.isEmpty()){ @@ -4880,6 +4878,10 @@ void MainWindow::processDecodedLine(QByteArray t){ if(t.indexOf("f1") >= 0){ auto segs = QString(t.trimmed()).split(QRegExp("[\\s\\t]+"), QString::SkipEmptyParts); if(!segs.isEmpty()){ + auto m1 = QString(segs.at(2)); + auto m = int(m1.toInt()); + auto period = computePeriodForSubmode(m); + auto f1 = QString(segs.at(4)); auto f = int(f1.toFloat()); @@ -4891,40 +4893,43 @@ void MainWindow::processDecodedLine(QByteArray t){ if(abs(xdt) <= 2){ if(s < 10){ - m_wideGraph->drawLine(QColor(Qt::darkCyan), f, f + computeBandwidthForSubmode(m_nSubMode)); + m_wideGraph->drawLine(QColor(Qt::darkCyan), f, f + computeBandwidthForSubmode(m)); } else if (s <= 21){ - m_wideGraph->drawLine(QColor(Qt::white), f, f + computeBandwidthForSubmode(m_nSubMode)); + m_wideGraph->drawLine(QColor(Qt::white), f, f + computeBandwidthForSubmode(m)); } } - if(t.contains("decode X")){ + if(t.contains("decode")){ auto now = QDateTime::currentDateTimeUtc(); float n = 0; - float nPos = m_TRperiod - (now.time().second() % m_TRperiod); - float nNeg = (now.time().second() % m_TRperiod) - m_TRperiod; - float offset = m_TRperiod - computeFramesNeededForDecode(m_nSubMode)/RX_SAMPLE_RATE + xdt; + float nPos = period - (now.time().second() % period); + float nNeg = (now.time().second() % period) - period; if(qAbs(nNeg) < nPos){ - n = nNeg + offset; + n = nNeg; } else { - n = nPos - offset; + n = nPos; } + n -= (float)period; + n += computeFramesNeededForDecode(m)/RX_SAMPLE_RATE; + n -= xdt; + int xdtmin = qMin(n*1000, (float)DriftingDateTime::drift()); int xdtmax = qMax(n*1000, (float)DriftingDateTime::drift()); - m_wideGraph->drawLine(QColor(Qt::red), f, f + computeBandwidthForSubmode(m_nSubMode)); + m_wideGraph->drawLine(QColor(Qt::red), f, f + computeBandwidthForSubmode(m)); + int oldNewDrift = newDrift; newDrift = (xdtmin + (xdtmax-xdtmin)/2); newDrift = qMin(oldNewDrift, newDrift) + (qMax(oldNewDrift, newDrift)-qMin(oldNewDrift, newDrift))/2; hasNewDrift = true; } } - } + } - - if(JS8_DEBUG_DECODE) qDebug() << "--> busy?" << m_decoderBusy << "lock exists?" << ( QFile{m_config.temp_dir ().absoluteFilePath (".lock")}.exists()); + if(JS8_DEBUG_DECODE) qDebug() << "--> busy?" << m_decoderBusy << "lock exists?" << ( QFile{m_config.temp_dir ().absoluteFilePath (".lock")}.exists()); return; } @@ -4934,11 +4939,11 @@ void MainWindow::processDecodedLine(QByteArray t){ } if(t.indexOf("") >= 0) { - if(hasNewDrift){ - int oldDrift = DriftingDateTime::drift(); - newDrift = qMin(oldDrift, newDrift) + (qMax(oldDrift, newDrift)-qMin(oldDrift, newDrift))/2; + static int driftN = 1; + newDrift = ((driftN-1)*DriftingDateTime::drift() + newDrift)/driftN; setDrift(newDrift); + if(driftN < 60) driftN++; // cap it to 60 observations writeNoticeTextToUI(QDateTime::currentDateTimeUtc(), QString("Drift: %1").arg(newDrift)); hasNewDrift = false; } diff --git a/widegraph.cpp b/widegraph.cpp index d913874..2607fdf 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -356,6 +356,8 @@ void WideGraph::drawSwide(){ swideLocal[i] = flagValue; } ui->widePlot->draw(swideLocal,true,false); + } else if(lastSecondInPeriod != secondInPeriod) { + drawLine(Qt::gray, ui->widePlot->startFreq(), 10); } lastSecondInPeriod=secondInPeriod;