Instrumentation and pull ui update async

This commit is contained in:
Jordan Sherer 2018-10-15 00:59:38 -04:00
parent 8aa28108ea
commit 9e93745587

View File

@ -842,6 +842,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
, &QTextEdit::textChanged , &QTextEdit::textChanged
, [this] () {on_extFreeTextMsgEdit_currentTextChanged (ui->extFreeTextMsgEdit->toPlainText ());}); , [this] () {on_extFreeTextMsgEdit_currentTextChanged (ui->extFreeTextMsgEdit->toPlainText ());});
m_guiTimer.setSingleShot(true);
connect(&m_guiTimer, &QTimer::timeout, this, &MainWindow::guiUpdate); connect(&m_guiTimer, &QTimer::timeout, this, &MainWindow::guiUpdate);
m_guiTimer.start(100); //### Don't change the 100 ms! ### m_guiTimer.start(100); //### Don't change the 100 ms! ###
@ -4087,11 +4088,22 @@ void MainWindow::decodeBusy(bool b) //decodeBusy()
//------------------------------------------------------------- //guiUpdate() //------------------------------------------------------------- //guiUpdate()
void MainWindow::guiUpdate() void MainWindow::guiUpdate()
{ {
static quint64 lastLoop;
static char message[29]; static char message[29];
static char msgsent[29]; static char msgsent[29];
double txDuration; double txDuration;
QString rt; QString rt;
quint64 thisLoop = QDateTime::currentMSecsSinceEpoch();
if(lastLoop == 0){
lastLoop = thisLoop;
}
quint64 delta = thisLoop - lastLoop;
if(delta > (100 + 10)){
qDebug() << "guiupdate overrun" << (delta-100);
}
lastLoop = thisLoop;
if(m_TRperiod==0) m_TRperiod=60; if(m_TRperiod==0) m_TRperiod=60;
txDuration=0.0; txDuration=0.0;
if(m_modeTx=="FT8") txDuration=1.0 + NUM_FT8_SYMBOLS*1920/12000.0; // FT8 if(m_modeTx=="FT8") txDuration=1.0 + NUM_FT8_SYMBOLS*1920/12000.0; // FT8
@ -4533,18 +4545,21 @@ void MainWindow::guiUpdate()
tryBandHop(); tryBandHop();
} }
// once per period/3 // once at the end of the period
bool forceDirty = false; bool forceDirty = false;
if(m_sec0 % (m_TRperiod/3) == 0){ if(m_sec0 % (m_TRperiod-2) == 0 ||
// force rx dirty three times per period m_sec0 % (m_TRperiod-1) == 0 ||
m_sec0 % (m_TRperiod) == 0){
// force rx dirty once times per period
forceDirty = true; forceDirty = true;
} }
// once per second...
// update the dial frequency once per second.. // update the dial frequency once per second..
displayDialFrequency(); displayDialFrequency();
// once per second...but not when we're transmitting
if(!m_transmitting){
QTimer::singleShot(0, this, [this, forceDirty](){
// process all received activity... // process all received activity...
processActivity(forceDirty); processActivity(forceDirty);
@ -4555,6 +4570,8 @@ void MainWindow::guiUpdate()
displayActivity(forceDirty); displayActivity(forceDirty);
updateButtonDisplay(); updateButtonDisplay();
updateTextDisplay(); updateTextDisplay();
});
}
} }
// once per 100ms // once per 100ms
@ -4562,6 +4579,16 @@ void MainWindow::guiUpdate()
m_iptt0=g_iptt; m_iptt0=g_iptt;
m_btxok0=m_btxok; m_btxok0=m_btxok;
// compute the processing time and adjust loop to hit the next 100ms
auto endLoop = QDateTime::currentMSecsSinceEpoch();
auto processingTime = endLoop - thisLoop;
auto nextLoopMs = 0;
if(processingTime < 100){
nextLoopMs = 100 - processingTime;
}
m_guiTimer.start(nextLoopMs);
} //End of guiUpdate } //End of guiUpdate
@ -5454,7 +5481,8 @@ void MainWindow::on_extFreeTextMsgEdit_currentTextChanged (QString const& text)
ui->extFreeTextMsgEdit->setTextCursor(c); ui->extFreeTextMsgEdit->setTextCursor(c);
} }
m_txTextDirty = true; m_txTextDirty = x != m_txTextDirtyLastText;
m_txTextDirtyLastText = x;
// immediately update the display // immediately update the display
updateButtonDisplay(); updateButtonDisplay();