From 2fcf6c45fe82b9ece9745ff6d5141a1170295d19 Mon Sep 17 00:00:00 2001
From: Joe Taylor <joe@princeton.edu>
Date: Fri, 16 Dec 2022 13:06:44 -0500
Subject: [PATCH 1/5] Fix a flaw that prevented Q65W decodes from being
 displayed in its main window.

---
 q65w/commons.h          | 3 ++-
 q65w/libq65/decode0.f90 | 1 -
 q65w/libq65/q65wa.f90   | 1 -
 q65w/mainwindow.cpp     | 7 +++++--
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/q65w/commons.h b/q65w/commons.h
index 405d44fd9..c5244be57 100644
--- a/q65w/commons.h
+++ b/q65w/commons.h
@@ -86,7 +86,8 @@ extern struct {                     //This is "common/datcom/..." in Fortran
 extern struct {
   int ndecodes;
   int ncand;
-  int nQDecoderBusy;
+  int nQDecoderDone;
+  int nWDecoderBusy;
   int nWTransmitting;
   char result[50][60];
 } decodes_;
diff --git a/q65w/libq65/decode0.f90 b/q65w/libq65/decode0.f90
index ffb330f90..772b3bb4a 100644
--- a/q65w/libq65/decode0.f90
+++ b/q65w/libq65/decode0.f90
@@ -46,7 +46,6 @@ subroutine decode0(dd,ss,savg)
        mousedf,mousefqso,nagain,ndecdone,nfshift,max_drift,         &
        nfcal,mycall,hiscall,hisgrid,nhsym,nfsample,nmode,ndop00)
   call timer('q65wa   ',1)
-  flush(6)
 
   return
 end subroutine decode0
diff --git a/q65w/libq65/q65wa.f90 b/q65w/libq65/q65wa.f90
index 479e1294a..1bd8bcb65 100644
--- a/q65w/libq65/q65wa.f90
+++ b/q65w/libq65/q65wa.f90
@@ -70,7 +70,6 @@ subroutine q65wa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb,         &
      if(idec.ge.0) candec(icand)=.true.
   enddo  ! icand
   ndecdone=2
-  nQDecoderDone=1
 
   return
 end subroutine q65wa
diff --git a/q65w/mainwindow.cpp b/q65w/mainwindow.cpp
index 46885a83e..e9492b304 100644
--- a/q65w/mainwindow.cpp
+++ b/q65w/mainwindow.cpp
@@ -743,7 +743,7 @@ void MainWindow::decoderFinished()                      //diskWriteFinished
   m_startAnother=m_loopall;
   ui->DecodeButton->setStyleSheet("");
   decodeBusy(false);
-
+  decodes_.nQDecoderDone=1;
   QString t1;
   t1=t1.asprintf(" %3d/%d  ",decodes_.ndecodes,decodes_.ncand);
   lab5->setText(t1);
@@ -908,6 +908,7 @@ void MainWindow::decode()                                       //decode()
 
   decodes_.ndecodes=0;
   decodes_.ncand=0;
+  decodes_.nQDecoderDone=0;
   m_fetched=0;
   int itimer=0;
   watcher3.setFuture(QtConcurrent::run (std::bind (q65c_, &itimer)));
@@ -952,9 +953,10 @@ void MainWindow::guiUpdate()
     on_actionOpen_next_in_directory_triggered();
   }
 
