1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00
sdrangel/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkgui.cpp

671 lines
21 KiB
C++
Raw Normal View History

2017-05-14 18:58:56 -04:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QTime>
#include <QDateTime>
#include <QString>
#include <QFileDialog>
#include <QMessageBox>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
2017-05-21 13:45:56 -04:00
#include <nanomsg/nn.h>
#include <nanomsg/pair.h>
#include "ui_sdrdaemonsinkgui.h"
2017-05-14 18:58:56 -04:00
#include "plugin/pluginapi.h"
#include "gui/colormapper.h"
#include "gui/glspectrum.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "mainwindow.h"
#include "device/devicesinkapi.h"
#include "device/deviceuiset.h"
2017-05-14 18:58:56 -04:00
#include "sdrdaemonsinkgui.h"
SDRdaemonSinkGui::SDRdaemonSinkGui(DeviceUISet *deviceUISet, QWidget* parent) :
2017-05-14 18:58:56 -04:00
QWidget(parent),
ui(new Ui::SDRdaemonSinkGui),
m_deviceUISet(deviceUISet),
2017-05-14 18:58:56 -04:00
m_settings(),
m_deviceSampleSink(0),
m_sampleRate(0),
m_samplesCount(0),
m_tickCount(0),
m_nbSinceLastFlowCheck(0),
2017-05-21 13:45:56 -04:00
m_lastEngineState((DSPDeviceSinkEngine::State)-1),
2017-05-22 19:41:30 -04:00
m_doApplySettings(true),
m_forceSettings(true)
2017-05-14 18:58:56 -04:00
{
2017-05-21 13:45:56 -04:00
m_nnSender = nn_socket(AF_SP, NN_PAIR);
assert(m_nnSender != -1);
int millis = 500;
2017-08-18 05:16:18 -04:00
int rc = nn_setsockopt(m_nnSender, NN_SOL_SOCKET, NN_SNDTIMEO, &millis, sizeof (millis));
if (rc != 0) {
qCritical("SDRdaemonSinkGui::SDRdaemonSinkGui: nn_setsockopt failed with rc %d", rc);
}
2017-05-21 13:45:56 -04:00
2017-06-05 19:53:21 -04:00
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);
ui->setupUi(this);
2017-05-14 18:58:56 -04:00
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
2017-05-14 18:58:56 -04:00
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
2017-05-14 18:58:56 -04:00
ui->sampleRate->setValueRange(7, 32000U, 9000000U);
connect(&(m_deviceUISet->m_deviceSinkAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
2017-05-14 18:58:56 -04:00
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
m_deviceSampleSink = (SDRdaemonSinkOutput*) m_deviceUISet->m_deviceSinkAPI->getSampleSink();
2017-05-14 18:58:56 -04:00
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
2017-05-21 13:45:56 -04:00
2017-06-05 19:53:21 -04:00
m_time.start();
displayEventCounts();
displayEventTimer();
2017-05-21 13:45:56 -04:00
displaySettings();
sendControl(true);
sendSettings();
2017-05-14 18:58:56 -04:00
}
SDRdaemonSinkGui::~SDRdaemonSinkGui()
2017-05-14 18:58:56 -04:00
{
delete ui;
}
2017-05-21 13:45:56 -04:00
void SDRdaemonSinkGui::blockApplySettings(bool block)
{
m_doApplySettings = !block;
}
void SDRdaemonSinkGui::destroy()
2017-05-14 18:58:56 -04:00
{
delete this;
}
void SDRdaemonSinkGui::setName(const QString& name)
2017-05-14 18:58:56 -04:00
{
setObjectName(name);
}
QString SDRdaemonSinkGui::getName() const
2017-05-14 18:58:56 -04:00
{
return objectName();
}
void SDRdaemonSinkGui::resetToDefaults()
2017-05-14 18:58:56 -04:00
{
2017-05-21 13:45:56 -04:00
blockApplySettings(true);
2017-05-14 18:58:56 -04:00
m_settings.resetToDefaults();
displaySettings();
2017-05-21 13:45:56 -04:00
blockApplySettings(false);
2017-05-14 18:58:56 -04:00
sendSettings();
}
qint64 SDRdaemonSinkGui::getCenterFrequency() const
2017-05-14 18:58:56 -04:00
{
return m_settings.m_centerFrequency;
}
void SDRdaemonSinkGui::setCenterFrequency(qint64 centerFrequency)
2017-05-14 18:58:56 -04:00
{
m_settings.m_centerFrequency = centerFrequency;
displaySettings();
2017-05-21 13:45:56 -04:00
sendControl();
2017-05-14 18:58:56 -04:00
sendSettings();
}
QByteArray SDRdaemonSinkGui::serialize() const
2017-05-14 18:58:56 -04:00
{
return m_settings.serialize();
}
bool SDRdaemonSinkGui::deserialize(const QByteArray& data)
2017-05-14 18:58:56 -04:00
{
2017-05-21 13:45:56 -04:00
blockApplySettings(true);
if(m_settings.deserialize(data))
{
2017-05-14 18:58:56 -04:00
displaySettings();
2017-05-21 13:45:56 -04:00
blockApplySettings(false);
sendControl(true);
2017-05-22 19:41:30 -04:00
m_forceSettings = true;
2017-05-14 18:58:56 -04:00
sendSettings();
return true;
2017-05-21 13:45:56 -04:00
}
else
{
blockApplySettings(false);
2017-05-14 18:58:56 -04:00
return false;
}
}
bool SDRdaemonSinkGui::handleMessage(const Message& message)
2017-05-14 18:58:56 -04:00
{
if (SDRdaemonSinkOutput::MsgConfigureSDRdaemonSink::match(message))
{
const SDRdaemonSinkOutput::MsgConfigureSDRdaemonSink& cfg = (SDRdaemonSinkOutput::MsgConfigureSDRdaemonSink&) message;
m_settings = cfg.getSettings();
blockApplySettings(true);
displaySettings();
blockApplySettings(false);
return true;
}
else if (SDRdaemonSinkOutput::MsgReportSDRdaemonSinkStreamTiming::match(message))
2017-05-14 18:58:56 -04:00
{
2017-05-20 22:19:12 -04:00
m_samplesCount = ((SDRdaemonSinkOutput::MsgReportSDRdaemonSinkStreamTiming&)message).getSamplesCount();
2017-05-14 18:58:56 -04:00
updateWithStreamTime();
return true;
}
else if (SDRdaemonSinkOutput::MsgStartStop::match(message))
{
SDRdaemonSinkOutput::MsgStartStop& notif = (SDRdaemonSinkOutput::MsgStartStop&) message;
blockApplySettings(true);
ui->startStop->setChecked(notif.getStartStop());
blockApplySettings(false);
return true;
}
2017-05-14 18:58:56 -04:00
else
{
return false;
}
}
void SDRdaemonSinkGui::handleInputMessages()
2017-05-14 18:58:56 -04:00
{
Message* message;
while ((message = m_inputMessageQueue.pop()) != 0)
2017-05-14 18:58:56 -04:00
{
qDebug("SDRdaemonSinkGui::handleInputMessages: message: %s", message->getIdentifier());
2017-05-14 18:58:56 -04:00
if (DSPSignalNotification::match(*message))
{
DSPSignalNotification* notif = (DSPSignalNotification*) message;
qDebug("SDRdaemonSinkGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
2017-05-14 18:58:56 -04:00
m_sampleRate = notif->getSampleRate();
m_deviceCenterFrequency = notif->getCenterFrequency();
updateSampleRateAndFrequency();
delete message;
}
else
2017-05-14 18:58:56 -04:00
{
if (handleMessage(*message)) {
delete message;
}
2017-05-14 18:58:56 -04:00
}
}
}
void SDRdaemonSinkGui::updateSampleRateAndFrequency()
2017-05-14 18:58:56 -04:00
{
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
2017-05-14 18:58:56 -04:00
ui->deviceRateText->setText(tr("%1k").arg((float)(m_sampleRate*(1<<m_settings.m_log2Interp)) / 1000));
}
void SDRdaemonSinkGui::updateTxDelayTooltip()
{
double delay = ((127*127*m_settings.m_txDelay) / m_settings.m_sampleRate)/(128 + m_settings.m_nbFECBlocks);
ui->txDelayText->setToolTip(tr("%1 us").arg(QString::number(delay*1e6, 'f', 0)));
}
void SDRdaemonSinkGui::displaySettings()
2017-05-14 18:58:56 -04:00
{
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->sampleRate->setValue(m_settings.m_sampleRate);
2017-05-21 13:45:56 -04:00
ui->deviceRateText->setText(tr("%1k").arg((float)(m_sampleRate*(1<<m_settings.m_log2Interp)) / 1000));
ui->interp->setCurrentIndex(m_settings.m_log2Interp);
ui->txDelay->setValue(m_settings.m_txDelay*100);
ui->txDelayText->setText(tr("%1").arg(m_settings.m_txDelay*100));
2017-05-21 13:45:56 -04:00
ui->nbFECBlocks->setValue(m_settings.m_nbFECBlocks);
QString s0 = QString::number(128 + m_settings.m_nbFECBlocks, 'f', 0);
QString s1 = QString::number(m_settings.m_nbFECBlocks, 'f', 0);
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s0).arg(s1));
ui->address->setText(m_settings.m_address);
ui->dataPort->setText(tr("%1").arg(m_settings.m_dataPort));
ui->controlPort->setText(tr("%1").arg(m_settings.m_controlPort));
ui->specificParms->setText(m_settings.m_specificParameters);
}
void SDRdaemonSinkGui::sendControl(bool force)
{
if ((m_settings.m_address != m_controlSettings.m_address) ||
(m_settings.m_controlPort != m_controlSettings.m_controlPort) || force)
{
int rc = nn_shutdown(m_nnSender, 0);
if (rc < 0) {
qDebug() << "SDRdaemonSinkGui::sendControl: disconnection failed";
} else {
qDebug() << "SDRdaemonSinkGui::sendControl: disconnection successful";
}
std::ostringstream os;
os << "tcp://" << m_settings.m_address.toStdString() << ":" << m_settings.m_controlPort;
std::string addrstrng = os.str();
rc = nn_connect(m_nnSender, addrstrng.c_str());
if (rc < 0)
{
qDebug() << "SDRdaemonSinkGui::sendControl: connection to " << addrstrng.c_str() << " failed";
QMessageBox::information(this, tr("Message"), tr("Cannot connect to remote control port"));
return;
}
else
{
qDebug() << "SDRdaemonSinkGui::sendControl: connection to " << addrstrng.c_str() << " successful";
force = true;
}
}
std::ostringstream os;
int nbArgs = 0;
if ((m_settings.m_centerFrequency != m_controlSettings.m_centerFrequency) || force)
{
os << "freq=" << m_settings.m_centerFrequency;
2017-05-21 13:45:56 -04:00
nbArgs++;
}
if ((m_settings.m_sampleRate != m_controlSettings.m_sampleRate) || (m_settings.m_log2Interp != m_controlSettings.m_log2Interp) || force)
2017-05-21 13:45:56 -04:00
{
if (nbArgs > 0) os << ",";
os << "srate=" << m_settings.m_sampleRate * (1<<m_settings.m_log2Interp);
2017-05-21 13:45:56 -04:00
nbArgs++;
if ((m_settings.m_log2Interp != m_controlSettings.m_log2Interp) || force)
{
os << ",interp=" << m_settings.m_log2Interp;
nbArgs++;
}
2017-05-21 13:45:56 -04:00
}
if ((m_settings.m_specificParameters != m_controlSettings.m_specificParameters) || force)
{
if (nbArgs > 0) os << ",";
os << m_settings.m_specificParameters.toStdString();
nbArgs++;
}
if (nbArgs > 0)
{
int config_size = os.str().size();
int rc = nn_send(m_nnSender, (void *) os.str().c_str(), config_size, 0);
if (rc != config_size)
{
//QMessageBox::information(this, tr("Message"), tr("Cannot send message to remote control port"));
qDebug() << "SDRdaemonSinkGui::sendControl: Cannot send message to remote control port."
<< " remoteAddress: " << m_settings.m_address
<< " remotePort: " << m_settings.m_controlPort
<< " message: " << os.str().c_str();
2017-05-21 13:45:56 -04:00
}
else
{
qDebug() << "SDRdaemonSinkGui::sendControl:"
<< "remoteAddress:" << m_settings.m_address
<< "remotePort:" << m_settings.m_controlPort
<< "message:" << os.str().c_str();
2017-05-21 13:45:56 -04:00
}
}
m_controlSettings.m_address = m_settings.m_address;
m_controlSettings.m_controlPort = m_settings.m_controlPort;
m_controlSettings.m_centerFrequency = m_settings.m_centerFrequency;
2017-05-21 13:45:56 -04:00
m_controlSettings.m_sampleRate = m_settings.m_sampleRate;
m_controlSettings.m_log2Interp = m_settings.m_log2Interp;
m_controlSettings.m_specificParameters = m_settings.m_specificParameters;
2017-05-14 18:58:56 -04:00
}
void SDRdaemonSinkGui::sendSettings()
2017-05-14 18:58:56 -04:00
{
if(!m_updateTimer.isActive())
m_updateTimer.start(100);
}
void SDRdaemonSinkGui::updateHardware()
2017-05-14 18:58:56 -04:00
{
qDebug() << "SDRdaemonSinkGui::updateHardware";
2017-05-22 19:41:30 -04:00
SDRdaemonSinkOutput::MsgConfigureSDRdaemonSink* message = SDRdaemonSinkOutput::MsgConfigureSDRdaemonSink::create(m_settings, m_forceSettings);
2017-05-14 18:58:56 -04:00
m_deviceSampleSink->getInputMessageQueue()->push(message);
2017-05-22 19:41:30 -04:00
m_forceSettings = false;
2017-05-14 18:58:56 -04:00
m_updateTimer.stop();
}
void SDRdaemonSinkGui::updateStatus()
2017-05-14 18:58:56 -04:00
{
int state = m_deviceUISet->m_deviceSinkAPI->state();
2017-05-14 18:58:56 -04:00
if(m_lastEngineState != state)
{
switch(state)
{
case DSPDeviceSinkEngine::StNotStarted:
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
break;
case DSPDeviceSinkEngine::StIdle:
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
break;
case DSPDeviceSinkEngine::StRunning:
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
2017-05-14 18:58:56 -04:00
break;
case DSPDeviceSinkEngine::StError:
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceSinkAPI->errorMessage());
2017-05-14 18:58:56 -04:00
break;
default:
break;
}
m_lastEngineState = state;
}
}
void SDRdaemonSinkGui::on_centerFrequency_changed(quint64 value)
2017-05-14 18:58:56 -04:00
{
m_settings.m_centerFrequency = value * 1000;
2017-05-21 13:45:56 -04:00
sendControl();
2017-05-14 18:58:56 -04:00
sendSettings();
}
void SDRdaemonSinkGui::on_sampleRate_changed(quint64 value)
2017-05-14 18:58:56 -04:00
{
m_settings.m_sampleRate = value;
updateTxDelayTooltip();
2017-05-21 13:45:56 -04:00
sendControl();
2017-05-14 18:58:56 -04:00
sendSettings();
}
void SDRdaemonSinkGui::on_interp_currentIndexChanged(int index)
2017-05-14 18:58:56 -04:00
{
if (index < 0) {
return;
}
m_settings.m_log2Interp = index;
updateSampleRateAndFrequency();
2017-05-21 13:45:56 -04:00
sendControl();
}
void SDRdaemonSinkGui::on_txDelay_valueChanged(int value)
{
m_settings.m_txDelay = value / 100.0;
ui->txDelayText->setText(tr("%1").arg(value));
updateTxDelayTooltip();
2017-05-21 13:45:56 -04:00
sendSettings();
}
void SDRdaemonSinkGui::on_nbFECBlocks_valueChanged(int value)
{
m_settings.m_nbFECBlocks = value;
int nbOriginalBlocks = 128;
int nbFECBlocks = value;
QString s = QString::number(nbOriginalBlocks + nbFECBlocks, 'f', 0);
QString s1 = QString::number(nbFECBlocks, 'f', 0);
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1));
updateTxDelayTooltip();
2017-05-14 18:58:56 -04:00
sendSettings();
}
void SDRdaemonSinkGui::on_address_returnPressed()
2017-05-21 13:45:56 -04:00
{
m_settings.m_address = ui->address->text();
sendControl();
sendSettings();
}
void SDRdaemonSinkGui::on_dataPort_returnPressed()
2017-05-21 13:45:56 -04:00
{
bool dataOk;
int udpDataPort = ui->dataPort->text().toInt(&dataOk);
if((!dataOk) || (udpDataPort < 1024) || (udpDataPort > 65535))
{
return;
}
else
{
m_settings.m_dataPort = udpDataPort;
}
sendSettings();
}
void SDRdaemonSinkGui::on_controlPort_returnPressed()
2017-05-21 13:45:56 -04:00
{
bool ctlOk;
int udpCtlPort = ui->controlPort->text().toInt(&ctlOk);
2017-05-21 13:45:56 -04:00
if((!ctlOk) || (udpCtlPort < 1024) || (udpCtlPort > 65535))
{
return;
}
else
{
m_settings.m_controlPort = udpCtlPort;
}
sendControl();
}
void SDRdaemonSinkGui::on_specificParms_returnPressed()
2017-05-21 13:45:56 -04:00
{
m_settings.m_specificParameters = ui->specificParms->text();
sendControl();
}
void SDRdaemonSinkGui::on_applyButton_clicked(bool checked __attribute__((unused)))
2017-05-21 13:45:56 -04:00
{
m_settings.m_address = ui->address->text();
bool ctlOk;
int udpCtlPort = ui->controlPort->text().toInt(&ctlOk);
if((ctlOk) && (udpCtlPort >= 1024) && (udpCtlPort < 65535))
{
m_settings.m_controlPort = udpCtlPort;
}
bool dataOk;
int udpDataPort = ui->dataPort->text().toInt(&dataOk);
if((dataOk) && (udpDataPort >= 1024) && (udpDataPort < 65535))
{
m_settings.m_dataPort = udpDataPort;
}
2017-05-21 13:45:56 -04:00
}
void SDRdaemonSinkGui::on_sendButton_clicked(bool checked __attribute__((unused)))
2017-05-21 13:45:56 -04:00
{
sendControl(true);
2017-05-21 13:45:56 -04:00
}
void SDRdaemonSinkGui::on_startStop_toggled(bool checked)
2017-05-14 18:58:56 -04:00
{
if (m_doApplySettings)
2017-05-14 18:58:56 -04:00
{
SDRdaemonSinkOutput::MsgStartStop *message = SDRdaemonSinkOutput::MsgStartStop::create(checked);
m_deviceSampleSink->getInputMessageQueue()->push(message);
2017-05-14 18:58:56 -04:00
}
}
2017-06-05 19:53:21 -04:00
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()
2017-05-14 18:58:56 -04:00
{
int t_sec = 0;
int t_msec = 0;
if (m_settings.m_sampleRate > 0){
t_msec = ((m_samplesCount * 1000) / m_settings.m_sampleRate) % 1000;
t_sec = m_samplesCount / m_settings.m_sampleRate;
}
QTime t(0, 0, 0, 0);
t = t.addSecs(t_sec);
t = t.addMSecs(t_msec);
QString s_timems = t.toString("hh:mm:ss.zzz");
//ui->relTimeText->setText(s_timems); TODO with absolute time
2017-05-14 18:58:56 -04:00
}
void SDRdaemonSinkGui::tick()
2017-05-14 18:58:56 -04:00
{
if ((++m_tickCount & 0xf) == 0) // 16*50ms ~800ms
2017-05-14 18:58:56 -04:00
{
void *msgBuf = 0;
2017-05-20 22:19:12 -04:00
SDRdaemonSinkOutput::MsgConfigureSDRdaemonSinkStreamTiming* message = SDRdaemonSinkOutput::MsgConfigureSDRdaemonSinkStreamTiming::create();
2017-05-14 18:58:56 -04:00
m_deviceSampleSink->getInputMessageQueue()->push(message);
int len = nn_recv(m_nnSender, &msgBuf, NN_MSG, NN_DONTWAIT);
if ((len > 0) && msgBuf)
{
std::string msg((char *) msgBuf, len);
std::vector<std::string> strs;
boost::split(strs, msg, boost::is_any_of(":"));
unsigned int nbTokens = strs.size();
unsigned int status = 0;
2017-06-05 19:53:21 -04:00
bool updateEventCounts = false;
if (nbTokens > 0) // at least the queue length is given
{
try
{
int queueLength = boost::lexical_cast<int>(strs[0]);
ui->queueLengthText->setText(QString::fromStdString(strs[0]));
m_nbSinceLastFlowCheck++;
int samplesCorr = 0;
bool quickStart = false;
if (queueLength < 2)
{
samplesCorr = 127*8;
quickStart = true;
}
else if (queueLength < 16)
{
samplesCorr = ((8 - queueLength)*16)/m_nbSinceLastFlowCheck;
}
else
{
samplesCorr = -127*16;
quickStart = true;
}
if (samplesCorr != 0)
{
samplesCorr = quickStart ? samplesCorr : samplesCorr <= -50 ? -50 : samplesCorr >= 50 ? 50 : samplesCorr;
SDRdaemonSinkOutput::MsgConfigureSDRdaemonSinkChunkCorrection* message = SDRdaemonSinkOutput::MsgConfigureSDRdaemonSinkChunkCorrection::create(samplesCorr);
m_deviceSampleSink->getInputMessageQueue()->push(message);
m_nbSinceLastFlowCheck = 0;
}
}
catch(const boost::bad_lexical_cast &)
{
qDebug("SDRdaemonSinkGui::tick: queue length invalid: %s", strs[0].c_str());
}
}
if (nbTokens > 1) // the quality status is given also
{
2017-06-05 19:53:21 -04:00
if (strs[1] == "2")
{
status = 2;
2017-06-05 19:53:21 -04:00
}
else if (strs[1] == "1")
{
status = 1;
2017-06-05 19:53:21 -04:00
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());
}
}
if (nbTokens > 2) // the quality indicator message is given also
{
ui->qualityStatusText->setText(QString::fromStdString(strs[2]));
}
if (status == 2) { // all OK
ui->allFramesDecoded->setStyleSheet("QToolButton { background-color : green; }");
} else if (status == 1) { // unrecoverable errors
ui->allFramesDecoded->setStyleSheet("QToolButton { background-color : red; }");
} else { // recoverable errors or unknown status
ui->allFramesDecoded->setStyleSheet("QToolButton { background:rgb(56,56,56); }");
}
2017-06-05 19:53:21 -04:00
if (updateEventCounts)
{
displayEventCounts();
}
}
2017-06-05 19:53:21 -04:00
displayEventTimer();
2017-05-14 18:58:56 -04:00
}
}