From 2f1082e973d14d0d5ccf10f7755546e52d6c1789 Mon Sep 17 00:00:00 2001
From: Joe Taylor <joe@princeton.edu>
Date: Sat, 9 Dec 2023 15:20:59 -0500
Subject: [PATCH] Try to correct the logic about not decoding if we transmitted
 too much.  Not fully tested!

---
 qmap/mainwindow.cpp    | 14 +++++++++-----
 qmap/mainwindow.h      |  1 +
 widgets/mainwindow.cpp |  2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/qmap/mainwindow.cpp b/qmap/mainwindow.cpp
index 519e66b20..ce8d9c0a6 100644
--- a/qmap/mainwindow.cpp
+++ b/qmap/mainwindow.cpp
@@ -412,7 +412,7 @@ void MainWindow::dataSink(int k)
     QDateTime t = QDateTime::currentDateTimeUtc();
     m_dateTime=t.toString("yyMMdd_hhmm");
     decode();                                           //Start the decoder
-    if(m_saveAll and !m_diskData and m_nTransmitted<10) {
+    if(m_saveAll and !m_diskData and m_nTransmitted<30) {
       QString fname=m_saveDir + "/" + t.date().toString("yyMMdd") + "_" +
           t.time().toString("hhmm");
       fname += ".iq";
@@ -799,7 +799,9 @@ void MainWindow::freezeDecode(int n)                          //freezeDecode()
 void MainWindow::decode()                                       //decode()
 {
 //Don't attempt to decode if decoder is already busy, or if we transmitted for 10 s or more.
-  if(m_decoderBusy or m_nTransmitted>10) return;
+  if(m_decoderBusy) return;
+  if(m_WSJTX_TRperiod==60 and m_nTransmitted>10) return;
+  if(m_WSJTX_TRperiod==30 and m_nTransmitted>35) return;
   QString fname="           ";
   ui->DecodeButton->setStyleSheet(m_pbdecoding_style1);
 
@@ -973,9 +975,11 @@ void MainWindow::guiUpdate()
     mem_qmap.lock();
     memcpy(&itest, (char*)ipc_wsjtx, 20);
     mem_qmap.unlock();
-    if(itest[4]==1) m_nTransmitted++;
-//    qDebug() << "AAA" << n60 << itest[0] << itest[1] << itest[2] << itest[3] << itest[4]
-//             << m_nTransmitted;
+    if(itest[4]>0) {
+      m_WSJTX_TRperiod=itest[4];
+      m_nTransmitted++;              //0 if WSJT-X is not transmitting, otherwise TRperiod
+    }
+//    qDebug() << "AAA" << n60 << itest[0] << itest[1] << itest[2] << itest[3] << itest[4] << m_nTransmitted;
     if(n60<n60z) m_nTransmitted=0;
     n60z=n60;
 
diff --git a/qmap/mainwindow.h b/qmap/mainwindow.h
index f0437d1a3..68769a9f6 100644
--- a/qmap/mainwindow.h
+++ b/qmap/mainwindow.h
@@ -117,6 +117,7 @@ private:
   qint32  m_nTransmitted=0;
   qint32  m_nDoubleClicked=0;
   qint32  m_nline=0;
+  qint32  m_WSJTX_TRperiod=0;
 
   double  m_fAdd;
   double  m_xavg;
diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp
index 823d3e800..16dafb3ea 100644
--- a/widgets/mainwindow.cpp
+++ b/widgets/mainwindow.cpp
@@ -5070,7 +5070,7 @@ void MainWindow::guiUpdate()
     if(m_decoderBusy) n=1;
     ipc_qmap[3]=n;
     n=0;
-    if(m_transmitting) n=1;
+    if(m_transmitting) n=m_TRperiod;
     ipc_qmap[4]=n;
     if(ipc_qmap[0] > 0) {             //ndecodes
       memcpy(&qmapcom, (char*)ipc_qmap, sizeof(qmapcom));  //Fetch the new decode(s)