From a360a64275ff395b741a6830858a2932dffb856a Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 18 Mar 2013 16:14:18 +0000 Subject: [PATCH] Combining wsjtx_rx.log and wsjtx_tx.log into ALL.TXT. Implementing ADIF log. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3050 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/decoder.f90 | 17 +----- lib/jt9a.F90 | 11 ---- mainwindow.cpp | 150 +++++++++++++++++++++++++++++++++++++----------- mainwindow.h | 10 +++- mainwindow.ui | 24 ++++---- widegraph.cpp | 13 +---- 6 files changed, 137 insertions(+), 88 deletions(-) diff --git a/lib/decoder.f90 b/lib/decoder.f90 index bdccd2d77..1da6644f8 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -8,7 +8,7 @@ subroutine decoder(ss,c0) real ss(184,NSMAX) character*22 msg character*33 line - character*80 fmt,fmt14 + character*80 fmt character*20 datetime real*4 ccfred(NSMAX) integer*1 i1SoftSymbols(207) @@ -36,27 +36,22 @@ subroutine decoder(ss,c0) nsps=6912 df3=1500.0/2048.0 fmt='(i4.4,i4,i5,f6.1,f8.0,i4,3x,a22)' - fmt14='(i4.4,i4,i5,f6.1,f8.0,i4,3x,a22,i8,i3)' else if(ntrMinutes.eq.2) then nsps=15360 df3=1500.0/2048.0 fmt='(i4.4,i4,i5,f6.1,f8.1,i4,3x,a22)' - fmt14='(i4.4,i4,i5,f6.1,f8.1,i4,3x,a22,i8,i3)' else if(ntrMinutes.eq.5) then nsps=40960 df3=1500.0/6144.0 fmt='(i4.4,i4,i5,f6.1,f8.1,i4,3x,a22)' - fmt14='(i4.4,i4,i5,f6.1,f8.1,i4,3x,a22,i8,i3)' else if(ntrMinutes.eq.10) then nsps=82944 df3=1500.0/12288.0 fmt='(i4.4,i4,i5,f6.1,f8.2,i4,3x,a22)' - fmt14='(i4.4,i4,i5,f6.1,f8.2,i4,3x,a22,i8,i3)' else if(ntrMinutes.eq.30) then nsps=252000 df3=1500.0/32768.0 fmt='(i4.4,i4,i5,f6.1,f8.2,i4,3x,a22)' - fmt14='(i4.4,i4,i5,f6.1,f8.2,i4,3x,a22,i8,i3)' endif if(nsps.eq.0) stop 'Error: bad TRperiod' !Better: return an error code### @@ -67,13 +62,6 @@ subroutine decoder(ss,c0) call sync9(ss,nzhsym,tstep,df3,ntol,nfqso,ccfred,ia,ib,ipk) !Compute ccfred call timer('sync9 ',1) -! open(13,file='decoded.txt',status='unknown') -! rewind 13 - if(iand(nRxLog,2).ne.0) rewind 14 - if(iand(nRxLog,1).ne.0) then -! Write date and time to lu 14 - endif - nRxLog=0 fgood=0. nsps8=nsps/8 @@ -111,7 +99,6 @@ subroutine decoder(ss,c0) if(msg.ne.' ') then write(*,fmt) nutc,nsync,nsnr,xdt,freq,ndrift,msg - write(14,fmt14) nutc,nsync,nsnr,xdt,freq,ndrift,msg,nlim,ntrMinutes fgood=f nsynced=1 ndecoded=1 @@ -123,7 +110,6 @@ subroutine decoder(ss,c0) if(fgood.eq.0.0) then write(*,1020) line - write(14,1020) line 1020 format(a33) endif @@ -132,7 +118,6 @@ subroutine decoder(ss,c0) flush(6) call flush(6) - call flush(14) call timer('decoder ',1) if(nstandalone.eq.0) call timer('decoder ',101) diff --git a/lib/jt9a.F90 b/lib/jt9a.F90 index 7685e7c76..1155a8ebb 100644 --- a/lib/jt9a.F90 +++ b/lib/jt9a.F90 @@ -18,9 +18,7 @@ subroutine jt9a common/tracer/limtrace,lu call getcwd(cwd) -! call ftninit(trim(cwd)) open(12,file='timer.out',status='unknown') - open(14,file='wsjtx_rx.log',status='unknown',position='append') limtrace=0 lu=12 @@ -88,15 +86,6 @@ subroutine jt9c(ss,savg,c0,id2,nparams0) npatience=1 call flush(6) - - if(iand(nrxlog,1).ne.0) then - write(14,1000) datetime(:17) -1000 format(/'UTC Date: 'a17/78('-')) - flush(14) - endif - if(iand(nrxlog,2).ne.0) rewind 14 -! if(iand(nrxlog,4).ne.0) rewind 26 - nstandalone=0 if(sum(nparams).ne.0) call decoder(ss,c0) diff --git a/mainwindow.cpp b/mainwindow.cpp index 4d5cd2869..a97303331 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,4 +1,4 @@ -//-------------------------------------------------------------- MainWindow +//--------------------------------------------------------------- MainWindow #include "mainwindow.h" #include "ui_mainwindow.h" #include "devsetup.h" @@ -31,9 +31,6 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); -#ifdef WIN32 - freopen("wsjtx.log","w",stderr); -#endif on_EraseButton_clicked(); ui->labUTC->setStyleSheet( \ "QLabel { background-color : black; color : yellow; }"); @@ -177,6 +174,8 @@ MainWindow::MainWindow(QWidget *parent) : genStdMsgs("-30"); on_actionWide_Waterfall_triggered(); //### g_pWideGraph->setTxFreq(m_txFreq); + m_dialFreq=g_pWideGraph->dialFreq(); + if(m_mode=="JT9-1") on_actionJT9_1_triggered(); if(m_mode=="JT9-2") on_actionJT9_2_triggered(); if(m_mode=="JT9-5") on_actionJT9_5_triggered(); @@ -1014,6 +1013,17 @@ void MainWindow::readFromStdout() //readFromStdout m_startAnother=m_loopall; return; } else { + + QFile f("ALL.TXT"); + f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); + QTextStream out(&f); + if(m_RxLog & 1) { + out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm") + << endl; + } + out << t << endl; + f.close(); + int n=t.length(); QString bg="white"; if(t.indexOf(" CQ ")>0) bg="#66ff66"; //Light green @@ -1023,6 +1033,23 @@ void MainWindow::readFromStdout() //readFromStdout ui->decodedTextBrowser->append(t); QString msg=t.mid(34,22); bool b=stdmsg_(msg.toAscii().constData()); + QStringList w=msg.split(" ",QString::SkipEmptyParts); + if(b and w[1]==m_myCall) { + QString tt=w[2]; + int i1; + bool ok; + i1=tt.toInt(&ok); + if(ok and i1>=-50 and i1<50) { + m_rptRcvd=tt; + } else { + if(tt.mid(0,1)=="R") { + i1=tt.mid(1).toInt(&ok); + if(ok and i1>=-50 and i1<50) { + m_rptRcvd=tt.mid(1); + } + } + } + } if(m_pskReporterInit and b and !m_diskData) { // if(m_pskReporterInit and b) { int i1=msg.indexOf(" "); @@ -1147,7 +1174,7 @@ void MainWindow::guiUpdate() } } -// Calculate Tx waveform when needed +// Calculate Tx tones when needed if((iptt==1 && iptt0==0) || m_restart) { QByteArray ba; if(m_ntx == 1) ba=ui->tx1->text().toLocal8Bit(); @@ -1164,16 +1191,36 @@ void MainWindow::guiUpdate() genjt9_(message,&ichk,msgsent,itone,&itext,len1,len1); msgsent[22]=0; lab5->setText("Last Tx: " + QString::fromAscii(msgsent)); + QString t=QString::fromAscii(msgsent); if(m_restart) { - QFile f("wsjtx_tx.log"); + QFile f("ALL.TXT"); f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); QTextStream out(&f); out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm") - << " Tx message: " << QString::fromAscii(msgsent) << endl; + << " Tx message: " << t << endl; f.close(); - } - + QStringList w=t.split(" ",QString::SkipEmptyParts); + QString t2=QDateTime::currentDateTimeUtc().toString("hhmm"); + if(itext==0 and w[1]==m_myCall) { + t=w[2]; + int i1; + bool ok; + i1=t.toInt(&ok); + if(ok and i1>=-50 and i1<50) { + m_rptSent=t; + m_qsoStart=t2; + } else { + if(t.mid(0,1)=="R") { + i1=t.mid(1).toInt(&ok); + if(ok and i1>=-50 and i1<50) { + m_rptSent=t.mid(1); + m_qsoStart=t2; + } + } + } + } + if(itext==1 or w[2]=="73") m_qsoStop=t2; m_restart=false; } @@ -1187,7 +1234,7 @@ void MainWindow::guiUpdate() btxok=true; m_transmitting=true; - QFile f("wsjtx_tx.log"); + QFile f("ALL.TXT"); f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); QTextStream out(&f); out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm") @@ -1655,38 +1702,49 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button { double dialFreq=g_pWideGraph->dialFreq(); QDateTime t = QDateTime::currentDateTimeUtc(); - QString logEntry=t.date().toString("yyyy-MMM-dd,") + - t.time().toString("hh:mm,") + m_hisCall + "," + m_hisGrid + "," + - QString::number(dialFreq) + "," + m_mode + "\n"; QFile f("wsjtx.log"); if(!f.open(QFile::Append)) { msgBox("Cannot open file \"wsjtx.log\"."); - return; + } else { + QString logEntry=t.date().toString("yyyy-MMM-dd,") + + t.time().toString("hh:mm,") + m_hisCall + "," + m_hisGrid + "," + + QString::number(dialFreq) + "," + m_mode + "," + + m_rptSent + "," + m_rptRcvd; QTextStream out(&f); +// out << logEntry << "\r\n"; + out << logEntry << endl; + f.close(); } - QTextStream out(&f); - out << logEntry << "\r\n"; - f.close(); -} -void MainWindow::on_actionErase_wsjtx_rx_log_triggered() //Erase Rx log -{ - int ret = QMessageBox::warning(this, "Confirm Erase", - "Are you sure you want to erase file wsjtx_rx.log ?", - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - if(ret==QMessageBox::Yes) { - m_RxLog |= 2; // Rewind wsjtx_rx.log - } -} + QFile f2("wsjtx_log.adi"); + if(!f2.open(QFile::Append)) { + msgBox("Cannot open file \"wsjtx_log.adi\"."); + } else { -void MainWindow::on_actionErase_wsjtx_tx_log_triggered() //Erase Tx log -{ - int ret = QMessageBox::warning(this, "Confirm Erase", - "Are you sure you want to erase file wsjtx_tx.log ?", - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - if(ret==QMessageBox::Yes) { - QFile f("wsjtx_tx.log"); - f.remove(); + QTextStream out(&f2); + if(f2.size()==0) out << "WSJT-X ADIF Export" << endl; +/* +K1ABCFN42JT65-15 +-1713551357 +5JimK1JTFN20 +*/ + QString t; + t="" + m_hisCall; + t+="" + m_hisGrid; + t+="" + m_mode; + t+="" + m_rptSent; + t+="" + m_rptRcvd; + t+=""; + t+="" + m_qsoStart; + t+="" + m_qsoStop; + t+="" + m_myCall; + t+="" + m_myGrid; +// t.date.toString("yyyymmdd"); + out << t << endl; + f2.close(); } + + m_rptSent=""; + m_rptRcvd=""; } void MainWindow::on_actionJT9_1_triggered() @@ -1816,3 +1874,25 @@ void MainWindow::on_actionMonitor_OFF_at_startup_triggered() { m_monitorStartOFF=!m_monitorStartOFF; } + +void MainWindow::on_actionErase_ALL_TXT_triggered() //Erase ALL.TXT +{ + int ret = QMessageBox::warning(this, "Confirm Erase", + "Are you sure you want to erase file ALL.TXT ?", + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + if(ret==QMessageBox::Yes) { + QFile f("ALL.TXT"); + f.remove(); + } +} + +void MainWindow::on_actionErase_wsjtx_log_adi_triggered() +{ + int ret = QMessageBox::warning(this, "Confirm Erase", + "Are you sure you want to erase file wsjtx_log.adi ?", + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + if(ret==QMessageBox::Yes) { + QFile f("wsjtx_log.adi"); + f.remove(); + } +} diff --git a/mainwindow.h b/mainwindow.h index 1f803d7c0..85403a0f7 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -88,8 +88,6 @@ private slots: void on_dxGridEntry_textChanged(const QString &arg1); void on_genStdMsgsPushButton_clicked(); void on_logQSOButton_clicked(); - void on_actionErase_wsjtx_rx_log_triggered(); - void on_actionErase_wsjtx_tx_log_triggered(); void on_actionAFMHot_triggered(); void on_actionBlue_triggered(); void on_actionJT9_2_triggered(); @@ -111,6 +109,10 @@ private slots: void on_actionMonitor_OFF_at_startup_triggered(); void dialFreqChanged2(double f); + void on_actionErase_ALL_TXT_triggered(); + + void on_actionErase_wsjtx_log_adi_triggered(); + private: Ui::MainWindow *ui; @@ -206,6 +208,10 @@ private: QString m_dateTime; QString m_mode; QString m_fname; + QString m_rptSent; + QString m_rptRcvd; + QString m_qsoStart; + QString m_qsoStop; SoundInThread soundInThread; //Instantiate the audio threads SoundOutThread soundOutThread; diff --git a/mainwindow.ui b/mainwindow.ui index b3242aa09..c7baffaf1 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -1191,8 +1191,8 @@ p, li { white-space: pre-wrap; } - - + + @@ -1352,11 +1352,6 @@ p, li { white-space: pre-wrap; } Erase Band Map and Messages - - - Erase wsjtx_rx.log - - true @@ -1504,11 +1499,6 @@ p, li { white-space: pre-wrap; } Available suffixes and add-on-prefixes - - - Erase wsjtx_tx.log - - true @@ -1667,6 +1657,16 @@ p, li { white-space: pre-wrap; } Monitor OFF at startup + + + Erase ALL.TXT + + + + + Erase wsjtx_log.adi + + diff --git a/widegraph.cpp b/widegraph.cpp index e918b2736..d7565a7b9 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -52,18 +52,7 @@ WideGraph::WideGraph(QWidget *parent) : m_qsoFreq=settings.value("QSOfreq",1010).toInt(); ui->widePlot->setFQSO(m_qsoFreq,true); settings.endGroup(); - -// Change the following to a slot in mainwindow; emit a corresponding -// signal here, instead. - QFile f("wsjtx_qrg.txt"); - if(f.open(QFile::WriteOnly)) { - QTextStream out(&f); - out << m_dialFreq << "\r\n"; - f.close(); - } else { -// msgBox("Cannot open file \"wsjtx_qrg.txt\"."); - qDebug() << "Cannot open file \"wsjtx_qrg.txt\"."; - } + emit dialFreqChanged(m_dialFreq); } WideGraph::~WideGraph()