From f635ba3a338fd36c783ba6545dfb6a864d9739f0 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Thu, 14 Nov 2019 16:07:49 -0500 Subject: [PATCH] Delay first decode until start of the next period on startup --- mainwindow.cpp | 10 ++++++---- mainwindow.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 62a05ce..8c86da0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1496,7 +1496,9 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, // Don't block heartbeat's first run... m_lastTxStartTime = DriftingDateTime::currentDateTimeUtc().addSecs(-300); - m_lastTxStopTime = DriftingDateTime::currentDateTimeUtc().addSecs(-300); + + // But do block the decoder's first run until the next transmit period + m_lastTxStopTime = nextTransmitCycle(); int width = 75; /* @@ -4036,7 +4038,7 @@ bool MainWindow::decode(){ } int threshold = 1000; // one second - if(isInTransmitDecodeThreshold(threshold)){ + if(isInDecodeDelayThreshold(threshold)){ if(JS8_DEBUG_DECODE) qDebug() << "--> decoder paused for" << threshold << "ms after transmit stop"; return false; } @@ -4570,7 +4572,7 @@ QDateTime MainWindow::nextTransmitCycle(){ // round to 15 second increment int secondsSinceEpoch = (timestamp.toMSecsSinceEpoch()/1000); - int delta = roundUp(secondsSinceEpoch, 15) + 1 - secondsSinceEpoch; + int delta = roundUp(secondsSinceEpoch, m_TRperiod) + 1 - secondsSinceEpoch; timestamp = timestamp.addSecs(delta); return timestamp; @@ -6472,7 +6474,7 @@ bool MainWindow::isMessageQueuedForTransmit(){ return m_transmitting || m_txFrameCount > 0; } -bool MainWindow::isInTransmitDecodeThreshold(int ms){ +bool MainWindow::isInDecodeDelayThreshold(int ms){ if(m_lastTxStopTime.isNull()){ return false; } diff --git a/mainwindow.h b/mainwindow.h index 6f05263..541452b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -146,7 +146,7 @@ public slots: void writeNoticeTextToUI(QDateTime date, QString text); int writeMessageTextToUI(QDateTime date, QString text, int freq, bool isTx, int block=-1); bool isMessageQueuedForTransmit(); - bool isInTransmitDecodeThreshold(int seconds); + bool isInDecodeDelayThreshold(int seconds); void prependMessageText(QString text); void addMessageText(QString text, bool clear=false, bool selectFirstPlaceholder=false); void enqueueMessage(int priority, QString message, int freq, Callback c);