mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-23 12:48:40 -05:00
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:
parent
a09cd784af
commit
6e72f74395
@ -5,11 +5,11 @@
|
||||
|
||||
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
|
||||
int kin;
|
||||
int ndiskdat;
|
||||
} datcom_;
|
||||
} mscom_;
|
||||
}
|
||||
|
||||
#endif // COMMONS_H
|
||||
|
10
getfile.cpp
10
getfile.cpp
@ -12,12 +12,12 @@ void getfile(QString fname, bool xpol, int dbDgrd)
|
||||
FILE* fp=fopen(name,"rb");
|
||||
|
||||
int npts=30*48000;
|
||||
memset(datcom_.d2,0,2*npts);
|
||||
memset(mscom_.d2,0,2*npts);
|
||||
|
||||
if(fp != NULL) {
|
||||
// Read (and ignore) a 44-byte WAV header; then read data
|
||||
fread(datcom_.d2,1,44,fp);
|
||||
int nrd=fread(datcom_.d2,2,npts,fp);
|
||||
fread(mscom_.d2,1,44,fp);
|
||||
int nrd=fread(mscom_.d2,2,npts,fp);
|
||||
qDebug() << "Getfile" << npts << nrd;
|
||||
fclose(fp);
|
||||
}
|
||||
@ -76,9 +76,9 @@ void savewav(QString fname)
|
||||
hdr.ndata=2*npts;
|
||||
|
||||
fwrite(&hdr,sizeof(hdr),1,fp);
|
||||
// memcpy(datcom_.d2,buf,2*npts);
|
||||
// memcpy(mscom_.d2,buf,2*npts);
|
||||
// fwrite(buf,2,npts,fp);
|
||||
fwrite(datcom_.d2,2,npts,fp);
|
||||
fwrite(mscom_.d2,2,npts,fp);
|
||||
fclose(fp);
|
||||
}
|
||||
// free(buf);
|
||||
|
129
mainwindow.cpp
129
mainwindow.cpp
@ -140,13 +140,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
#endif
|
||||
/*
|
||||
if(!mem_m65.attach()) {
|
||||
if (!mem_m65.create(sizeof(datcom_))) {
|
||||
if (!mem_m65.create(sizeof(mscom_))) {
|
||||
msgBox("Unable to create shared memory segment.");
|
||||
}
|
||||
}
|
||||
char *to = (char*)mem_m65.data();
|
||||
int size=sizeof(datcom_);
|
||||
if(datcom_.newdat==0) {
|
||||
int size=sizeof(mscom_);
|
||||
if(mscom_.newdat==0) {
|
||||
int noffset = 4*4*5760000 + 4*4*322*32768 + 4*4*32768;
|
||||
to += noffset;
|
||||
size -= noffset;
|
||||
@ -392,43 +392,34 @@ void MainWindow::dataSink(int k)
|
||||
static int nwrite=0;
|
||||
static int k0=99999999;
|
||||
static float px=0.0;
|
||||
static float sq0=0.0;
|
||||
static float sqave=1000.0;
|
||||
static float green[704];
|
||||
static int ig=0;
|
||||
|
||||
if(k < k0) {
|
||||
nwrite=0;
|
||||
ig=0;
|
||||
}
|
||||
|
||||
if(m_diskData) {
|
||||
ndiskdat=1;
|
||||
datcom_.ndiskdat=1;
|
||||
mscom_.ndiskdat=1;
|
||||
} else {
|
||||
ndiskdat=0;
|
||||
datcom_.ndiskdat=0;
|
||||
mscom_.ndiskdat=0;
|
||||
}
|
||||
|
||||
float sq=0.0;
|
||||
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;
|
||||
specjtms_(&k,&px);
|
||||
QString t;
|
||||
t.sprintf(" Rx noise: %5.1f ",px);
|
||||
lab2->setText(t);
|
||||
ui->xThermo->setValue((double)px); //Update the bargraphs
|
||||
ui->xThermo->setValue((double)px); //Update the Thermo
|
||||
|
||||
/*
|
||||
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
|
||||
if (n==0) {
|
||||
for (int i=0; i<NFFT; i++)
|
||||
@ -449,7 +440,7 @@ void MainWindow::dataSink(int k)
|
||||
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
||||
int n300 = (ms/100) % 300;
|
||||
|
||||
qDebug() << "dataSink" << k << ms % 60000;
|
||||
// qDebug() << k/2048 << 0.001*(ms % 60000);
|
||||
if(n300 >= 295 and nwrite==0) {
|
||||
nwrite=1;
|
||||
if(m_saveAll) {
|
||||
@ -933,8 +924,8 @@ void MainWindow::on_DecodeButton_clicked() //Decode request
|
||||
int n=m_sec0%60;
|
||||
if(m_monitoring and n>47 and (n<52 or m_decoderBusy)) return;
|
||||
if(!m_decoderBusy) {
|
||||
datcom_.newdat=0;
|
||||
datcom_.nagain=1;
|
||||
mscom_.newdat=0;
|
||||
mscom_.nagain=1;
|
||||
decode();
|
||||
}
|
||||
*/
|
||||
@ -945,15 +936,15 @@ void MainWindow::freezeDecode(int n) //freezeDecode()
|
||||
/*
|
||||
if(n==2) {
|
||||
ui->tolSpinBox->setValue(5);
|
||||
datcom_.ntol=m_tol;
|
||||
datcom_.mousedf=0;
|
||||
mscom_.ntol=m_tol;
|
||||
mscom_.mousedf=0;
|
||||
} else {
|
||||
ui->tolSpinBox->setValue(3);
|
||||
datcom_.ntol=m_tol;
|
||||
mscom_.ntol=m_tol;
|
||||
}
|
||||
if(!m_decoderBusy) {
|
||||
datcom_.nagain=1;
|
||||
datcom_.newdat=0;
|
||||
mscom_.nagain=1;
|
||||
mscom_.newdat=0;
|
||||
decode();
|
||||
}
|
||||
*/
|
||||
@ -963,75 +954,75 @@ void MainWindow::decode() //decode()
|
||||
{
|
||||
/*
|
||||
ui->DecodeButton->setStyleSheet(m_pbdecoding_style1);
|
||||
if(datcom_.nagain==0 && (!m_diskData)) {
|
||||
if(mscom_.nagain==0 && (!m_diskData)) {
|
||||
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
||||
int imin=ms/60000;
|
||||
int ihr=imin/60;
|
||||
imin=imin % 60;
|
||||
datcom_.nutc=100*ihr + imin;
|
||||
mscom_.nutc=100*ihr + imin;
|
||||
}
|
||||
|
||||
datcom_.idphi=m_dPhi;
|
||||
datcom_.mousedf=g_pWideGraph->DF();
|
||||
datcom_.mousefqso=g_pWideGraph->QSOfreq();
|
||||
datcom_.ndepth=m_ndepth;
|
||||
datcom_.ndiskdat=0;
|
||||
if(m_diskData) datcom_.ndiskdat=1;
|
||||
datcom_.neme=0;
|
||||
if(ui->actionOnly_EME_calls->isChecked()) datcom_.neme=1;
|
||||
mscom_.idphi=m_dPhi;
|
||||
mscom_.mousedf=g_pWideGraph->DF();
|
||||
mscom_.mousefqso=g_pWideGraph->QSOfreq();
|
||||
mscom_.ndepth=m_ndepth;
|
||||
mscom_.ndiskdat=0;
|
||||
if(m_diskData) mscom_.ndiskdat=1;
|
||||
mscom_.neme=0;
|
||||
if(ui->actionOnly_EME_calls->isChecked()) mscom_.neme=1;
|
||||
|
||||
int ispan=int(g_pWideGraph->fSpan());
|
||||
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 nfb=nfa+ispan;
|
||||
int nfshift=nfa + ispan/2 - ifc;
|
||||
|
||||
datcom_.nfa=nfa;
|
||||
datcom_.nfb=nfb;
|
||||
datcom_.nfcal=m_fCal;
|
||||
datcom_.nfshift=nfshift;
|
||||
datcom_.mcall3=0;
|
||||
if(m_call3Modified) datcom_.mcall3=1;
|
||||
datcom_.ntimeout=m_timeout;
|
||||
datcom_.ntol=m_tol;
|
||||
datcom_.nxant=0;
|
||||
if(m_xpolx) datcom_.nxant=1;
|
||||
if(datcom_.nutc < m_nutc0) m_jtms3RxLog |= 1; //Date and Time to all65.txt
|
||||
m_nutc0=datcom_.nutc;
|
||||
// datcom_.jtms3RxLog=m_jtms3RxLog;
|
||||
datcom_.nfsample=96000;
|
||||
if(!m_fs96000) datcom_.nfsample=95238;
|
||||
datcom_.nxpol=0;
|
||||
if(m_xpol) datcom_.nxpol=1;
|
||||
datcom_.mode65=m_mode65;
|
||||
mscom_.nfa=nfa;
|
||||
mscom_.nfb=nfb;
|
||||
mscom_.nfcal=m_fCal;
|
||||
mscom_.nfshift=nfshift;
|
||||
mscom_.mcall3=0;
|
||||
if(m_call3Modified) mscom_.mcall3=1;
|
||||
mscom_.ntimeout=m_timeout;
|
||||
mscom_.ntol=m_tol;
|
||||
mscom_.nxant=0;
|
||||
if(m_xpolx) mscom_.nxant=1;
|
||||
if(mscom_.nutc < m_nutc0) m_jtms3RxLog |= 1; //Date and Time to all65.txt
|
||||
m_nutc0=mscom_.nutc;
|
||||
// mscom_.jtms3RxLog=m_jtms3RxLog;
|
||||
mscom_.nfsample=96000;
|
||||
if(!m_fs96000) mscom_.nfsample=95238;
|
||||
mscom_.nxpol=0;
|
||||
if(m_xpol) mscom_.nxpol=1;
|
||||
mscom_.mode65=m_mode65;
|
||||
|
||||
QString mcall=(m_myCall+" ").mid(0,12);
|
||||
QString mgrid=(m_myGrid+" ").mid(0,6);
|
||||
QString hcall=(ui->dxCallEntry->text()+" ").mid(0,12);
|
||||
QString hgrid=(ui->dxGridEntry->text()+" ").mid(0,6);
|
||||
|
||||
strncpy(datcom_.mycall, mcall.toAscii(), 12);
|
||||
strncpy(datcom_.mygrid, mgrid.toAscii(), 6);
|
||||
strncpy(datcom_.hiscall, hcall.toAscii(), 12);
|
||||
strncpy(datcom_.hisgrid, hgrid.toAscii(), 6);
|
||||
strncpy(datcom_.datetime, m_dateTime.toAscii(), 20);
|
||||
strncpy(mscom_.mycall, mcall.toAscii(), 12);
|
||||
strncpy(mscom_.mygrid, mgrid.toAscii(), 6);
|
||||
strncpy(mscom_.hiscall, hcall.toAscii(), 12);
|
||||
strncpy(mscom_.hisgrid, hgrid.toAscii(), 6);
|
||||
strncpy(mscom_.datetime, m_dateTime.toAscii(), 20);
|
||||
|
||||
//newdat=1 ==> this is new data, must do the big FFT
|
||||
//nagain=1 ==> decode only at fQSO +/- Tol
|
||||
|
||||
char *to = (char*)mem_m65.data();
|
||||
char *from = (char*) datcom_.d4;
|
||||
int size=sizeof(datcom_);
|
||||
if(datcom_.newdat==0) {
|
||||
char *from = (char*) mscom_.d4;
|
||||
int size=sizeof(mscom_);
|
||||
if(mscom_.newdat==0) {
|
||||
int noffset = 4*4*5760000 + 4*4*322*32768 + 4*4*32768;
|
||||
to += noffset;
|
||||
from += noffset;
|
||||
size -= noffset;
|
||||
}
|
||||
memcpy(to, from, qMin(mem_m65.size(), size));
|
||||
datcom_.nagain=0;
|
||||
datcom_.ndiskdat=0;
|
||||
mscom_.nagain=0;
|
||||
mscom_.ndiskdat=0;
|
||||
m_call3Modified=false;
|
||||
|
||||
QFile lockFile(m_appDir + "/.lock"); // Allow m65 to start
|
||||
|
@ -235,12 +235,7 @@ extern void getDev(int* numDevices,char hostAPI_DeviceName[][50],
|
||||
|
||||
extern "C" {
|
||||
//----------------------------------------------------- C and Fortran routines
|
||||
void symspec_(int* k, int* nxpol, int* ndiskdat, int* nb, int* m_NBslider,
|
||||
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 specjtms_(int* k, float* px);
|
||||
|
||||
void genjtms3_(char* message, char* msgsent, short iwave[],
|
||||
int* nwave, int len1, int len2);
|
||||
|
65
plotter.cpp
65
plotter.cpp
@ -77,8 +77,9 @@ void CPlotter::paintEvent(QPaintEvent *) // paintEvent()
|
||||
int h = (m_Size.height()-60)/2;
|
||||
painter.drawPixmap(0,0,m_ScalePixmap);
|
||||
painter.drawPixmap(0,30,m_WaterfallPixmap);
|
||||
m_2Dspec=true;
|
||||
if(m_2Dspec) {
|
||||
painter.drawPixmap(0,h+30,m_ScalePixmap);
|
||||
// painter.drawPixmap(0,h+30,m_ScalePixmap);
|
||||
painter.drawPixmap(0,h+60,m_2DPixmap);
|
||||
m_paintEventBusy=false;
|
||||
return;
|
||||
@ -106,12 +107,11 @@ void CPlotter::paintEvent(QPaintEvent *) // paintEvent()
|
||||
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;
|
||||
float y;
|
||||
|
||||
m_i0=i0;
|
||||
w = m_WaterfallPixmap.width();
|
||||
h = m_WaterfallPixmap.height();
|
||||
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 painter2D(&m_2DPixmap);
|
||||
|
||||
for(i=0; i<256; i++) { //Zero the histograms
|
||||
m_hist1[i]=0;
|
||||
m_hist2[i]=0;
|
||||
}
|
||||
|
||||
painter2D.setPen(Qt::green);
|
||||
QRect tmp(0,0,w,h);
|
||||
painter2D.fillRect(tmp,Qt::black);
|
||||
QPoint LineBuf[MAX_SCREENSIZE];
|
||||
j=0;
|
||||
bool strong0=false;
|
||||
bool strong=false;
|
||||
|
||||
for(i=0; i<w; i++) {
|
||||
strong=false;
|
||||
if(s[i]<0) {
|
||||
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]);
|
||||
painter2D.setPen(Qt::green);
|
||||
for(i=0; i<ig; i++) {
|
||||
y = green[i];
|
||||
painter1.drawPoint(i,0);
|
||||
if(m_2Dspec) {
|
||||
int y2 = gain*(y + 34 -m_plotZero);
|
||||
if (y2<0) y2=0;
|
||||
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].setY(h-y2);
|
||||
j++;
|
||||
}
|
||||
int y2 = 7*(y-m_plotZero);
|
||||
if (y2<0) y2=0;
|
||||
if (y2>254) y2=254;
|
||||
LineBuf[j].setX(i);
|
||||
LineBuf[j].setY(h-y2);
|
||||
j++;
|
||||
}
|
||||
|
||||
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++;
|
||||
painter2D.drawPolyline(LineBuf,ig);
|
||||
update(); //trigger a new paintEvent
|
||||
}
|
||||
|
||||
|
@ -31,19 +31,17 @@ public:
|
||||
qint32 m_DF;
|
||||
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 setPlotZero(int plotZero);
|
||||
int getPlotZero();
|
||||
void setPlotGain(int plotGain);
|
||||
int getPlotGain();
|
||||
int plotWidth();
|
||||
void setNSpan(int n);
|
||||
void UpdateOverlay();
|
||||
void setDataFromDisk(bool b);
|
||||
void setTol(int n);
|
||||
void DrawOverlay();
|
||||
int fQSO();
|
||||
int DF();
|
||||
int autoZero();
|
||||
void setPalette(QString palette);
|
||||
|
13
soundin.cpp
13
soundin.cpp
@ -7,9 +7,9 @@
|
||||
extern "C" {
|
||||
#include <portaudio.h>
|
||||
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;
|
||||
} datcom_;
|
||||
} mscom_;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
@ -48,9 +48,9 @@ extern "C" int a2dCallback( const void *inputBuffer, void *outputBuffer,
|
||||
|
||||
nbytes=2*framesToProcess; //Bytes per frame
|
||||
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;
|
||||
datcom_.kin=udata->kin;
|
||||
mscom_.kin=udata->kin;
|
||||
|
||||
return paContinue;
|
||||
}
|
||||
@ -118,19 +118,18 @@ void SoundInThread::run() //SoundInThread::run()
|
||||
}
|
||||
k=udata.kin;
|
||||
if(m_monitoring) {
|
||||
m_step=k/(2*6192);
|
||||
m_step=k/2048;
|
||||
if(m_step != nstep0) {
|
||||
if(m_dataSinkBusy) {
|
||||
nBusy++;
|
||||
} else {
|
||||
// m_dataSinkBusy=true;
|
||||
// qDebug() << "Calling dataSink" << k;
|
||||
emit readyForFFT(k); //Signal to compute new FFTs
|
||||
}
|
||||
nstep0=m_step;
|
||||
}
|
||||
}
|
||||
msleep(100);
|
||||
msleep(10);
|
||||
n30z=n30;
|
||||
}
|
||||
Pa_StopStream(inStream);
|
||||
|
@ -62,9 +62,9 @@ void WideGraph::saveSettings()
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void WideGraph::dataSink2(float s[], int nkhz, int ihsym, int ndiskdata,
|
||||
uchar lstrong[])
|
||||
void WideGraph::dataSink2(float green[], int ig)
|
||||
{
|
||||
ui->widePlot->draw(green,ig);
|
||||
/*
|
||||
static float splot[NFFT];
|
||||
float swide[2048];
|
||||
|
@ -19,8 +19,7 @@ public:
|
||||
double m_dForceCenterFreq;
|
||||
double m_cal570;
|
||||
|
||||
void dataSink2(float s[], int nkhz, int ihsym, int ndiskdata,
|
||||
uchar lstrong[]);
|
||||
void dataSink2(float green[], int ig);
|
||||
int QSOfreq();
|
||||
int nSpan();
|
||||
int nStartFreq();
|
||||
|
Loading…
Reference in New Issue
Block a user