From be5eb31884a77d6ef85b42211fd32f3637a7c39a Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 8 Jun 2015 19:42:20 +0000 Subject: [PATCH] Basic functionality of Echo spectrum is in place. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5557 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- CMakeLists.txt | 1 + commons.h | 7 +++ echograph.cpp | 11 ++++- echograph.h | 3 +- echograph.ui | 35 ++++++++++++--- echoplot.cpp | 16 +++---- echoplot.h | 3 +- lib/avecho.f90 | 119 +++++++++++++++++++++++++++++++++++++++++++++++++ mainwindow.cpp | 43 +++++++++++++----- mainwindow.h | 7 +++ 10 files changed, 215 insertions(+), 30 deletions(-) create mode 100644 lib/avecho.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bb95af04..374414573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -262,6 +262,7 @@ set (wsjt_FSRCS lib/astro.f90 lib/astrosub.f90 lib/astro0.f90 + lib/avecho.f90 lib/avg4.f90 lib/azdist.f90 lib/baddata.f90 diff --git a/commons.h b/commons.h index d572e1d3c..308447633 100644 --- a/commons.h +++ b/commons.h @@ -44,6 +44,13 @@ extern "C" { extern struct { float syellow[NSMAX]; } jt9w_; +extern struct { + int nclearave; + int nsum; + float blue[2000]; + float red[2000]; +} echocom_; + } #endif // COMMONS_H diff --git a/echograph.cpp b/echograph.cpp index f3d890bcb..d3f33a55b 100644 --- a/echograph.cpp +++ b/echograph.cpp @@ -1,4 +1,4 @@ -//#include "commons.h" +#include "commons.h" #include #include "echoplot.h" #include "echograph.h" @@ -27,6 +27,7 @@ EchoGraph::EchoGraph(QSettings * settings, QWidget *parent) : ui->zeroSlider->setValue(ui->echoPlot->getPlotZero()); ui->gainSlider->setValue(ui->echoPlot->getPlotGain()); ui->smoothSpinBox->setValue(m_settings->value("Smooth",0).toInt()); + ui->binsPerPixelSpinBox->setValue(m_settings->value("EchoBPP",0).toInt()); ui->echoPlot->m_blue=m_settings->value("BlueCurve",false).toBool(); ui->cbBlue->setChecked(ui->echoPlot->m_blue); m_settings->endGroup(); @@ -52,6 +53,7 @@ void EchoGraph::saveSettings() m_settings->setValue("PlotZero",ui->echoPlot->m_plotZero); m_settings->setValue("PlotGain",ui->echoPlot->m_plotGain); m_settings->setValue("Smooth",ui->echoPlot->m_smooth); + m_settings->setValue("EchoBPP",ui->echoPlot->m_binsPerPixel); m_settings->setValue("BlueCurve",ui->echoPlot->m_blue); m_settings->endGroup(); } @@ -84,3 +86,10 @@ void EchoGraph::on_zeroSlider_valueChanged(int value) ui->echoPlot->setPlotZero(value); ui->echoPlot->draw(); } + +void EchoGraph::on_binsPerPixelSpinBox_valueChanged(int n) +{ + ui->echoPlot->m_binsPerPixel=n; + ui->echoPlot->DrawOverlay(); + ui->echoPlot->draw(); +} diff --git a/echograph.h b/echograph.h index d2f61bf93..445e6e478 100644 --- a/echograph.h +++ b/echograph.h @@ -26,7 +26,8 @@ private slots: void on_smoothSpinBox_valueChanged(int n); void on_cbBlue_toggled(bool checked); void on_gainSlider_valueChanged(int value); - void on_zeroSlider_valueChanged(int value); + void on_zeroSlider_valueChanged(int value); + void on_binsPerPixelSpinBox_valueChanged(int n); private: QSettings * m_settings; diff --git a/echograph.ui b/echograph.ui index 78121764a..8522cca83 100644 --- a/echograph.ui +++ b/echograph.ui @@ -89,6 +89,25 @@ + + + + + 60 + 0 + + + + Bins/Pixel + + + 1 + + + 10 + + + @@ -161,15 +180,17 @@ - - - - Smooth - - - + + + 60 + 0 + + + + Smooth + 20 diff --git a/echoplot.cpp b/echoplot.cpp index e0e44e53c..c0e314422 100644 --- a/echoplot.cpp +++ b/echoplot.cpp @@ -1,5 +1,5 @@ #include "echoplot.h" -//#include "commons.h" +#include "commons.h" #include #include #include "moc_echoplot.cpp" @@ -18,7 +18,7 @@ EPlotter::EPlotter(QWidget *parent) : //EPlotter Constructor setAttribute(Qt::WA_NoSystemBackground, true); m_StartFreq = -200; - m_fftBinWidth=48000.0/131072.0; + m_fftBinWidth=12000.0/32768.0; m_fSpan=1000.0; m_hdivs = HORZ_DIVS; m_Running = false; @@ -81,7 +81,7 @@ void EPlotter::paintEvent(QPaintEvent *) // paintEvent() m_paintEventBusy=false; } -void EPlotter::draw() //draw() +void EPlotter::draw() //draw() { int i,j,y; float blue[2000],red[2000]; @@ -91,16 +91,16 @@ void EPlotter::draw() //draw() QPainter painter2D(&m_2DPixmap); QRect tmp(0,0,m_w,m_h2); painter2D.fillRect(tmp,Qt::black); -/* - if(datcom_.nclearave==0) { + + if(echocom_.nclearave==0) { QPoint LineBuf[MAX_SCREENSIZE]; QPen penBlue(QColor(0,255,255),1); QPen penRed(Qt::red,1); j=0; int i0=1000 + int(m_StartFreq/m_fftBinWidth); for(i=0; i<2000; i++) { - blue[i]=datcom_.blue[i]; - red[i]=datcom_.red[i]; + blue[i]=echocom_.blue[i]; + red[i]=echocom_.red[i]; } if(m_smooth>0) { for(i=0; imeterFrame); signalMeter->resize(50, 160); @@ -820,8 +824,20 @@ void MainWindow::dataSink(qint64 frames) if(ihsym == m_hsymStop) { if(m_mode=="Echo") { - qDebug() << "call plotSpec()" << m_s6; + float snr=0; + int nfrit=0; + int nqual=0; + float f1=1500.0; + float rms=0.0; + float sigdb=0.0; + float dfreq=0.0; + float width=0.0; + echocom_.nclearave=m_nclearave; + avecho_(&jt9com_.d2[0],&m_nDop00,&nfrit,&nqual,&f1,&rms,&sigdb, + &snr,&dfreq,&width); + qDebug() << "A" << echocom_.nclearave << echocom_.nsum << rms << sigdb; if(m_echoGraph->isVisible()) m_echoGraph->plotSpec(); + m_nclearave=0; return; } if( m_dialFreqRxWSPR==0) m_dialFreqRxWSPR=m_dialFreq; @@ -2145,9 +2161,8 @@ void MainWindow::guiUpdate() QDateTime t = QDateTime::currentDateTimeUtc(); if(m_astroWidget) { m_freqMoon=m_dialFreq + 1000*m_astroWidget->m_kHz + m_astroWidget->m_Hz; - int ndop,ndop00; m_astroWidget->astroUpdate(t, m_config.my_grid (), m_hisGrid,m_freqMoon, - &ndop, &ndop00, m_transmitting, + &m_nDop, &m_nDop00, m_transmitting, m_config.data_dir().absoluteFilePath("JPLEPH")); //Apply Doppler corrections only for 50 MHz and above @@ -2155,23 +2170,28 @@ void MainWindow::guiUpdate() if(m_astroWidget->m_bDopplerTracking) { - int ndopr=0; // No Doppler Correction if(m_DopplerMethod==1) { - // All Doppler correction done here; DX station stays at nominal dial frequency. - ndopr=m_astroWidget->m_stepHz*qRound(double(ndop)/double(m_astroWidget->m_stepHz)); +// All Doppler correction done here; DX station stays at nominal dial frequency. + m_nDopr=m_astroWidget->m_stepHz*qRound(double(m_nDop)/double( + m_astroWidget->m_stepHz)); } if(m_DopplerMethod==2) { // Doppler correction to constant frequency on Moon - ndopr=m_astroWidget->m_stepHz*qRound(double(ndop00/2.0)/double(m_astroWidget->m_stepHz)); + m_nDopr=m_astroWidget->m_stepHz*qRound(double(m_nDop00/2.0)/double( + m_astroWidget->m_stepHz)); } if(m_transmitting) { - m_dialFreqTx=m_freqNominal + 1000*m_astroWidget->m_kHz + m_astroWidget->m_Hz - ndopr; - ui->labDialFreq->setText (Radio::pretty_frequency_MHz_string (m_dialFreqTx)); + m_dialFreqTx=m_freqNominal + 1000*m_astroWidget->m_kHz + + m_astroWidget->m_Hz - m_nDopr; + ui->labDialFreq->setText (Radio::pretty_frequency_MHz_string ( + m_dialFreqTx)); Q_EMIT m_config.transceiver_tx_frequency (m_dialFreqTx); } else { - m_dialFreq=m_freqNominal + 1000*m_astroWidget->m_kHz + m_astroWidget->m_Hz + ndopr; - ui->labDialFreq->setText (Radio::pretty_frequency_MHz_string (m_dialFreq)); + m_dialFreq=m_freqNominal + 1000*m_astroWidget->m_kHz + + m_astroWidget->m_Hz + m_nDopr; + ui->labDialFreq->setText (Radio::pretty_frequency_MHz_string ( + m_dialFreq)); Q_EMIT m_config.transceiver_frequency(m_dialFreq); } } @@ -2216,7 +2236,6 @@ void MainWindow::guiUpdate() if(!m_monitoring and !m_diskData) { signalMeter->setValue(0); } - m_sec0=nsec; } diff --git a/mainwindow.h b/mainwindow.h index 353f59a02..6e6902a15 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -333,6 +333,9 @@ private: qint32 m_dBm; qint32 m_pctx; qint32 m_nseq; + qint32 m_nDop; //Doppler shift of EME DX station + qint32 m_nDop00; //EME self-Doppler + qint32 m_nDopr; //Applied Doppler, rounded to nearest 1, 10 or 100 Hz bool m_btxok; //True if OK to transmit bool m_diskData; @@ -555,6 +558,10 @@ extern "C" { void wspr_downsample_(short int d2[], int* k); void savec2_(char* fname, int* m_TRseconds, double* m_dialFreq, int len1); + + void avecho_( short id2[], int* dop, int* nfrit, int* nqual, float* f1, + float* rms, float* sigdb, float* snr, float* dfreq, + float* width); } #endif // MAINWINDOW_H