diff --git a/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.cpp b/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.cpp index 3b3a4e4c2..ea6102c72 100644 --- a/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.cpp +++ b/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.cpp @@ -60,6 +60,9 @@ SDRdaemonSinkGui::SDRdaemonSinkGui(DeviceSinkAPI *deviceAPI, QWidget* parent) : nn_setsockopt (m_nnSender, NN_SOL_SOCKET, NN_SNDTIMEO, &millis, sizeof (millis)); assert (rc == 0); + m_countUnrecoverable = 0; + m_countRecovered = 0; + m_paletteGreenText.setColor(QPalette::WindowText, Qt::green); m_paletteRedText.setColor(QPalette::WindowText, Qt::red); m_paletteWhiteText.setColor(QPalette::WindowText, Qt::white); @@ -83,6 +86,10 @@ SDRdaemonSinkGui::SDRdaemonSinkGui(DeviceSinkAPI *deviceAPI, QWidget* parent) : connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); + m_time.start(); + displayEventCounts(); + displayEventTimer(); + displaySettings(); sendControl(true); sendSettings(); @@ -509,6 +516,32 @@ void SDRdaemonSinkGui::on_startStop_toggled(bool checked) } } +void SDRdaemonSinkGui::on_eventCountsReset_clicked(bool checked __attribute__((unused))) +{ + m_countUnrecoverable = 0; + m_countRecovered = 0; + m_time.start(); + displayEventCounts(); + displayEventTimer(); +} + +void SDRdaemonSinkGui::displayEventCounts() +{ + QString nstr = QString("%1").arg(m_countUnrecoverable, 3, 10, QChar('0')); + ui->eventUnrecText->setText(nstr); + nstr = QString("%1").arg(m_countRecovered, 3, 10, QChar('0')); + ui->eventRecText->setText(nstr); +} + +void SDRdaemonSinkGui::displayEventTimer() +{ + int elapsedTimeMillis = m_time.elapsed(); + QTime recordLength(0, 0, 0, 0); + recordLength = recordLength.addSecs(elapsedTimeMillis/1000); + QString s_time = recordLength.toString("hh:mm:ss"); + ui->eventCountsTimeText->setText(s_time); +} + void SDRdaemonSinkGui::updateWithStreamTime() { int t_sec = 0; @@ -540,11 +573,11 @@ void SDRdaemonSinkGui::tick() if ((len > 0) && msgBuf) { std::string msg((char *) msgBuf, len); - //qDebug("SDRdaemonSinkGui::tick: %s", msg.c_str()); std::vector strs; boost::split(strs, msg, boost::is_any_of(":")); unsigned int nbTokens = strs.size(); unsigned int status = 0; + bool updateEventCounts = false; if (nbTokens > 0) // at least the queue length is given { @@ -591,10 +624,22 @@ void SDRdaemonSinkGui::tick() if (nbTokens > 1) // the quality status is given also { - if (strs[1] == "2") { + if (strs[1] == "2") + { status = 2; - } else if (strs[1] == "1") { + } + else if (strs[1] == "1") + { status = 1; + if (m_countUnrecoverable < 999) m_countUnrecoverable++; + updateEventCounts = true; + qDebug("SDRdaemonSinkGui::tick: %s", msg.c_str()); + } + else + { + if (m_countRecovered < 999) m_countRecovered++; + updateEventCounts = true; + qDebug("SDRdaemonSinkGui::tick: %s", msg.c_str()); } } @@ -610,6 +655,13 @@ void SDRdaemonSinkGui::tick() } else { // recoverable errors or unknown status ui->allFramesDecoded->setStyleSheet("QToolButton { background:rgb(56,56,56); }"); } + + if (updateEventCounts) + { + displayEventCounts(); + } } + + displayEventTimer(); } } diff --git a/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.h b/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.h index 79267ae23..2f10bf23d 100644 --- a/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.h +++ b/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.h @@ -18,6 +18,7 @@ #define INCLUDE_SDRDAEMONSINKGUI_H #include +#include #include "plugin/plugingui.h" #include "sdrdaemonsinksettings.h" @@ -69,6 +70,10 @@ private: int m_nnSender; + uint32_t m_countUnrecoverable; + uint32_t m_countRecovered; + QTime m_time; + QPalette m_paletteGreenText; QPalette m_paletteRedText; QPalette m_paletteWhiteText; @@ -80,6 +85,8 @@ private: void sendSettings(); void updateWithStreamTime(); void updateSampleRateAndFrequency(); + void displayEventCounts(); + void displayEventTimer(); private slots: void handleDSPMessages(); @@ -96,6 +103,7 @@ private slots: void on_applyButton_clicked(bool checked); void on_sendButton_clicked(bool checked); void on_startStop_toggled(bool checked); + void on_eventCountsReset_clicked(bool checked); void updateHardware(); void updateStatus(); void tick(); diff --git a/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.ui b/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.ui index 91ddc45b1..fcab4e84d 100644 --- a/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.ui +++ b/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.ui @@ -6,7 +6,7 @@ 0 0 - 380 + 411 217 @@ -371,7 +371,7 @@ - 000/000 + 000/00 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -439,7 +439,7 @@ - 50 + 52 0 @@ -471,7 +471,7 @@ - 18 + 25 0 @@ -479,7 +479,7 @@ Number of uncrecoverable errors since event counts reset - 00 + 000 @@ -487,7 +487,7 @@ - 18 + 25 0 @@ -495,7 +495,7 @@ Number of correctable errors since event counts reset - 00 + 000