From cdf8a272966e62c3d146e52a998d8e29fe4a7efd Mon Sep 17 00:00:00 2001
From: Joe Taylor <k1jt@arrl.org>
Date: Sat, 6 Jun 2015 18:02:39 +0000
Subject: [PATCH] Don't allow a partial transmission in Echo mode. Fix RA, Dec,
 and Tsky returned by astro().

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5548 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
---
 lib/astro.f90  |  4 +++-
 mainwindow.cpp | 19 ++++++++++++-------
 mainwindow.h   |  1 +
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lib/astro.f90 b/lib/astro.f90
index a9f858d89..c446e85ed 100644
--- a/lib/astro.f90
+++ b/lib/astro.f90
@@ -44,6 +44,8 @@ subroutine astro(nyear,month,nday,uth,freq8,Mygrid,                    &
 
   call MoonDopJPL(nyear,month,nday,uth,lon,lat,RAMoon,DecMoon,    &
        LST,HA,AzMoon,ElMoon,vr,techo)
+  RAMoon=rad*RAMoon
+  DecMoon=rad*DecMoon
   dist=2.99792458d5*techo/2.d0
 
 ! Compute spatial polarization offset
@@ -59,7 +61,7 @@ subroutine astro(nyear,month,nday,uth,freq8,Mygrid,                    &
   longecl_half=nint(rad*el/2.0)
   if(longecl_half.lt.1 .or. longecl_half.gt.180) longecl_half=180
   t144=nt144(longecl_half)
-  tsky=(t144-2.7)*(144.0/freq8)**2.6 + 2.7      !Tsky for obs freq
+  tsky=(t144-2.7)*(144.0d6/freq8)**2.6 + 2.7      !Tsky for obs freq
 
   xdop(NStation)=doppler
   if(NStation.eq.2) then
diff --git a/mainwindow.cpp b/mainwindow.cpp
index d8c98ab5d..a45370ceb 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -408,6 +408,7 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme
   m_bTxTime=false;
   m_rxDone=false;
   m_bHaveTransmitted=false;
+  m_bEchoTxOK=false;
   m_bTransmittedEcho=false;
 
   signalMeter = new SignalMeter(ui->meterFrame);
@@ -963,6 +964,7 @@ void MainWindow::on_autoButton_clicked (bool checked)
                                   QString::number (ui->rptSpinBox->value ()),
                                   m_modeTx, ui->autoButton->isChecked (),
                                   m_transmitting);
+  m_bEchoTxOK=false;
   if(m_mode.mid(0,4)=="WSPR")  {
     QPalette* palette = new QPalette();
     if(m_auto or m_pctx==0) {
@@ -1811,12 +1813,6 @@ void MainWindow::guiUpdate()
     tx2 += m_TRperiod;
   }
 
-  if(m_mode=="Echo") {
-    txDuration=2.5;
-    tx1=0.0;
-    tx2=txDuration;
-  }
-
   qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
   int nsec=ms/1000;
   double tsec=0.001*ms;
@@ -1824,6 +1820,13 @@ void MainWindow::guiUpdate()
   m_s6=fmod(tsec,6.0);
   m_nseq = nsec % m_TRperiod;
 
+  if(m_mode=="Echo") {
+    txDuration=2.5;
+    tx1=0.0;
+    tx2=txDuration;
+    if(m_auto and m_s6>4.0) m_bEchoTxOK=true;
+  }
+
   if(m_mode.mid(0,4)=="WSPR") {
     if(m_nseq==0 and m_ntr==0) {                   //Decide whether to Tx or Rx
       m_tuneup=false;                              //This is not an ATU tuneup
@@ -1849,6 +1852,7 @@ void MainWindow::guiUpdate()
   } else {
  // For all modes other than WSPR
     m_bTxTime = (t2p >= tx1) and (t2p < tx2);
+    if(m_mode=="Echo") m_bTxTime = m_bTxTime and m_bEchoTxOK;
   }
   if(m_tune) m_bTxTime=true;                 //"Tune" takes precedence
 
@@ -2123,7 +2127,8 @@ void MainWindow::guiUpdate()
     m_DopplerMethod0 = m_DopplerMethod;
   }
 
-  if(m_auto and m_mode=="Echo") progressBar->setValue(int(100*m_s6/6.0));
+  if(m_auto and m_mode=="Echo" and m_bEchoTxOK) progressBar->setValue(
+        int(100*m_s6/6.0));
 
   if(nsec != m_sec0) {                                                //Once per second
     if(m_mode!="Echo") {
diff --git a/mainwindow.h b/mainwindow.h
index 7a7483faa..11f77db18 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -387,6 +387,7 @@ private:
   bool    m_rxDone;
   bool    m_bHaveTransmitted;    //Can be used to prohibit consecutive WSPR transmissions
   int     m_nonWSPRTab;
+  bool    m_bEchoTxOK;
   bool    m_bTransmittedEcho;
 
   float   m_pctZap;