Plot a red "sync" curve in QRA64 mode.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6876 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2016-07-06 14:18:23 +00:00
parent 73c5fef39b
commit 77e295d36d
9 changed files with 122 additions and 27 deletions

View File

@ -19,6 +19,7 @@ extern "C" {
extern struct dec_data {
float ss[184*NSMAX];
float savg[NSMAX];
float sred[5760];
short int d2[NTMAX*RX_SAMPLE_RATE];
struct
{

View File

@ -52,8 +52,10 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
else
open(13,file=trim(temp_dir)//'/decoded.txt',status='unknown')
end if
if(params%nmode.eq.4 .or. params%nmode.eq.65) open(14,file=trim(temp_dir)//'/avemsg.txt', &
status='unknown')
if(params%nmode.eq.4 .or. params%nmode.eq.65) open(14,file=trim(temp_dir)// &
'/avemsg.txt',status='unknown')
if(params%nmode.eq.164) open(17,file=trim(temp_dir)//'/red.dat', &
access='stream',status='unknown')
if(params%nmode.eq.4) then
jz=52*nfsample
@ -84,7 +86,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
!$omp parallel sections num_threads(2) copyin(/timer_private/) shared(ndecoded) if(.true.) !iif() needed on Mac
!$omp section
if(params%nmode.eq.65 .or. params%nmode.eq.165 .or. &
if(params%nmode.eq.65 .or. params%nmode.eq.164 .or. &
(params%nmode.eq.(65+9) .and. params%ntxmode.eq.65)) then
! We're in JT65 mode, or should do JT65 first
if(newdat65) dd(1:npts65)=id2(1:npts65)

View File

@ -45,6 +45,7 @@
type, bind(C) :: dec_data
real(c_float) :: ss(184,NSMAX)
real(c_float) :: savg(NSMAX)
real(c_float) :: sred(5760)
integer(c_short) :: id2(NMAX)
type(params_block) :: params
end type dec_data

View File

@ -14,6 +14,7 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,sync,nsnr,dtx,nfreq, &
real s(NZ)
real savg(NZ)
real blue(0:25)
real red0(NZ)
real red(NZ)
real x(NFFT)
complex cx(0:NH)
@ -23,11 +24,6 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,sync,nsnr,dtx,nfreq, &
common/qra64com/ss(NZ,194),s3(0:63,1:63),ccf(NZ,0:25)
save
! rewind 73
! rewind 74
! rewind 75
! rewind 76
decoded=' '
nft=99
nsnr=-30
@ -59,10 +55,11 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,sync,nsnr,dtx,nfreq, &
fb=min(nf2,nfqso+ntol)
ia=nint(fa/df)
ib=nint(fb/df)
red0=0.
fac=1.0/sqrt(21.0)
sync=0.
do if0=ia,ib
red(if0)=0.
red0(if0)=0.
do j=0,25
t=-3.0
do n=0,6
@ -70,10 +67,10 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,sync,nsnr,dtx,nfreq, &
t=t + ss(i,1+2*n+j) + ss(i,1+2*n+j+78) + ss(i,1+2*n+j+154)
enddo
ccf(if0,j)=fac*t
if(ccf(if0,j).gt.red(if0)) then
red(if0)=ccf(if0,j)
if(red(if0).gt.sync) then
sync=red(if0)
if(ccf(if0,j).gt.red0(if0)) then
red0(if0)=ccf(if0,j)
if(red0(if0).gt.sync) then
sync=red0(if0)
f0=if0*df
dtx=j*istep/12000.0 - 1.0
i0=if0
@ -83,6 +80,22 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,sync,nsnr,dtx,nfreq, &
enddo
enddo
red(ia:ib)=0.
rewind 73
do i=ia+3,ib-3
r1=red0(i)
red0(i)=0.
r0=maxval(red0(i-3:i+3))
red0(i)=r1
red(i)=max(0.0,r1-r0)
write(73,3001) i*df,red(i),red0(i),r0
3001 format(4f12.3)
enddo
flush(73)
write(17) ia,ib,red(ia:ib)
close(17)
if0=nint(f0/df)
nfreq=nint(f0)
blue(0:25)=ccf(if0,0:25)

View File

@ -2117,8 +2117,8 @@ void MainWindow::decode() //decode()
if(m_modeTx=="JT65") dec_data.params.ntxmode=65;
dec_data.params.nmode=9;
if(m_mode=="JT65") dec_data.params.nmode=65;
if(m_mode=="QRA64") dec_data.params.nmode=165;
if(m_mode=="QRA64") dec_data.params.ntxmode=165;
if(m_mode=="QRA64") dec_data.params.nmode=164;
if(m_mode=="QRA64") dec_data.params.ntxmode=164;
if(m_mode=="JT9+JT65") dec_data.params.nmode=9+65; // = 74
if(m_mode=="JT4") {
dec_data.params.nmode=4;
@ -2326,6 +2326,26 @@ void MainWindow::readFromStdout() //readFromStdout
}
}
if(t.indexOf("<DecodeFinished>") >= 0) {
//###
if(m_mode=="QRA64") {
char name[512];
QString fname=m_config.temp_dir ().absoluteFilePath ("red.dat");
strncpy(name,fname.toLatin1(), sizeof (name) - 1);
name[sizeof (name) - 1] = '\0';
FILE* fp=fopen(name,"rb");
if(fp != NULL) {
int n,ia,ib;
memset(dec_data.sred,0,4*5760);
n=fread(&ia,4,1,fp);
n=fread(&ib,4,1,fp);
n=fread(&dec_data.sred[ia-1],4,ib-ia+1,fp);
m_wideGraph->drawRed(ia,ib);
}
}
//###
m_bDecoded = t.mid (20).trimmed ().toInt () > 0;
if(!m_diskData) killFileTimer.start (3*1000*m_TRperiod/4); //Kill in 45 s
decodeDone ();

View File

@ -92,11 +92,11 @@ void CPlotter::paintEvent(QPaintEvent *) // paint
m_paintEventBusy=false;
}
void CPlotter::draw(float swide[], bool bScroll) //draw()
void CPlotter::draw(float swide[], bool bScroll, bool bRed)
{
int j,j0;
static int jtop=0;
float y,y2,ymin;
double fac = sqrt(m_binsPerPixel*m_waterfallAvg/15.0);
double gain = fac*pow(10.0,0.02*m_plotGain);
double gain2d = pow(10.0,0.02*(m_plot2dGain));
@ -118,18 +118,53 @@ void CPlotter::draw(float swide[], bool bScroll) //dr
if(m_bLinearAvg) {
painter2D.setPen(Qt::yellow);
} else if(m_bReference) {
painter2D.setPen(Qt::red);
painter2D.setPen(Qt::blue);
} else {
painter2D.setPen(Qt::green);
}
QPoint LineBuf[MAX_SCREENSIZE];
static QPoint LineBuf[MAX_SCREENSIZE];
QPoint LineBuf2[MAX_SCREENSIZE];
j=0;
j0=int(m_startFreq/m_fftBinWidth + 0.5);
int iz=XfromFreq(5000.0);
int jz=iz*m_binsPerPixel;
m_fMax=FreqfromX(iz);
m_line++;
if(m_mode=="QRA64" and bRed) {
double df_qra64=12000.0/(2*6912);
int j0,j1;
int k=0;
float smax,y3max=0;
float y3[MAX_SCREENSIZE];
for(int i=1; i<iz; i++) {
j0=FreqfromX(i-1)/df_qra64;
j1=FreqfromX(i)/df_qra64;
smax=0.0;
y3[i]=0.0;
for(int jj=j0; jj<=j1; jj++) {
if(dec_data.sred[jj]>smax) smax=dec_data.sred[jj];
}
y3[i]=smax;
if(smax>y3max)y3max=smax;
}
// qDebug() << "a" << y3max << m_ia << m_ib;
float fac=0.8/qMax(y3max,50.0f);
for(int i=1; i<iz; i++) {
if(y3[i]>0.0) {
y2=fac*y3[i];
LineBuf2[k].setX(i);
LineBuf2[k].setY(int(m_h2*(0.9-y2)));
k++;
}
}
painter2D.drawPolyline(LineBuf,jtop);
painter2D.setPen(Qt::red);
painter2D.drawPolyline(LineBuf2,k);
update(); //trigger a new paintEvent
return;
}
if(bScroll) {
flat4_(swide,&iz,&m_Flatten);
flat4_(&dec_data.savg[j0],&jz,&m_Flatten);
@ -184,6 +219,7 @@ void CPlotter::draw(float swide[], bool bScroll) //dr
}
if(i==iz-1) painter2D.drawPolyline(LineBuf,j);
jtop=j;
LineBuf[j].setX(i);
LineBuf[j].setY(int(0.9*m_h2-y2*m_h2/70.0));
if(y2<y2min) y2min=y2;
@ -192,7 +228,6 @@ void CPlotter::draw(float swide[], bool bScroll) //dr
}
if(swide[0]>1.0e29) m_line=0;
m_line++;
if(m_line == painter1.fontMetrics ().height ()) {
painter1.setPen(Qt::white);
QString t;
@ -226,6 +261,14 @@ void CPlotter::draw(float swide[], bool bScroll) //dr
m_bScaleOK=true;
}
void CPlotter::drawRed(int ia, int ib, float swide[])
{
m_ia=ia;
m_ib=ib;
draw(swide,false,true);
}
void CPlotter::DrawOverlay() //DrawOverlay()
{
if(m_OverlayPixmap.isNull()) return;

View File

@ -35,7 +35,7 @@ public:
QSize sizeHint() const;
bool m_bScaleOK;
void draw(float swide[], bool bScroll); //Update the waterfall
void draw(float swide[], bool bScroll, bool bRed); //Update the waterfall
void SetRunningState(bool running);
void setPlotZero(int plotZero);
int plotZero();
@ -82,6 +82,7 @@ public:
void setRxBand(QString band);
void setReference(bool b) {m_bReference = b;}
bool Reference() const {return m_bReference;}
void drawRed(int ia, int ib, float swide[]);
signals:
void freezeDecode1(int n);
@ -116,6 +117,8 @@ private:
qint32 m_w;
qint32 m_Flatten;
qint32 m_nSubMode;
qint32 m_ia;
qint32 m_ib;
QPixmap m_WaterfallPixmap;
QPixmap m_2DPixmap;

View File

@ -139,6 +139,11 @@ void WideGraph::saveSettings() //saveS
m_settings->endGroup ();
}
void WideGraph::drawRed(int ia, int ib)
{
ui->widePlot->drawRed(ia,ib,swide);
}
void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dataSink2
{
static float splot[NSMAX];
@ -181,7 +186,7 @@ void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dat
m_bHaveTransmitted=false;
}
m_ntr0=ntr;
ui->widePlot->draw(swide,true);
ui->widePlot->draw(swide,true,false);
}
}
@ -219,7 +224,7 @@ void WideGraph::keyPressEvent(QKeyEvent *e) //F1
void WideGraph::setRxFreq(int n) //setRxFreq
{
ui->widePlot->setRxFreq(n);
ui->widePlot->draw(swide,false);
ui->widePlot->draw(swide,false,false);
if(m_lockTxFreq) setTxFreq(n);
}
@ -316,7 +321,7 @@ void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1)
if(arg1=="Reference") {
ui->widePlot->setReference(true);
}
if(ui->widePlot->m_bScaleOK) ui->widePlot->draw(swide,false);
if(ui->widePlot->m_bScaleOK) ui->widePlot->draw(swide,false,false);
}
void WideGraph::on_fSplitSpinBox_valueChanged(int n) //fSplit
@ -437,13 +442,19 @@ void WideGraph::on_zeroSlider_valueChanged(int value) //Zero
void WideGraph::on_gain2dSlider_valueChanged(int value) //Gain2
{
ui->widePlot->setPlot2dGain(value);
if(ui->widePlot->m_bScaleOK) ui->widePlot->draw(swide,false);
if(ui->widePlot->m_bScaleOK) {
ui->widePlot->draw(swide,false,false);
if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true);
}
}
void WideGraph::on_zero2dSlider_valueChanged(int value) //Zero2
{
ui->widePlot->setPlot2dZero(value);
if(ui->widePlot->m_bScaleOK) ui->widePlot->draw(swide,false);
if(ui->widePlot->m_bScaleOK) {
ui->widePlot->draw(swide,false,false);
if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true);
}
}
void WideGraph::setTol(int n) //setTol

View File

@ -46,6 +46,7 @@ public:
int smoothYellow();
void setRxBand(QString band);
void setWSPRtransmitted();
void drawRed(int ia, int ib);
signals:
void freezeDecode2(int n);