We are now plotting a green line. (Needs more work, though.)

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/jtms3@2501 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2012-07-07 18:10:39 +00:00
parent a09cd784af
commit 6e72f74395
9 changed files with 91 additions and 148 deletions

View File

@ -5,11 +5,11 @@
extern "C" { extern "C" {
extern struct { //This is "common/datcom/..." in Fortran extern struct { //This is "common/mscom/..." in Fortran
short int d2[30*48000]; //Raw data short int d2[30*48000]; //Raw data
int kin; int kin;
int ndiskdat; int ndiskdat;
} datcom_; } mscom_;
} }
#endif // COMMONS_H #endif // COMMONS_H

View File

@ -12,12 +12,12 @@ void getfile(QString fname, bool xpol, int dbDgrd)
FILE* fp=fopen(name,"rb"); FILE* fp=fopen(name,"rb");
int npts=30*48000; int npts=30*48000;
memset(datcom_.d2,0,2*npts); memset(mscom_.d2,0,2*npts);
if(fp != NULL) { if(fp != NULL) {
// Read (and ignore) a 44-byte WAV header; then read data // Read (and ignore) a 44-byte WAV header; then read data
fread(datcom_.d2,1,44,fp); fread(mscom_.d2,1,44,fp);
int nrd=fread(datcom_.d2,2,npts,fp); int nrd=fread(mscom_.d2,2,npts,fp);
qDebug() << "Getfile" << npts << nrd; qDebug() << "Getfile" << npts << nrd;
fclose(fp); fclose(fp);
} }
@ -76,9 +76,9 @@ void savewav(QString fname)
hdr.ndata=2*npts; hdr.ndata=2*npts;
fwrite(&hdr,sizeof(hdr),1,fp); fwrite(&hdr,sizeof(hdr),1,fp);
// memcpy(datcom_.d2,buf,2*npts); // memcpy(mscom_.d2,buf,2*npts);
// fwrite(buf,2,npts,fp); // fwrite(buf,2,npts,fp);
fwrite(datcom_.d2,2,npts,fp); fwrite(mscom_.d2,2,npts,fp);
fclose(fp); fclose(fp);
} }
// free(buf); // free(buf);

View File

