From 6d64eaa37bf51b390cb1225d7f668caa60bfa2b2 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 5 Jan 2017 18:35:26 +0000 Subject: [PATCH] More work on FreqCal mode. Some of this code is temporary! git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7451 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/freqcal.f90 | 25 ++++++++++++++++--------- mainwindow.cpp | 26 ++++++++++++++++++++------ mainwindow.h | 5 +++-- mainwindow.ui | 40 +++++++++++++++++++++++++++------------- shortcuts.txt | 1 + 5 files changed, 67 insertions(+), 30 deletions(-) diff --git a/lib/freqcal.f90 b/lib/freqcal.f90 index 1e74794d1..c8bea6f9c 100644 --- a/lib/freqcal.f90 +++ b/lib/freqcal.f90 @@ -1,10 +1,10 @@ -subroutine freqcal(id2,k,nfreq,ntol,line) +subroutine freqcal(id2,k,nkhz,noffset,ntol,line) parameter (NZ=30*12000,NFFT=55296,NH=NFFT/2) integer*2 id2(0:NZ-1) real x(0:NFFT-1) real s(NH) - character line*27 + character line*80,cflag*1 complex cx(0:NH) equivalence (x,cx) data n/0/,k0/9999999/ @@ -16,8 +16,8 @@ subroutine freqcal(id2,k,nfreq,ntol,line) x=0.001*id2(k-NFFT:k-1) call four2a(x,NFFT,1,-1,0) !Compute spectrum, r2c df=12000.0/NFFT - ia=nint((nfreq-ntol)/df) - ib=nint((nfreq+ntol)/df) + ia=nint((noffset-ntol)/df) + ib=nint((noffset+ntol)/df) smax=0. s=0. do i=ia,ib @@ -39,13 +39,20 @@ subroutine freqcal(id2,k,nfreq,ntol,line) endif enddo ave=sum/nsum - pave=db(ave) + 8.0 snr=db(smax/ave) -! if(snr.lt.20.0) cflag='*' + pave=db(ave) + 8.0 + cflag=' ' + if(snr.lt.20.0) cflag='*' n=n+1 - write(line,1100) fpeak,snr -1100 format(2f8.1) - line(27:27)=char(0) + nsec=mod(time(),86400) + nhr=nsec/3600 + nmin=mod(nsec/60,60) + nsec=mod(nsec,60) + ncal=1 + ferr=fpeak-noffset + write(line,1100) nhr,nmin,nsec,nkhz,ncal,noffset,fpeak,ferr,pave, & + snr,callsign,cflag,char(0) +1100 format(i2.2,':',i2.2,':',i2.2,i7,i3,i6,2f10.3,2f7.1,2x,a6,2x,a1,a1) return end subroutine freqcal diff --git a/mainwindow.cpp b/mainwindow.cpp index 80a9f16ef..64f2f1f71 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -119,7 +119,8 @@ extern "C" { void refspectrum_(short int d2[], bool* bclearrefspec, bool* brefspec, bool* buseref, const char* c_fname, int len); - void freqcal_(short d2[], int* k, int* nfreq, int* ntol, char line[], int len); + void freqcal_(short d2[], int* k, int* nkhz,int* noffset, int* ntol, + char line[], int len); } int volatile itone[NUM_ISCAT_SYMBOLS]; //Audio tones for all Tx symbols @@ -1095,7 +1096,7 @@ void MainWindow::fixStop() void MainWindow::dataSink(qint64 frames) { static float s[NSMAX]; - char line[27]; + char line[80]; int k (frames); QString fname {QDir::toNativeSeparators(m_dataDir.absoluteFilePath ("refspec.dat"))}; @@ -1141,7 +1142,8 @@ void MainWindow::dataSink(qint64 frames) fixStop(); if(m_mode=="FreqCal" and m_ihsym>=16 and m_ihsym%8==0) { m_RxFreq=ui->RxFreqSpinBox->value (); - freqcal_(&dec_data.d2[0],&k,&m_RxFreq,&m_Ftol,&line[0],27); + int nkhz=(m_freqNominal+m_RxFreq)/1000; + freqcal_(&dec_data.d2[0],&k,&nkhz,&m_RxFreq,&m_Ftol,&line[0],80); QString t=QString::fromLatin1(line); DecodedText decodedtext; @@ -4541,8 +4543,10 @@ void MainWindow::on_actionFreqCal_triggered() m_FFTSize = m_nsps / 2; Q_EMIT FFTSize (m_FFTSize); m_hsymStop=100; + ui->RxFreqSpinBox->setValue(1500); setup_status_bar (true); - ui->decodedTextLabel->setText(" Freq S/N"); +// 18:15:47 0 1 1500 1550.349 0.100 3.5 10.2 + ui->decodedTextLabel->setText(" UTC Freq CAL Offset fMeas DF Level S/N"); } void MainWindow::switch_mode (Mode mode) @@ -6068,17 +6072,27 @@ void MainWindow::fastPick(int x0, int x1, int y) } } -void MainWindow::on_actionSave_reference_spectrum_triggered() +void MainWindow::on_actionMeasure_reference_spectrum_triggered() { if(!m_monitoring) on_monitorButton_clicked (true); m_bRefSpec=true; } -void MainWindow::on_actionClear_reference_spectrum_triggered() +void MainWindow::on_actionErase_reference_spectrum_triggered() { m_bClearRefSpec=true; } +void MainWindow::on_actionFrequency_calibration_triggered() +{ + static int n=-1; + double fMHz[]={0.660,0.880,1.210,2.500,3.330,5.000, + 7.850,10.000,14.670,15.000,20.000}; + m_freqNominal=1000000.0*fMHz[++n] - m_RxFreq + 0.5; + if(n>=10) n=-1; + on_bandComboBox_activated(-1); +} + void MainWindow::on_sbCQTxFreq_valueChanged(int) { setXIT (ui->TxFreqSpinBox->value ()); diff --git a/mainwindow.h b/mainwindow.h index 42a8402eb..4bed4dda3 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -246,8 +246,9 @@ private slots: void on_actionFast_Graph_triggered(); void on_actionHide_Controls_triggered(); void fast_decode_done(); - void on_actionSave_reference_spectrum_triggered(); - void on_actionClear_reference_spectrum_triggered(); + void on_actionMeasure_reference_spectrum_triggered(); + void on_actionErase_reference_spectrum_triggered(); + void on_actionFrequency_calibration_triggered(); void on_sbTR_valueChanged(int index); void on_sbFtol_valueChanged(int index); void on_cbFast9_clicked(bool b); diff --git a/mainwindow.ui b/mainwindow.ui index 5eee0e14a..95b6988fd 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -2376,9 +2376,6 @@ QPushButton[state="ok"] { - - - @@ -2459,12 +2456,21 @@ QPushButton[state="ok"] { Configurations + + + Tools + + + + + + @@ -2893,11 +2899,6 @@ QPushButton[state="ok"] { F9 - - - Measure reference spectrum - - &Download Samples ... @@ -2938,11 +2939,6 @@ QPushButton[state="ok"] { - - - Clear reference spectrum - - Hide menus and labels @@ -2962,6 +2958,24 @@ QPushButton[state="ok"] { FreqCal + + + Measure reference spectrum + + + + + Erase reference spectrum + + + + + Frequency calibration + + + Ctrl+F10 + + diff --git a/shortcuts.txt b/shortcuts.txt index 7ddd71740..5d701fb85 100644 --- a/shortcuts.txt +++ b/shortcuts.txt @@ -7,6 +7,7 @@ Alt+F4 Exit program F5 Display special mouse commands F6 Open next file in directory + F7 Display Message Averaging window Shift+F6 Decode all remaining files in directrory F11 Move Rx frequency down 1 Hz Ctrl+F11 Move Rx and Tx frequencies down 1 Hz