-  if(decodes_.ndecodes>m_fetched) {
+  if(decodes_.ndecodes > m_fetched) {
     while(m_fetched<decodes_.ndecodes) {
       QString t=QString::fromLatin1(decodes_.result[m_fetched]);
+//      qDebug() << "CCC" << nsec%60 << decodes_.ndecodes << m_fetched << t;
       ui->decodedTextBrowser->append(t.trimmed());
       m_fetched++;
     }
@@ -965,6 +967,7 @@ void MainWindow::guiUpdate()
 
   if(nsec != m_sec0) {                                     //Once per second
 //    qDebug() << "AAA" << nsec%60 << ipc_wsjtx[3] << ipc_wsjtx[4]<< m_monitoring;
+//    qDebug() << "BBB" << nsec%60 << decodes_.ndecodes << m_fetched;
 
     if(m_pctZap>30.0) {
       lab4->setStyleSheet("QLabel{background-color: #ff0000}");

From 042ff589fb8d83a3e7781a24dd173635f294498a Mon Sep 17 00:00:00 2001
From: Joe Taylor <joe@princeton.edu>
Date: Fri, 16 Dec 2022 14:01:22 -0500
Subject: [PATCH 2/5] Another fix for communication between Q65W and WSJT-X.

---
 q65w/mainwindow.cpp    |  6 +++---
 widgets/mainwindow.cpp | 11 ++++++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/q65w/mainwindow.cpp b/q65w/mainwindow.cpp
index e9492b304..b0dbcb46f 100644
--- a/q65w/mainwindow.cpp
+++ b/q65w/mainwindow.cpp
@@ -744,6 +744,9 @@ void MainWindow::decoderFinished()                      //diskWriteFinished
   ui->DecodeButton->setStyleSheet("");
   decodeBusy(false);
   decodes_.nQDecoderDone=1;
+  mem_q65w.lock();
+  memcpy((char*)ipc_wsjtx, &decodes_, sizeof(decodes_));
+  mem_q65w.unlock();
   QString t1;
   t1=t1.asprintf(" %3d/%d  ",decodes_.ndecodes,decodes_.ncand);
   lab5->setText(t1);
@@ -960,9 +963,6 @@ void MainWindow::guiUpdate()
       ui->decodedTextBrowser->append(t.trimmed());
       m_fetched++;
     }
-    mem_q65w.lock();
-    memcpy((char*)ipc_wsjtx, &decodes_, sizeof(decodes_));
-    mem_q65w.unlock();
   }
 
   if(nsec != m_sec0) {                                     //Once per second
diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp
index 8706c0f60..d748f8931 100644
--- a/widgets/mainwindow.cpp
+++ b/widgets/mainwindow.cpp
@@ -4824,7 +4824,7 @@ void MainWindow::guiUpdate()
     if(m_transmitting) n=1;
     ipc_q65w[4]=n;
     if(ipc_q65w[0] > m_fetched) {             //ndecodes
-      memcpy(&q65wcom, (char*)ipc_q65w, sizeof(q65wcom));
+      memcpy(&q65wcom, (char*)ipc_q65w, sizeof(q65wcom));  //Fetch the new decode(s)
       readWidebandDecodes();
     }
     mem_q65w.unlock();
@@ -4832,7 +4832,8 @@ void MainWindow::guiUpdate()
 
 //Once per second (onesec)
   if(nsec != m_sec0) {
-//    qDebug() << "AAA" << nsec << ipc_q65w[0] << ipc_q65w[1];
+//    qDebug() << "AAA" << nsec << ipc_q65w[0] << ipc_q65w[1] << ipc_q65w[2]
+//             << ipc_q65w[3] << ipc_q65w[4] << m_fetched;
 
     if(m_mode=="FST4") chk_FST4_freq_range();
     m_currentBand=m_config.bands()->find(m_freqNominal);
@@ -9290,7 +9291,11 @@ void MainWindow::readWidebandDecodes()
     m_ActiveStationsWidget->displayRecentStations(m_mode,t);
     m_ActiveStationsWidget->setClickOK(true);
   }
-  if(q65wcom.nQDecoderDone==1) m_fetched=0;
+  if(ipc_q65w[2]==1) {
+    m_fetched=0;
+    ipc_q65w[0]=0;
+    ipc_q65w[2]=0;
+  }
 }
 
 // -------------------------- Code for FT8 DXpedition Mode ---------------------------

From 8d0186bd2a9b52a64acf1b1ae065d8a02a58cfcb Mon Sep 17 00:00:00 2001
From: Joe Taylor <joe@princeton.edu>
Date: Sat, 17 Dec 2022 08:28:48 -0500
Subject: [PATCH 3/5] Minimal solution to activate double-click decodes in
 narrow frequency range.

---
 q65w/libq65/q65c.f90 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/q65w/libq65/q65c.f90 b/q65w/libq65/q65c.f90
index f2b9d89ab..9a127757b 100644
--- a/q65w/libq65/q65c.f90
+++ b/q65w/libq65/q65c.f90
@@ -37,6 +37,12 @@ subroutine q65c(itimer)
 
   datetime(18:20)=':00'
   npatience=1
+
+  if(newdat.eq.0 .and. nagain.eq.1) then
+     nfa=nint(mousefqso+0.001*mousedf) - 1  !Minimal solution for
+     nfb=nint(mousefqso+0.001*mousedf) + 1  !double-click decodes
+  endif
+
   call timer('decode0 ',0)
   call decode0(dd,ss,savg)
   call timer('decode0 ',1)

From 6771bd7970c2a1c80a03faa24f16df78b321abf6 Mon Sep 17 00:00:00 2001
From: Joe Taylor <joe@princeton.edu>
Date: Sat, 17 Dec 2022 09:41:42 -0500
Subject: [PATCH 4/5] Attempting to solve the "decoder not always called"
 problem.

---
 q65w/mainwindow.cpp | 64 +++++++++++++++++++++++++++------------------
 q65w/mainwindow.h   |  6 +++++
 2 files changed, 45 insertions(+), 25 deletions(-)

diff --git a/q65w/mainwindow.cpp b/q65w/mainwindow.cpp
index b0dbcb46f..1b1f226ce 100644
--- a/q65w/mainwindow.cpp
+++ b/q65w/mainwindow.cpp
@@ -375,7 +375,7 @@ void MainWindow::dataSink(int k)
   QString t;
   m_pctZap=nzap/178.3;
 
-  lab4->setText (
+  lab2->setText (
         QString {" Rx: %1  %2 % "}
         .arg (px, 5, 'f', 1)
         .arg (m_pctZap, 5, 'f', 1)
@@ -414,14 +414,18 @@ void MainWindow::dataSink(int k)
     n=0;
   }
 
-  if(ihsym==302) {   //Decode at t=56 s (for Q65 and data from disk)
+  lab5->setText(QString::number(ihsym));
+  if(ihsym < m_hsymStop) m_decode_called=false;
+  if(ihsym >= m_hsymStop and !m_decode_called) {   //Decode at t=56 s (for Q65 and data from disk)
     m_RxState=2;
     datcom_.newdat=1;
     datcom_.nagain=0;
     datcom_.nhsym=ihsym;
     QDateTime t = QDateTime::currentDateTimeUtc();
     m_dateTime=t.toString("yyyy-MMM-dd hh:mm");
+    qDebug() << "aa" << "Decoder called" << ihsym;;
     decode();                                           //Start the decoder
+    m_decode_called=true;
     if(m_saveAll and !m_diskData) {
       QString fname=m_saveDir + "/" + t.date().toString("yyMMdd") + "_" +
           t.time().toString("hhmm");
@@ -592,9 +596,21 @@ void MainWindow::createStatusBar()                           //createStatusBar
   lab1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
   statusBar()->addWidget(lab1);
 
+  lab2 = new QLabel("");
+  lab2->setAlignment(Qt::AlignHCenter);
+  lab2->setMinimumSize(QSize(80,10));
+  lab2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+  statusBar()->addWidget(lab2);
+
+  lab3 = new QLabel("");
+  lab3->setAlignment(Qt::AlignHCenter);
+  lab3->setMinimumSize(QSize(50,10));
+  lab3->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+  statusBar()->addWidget(lab3);
+
   lab4 = new QLabel("");
   lab4->setAlignment(Qt::AlignHCenter);
-  lab4->setMinimumSize(QSize(80,10));
+  lab4->setMinimumSize(QSize(50,10));
   lab4->setFrameStyle(QFrame::Panel | QFrame::Sunken);
   statusBar()->addWidget(lab4);
 
@@ -603,12 +619,6 @@ void MainWindow::createStatusBar()                           //createStatusBar
   lab5->setMinimumSize(QSize(50,10));
   lab5->setFrameStyle(QFrame::Panel | QFrame::Sunken);
   statusBar()->addWidget(lab5);
-
-  lab6 = new QLabel("");
-  lab6->setAlignment(Qt::AlignHCenter);
-  lab6->setMinimumSize(QSize(50,10));
-  lab6->setFrameStyle(QFrame::Panel | QFrame::Sunken);
-  statusBar()->addWidget(lab6);
 }
 
 void MainWindow::on_tolSpinBox_valueChanged(int i)             //tolSpinBox
@@ -749,7 +759,10 @@ void MainWindow::decoderFinished()                      //diskWriteFinished
   mem_q65w.unlock();
   QString t1;
   t1=t1.asprintf(" %3d/%d  ",decodes_.ndecodes,decodes_.ncand);
-  lab5->setText(t1);
+  lab3->setText(t1);
+  QDateTime now=QDateTime::currentDateTimeUtc();
+  float secToDecode=0.001*m_decoder_start_time.msecsTo(now);
+  qDebug() << "bb" << "Decoder Finished" << t1 << secToDecode;
 }
 
 void MainWindow::on_actionDelete_all_iq_files_in_SaveDir_triggered()
@@ -801,8 +814,6 @@ void MainWindow::on_actionSave_all_triggered()                //Save All
                                           //Display list of keyboard shortcuts                                           //Display list of mouse commands                                             //Diaplay list of Add-On pfx/sfx
 void MainWindow::on_DecodeButton_clicked()                    //Decode request
 {
-  int n=m_sec0%m_TRperiod;
-  if(m_monitoring and n>47 and (n<52 or m_decoderBusy)) return;
   if(!m_decoderBusy) {
     datcom_.newdat=0;
     datcom_.nagain=1;
@@ -914,6 +925,7 @@ void MainWindow::decode()                                       //decode()
   decodes_.nQDecoderDone=0;
   m_fetched=0;
   int itimer=0;
+  m_decoder_start_time=QDateTime::currentDateTimeUtc();
   watcher3.setFuture(QtConcurrent::run (std::bind (q65c_, &itimer)));
 
   decodeBusy(true);
@@ -922,7 +934,7 @@ void MainWindow::decode()                                       //decode()
 void MainWindow::on_EraseButton_clicked()
 {
   ui->decodedTextBrowser->clear();
-  lab5->clear();
+  lab3->clear();
 }
 
 
@@ -970,10 +982,12 @@ void MainWindow::guiUpdate()
 //    qDebug() << "BBB" << nsec%60 << decodes_.ndecodes << m_fetched;
 
     if(m_pctZap>30.0) {
-      lab4->setStyleSheet("QLabel{background-color: #ff0000}");
+      lab2->setStyleSheet("QLabel{background-color: #ff0000}");
     } else {
-      lab4->setStyleSheet("");
+      lab2->setStyleSheet("");
     }
+//    lab5->setText("Q65A");
+
 
     if(m_monitoring) {
       lab1->setStyleSheet("QLabel{background-color: #00ff00}");
@@ -1165,36 +1179,36 @@ void MainWindow::on_dxGridEntry_textChanged(const QString &t) //dxGrid changed
 void MainWindow::on_actionQ65A_triggered()
 {
   m_modeQ65=1;
-  lab6->setStyleSheet("QLabel{background-color: #ffb266}");
-  lab6->setText("Q65A");
+  lab4->setStyleSheet("QLabel{background-color: #ffb266}");
+  lab4->setText("Q65A");
 }
 
 void MainWindow::on_actionQ65B_triggered()
 {
   m_modeQ65=2;
-  lab6->setStyleSheet("QLabel{background-color: #b2ff66}");
-  lab6->setText("Q65B");
+  lab4->setStyleSheet("QLabel{background-color: #b2ff66}");
+  lab4->setText("Q65B");
 }
 
 void MainWindow::on_actionQ65C_triggered()
 {
   m_modeQ65=3;
-  lab6->setStyleSheet("QLabel{background-color: #66ffff}");
-  lab6->setText("Q65C");
+  lab4->setStyleSheet("QLabel{background-color: #66ffff}");
+  lab4->setText("Q65C");
 }
 
 void MainWindow::on_actionQ65D_triggered()
 {
   m_modeQ65=4;
-  lab6->setStyleSheet("QLabel{background-color: #b266ff}");
-  lab6->setText("Q65D");
+  lab4->setStyleSheet("QLabel{background-color: #b266ff}");
+  lab4->setText("Q65D");
 }
 
 void MainWindow::on_actionQ65E_triggered()
 {
   m_modeQ65=5;
-  lab6->setStyleSheet("QLabel{background-color: #ff66ff}");
-  lab6->setText("Q65E");
+  lab4->setStyleSheet("QLabel{background-color: #ff66ff}");
+  lab4->setText("Q65E");
 }
 
 
diff --git a/q65w/mainwindow.h b/q65w/mainwindow.h
index 4bd676a70..341dc1ffd 100644
--- a/q65w/mainwindow.h
+++ b/q65w/mainwindow.h
@@ -122,6 +122,7 @@ private:
   qint32  m_RxState;
   qint32  m_dB;
   qint32  m_fetched=0;
+  qint32  m_hsymStop=302;
 
   double  m_fAdd;
   double  m_xavg;
@@ -138,6 +139,7 @@ private:
   bool    m_kb8rq;
   bool    m_NB;
   bool    m_fs96000;
+  bool    m_decode_called=false;
 
   float   m_gainx;
   float   m_gainy;
@@ -148,6 +150,8 @@ private:
   QRect   m_wideGraphGeom;
 
   QLabel* lab1;                            // labels in status bar
+  QLabel* lab2;                            // labels in status bar
+  QLabel* lab3;                            // labels in status bar
   QLabel* lab4;
   QLabel* lab5;
   QLabel* lab6;
@@ -162,6 +166,8 @@ private:
 
   QFutureWatcher<void> watcher3;     //For decoder
 
+  QDateTime m_decoder_start_time;
+
   QString m_path;
   QString m_pbdecoding_style1;
   QString m_pbmonitor_style;

From 7105d67e2bd4ed067f47e5121ba5988a636e8b0d Mon Sep 17 00:00:00 2001
From: Joe Taylor <joe@princeton.edu>
Date: Sat, 17 Dec 2022 15:08:26 -0500
Subject: [PATCH 5/5] Rationalize use of ndepth (1-3) and datetime
 (yymmdd_hhmm).  Add output tp all_q65w.txt.

---
 lib/map65_mmdec.f90     |  5 +----
 q65w/libq65/decode0.f90 |  3 ++-
 q65w/libq65/ftninit.f90 |  1 +
 q65w/libq65/q65b.f90    |  9 ++++++---
 q65w/libq65/q65wa.f90   | 11 +++++------
 q65w/mainwindow.cpp     | 15 ++++++++++-----
 q65w/mainwindow.h       |  3 ---
 7 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/lib/map65_mmdec.f90 b/lib/map65_mmdec.f90
index dc62e6e7e..3e28e5464 100644
--- a/lib/map65_mmdec.f90
+++ b/lib/map65_mmdec.f90
@@ -1,5 +1,5 @@
 subroutine map65_mmdec(nutc,id2,nqd,nsubmode,nfa,nfb,nfqso,ntol,newdat,   &
-     nagain,max_drift,mycall,hiscall,hisgrid)
+     nagain,max_drift,ndepth,mycall,hiscall,hisgrid)
 
   use prog_args
   use timer_module, only: timer
@@ -15,7 +15,6 @@ subroutine map65_mmdec(nutc,id2,nqd,nsubmode,nfa,nfb,nfqso,ntol,newdat,   &
   logical single_decode,bVHF,lnewdat,lagain,lclearave,lapcqonly
   integer*2 id2(300*12000)
 !  type(params_block) :: params
-  character(len=20) :: datetime
   character(len=12) :: mycall, hiscall
   character(len=6) :: hisgrid
   data ntr0/-1/
@@ -28,7 +27,6 @@ subroutine map65_mmdec(nutc,id2,nqd,nsubmode,nfa,nfb,nfqso,ntol,newdat,   &
 !  hiscall=transfer(params%hiscall,hiscall)
 !  mygrid=transfer(params%mygrid,mygrid)
 !  hisgrid=transfer(params%hisgrid,hisgrid)
-  datetime=' '
 
   my_q65%decoded = 0
   ncontest=0
@@ -40,7 +38,6 @@ subroutine map65_mmdec(nutc,id2,nqd,nsubmode,nfa,nfb,nfqso,ntol,newdat,   &
   lagain=(nagain.ne.0)
   bVHF=.true.
   emedelay=2.5
-  ndepth=2                       !Does this make it too slow?
   ntrperiod=60
 
   call timer('dec_q65 ',0)
diff --git a/q65w/libq65/decode0.f90 b/q65w/libq65/decode0.f90
index 772b3bb4a..916eb62b2 100644
--- a/q65w/libq65/decode0.f90
+++ b/q65w/libq65/decode0.f90
@@ -44,7 +44,8 @@ subroutine decode0(dd,ss,savg)
   call timer('q65wa   ',0)
   call q65wa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb,           &
        mousedf,mousefqso,nagain,ndecdone,nfshift,max_drift,         &
-       nfcal,mycall,hiscall,hisgrid,nhsym,nfsample,nmode,ndop00)
+       nfcal,mycall,hiscall,hisgrid,nhsym,nfsample,nmode,ndepth,    &
+       datetime,ndop00)
   call timer('q65wa   ',1)
 
   return
diff --git a/q65w/libq65/ftninit.f90 b/q65w/libq65/ftninit.f90
index 565398565..2255452b0 100644
--- a/q65w/libq65/ftninit.f90
+++ b/q65w/libq65/ftninit.f90
@@ -15,6 +15,7 @@ subroutine ftninit
   
   appd='.'
   addpfx='    '
+  open(12,file=appd//'/all_q65w.txt',status='unknown',position='append')
   open(17,file=appd//'/red.dat',status='unknown')
   open(19,file=appd//'/livecq.txt',status='unknown')
   open(71,file=appd//'/debug.tmp',status='unknown')
diff --git a/q65w/libq65/q65b.f90 b/q65w/libq65/q65b.f90
index 4dd038de0..7e0447e28 100644
--- a/q65w/libq65/q65b.f90
+++ b/q65w/libq65/q65b.f90
@@ -1,6 +1,6 @@
 subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
      mycall0,hiscall0,hisgrid,mode_q65,f0,fqso,newdat,nagain,          &
-     max_drift,ndop00)
+     max_drift,ndepth,datetime,ndop00)
 
 ! This routine provides an interface between MAP65 and the Q65 decoder
 ! in WSJT-X.  All arguments are input data obtained from the MAP65 GUI.
@@ -26,6 +26,7 @@ subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
   character*6 hisgrid
   character*4 grid4
   character*60 result
+  character*20 datetime
   common/decodes/ndecodes,ncand,nQDecoderDone,nWDecoderBusy,              &
        nWTransmitting,result(50)
   common/cacb/ca
@@ -110,7 +111,7 @@ subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
 ! NB: Frequency of ipk is now shifted to 1000 Hz.
 
   call map65_mmdec(nutc,iwave,nqd,nsubmode,nfa,nfb,1000,ntol,     &
-       newdat,nagain,max_drift,mycall,hiscall,hisgrid)
+       newdat,nagain,max_drift,ndepth,mycall,hiscall,hisgrid)
    MHz=fcenter
   freq0=MHz + 0.001d0*ikhz
 
@@ -128,10 +129,12 @@ subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
      fsked=frx - 0.001*ndop00/2.0 - 1.5
      write(result(ndecodes),1120) nutc,fsked,xdt0,nsnr0,trim(msg0)
 1120 format(i4.4,f9.3,f7.2,i5,2x,a,i6)
+     write(12,1130) datetime,trim(result(ndecodes)(5:))
+1130 format(a11,1x,a)
      result(ndecodes)=trim(result(ndecodes))//char(0)
   endif
 
-900 call flush(6)
+900 flush(12)
 
   return
 end subroutine q65b
diff --git a/q65w/libq65/q65wa.f90 b/q65w/libq65/q65wa.f90
index 1bd8bcb65..6968c22e8 100644
--- a/q65w/libq65/q65wa.f90
+++ b/q65w/libq65/q65wa.f90
@@ -1,6 +1,7 @@
 subroutine q65wa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb,         &
      mousedf,mousefqso,nagain,ndecdone,nfshift,max_drift,             &
-     nfcal,mycall,hiscall,hisgrid,nhsym,nfsample,nmode,ndop00)
+     nfcal,mycall,hiscall,hisgrid,nhsym,nfsample,nmode,ndepth,        &
+     datetime,ndop00)
 
 !  Processes timf2 data from Linrad to find and decode JT65 and Q65 signals.
 
@@ -18,16 +19,14 @@ subroutine q65wa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb,         &
   logical candec(MAX_CANDIDATES)
   type(candidate) :: cand(MAX_CANDIDATES)
   character*60 result
+  character*20 datetime
   common/decodes/ndecodes,ncand,nQDecoderDone,nWDecoderBusy,              &
        nWTransmitting,result(50)
   common/testcom/ifreq
   save
 
-!  write(*,3001) newdat,ntol,nfa,nfb,mousedf,mousefqso,nagain,nfshift,max_drift
-!3001 format(9i6)
-
+  if(nagain.eq.1) ndepth=3
   nagain=0              !### TEMPORARY ? ###
-  rewind 12
 
   nkhz_center=nint(1000.0*(fcenter-int(fcenter)))
   mfa=nfa-nkhz_center+48
@@ -65,7 +64,7 @@ subroutine q65wa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb,         &
      call timer('q65b    ',0)
      call q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
           mycall,hiscall,hisgrid,mode_q65,f0,fqso,newdat,   &
-          nagain,max_drift,ndop00)
+          nagain,max_drift,ndepth,datetime,ndop00)
      call timer('q65b    ',1)
      if(idec.ge.0) candec(icand)=.true.
   enddo  ! icand
diff --git a/q65w/mainwindow.cpp b/q65w/mainwindow.cpp
index 1b1f226ce..7d561e801 100644
--- a/q65w/mainwindow.cpp
+++ b/q65w/mainwindow.cpp
@@ -422,7 +422,7 @@ void MainWindow::dataSink(int k)
     datcom_.nagain=0;
     datcom_.nhsym=ihsym;
     QDateTime t = QDateTime::currentDateTimeUtc();
-    m_dateTime=t.toString("yyyy-MMM-dd hh:mm");
+    m_dateTime=t.toString("yymmdd_hhmm");
     qDebug() << "aa" << "Decoder called" << ihsym;;
     decode();                                           //Start the decoder
     m_decode_called=true;
@@ -762,7 +762,7 @@ void MainWindow::decoderFinished()                      //diskWriteFinished
   lab3->setText(t1);
   QDateTime now=QDateTime::currentDateTimeUtc();
   float secToDecode=0.001*m_decoder_start_time.msecsTo(now);
-  qDebug() << "bb" << "Decoder Finished" << t1 << secToDecode;
+  qDebug() << "bb" << "Decoder Finished" << t1 << secToDecode << now.toString("hh:mm:ss.z");
 }
 
 void MainWindow::on_actionDelete_all_iq_files_in_SaveDir_triggered()
@@ -840,6 +840,7 @@ void MainWindow::freezeDecode(int n)                          //freezeDecode()
 
 void MainWindow::decode()                                       //decode()
 {
+  QString fname="           ";
   ui->DecodeButton->setStyleSheet(m_pbdecoding_style1);
 
   if(datcom_.nagain==0 && (!m_diskData)) {
@@ -853,7 +854,7 @@ void MainWindow::decode()                                       //decode()
   datcom_.idphi=m_dPhi;
   datcom_.mousedf=m_wide_graph_window->DF();
   datcom_.mousefqso=m_wide_graph_window->QSOfreq();
-  datcom_.ndepth=m_ndepth;
+  datcom_.ndepth=m_ndepth+1;
   datcom_.ndiskdat=0;
   if(m_diskData) {
     datcom_.ndiskdat=1;
@@ -870,6 +871,7 @@ void MainWindow::decode()                                       //decode()
       int ndop00;
       astrosub00_(&nyear, &month, &nday, &uth, &nfreq, m_myGrid.toLatin1(),&ndop00,6);
       datcom_.ndop00=ndop00;               //Send self Doppler to decoder, via datcom
+      fname=m_path.mid(i0-11,11);
     }
   }
   datcom_.neme=0;
@@ -909,7 +911,11 @@ void MainWindow::decode()                                       //decode()
   memcpy(datcom_.mygrid, mgrid.toLatin1(), 6);
   memcpy(datcom_.hiscall, hcall.toLatin1(), 12);
   memcpy(datcom_.hisgrid, hgrid.toLatin1(), 6);
-  memcpy(datcom_.datetime, m_dateTime.toLatin1(), 17);
+  if(m_diskData) {
+    memcpy(datcom_.datetime, fname.toLatin1(), 11);
+  } else {
+    memcpy(datcom_.datetime, m_dateTime.toLatin1(), 11);
+  }
   datcom_.junk1=1234;                                     //Cecck for these values in m65
   datcom_.junk2=5678;
 
@@ -971,7 +977,6 @@ void MainWindow::guiUpdate()
   if(decodes_.ndecodes > m_fetched) {
     while(m_fetched<decodes_.ndecodes) {
       QString t=QString::fromLatin1(decodes_.result[m_fetched]);
-//      qDebug() << "CCC" << nsec%60 << decodes_.ndecodes << m_fetched << t;
       ui->decodedTextBrowser->append(t.trimmed());
       m_fetched++;
     }
diff --git a/q65w/mainwindow.h b/q65w/mainwindow.h
index 341dc1ffd..265815b72 100644
--- a/q65w/mainwindow.h
+++ b/q65w/mainwindow.h
@@ -182,9 +182,6 @@ private:
   QString m_palette;
   QString m_dateTime;
   QString m_mode;
-  QString m_colors;                     //Why still needed?
-  QString m_editorCommand;              //Why still needed?
-  QString m_modeTx;                     //Why still needed?
 
   QHash<QString,bool> m_worked;