@ -140,13 +140,13 @@ MainWindow::MainWindow(QWidget *parent) :
#endif #endif
/* /*
if(!mem_m65.attach()) { if(!mem_m65.attach()) {
if (!mem_m65.create(sizeof(datcom_))) { if (!mem_m65.create(sizeof(mscom_))) {
msgBox("Unable to create shared memory segment."); msgBox("Unable to create shared memory segment.");
} }
} }
char *to = (char*)mem_m65.data(); char *to = (char*)mem_m65.data();
int size=sizeof(datcom_); int size=sizeof(mscom_);
if(datcom_.newdat==0) { if(mscom_.newdat==0) {
int noffset = 4*4*5760000 + 4*4*322*32768 + 4*4*32768; int noffset = 4*4*5760000 + 4*4*322*32768 + 4*4*32768;
to += noffset; to += noffset;
size -= noffset; size -= noffset;
@ -392,43 +392,34 @@ void MainWindow::dataSink(int k)
static int nwrite=0; static int nwrite=0;
static int k0=99999999; static int k0=99999999;
static float px=0.0; static float px=0.0;
static float sq0=0.0; static float green[704];
static float sqave=1000.0; static int ig=0;
if(k < k0) { if(k < k0) {
nwrite=0; nwrite=0;
ig=0;
} }
if(m_diskData) { if(m_diskData) {
ndiskdat=1; ndiskdat=1;
datcom_.ndiskdat=1; mscom_.ndiskdat=1;
} else { } else {
ndiskdat=0; ndiskdat=0;
datcom_.ndiskdat=0; mscom_.ndiskdat=0;
} }
float sq=0.0; specjtms_(&k,&px);
float x;
float fac=1.0/30.0;
for(int i=0; i<6192; i++) {
x=fac*datcom_.d2[k-6192+i];
sq += x*x;
}
sqave=0.5*(sq+sq0);
sq0=sq;
px = 10.0*log10(sqave/6192.0);
if(px>60.0) px=60.0;
if(px<0.0) px=0.0;
QString t; QString t;
t.sprintf(" Rx noise: %5.1f ",px); t.sprintf(" Rx noise: %5.1f ",px);
lab2->setText(t); lab2->setText(t);
ui->xThermo->setValue((double)px); //Update the bargraphs ui->xThermo->setValue((double)px); //Update the Thermo
/*
if(m_monitoring || m_diskData) { if(m_monitoring || m_diskData) {
g_pWideGraph->dataSink2(s,nkhz,ihsym,m_diskData,lstrong); green[ig++]=px;
g_pWideGraph->dataSink2(green,ig-1);
} }
/*
//Average over specified number of spectra //Average over specified number of spectra
if (n==0) { if (n==0) {
for (int i=0; i<NFFT; i++) for (int i=0; i<NFFT; i++)
@ -449,7 +440,7 @@ void MainWindow::dataSink(int k)
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
int n300 = (ms/100) % 300; int n300 = (ms/100) % 300;
qDebug() << "dataSink" << k << ms % 60000; // qDebug() << k/2048 << 0.001*(ms % 60000);
if(n300 >= 295 and nwrite==0) { if(n300 >= 295 and nwrite==0) {
nwrite=1; nwrite=1;
if(m_saveAll) { if(m_saveAll) {
@ -933,8 +924,8 @@ void MainWindow::on_DecodeButton_clicked() //Decode request
int n=m_sec0%60; int n=m_sec0%60;
if(m_monitoring and n>47 and (n<52 or m_decoderBusy)) return; if(m_monitoring and n>47 and (n<52 or m_decoderBusy)) return;
if(!m_decoderBusy) { if(!m_decoderBusy) {
datcom_.newdat=0; mscom_.newdat=0;
datcom_.nagain=1; mscom_.nagain=1;
decode(); decode();
} }
*/ */
@ -945,15 +936,15 @@ void MainWindow::freezeDecode(int n) //freezeDecode()
/* /*
if(n==2) { if(n==2) {
ui->tolSpinBox->setValue(5); ui->tolSpinBox->setValue(5);
datcom_.ntol=m_tol; mscom_.ntol=m_tol;
datcom_.mousedf=0; mscom_.mousedf=0;
} else { } else {
ui->tolSpinBox->setValue(3); ui->tolSpinBox->setValue(3);
datcom_.ntol=m_tol; mscom_.ntol=m_tol;
} }
if(!m_decoderBusy) { if(!m_decoderBusy) {
datcom_.nagain=1; mscom_.nagain=1;
datcom_.newdat=0; mscom_.newdat=0;
decode(); decode();
} }
*/ */
@ -963,75 +954,75 @@ void MainWindow::decode() //decode()
{ {
/* /*
ui->DecodeButton->setStyleSheet(m_pbdecoding_style1); ui->DecodeButton->setStyleSheet(m_pbdecoding_style1);
if(datcom_.nagain==0 && (!m_diskData)) { if(mscom_.nagain==0 && (!m_diskData)) {
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
int imin=ms/60000; int imin=ms/60000;
int ihr=imin/60; int ihr=imin/60;
imin=imin % 60; imin=imin % 60;
datcom_.nutc=100*ihr + imin; mscom_.nutc=100*ihr + imin;
} }
datcom_.idphi=m_dPhi; mscom_.idphi=m_dPhi;
datcom_.mousedf=g_pWideGraph->DF(); mscom_.mousedf=g_pWideGraph->DF();
datcom_.mousefqso=g_pWideGraph->QSOfreq(); mscom_.mousefqso=g_pWideGraph->QSOfreq();
datcom_.ndepth=m_ndepth; mscom_.ndepth=m_ndepth;
datcom_.ndiskdat=0; mscom_.ndiskdat=0;
if(m_diskData) datcom_.ndiskdat=1; if(m_diskData) mscom_.ndiskdat=1;
datcom_.neme=0; mscom_.neme=0;
if(ui->actionOnly_EME_calls->isChecked()) datcom_.neme=1; if(ui->actionOnly_EME_calls->isChecked()) mscom_.neme=1;
int ispan=int(g_pWideGraph->fSpan()); int ispan=int(g_pWideGraph->fSpan());
if(ispan%2 == 1) ispan++; if(ispan%2 == 1) ispan++;
int ifc=int(1000.0*(datcom_.fcenter - int(datcom_.fcenter))+0.5); int ifc=int(1000.0*(mscom_.fcenter - int(mscom_.fcenter))+0.5);
int nfa=g_pWideGraph->nStartFreq(); int nfa=g_pWideGraph->nStartFreq();
int nfb=nfa+ispan; int nfb=nfa+ispan;
int nfshift=nfa + ispan/2 - ifc; int nfshift=nfa + ispan/2 - ifc;
datcom_.nfa=nfa; mscom_.nfa=nfa;
datcom_.nfb=nfb; mscom_.nfb=nfb;
datcom_.nfcal=m_fCal; mscom_.nfcal=m_fCal;
datcom_.nfshift=nfshift; mscom_.nfshift=nfshift;
datcom_.mcall3=0; mscom_.mcall3=0;
if(m_call3Modified) datcom_.mcall3=1; if(m_call3Modified) mscom_.mcall3=1;
datcom_.ntimeout=m_timeout; mscom_.ntimeout=m_timeout;
datcom_.ntol=m_tol; mscom_.ntol=m_tol;
datcom_.nxant=0; mscom_.nxant=0;
if(m_xpolx) datcom_.nxant=1; if(m_xpolx) mscom_.nxant=1;
if(datcom_.nutc < m_nutc0) m_jtms3RxLog |= 1; //Date and Time to all65.txt if(mscom_.nutc < m_nutc0) m_jtms3RxLog |= 1; //Date and Time to all65.txt
m_nutc0=datcom_.nutc; m_nutc0=mscom_.nutc;
// datcom_.jtms3RxLog=m_jtms3RxLog; // mscom_.jtms3RxLog=m_jtms3RxLog;
datcom_.nfsample=96000; mscom_.nfsample=96000;
if(!m_fs96000) datcom_.nfsample=95238; if(!m_fs96000) mscom_.nfsample=95238;
datcom_.nxpol=0; mscom_.nxpol=0;
if(m_xpol) datcom_.nxpol=1; if(m_xpol) mscom_.nxpol=1;
datcom_.mode65=m_mode65; mscom_.mode65=m_mode65;
QString mcall=(m_myCall+" ").mid(0,12); QString mcall=(m_myCall+" ").mid(0,12);
QString mgrid=(m_myGrid+" ").mid(0,6); QString mgrid=(m_myGrid+" ").mid(0,6);
QString hcall=(ui->dxCallEntry->text()+" ").mid(0,12); QString hcall=(ui->dxCallEntry->text()+" ").mid(0,12);
QString hgrid=(ui->dxGridEntry->text()+" ").mid(0,6); QString hgrid=(ui->dxGridEntry->text()+" ").mid(0,6);
strncpy(datcom_.mycall, mcall.toAscii(), 12); strncpy(mscom_.mycall, mcall.toAscii(), 12);
strncpy(datcom_.mygrid, mgrid.toAscii(), 6); strncpy(mscom_.mygrid, mgrid.toAscii(), 6);
strncpy(datcom_.hiscall, hcall.toAscii(), 12); strncpy(mscom_.hiscall, hcall.toAscii(), 12);
strncpy(datcom_.hisgrid, hgrid.toAscii(), 6); strncpy(mscom_.hisgrid, hgrid.toAscii(), 6);
strncpy(datcom_.datetime, m_dateTime.toAscii(), 20); strncpy(mscom_.datetime, m_dateTime.toAscii(), 20);
//newdat=1 ==> this is new data, must do the big FFT //newdat=1 ==> this is new data, must do the big FFT
//nagain=1 ==> decode only at fQSO +/- Tol //nagain=1 ==> decode only at fQSO +/- Tol
char *to = (char*)mem_m65.data(); char *to = (char*)mem_m65.data();
char *from = (char*) datcom_.d4; char *from = (char*) mscom_.d4;
int size=sizeof(datcom_); int size=sizeof(mscom_);
if(datcom_.newdat==0) { if(mscom_.newdat==0) {
int noffset = 4*4*5760000 + 4*4*322*32768 + 4*4*32768; int noffset = 4*4*5760000 + 4*4*322*32768 + 4*4*32768;
to += noffset; to += noffset;
from += noffset; from += noffset;
size -= noffset; size -= noffset;
} }
memcpy(to, from, qMin(mem_m65.size(), size)); memcpy(to, from, qMin(mem_m65.size(), size));
datcom_.nagain=0; mscom_.nagain=0;
datcom_.ndiskdat=0; mscom_.ndiskdat=0;
m_call3Modified=false; m_call3Modified=false;
QFile lockFile(m_appDir + "/.lock"); // Allow m65 to start QFile lockFile(m_appDir + "/.lock"); // Allow m65 to start

View File

@ -235,12 +235,7 @@ extern void getDev(int* numDevices,char hostAPI_DeviceName[][50],
extern "C" { extern "C" {
//----------------------------------------------------- C and Fortran routines //----------------------------------------------------- C and Fortran routines
void symspec_(int* k, int* nxpol, int* ndiskdat, int* nb, int* m_NBslider, void specjtms_(int* k, float* px);
int* idphi, int* nfsample, float* fgreen, int* iqadjust,
int* iqapply, float* gainx, float* gainy, float* phasex,
float* phasey, float* rejectx, float* rejecty, float* px,
float* py, float s[], int* nkhz, int* nhsym, int* nzap,
float* slimit, uchar lstrong[]);
void genjtms3_(char* message, char* msgsent, short iwave[], void genjtms3_(char* message, char* msgsent, short iwave[],
int* nwave, int len1, int len2); int* nwave, int len1, int len2);

View File

@ -77,8 +77,9 @@ void CPlotter::paintEvent(QPaintEvent *) // paintEvent()
int h = (m_Size.height()-60)/2; int h = (m_Size.height()-60)/2;
painter.drawPixmap(0,0,m_ScalePixmap); painter.drawPixmap(0,0,m_ScalePixmap);
painter.drawPixmap(0,30,m_WaterfallPixmap); painter.drawPixmap(0,30,m_WaterfallPixmap);
m_2Dspec=true;
if(m_2Dspec) { if(m_2Dspec) {
painter.drawPixmap(0,h+30,m_ScalePixmap); // painter.drawPixmap(0,h+30,m_ScalePixmap);
painter.drawPixmap(0,h+60,m_2DPixmap); painter.drawPixmap(0,h+60,m_2DPixmap);
m_paintEventBusy=false; m_paintEventBusy=false;
return; return;
@ -106,12 +107,11 @@ void CPlotter::paintEvent(QPaintEvent *) // paintEvent()
m_paintEventBusy=false; m_paintEventBusy=false;
} }
void CPlotter::draw(float s[], int i0, float splot[]) //draw() void CPlotter::draw(float green[], int ig) //draw()
{ {
int i,j,w,h; int i,j,w,h;
float y; float y;
m_i0=i0;
w = m_WaterfallPixmap.width(); w = m_WaterfallPixmap.width();
h = m_WaterfallPixmap.height(); h = m_WaterfallPixmap.height();
double gain = pow(10.0,0.05*(m_plotGain+7)); double gain = pow(10.0,0.05*(m_plotGain+7));
@ -124,63 +124,24 @@ void CPlotter::draw(float s[], int i0, float splot[]) //dr
QPainter painter1(&m_WaterfallPixmap); QPainter painter1(&m_WaterfallPixmap);
QPainter painter2D(&m_2DPixmap); QPainter painter2D(&m_2DPixmap);
for(i=0; i<256; i++) { //Zero the histograms
m_hist1[i]=0;
m_hist2[i]=0;
}
painter2D.setPen(Qt::green); painter2D.setPen(Qt::green);
QRect tmp(0,0,w,h); QRect tmp(0,0,w,h);
painter2D.fillRect(tmp,Qt::black); painter2D.fillRect(tmp,Qt::black);
QPoint LineBuf[MAX_SCREENSIZE]; QPoint LineBuf[MAX_SCREENSIZE];
j=0; j=0;
bool strong0=false;
bool strong=false;
for(i=0; i<w; i++) { painter2D.setPen(Qt::green);
strong=false; for(i=0; i<ig; i++) {
if(s[i]<0) { y = green[i];
strong=true;
s[i]=-s[i];
}
y = 10.0*log10(s[i]);
int y1 = 5.0*gain*(y + 29 -m_plotZero);
if (y1<0) y1=0;
if (y1>254) y1=254;
if (s[i]>1.e29) y1=255;
m_hist1[y1]++;
painter1.setPen(m_ColorTbl[y1]);
painter1.drawPoint(i,0); painter1.drawPoint(i,0);
if(m_2Dspec) { int y2 = 7*(y-m_plotZero);
int y2 = gain*(y + 34 -m_plotZero);
if (y2<0) y2=0; if (y2<0) y2=0;
if (y2>254) y2=254; if (y2>254) y2=254;
if (s[i]>1.e29) y2=255;
if(strong != strong0 or i==w-1) {
painter2D.drawPolyline(LineBuf,j);
j=0;
strong0=strong;
if(strong0) painter2D.setPen(Qt::red);
if(!strong0) painter2D.setPen(Qt::green);
}
LineBuf[j].setX(i); LineBuf[j].setX(i);
LineBuf[j].setY(h-y2); LineBuf[j].setY(h-y2);
j++; j++;
} }
} painter2D.drawPolyline(LineBuf,ig);
for(i=0; i<32768; i++) {
y = 10.0*log10(splot[i]);
int y1 = 5.0*gain*(y + 30 - m_plotZero);
if (y1<0) y1=0;
if (y1>254) y1=254;
if (splot[i]>1.e29) y1=255;
m_hist2[y1]++;
m_zwf[i]=y1;
}
if(s[0]>1.0e29) m_line=0;
m_line++;
update(); //trigger a new paintEvent update(); //trigger a new paintEvent
} }

View File

@ -31,19 +31,17 @@ public:
qint32 m_DF; qint32 m_DF;
qint32 m_tol; qint32 m_tol;
void draw(float sw[], int i0, float splot[]); //Update the waterfalls void draw(float green[], int ig); //Update the graphics
void SetRunningState(bool running); void SetRunningState(bool running);
void setPlotZero(int plotZero); void setPlotZero(int plotZero);
int getPlotZero(); int getPlotZero();
void setPlotGain(int plotGain); void setPlotGain(int plotGain);
int getPlotGain(); int getPlotGain();
int plotWidth(); int plotWidth();
void setNSpan(int n);
void UpdateOverlay(); void UpdateOverlay();
void setDataFromDisk(bool b); void setDataFromDisk(bool b);
void setTol(int n); void setTol(int n);
void DrawOverlay(); void DrawOverlay();
int fQSO();
int DF(); int DF();
int autoZero(); int autoZero();
void setPalette(QString palette); void setPalette(QString palette);

View File

@ -7,9 +7,9 @@
extern "C" { extern "C" {
#include <portaudio.h> #include <portaudio.h>
extern struct { extern struct {
short int d2[30*48000]; //This is "common/datcom/..." in fortran short int d2[30*48000]; //This is "common/mscom/..." in fortran
int kin; int kin;
} datcom_; } mscom_;
} }
typedef struct typedef struct
@ -48,9 +48,9 @@ extern "C" int a2dCallback( const void *inputBuffer, void *outputBuffer,
nbytes=2*framesToProcess; //Bytes per frame nbytes=2*framesToProcess; //Bytes per frame
k=udata->kin; k=udata->kin;
memcpy(&datcom_.d2[k],inputBuffer,nbytes); //Copy all samples to d2 memcpy(&mscom_.d2[k],inputBuffer,nbytes); //Copy all samples to d2
udata->kin += framesToProcess; udata->kin += framesToProcess;
datcom_.kin=udata->kin; mscom_.kin=udata->kin;
return paContinue; return paContinue;
} }
@ -118,19 +118,18 @@ void SoundInThread::run() //SoundInThread::run()
} }
k=udata.kin; k=udata.kin;
if(m_monitoring) { if(m_monitoring) {
m_step=k/(2*6192); m_step=k/2048;
if(m_step != nstep0) { if(m_step != nstep0) {
if(m_dataSinkBusy) { if(m_dataSinkBusy) {
nBusy++; nBusy++;
} else { } else {
// m_dataSinkBusy=true; // m_dataSinkBusy=true;
// qDebug() << "Calling dataSink" << k;
emit readyForFFT(k); //Signal to compute new FFTs emit readyForFFT(k); //Signal to compute new FFTs
} }
nstep0=m_step; nstep0=m_step;
} }
} }
msleep(100); msleep(10);
n30z=n30; n30z=n30;
} }
Pa_StopStream(inStream); Pa_StopStream(inStream);

View File

@ -62,9 +62,9 @@ void WideGraph::saveSettings()
settings.endGroup(); settings.endGroup();
} }
void WideGraph::dataSink2(float s[], int nkhz, int ihsym, int ndiskdata, void WideGraph::dataSink2(float green[], int ig)
uchar lstrong[])
{ {
ui->widePlot->draw(green,ig);
/* /*
static float splot[NFFT]; static float splot[NFFT];
float swide[2048]; float swide[2048];

View File

@ -19,8 +19,7 @@ public:
double m_dForceCenterFreq; double m_dForceCenterFreq;
double m_cal570; double m_cal570;
void dataSink2(float s[], int nkhz, int ihsym, int ndiskdata, void dataSink2(float green[], int ig);
uchar lstrong[]);
int QSOfreq(); int QSOfreq();
int nSpan(); int nSpan();
int nStartFreq(); int nStartFreq();