From 71ca3fc1c0518ebd9698a00c3d7358a53ec1dfb5 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 21 Mar 2013 22:58:16 +0000 Subject: [PATCH] LogQSO now has a confirmation step where you can edit the log entries. Tx macros are now enabled. Bug in decoder fixed. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3068 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- devsetup.cpp | 24 ++++++++++++ devsetup.h | 2 + devsetup.ui | 6 +-- lib/decoder.f90 | 73 ++++++++++++++++-------------------- logqso.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++-- logqso.h | 12 +++++- logqso.ui | 22 +++++------ mainwindow.cpp | 98 ++++++++++++++++++++++++++----------------------- mainwindow.h | 10 +++++ 9 files changed, 232 insertions(+), 107 deletions(-) diff --git a/devsetup.cpp b/devsetup.cpp index c729415c0..7f42edc11 100644 --- a/devsetup.cpp +++ b/devsetup.cpp @@ -120,6 +120,17 @@ void DevSetup::initDlg() ui.cbPSKReporter->setChecked(m_pskReporter); m_paInDevice=m_inDevList[m_nDevIn]; m_paOutDevice=m_outDevList[m_nDevOut]; + ui.macro1->setText(m_macro[0].toUpper()); + ui.macro2->setText(m_macro[1].toUpper()); + ui.macro3->setText(m_macro[2].toUpper()); + ui.macro4->setText(m_macro[3].toUpper()); + ui.macro5->setText(m_macro[4].toUpper()); + ui.macro6->setText(m_macro[5].toUpper()); + ui.macro7->setText(m_macro[6].toUpper()); + ui.macro8->setText(m_macro[7].toUpper()); + ui.macro9->setText(m_macro[8].toUpper()); + ui.macro10->setText(m_macro[9].toUpper()); + } //------------------------------------------------------- accept() @@ -144,6 +155,19 @@ void DevSetup::accept() m_paInDevice=m_inDevList[m_nDevIn]; m_nDevOut=ui.comboBoxSndOut->currentIndex(); m_paOutDevice=m_outDevList[m_nDevOut]; + + m_macro.clear(); + m_macro.append(ui.macro1->text()); + m_macro.append(ui.macro2->text()); + m_macro.append(ui.macro3->text()); + m_macro.append(ui.macro4->text()); + m_macro.append(ui.macro5->text()); + m_macro.append(ui.macro6->text()); + m_macro.append(ui.macro7->text()); + m_macro.append(ui.macro8->text()); + m_macro.append(ui.macro9->text()); + m_macro.append(ui.macro10->text()); + QDialog::accept(); } diff --git a/devsetup.h b/devsetup.h index 14ffe1cad..419e36ad4 100644 --- a/devsetup.h +++ b/devsetup.h @@ -31,6 +31,8 @@ public: QString m_saveDir; QString m_azelDir; + QStringList m_macro; + public slots: void accept(); diff --git a/devsetup.ui b/devsetup.ui index 0ede8ed5f..369ebd22c 100644 --- a/devsetup.ui +++ b/devsetup.ui @@ -17,7 +17,7 @@ - 0 + 1 @@ -391,7 +391,7 @@ Tx Macros - + 110 @@ -828,7 +828,7 @@ - + 0 diff --git a/lib/decoder.f90 b/lib/decoder.f90 index 90e6bfbcb..07a8ab6db 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -86,52 +86,41 @@ subroutine decoder(ss,c0) i1=max(nint((nfqso-1000)/df3 - 10),ia) i2=min(nint((nfqso-1000)/df3 + 10),ib) ii=maxloc(ccfred(i1:i2)) - i=ii(1) + i1 - 1 - go to 12 + i00=ii(1) + i1 - 1 -10 ii=maxloc(ccfred(ia:ib)) - i=ii(1) + ia - 1 -12 f=(i-1)*df3 - if((i.eq.ipk .or. (ccfred(i).ge.3.0) .and. abs(f-fgood).gt.10.0*df8 .and. & - ccfok(i))) then - call timer('decode9a',0) - fpk=1000.0 + df3*(i-1) - c1(1:npts8)=conjg(c0(1:npts8)) - call decode9a(c1,npts8,nsps8,fpk,syncpk,snrdb,xdt,freq,drift,i1SoftSymbols) - call timer('decode9a',1) + do j=ia,ib + i=j + if(i.eq.i1) i=i00 + f=(i-1)*df3 + if(.not.ccfok(i)) cycle + if((i.eq.ipk .or. (ccfred(i).ge.3.0) .and. abs(f-fgood).gt.10.0*df8)) then + call timer('decode9a',0) + fpk=1000.0 + df3*(i-1) + c1(1:npts8)=conjg(c0(1:npts8)) + call decode9a(c1,npts8,nsps8,fpk,syncpk,snrdb,xdt,freq,drift, & + i1SoftSymbols) + call timer('decode9a',1) - call timer('decode9 ',0) - call decode9(i1SoftSymbols,limit,nlim,msg) - call timer('decode9 ',1) + call timer('decode9 ',0) + call decode9(i1SoftSymbols,limit,nlim,msg) + call timer('decode9 ',1) - sync=(syncpk-1.0)/2.0 - if(sync.lt.0.0 .or. snrdb.lt.dblim-2.0) sync=0.0 - nsync=sync - if(nsync.gt.10) nsync=10 - nsnr=nint(snrdb) - ndrift=nint(drift/df3) - - if(sync.gt.sbest .and. fgood.eq.0.0) then - sbest=sync - write(line,fmt) nutc,nsync,nsnr,xdt,freq,ndrift - if(nsync.gt.0) nsynced=1 + sync=(syncpk-1.0)/2.0 + if(sync.lt.0.0 .or. snrdb.lt.dblim-2.0) sync=0.0 + nsync=sync + if(nsync.gt.10) nsync=10 + nsnr=nint(snrdb) + ndrift=nint(drift/df3) + if(msg.ne.' ') then + write(*,fmt) nutc,nsync,nsnr,xdt,freq,ndrift,msg + fgood=f + nsynced=1 + ndecoded=1 +! ccfred(max(ia,i-3):min(ib,i+11))=0. + ccfok(max(ia,i-3):min(ib,i+11))=.false. + endif endif - - if(msg.ne.' ') then - write(*,fmt) nutc,nsync,nsnr,xdt,freq,ndrift,msg - fgood=f - nsynced=1 - ndecoded=1 - ccfred(max(ia,i-3):min(ib,i+11))=0. - endif - endif - ccfred(i)=0. - if(maxval(ccfred(ia:ib)).gt.3.0) go to 10 - - if(fgood.eq.0.0) then - write(*,1020) line -1020 format(a33) - endif + enddo write(*,1010) nsynced,ndecoded 1010 format('',2i4) diff --git a/logqso.cpp b/logqso.cpp index 25f965254..49c8b926e 100644 --- a/logqso.cpp +++ b/logqso.cpp @@ -1,7 +1,9 @@ #include "logqso.h" #include "ui_logqso.h" +#include #include + LogQSO::LogQSO(QWidget *parent) : QDialog(parent), ui(new Ui::LogQSO) @@ -14,13 +16,97 @@ LogQSO::~LogQSO() delete ui; } -void LogQSO::initLogQSO() +void LogQSO::initLogQSO(QString hisCall, QString hisGrid, QString mode, + QString rptSent, QString rptRcvd, QString date, + QString qsoStart, QString qsoStop, double dialFreq, + QString myCall, QString myGrid) { - qDebug() << "A"; + ui->call->setText(hisCall); + ui->grid->setText(hisGrid); + ui->mode->setText(mode); + ui->sent->setText(rptSent); + ui->rcvd->setText(rptRcvd); + date=date.mid(0,4) + "-" + date.mid(4,2) + "-" + date.mid(6,2); + ui->date->setText(date); + ui->time->setText(qsoStart); + m_dialFreq=dialFreq; + m_myCall=myCall; + m_myGrid=myGrid; + QString band=""; + if(dialFreq>0.135 and dialFreq<0.139) band="2200m"; + if(dialFreq>0.45 and dialFreq<0.55) band="630m"; + if(dialFreq>1.8 and dialFreq<2.0) band="160m"; + if(dialFreq>3.5 and dialFreq<4.0) band="80m"; + if(dialFreq>5.1 and dialFreq<5.45) band="60m"; + if(dialFreq>7.0 and dialFreq<7.3) band="40m"; + if(dialFreq>10.0 and dialFreq<10.15) band="30m"; + if(dialFreq>14.0 and dialFreq<14.35) band="20m"; + if(dialFreq>18.068 and dialFreq<18.168) band="17m"; + if(dialFreq>21.0 and dialFreq<21.45) band="15m"; + if(dialFreq>24.890 and dialFreq<24.990) band="12m"; + if(dialFreq>28.0 and dialFreq<29.7) band="10m"; + if(dialFreq>50.0 and dialFreq<54.0) band="6m"; + if(dialFreq>70.0 and dialFreq<71.0) band="4m"; + if(dialFreq>144.0 and dialFreq<148.0) band="2m"; + if(dialFreq>222.0 and dialFreq<225.0) band="1.25m"; + if(dialFreq>420.0 and dialFreq<450.0) band="70cm"; + if(dialFreq>902.0 and dialFreq<928.0) band="33cm"; + if(dialFreq>1240.0 and dialFreq<1300.0) band="23cm"; + if(dialFreq>2300.0 and dialFreq<2450.0) band="13cm"; + if(dialFreq>3300.0 and dialFreq<3500.0) band="9cm"; + if(dialFreq>5650.0 and dialFreq<5925.0) band="6cm"; + if(dialFreq>10000.0 and dialFreq<10500.0) band="3cm"; + if(dialFreq>24000.0 and dialFreq<24250.0) band="1.25cm"; + if(dialFreq>47000.0 and dialFreq<47200.0) band="6mm"; + if(dialFreq>75500.0 and dialFreq<81000.0) band="4mm"; + ui->band->setText(band); } void LogQSO::accept() { - qDebug() << "Z"; + QFile f2("wsjtx_log.adi"); + if(!f2.open(QIODevice::Text | QIODevice::Append)) { + QMessageBox m; + m.setText("Cannot open file \"wsjtx_log.adi\"."); + m.exec(); + } else { + QString hisCall,hisGrid,mode,rptSent,rptRcvd,date,qsoStart,band; +// if(qsoStart=="") qsoStart=qsoStop; +// if(qsoStop=="") qsoStop=qsoStart; + + hisCall=ui->call->text(); + hisGrid=ui->grid->text(); + mode=ui->mode->text(); + rptSent=ui->sent->text(); + rptRcvd=ui->rcvd->text(); + date=ui->date->text(); + date=date.mid(0,4) + date.mid(5,2) + date.mid(8,2); + qsoStart=ui->time->text(); + band=ui->band->text(); + + QString strDialFreq(QString::number(m_dialFreq,'f',6)); + + QTextStream out(&f2); + if(f2.size()==0) out << "WSJT-X ADIF Export" << endl; + + QString t; + t="" + hisCall; + t+=" " + hisGrid; + t+=" " + mode; + t+=" " + rptSent; + t+=" " + rptRcvd; + t+=" " + date; + t+=" " + qsoStart; +// t+=" " + qsoStop; + t+=" " + band; + t+=" " + strDialFreq; + t+=" " + + m_myCall; + t+=" " + + m_myGrid; + t+=" "; + out << t << endl; + f2.close(); + } QDialog::accept(); } diff --git a/logqso.h b/logqso.h index 6ff2238a9..61614996c 100644 --- a/logqso.h +++ b/logqso.h @@ -1,7 +1,8 @@ #ifndef LogQSO_H #define LogQSO_H -#include +#include +//#include namespace Ui { class LogQSO; @@ -14,7 +15,14 @@ class LogQSO : public QDialog public: explicit LogQSO(QWidget *parent = 0); ~LogQSO(); - void initLogQSO(); + void initLogQSO(QString hisCall, QString hisGrid, QString mode, + QString rptSent, QString rptRcvd, QString date, + QString qsoStart, QString qsoStop, double dialFreq, + QString myCall, QString myGrid); + + double m_dialFreq; + QString m_myCall; + QString m_myGrid; public slots: void accept(); diff --git a/logqso.ui b/logqso.ui index d648dbc16..749d576ea 100644 --- a/logqso.ui +++ b/logqso.ui @@ -29,7 +29,7 @@ QDialogButtonBox::Cancel|QDialogButtonBox::Ok - + 10 @@ -199,7 +199,7 @@ - + 0 @@ -221,7 +221,7 @@ - + 0 @@ -243,7 +243,7 @@ - + 50 @@ -259,7 +259,7 @@ - + 0 @@ -281,7 +281,7 @@ - + 0 @@ -436,7 +436,7 @@ - + 0 @@ -458,7 +458,7 @@ - + 0 @@ -480,7 +480,7 @@ - + 0 @@ -502,7 +502,7 @@ - + 0 @@ -548,7 +548,7 @@ - + diff --git a/mainwindow.cpp b/mainwindow.cpp index d9405b407..a51b7212c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -304,6 +304,7 @@ void MainWindow::writeSettings() settings.setValue("Tol",m_tol); settings.setValue("InGain",m_inGain); settings.setValue("PSKReporter",m_pskReporter); + settings.setValue("Macros",m_macro); settings.endGroup(); } @@ -367,6 +368,7 @@ void MainWindow::readSettings() m_monitorStartOFF=settings.value("MonitorOFF",false).toBool(); ui->actionMonitor_OFF_at_startup->setChecked(m_monitorStartOFF); m_pskReporter=settings.value("PSKReporter",false).toBool(); + m_macro=settings.value("Macros","").toStringList(); settings.endGroup(); if(!ui->actionLinrad->isChecked() && !ui->actionCuteSDR->isChecked() && @@ -457,6 +459,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog dlg.m_nDevIn=m_nDevIn; dlg.m_nDevOut=m_nDevOut; dlg.m_pskReporter=m_pskReporter; + dlg.m_macro=m_macro; dlg.initDlg(); if(dlg.exec() == QDialog::Accepted) { @@ -469,6 +472,8 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog m_paInDevice=dlg.m_paInDevice; m_nDevOut=dlg.m_nDevOut; m_paOutDevice=dlg.m_paOutDevice; + m_macro=dlg.m_macro; + #ifdef WIN32 if(dlg.m_pskReporter!=m_pskReporter) { if(dlg.m_pskReporter) { @@ -1008,7 +1013,7 @@ void MainWindow::readFromStdout() //readFromStdout m_bdecoded = (t.mid(23,1).toInt()==1); bool keepFile=m_saveAll or (m_saveSynced and m_bsynced) or (m_saveDecoded and m_bdecoded); - if(!keepFile) { + if(!keepFile and !m_diskData) { QFile savedFile(m_fname); savedFile.remove(); } @@ -1718,46 +1723,19 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button QString::number(dialFreq) + "," + m_mode + "," + m_rptSent + "," + m_rptRcvd; QTextStream out(&f); -// out << logEntry << "\r\n"; out << logEntry << endl; f.close(); } - QFile f2("wsjtx_log.adi"); - if(!f2.open(QIODevice::Text | QIODevice::Append)) { - msgBox("Cannot open file \"wsjtx_log.adi\"."); - } else { - - QTextStream out(&f2); - if(f2.size()==0) out << "WSJT-X ADIF Export" << endl; - - if(m_qsoStop=="") m_qsoStop=m_qsoStart; - if(m_qsoStart=="") m_qsoStart=m_qsoStop; - QString strDialFreq(QString::number(m_dialFreq,'f',6)); - - QString t; - t="" + m_hisCall; - t+=" " + m_hisGrid; - t+=" " + m_mode; - t+=" " + m_rptSent; - t+=" " + m_rptRcvd; - t+=" " + date; - t+=" " + m_qsoStart; - t+=" " + m_qsoStop; - t+=" " + strDialFreq; - t+=" " + m_myCall; - t+=" " + m_myGrid; - t+=" "; - out << t << endl; - f2.close(); - LogQSO logDlg(this); - logDlg.initLogQSO(); - if(logDlg.exec() == QDialog::Accepted) { - qDebug() << "ZZ"; - } + LogQSO logDlg(this); + logDlg.initLogQSO(m_hisCall,m_hisGrid,m_mode,m_rptSent,m_rptRcvd,date, + m_qsoStart,m_qsoStop,m_dialFreq,m_myCall,m_myGrid); + if(logDlg.exec() == QDialog::Accepted) { } m_rptSent=""; m_rptRcvd=""; + m_qsoStart=""; + m_qsoStop=""; } void MainWindow::on_actionJT9_1_triggered() @@ -1915,24 +1893,52 @@ void MainWindow::showMacros(const QPoint &pos) { QPoint globalPos = ui->tx5->mapToGlobal(pos); QMenu popupMenu; - QAction* popup1 = new QAction("5W DIP 73 GL",ui->tx5); - QAction* popup2 = new QAction("TNX 73 GL",ui->tx5); - popupMenu.addAction(popup1); - popupMenu.addAction(popup2); + QAction* popup1 = new QAction(m_macro[0],ui->tx5); + QAction* popup2 = new QAction(m_macro[1],ui->tx5); + QAction* popup3 = new QAction(m_macro[2],ui->tx5); + QAction* popup4 = new QAction(m_macro[3],ui->tx5); + QAction* popup5 = new QAction(m_macro[4],ui->tx5); + QAction* popup6 = new QAction(m_macro[5],ui->tx5); + QAction* popup7 = new QAction(m_macro[6],ui->tx5); + QAction* popup8 = new QAction(m_macro[7],ui->tx5); + QAction* popup9 = new QAction(m_macro[8],ui->tx5); + QAction* popup10 = new QAction(m_macro[9],ui->tx5); + + if(m_macro[0]!="") popupMenu.addAction(popup1); + if(m_macro[1]!="") popupMenu.addAction(popup2); + if(m_macro[2]!="") popupMenu.addAction(popup3); + if(m_macro[3]!="") popupMenu.addAction(popup4); + if(m_macro[4]!="") popupMenu.addAction(popup5); + if(m_macro[5]!="") popupMenu.addAction(popup6); + if(m_macro[6]!="") popupMenu.addAction(popup7); + if(m_macro[7]!="") popupMenu.addAction(popup8); + if(m_macro[8]!="") popupMenu.addAction(popup9); + if(m_macro[9]!="") popupMenu.addAction(popup10); + connect(popup1,SIGNAL(triggered()), this, SLOT(onPopup1())); connect(popup2,SIGNAL(triggered()), this, SLOT(onPopup2())); + connect(popup3,SIGNAL(triggered()), this, SLOT(onPopup3())); + connect(popup4,SIGNAL(triggered()), this, SLOT(onPopup4())); + connect(popup5,SIGNAL(triggered()), this, SLOT(onPopup5())); + connect(popup6,SIGNAL(triggered()), this, SLOT(onPopup6())); + connect(popup7,SIGNAL(triggered()), this, SLOT(onPopup7())); + connect(popup8,SIGNAL(triggered()), this, SLOT(onPopup8())); + connect(popup9,SIGNAL(triggered()), this, SLOT(onPopup9())); + connect(popup10,SIGNAL(triggered()), this, SLOT(onPopup10())); popupMenu.exec(globalPos); } -void MainWindow::onPopup1() -{ - ui->tx5->setText("5W DIP 73 GL"); -} +void MainWindow::onPopup1() { ui->tx5->setText(m_macro[0]); } +void MainWindow::onPopup2() { ui->tx5->setText(m_macro[1]); } +void MainWindow::onPopup3() { ui->tx5->setText(m_macro[2]); } +void MainWindow::onPopup4() { ui->tx5->setText(m_macro[3]); } +void MainWindow::onPopup5() { ui->tx5->setText(m_macro[4]); } +void MainWindow::onPopup6() { ui->tx5->setText(m_macro[5]); } +void MainWindow::onPopup7() { ui->tx5->setText(m_macro[6]); } +void MainWindow::onPopup8() { ui->tx5->setText(m_macro[7]); } +void MainWindow::onPopup9() { ui->tx5->setText(m_macro[8]); } +void MainWindow::onPopup10() { ui->tx5->setText(m_macro[9]); } -void MainWindow::onPopup2() -{ - ui->tx5->setText("TNX 73 GL"); -} bool MainWindow::gridOK(QString g) { diff --git a/mainwindow.h b/mainwindow.h index a55b45ec9..073f4110c 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -117,6 +117,14 @@ private slots: void showMacros(const QPoint& pos); void onPopup1(); void onPopup2(); + void onPopup3(); + void onPopup4(); + void onPopup5(); + void onPopup6(); + void onPopup7(); + void onPopup8(); + void onPopup9(); + void onPopup10(); private: Ui::MainWindow *ui; @@ -218,6 +226,8 @@ private slots: QString m_qsoStart; QString m_qsoStop; + QStringList m_macro; + SoundInThread soundInThread; //Instantiate the audio threads SoundOutThread soundOutThread;