Further progress toward a usable "FreqCal" (Frequency Calibration) mode.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7448 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2017-01-04 19:07:35 +00:00
parent 838555c08c
commit 6d3ca346e0
5 changed files with 112 additions and 19 deletions

View File

@ -363,6 +363,7 @@ set (wsjt_FSRCS
lib/foldspec9f.f90
lib/four2a.f90
lib/fqso_first.f90
lib/freqcal.f90
lib/gen4.f90
lib/gen65.f90
lib/gen9.f90

51
lib/freqcal.f90 Normal file
View File

@ -0,0 +1,51 @@
subroutine freqcal(id2,k,nfreq,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
complex cx(0:NH)
equivalence (x,cx)
data n/0/,k0/9999999/
save n,k0
if(k.lt.k0) n=0
k0=k
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)
smax=0.
s=0.
do i=ia,ib
s(i)=real(cx(i))**2 + aimag(cx(i))**2
if(s(i).gt.smax) then
smax=s(i)
ipk=i
endif
enddo
call peakup(s(ipk-1),s(ipk),s(ipk+1),dx)
fpeak=df * (ipk+dx)
sum=0.
nsum=0
do i=ia,ib
if(abs(i-ipk).gt.10) then
sum=sum+s(i)
nsum=nsum+1
endif
enddo
ave=sum/nsum
pave=db(ave) + 8.0
snr=db(smax/ave)
! if(snr.lt.20.0) cflag='*'
n=n+1
write(line,1100) fpeak,snr
1100 format(2f8.1)
line(27:27)=char(0)
return
end subroutine freqcal

View File

@ -102,6 +102,7 @@ extern "C" {
int ptt_(int nport, int ntx, int* iptt, int* nopen);
void wspr_downsample_(short int d2[], int* k);
int savec2_(char* fname, int* TR_seconds, double* dial_freq, int len1);
void avecho_( short id2[], int* dop, int* nfrit, int* nqual, float* f1,
@ -112,9 +113,13 @@ extern "C" {
char msg[], char mycall[], char hiscall[],
int len1, int len2, int len3);
void degrade_snr_(short d2[], int* n, float* db, float* bandwidth);
void wav12_(short d2[], short d1[], int* nbytes, short* nbitsam2);
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);
}
int volatile itone[NUM_ISCAT_SYMBOLS]; //Audio tones for all Tx symbols
@ -1090,6 +1095,7 @@ void MainWindow::fixStop()
void MainWindow::dataSink(qint64 frames)
{
static float s[NSMAX];
char line[27];
int k (frames);
QString fname {QDir::toNativeSeparators(m_dataDir.absoluteFilePath ("refspec.dat"))};
@ -1133,6 +1139,18 @@ 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);
QString t=QString::fromLatin1(line);
DecodedText decodedtext;
decodedtext=t;
ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(),
m_config.color_NewCall());
}
if(m_ihsym==3*m_hsymStop/4) {
m_dialFreqRxWSPR=m_freqNominal;
}
@ -1166,7 +1184,6 @@ void MainWindow::dataSink(qint64 frames)
return;
}
if(m_mode=="FreqCal") {
qDebug() << "A" << m_ihsym;
return;
}
if( m_dialFreqRxWSPR==0) m_dialFreqRxWSPR=m_freqNominal;
@ -1971,12 +1988,14 @@ void MainWindow::on_actionHide_Controls_triggered()
minimumSize().setWidth(770);
}
ui->menuBar->setVisible(!m_bHideControls);
if(m_mode!="FreqCal") {
ui->label_6->setVisible(!m_bHideControls);
ui->line->setVisible(!m_bHideControls);
ui->line_2->setVisible(!m_bHideControls);
ui->label_7->setVisible(!m_bHideControls);
ui->decodedTextLabel->setVisible(!m_bHideControls);
ui->decodedTextLabel2->setVisible(!m_bHideControls);
ui->line_2->setVisible(!m_bHideControls);
}
ui->line->setVisible(!m_bHideControls);
ui->decodedTextLabel->setVisible(!m_bHideControls);
ui->gridLayout_5->layout()->setSpacing(spacing);
ui->horizontalLayout->layout()->setSpacing(spacing);
ui->horizontalLayout_2->layout()->setSpacing(spacing);
@ -4508,14 +4527,13 @@ void MainWindow::on_actionEcho_triggered()
void MainWindow::on_actionFreqCal_triggered()
{
on_actionEcho_triggered();
if(m_echoGraph->isVisible()) m_echoGraph->hide();
if(ui->actionAstronomical_data->isChecked()) {
ui->actionAstronomical_data->setChecked (false);
}
on_actionJT9_triggered();
displayWidgets(nWidgets("001100000000000000000000"));
m_mode="FreqCal";
displayWidgets(nWidgets("000000000000000000000000"));
ui->actionFreqCal->setChecked(true);
switch_mode(Modes::FreqCal);
m_wideGraph->setMode(m_mode);
statusChanged();
m_TRperiod=30;
m_modulator->setPeriod(m_TRperiod); // TODO - not thread safe
m_detector->setPeriod(m_TRperiod); // TODO - not thread safe
@ -4523,15 +4541,8 @@ void MainWindow::on_actionFreqCal_triggered()
m_FFTSize = m_nsps / 2;
Q_EMIT FFTSize (m_FFTSize);
m_hsymStop=100;
switch_mode(Modes::FreqCal);
setup_status_bar (true);
m_wideGraph->setMode(m_mode);
m_bFastMode=true;
m_bFast9=false;
fast_config(false);
// WSPR_config(true);
ui->decodedTextLabel->setText(" UTC N Level Sig DF Width Q");
statusChanged();
ui->decodedTextLabel->setText(" Freq S/N");
}
void MainWindow::switch_mode (Mode mode)
@ -4558,6 +4569,15 @@ void MainWindow::switch_mode (Mode mode)
ui->RxFreqSpinBox->setSingleStep(1);
}
m_bVHFwarned=false;
bool b=m_mode=="FreqCal";
ui->tabWidget->setVisible(!b);
if(b) {
ui->DX_controls_widget->setVisible(false);
ui->decodedTextBrowser2->setVisible(false);
ui->decodedTextLabel2->setVisible(false);
ui->label_6->setVisible(false);
ui->label_7->setVisible(false);
}
}
void MainWindow::WSPR_config(bool b)

View File

@ -624,6 +624,12 @@ QLabel[oob=&quot;true&quot;] {
</item>
<item row="5" column="0">
<widget class="LettersSpinBox" name="sbFtol">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Frequency tolerance (Hz)</string>
</property>
@ -773,6 +779,12 @@ QLabel[oob=&quot;true&quot;] {
</item>
<item row="4" column="0">
<widget class="QSpinBox" name="RxFreqSpinBox">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Audio Rx frequency</string>
</property>

View File

@ -422,6 +422,15 @@ void CPlotter::DrawOverlay() //DrawOverlay()
x2=XfromFreq(1600);
painter0.drawLine(x1,29,x2,29);
}
if(m_mode=="FreqCal") { //FreqCal
x1=XfromFreq(m_rxFreq-m_tol);
x2=XfromFreq(m_rxFreq+m_tol);
painter0.drawLine(x1,29,x2,29);
x1=XfromFreq(m_rxFreq);
painter0.drawLine(x1,24,x1,30);
}
if(m_mode=="JT9" or m_mode=="JT65" or m_mode=="JT9+JT65" or m_mode=="QRA64") {
if(m_mode=="QRA64" or (m_mode=="JT65" and m_bVHF)) {